Untitled
unknown
java
2 years ago
4.0 kB
2
Indexable
Never
@SuppressWarnings("deprecation") @EventHandler public void onInvClick(InventoryClickEvent event){ if(event.getClickedInventory() == null){ return; } if(event.getView().getTitle().equalsIgnoreCase(ChatColor.BLACK + "" + ChatColor.BOLD + "Iron Crafting on a Stick")){ int[] lockedSlots = {0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,24,25,27,28,29,30,31,32,33,34,35,36,37,38,40,41,42,43,44,45,46}; int[] notLockedSlots = {3,19,21,23,39}; int[] notCenterSlots = {3,19,23,39}; int[] notNullSlots = new int[4]; int[] fnotNullSlots; event.getWhoClicked().sendMessage(String.valueOf(event.getRawSlot())); if(Arrays.stream(lockedSlots).anyMatch(x -> x == event.getRawSlot())){ event.setCancelled(true); } else if(Arrays.stream(notLockedSlots).anyMatch(x -> x == event.getRawSlot())){ int xss = 0; for(int ss = 0; ss<notCenterSlots.length; ss++){ if(event.getClickedInventory().getItem(notCenterSlots[ss]) != null){ System.out.println("Not null"); System.out.println(notCenterSlots[ss]); notNullSlots[xss] = notCenterSlots[ss]; xss++; } } fnotNullSlots = Arrays.copyOf(notNullSlots, notNullSlots.length); if(event.getClickedInventory().getItem(21) == null){ event.getWhoClicked().sendMessage("Slot is null"); event.getWhoClicked().sendMessage(event.getClickedInventory().getItem(21).toString()); } else { if(event.getClickedInventory().getItem(21).getType().equals(Material.TOTEM_OF_UNDYING)){ System.out.println("totem in"); for(int i = 0; i< fnotNullSlots.length; i++){ if(event.getRawSlot() == i){ int pearlCount = 0; int chorusCount = 0; int requiredExTotem = 0; if(event.getCursor().getType().equals(Material.ENDER_PEARL)){ System.out.println("pearl deinserted"); if(pearlCount <= 2 && pearlCount > 0){ requiredExTotem = requiredExTotem - 1; } pearlCount = pearlCount - 1; } else if(event.getCursor().getType().equals(Material.CHORUS_FRUIT)){ System.out.println("Chorus deinserted"); if(chorusCount <= 2 && chorusCount > 0){ requiredExTotem = requiredExTotem - 1; } chorusCount = chorusCount - 1; } if(event.getClickedInventory().getItem(notCenterSlots[i]).getType().equals(Material.CHORUS_FRUIT)){ pearlCount++; if(pearlCount<=2){ requiredExTotem++; System.out.println("pearl inserted"); } } if(event.getClickedInventory().getItem(notCenterSlots[i]).getType().equals(Material.CHORUS_FRUIT)){ chorusCount++; if(chorusCount<=2){ requiredExTotem++; System.out.println("Chorus inserted"); } } CraftingConfig.get().set("data." + event.getWhoClicked().getUniqueId() + "." + event.getWhoClicked().getName() + ".ExTotem.pearlCount", pearlCount); CraftingConfig.get().set("data." + event.getWhoClicked().getUniqueId() + "." + event.getWhoClicked().getName() + ".ExTotem.chorusCount", chorusCount); CraftingConfig.get().set("data." + event.getWhoClicked().getUniqueId() + "." + event.getWhoClicked().getName() + ".ExTotem.ResultReq", requiredExTotem); CraftingConfig.save(); CraftingConfig.reload(); } } if(Integer.parseInt(String.valueOf(CraftingConfig.get().get("data." + event.getWhoClicked().getUniqueId() + "." + event.getWhoClicked().getName() + ".ExTotem.ResultReq"))) == 4){ event.getClickedInventory().setItem(26, ChorusTotem.ChorusTotem); CraftingConfig.get().set("data." + event.getWhoClicked().getUniqueId() + "." + event.getWhoClicked().getName() + ".ExTotem.ResultReq", 0); CraftingConfig.save(); CraftingConfig.reload(); System.out.println("Craft Complete"); } } } } } }