aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHackOS <63157139+HackedOS@users.noreply.github.com>2022-05-14 16:33:43 +0530
committerGitHub <noreply@github.com>2022-05-14 13:03:43 +0200
commitd5fe0f0036400b9b726a615429ce99e03d0f7d63 (patch)
tree1ec220463f23d8b0ab55a6a7bb6ad66b7b0c7f37 /src
parentae12206958a0ba848594beeb2f804720d1a89d4f (diff)
downloadCOFL-d5fe0f0036400b9b726a615429ce99e03d0f7d63.tar.gz
COFL-d5fe0f0036400b9b726a615429ce99e03d0f7d63.tar.bz2
COFL-d5fe0f0036400b9b726a615429ce99e03d0f7d63.zip
Fix crash on buying stuff in AH (#60)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/torui/coflsky/EventRegistry.java67
1 files changed, 30 insertions, 37 deletions
diff --git a/src/main/java/de/torui/coflsky/EventRegistry.java b/src/main/java/de/torui/coflsky/EventRegistry.java
index 3434c1c..0e9aa6e 100644
--- a/src/main/java/de/torui/coflsky/EventRegistry.java
+++ b/src/main/java/de/torui/coflsky/EventRegistry.java
@@ -156,52 +156,45 @@ public class EventRegistry {
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void OnGuiClick(GuiScreenEvent.MouseInputEvent mie) {
- if (CoflSky.Wrapper.isRunning) {
- if (mie.gui instanceof GuiChest) { // verify that it's really a chest
+ if (!CoflSky.Wrapper.isRunning) return;
+ if (!(mie.gui instanceof GuiChest)) return; // verify that it's really a chest
+ if (!(((GuiChest) mie.gui).inventorySlots instanceof ContainerChest)) return;
+ ContainerChest chest = (ContainerChest) ((GuiChest) mie.gui).inventorySlots;
+ IInventory inv = chest.getLowerChestInventory();
+ if (inv.hasCustomName()) { // verify that the chest actually has a custom name
+ String chestName = inv.getName();
- ContainerChest chest = (ContainerChest) ((GuiChest) mie.gui).inventorySlots;
+ if (chestName.equalsIgnoreCase("BIN Auction View") || chestName.equalsIgnoreCase("Ekwav")) {
- IInventory inv = chest.getLowerChestInventory();
- if (inv.hasCustomName()) { // verify that the chest actually has a custom name
- String chestName = inv.getName();
+ ItemStack heldItem = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
- if (chestName.equalsIgnoreCase("BIN Auction View") || chestName.equalsIgnoreCase("Ekwav")) {
-
- ItemStack heldItem = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
-
- if (heldItem != null) {
- System.out.println("Clicked on: " + heldItem.getItem().getRegistryName());
-
- String itemUUID = ExtractUuidFromInventory(inv);
-
- if(System.currentTimeMillis() > lastStartTime) {
-
- if (heldItem.isItemEqual(GOLD_NUGGET)) {
- AuctionData ad = new AuctionData();
- ad.setItemId(itemUUID);
-
- if((LastViewAuctionInvocation+60*1000) >= System.currentTimeMillis()) {
- ad.setAuctionId(LastViewAuctionUUID);
- } else {
- ad.setAuctionId("");
- }
-
- Command<AuctionData> data = new Command<>(CommandType.PurchaseStart, ad);
- CoflSky.Wrapper.SendMessage(data);
- System.out.println("PurchaseStart");
- last = Pair.of("You claimed ", Pair.of(itemUUID, LocalDateTime.now()));
- lastStartTime = System.currentTimeMillis() + 200 /*ensure a small debounce*/;
- }
+ if (heldItem != null) {
+ System.out.println("Clicked on: " + heldItem.getItem().getRegistryName());
+
+ String itemUUID = ExtractUuidFromInventory(inv);
+
+ if(System.currentTimeMillis() > lastStartTime) {
+
+ if (heldItem.isItemEqual(GOLD_NUGGET)) {
+ AuctionData ad = new AuctionData();
+ ad.setItemId(itemUUID);
+
+ if((LastViewAuctionInvocation+60*1000) >= System.currentTimeMillis()) {
+ ad.setAuctionId(LastViewAuctionUUID);
+ } else {
+ ad.setAuctionId("");
}
-
- }
+ Command<AuctionData> data = new Command<>(CommandType.PurchaseStart, ad);
+ CoflSky.Wrapper.SendMessage(data);
+ System.out.println("PurchaseStart");
+ last = Pair.of("You claimed ", Pair.of(itemUUID, LocalDateTime.now()));
+ lastStartTime = System.currentTimeMillis() + 200 /*ensure a small debounce*/;
+ }
}
}
}
-
}
-
}
@SubscribeEvent