Advertisement
broken-arrow

Untitled

Sep 26th, 2021
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. import org.broken.cheststorage.ChestStorage;
  2. import org.broken.cheststorage.Guimenus.GuiUpgradePages;
  3. import org.broken.cheststorage.cache.ContainerRegistry;
  4. import org.broken.cheststorage.containerholders.InventoryHolder;
  5. import org.broken.cheststorage.util.MetadataEnumsForGui;
  6. import org.bukkit.Location;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.event.EventHandler;
  9. import org.bukkit.event.EventPriority;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.inventory.InventoryClickEvent;
  12. import org.bukkit.event.inventory.InventoryType;
  13. import org.bukkit.inventory.Inventory;
  14. import org.bukkit.inventory.ItemStack;
  15. import org.mineacademy.fo.SerializeUtil;
  16. import org.mineacademy.fo.remain.CompMetadata;
  17.  
  18. public class MenuEvents implements Listener {
  19. ChestStorage plugin = ChestStorage.getInstance();
  20.  
  21. @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  22. public void onInteract(InventoryClickEvent event) {
  23. if (event.getSlotType() != InventoryType.SlotType.OUTSIDE) return;
  24. Player player = (Player) event.getWhoClicked();
  25.  
  26. if (player.hasMetadata(MetadataEnumsForGui.INVENTORY_CRAFTINGGUI.toString())) return;
  27. if (player.hasMetadata(MetadataEnumsForGui.INVENTORY_FILTERGUI.toString())) return;
  28. if (player.hasMetadata(MetadataEnumsForGui.INVENTORY_LINKTOCONTAINER.toString())) return;
  29.  
  30. Inventory clickedInventory = event.getView().getTopInventory();
  31.  
  32. ContainerRegistry registry = ContainerRegistry.getInstance();
  33. GuiUpgradePages upgradePages = GuiUpgradePages.getInstance();
  34.  
  35. Location location = SerializeUtil.deserializeLocation(CompMetadata.getMetadata(player,
  36. MetadataEnumsForGui.CHEST_METADATA.toString()));
  37.  
  38. if (location != null) {
  39. if (upgradePages.getBuyGuiForPlayer(player) != null)
  40. if (upgradePages.getBuyGuiForPlayer(player).equals(clickedInventory)) {
  41. event.setCancelled(true);
  42. return;
  43. }
  44. InventoryHolder defultchest = plugin.getClassinstans().createObjektInventoryHolder(location, player);
  45. if (defultchest != null && defultchest.getInventory(location) != null && registry.isRegistered(location) &&
  46. defultchest.getInventory(location).contains(clickedInventory)
  47. && registry.getTypeofContainer(location) == ContainerRegistry.TypeOfContainer.PAGEDCONTAINER) {
  48. defultchest.onClickingInsideGui(registry, upgradePages, location, event, player);
  49. }
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement