Advertisement
broken-arrow

Untitled

Oct 14th, 2021
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. public void onBlockClick(PlayerInteractEvent event) {
  2.  
  3. System.out.println("event open " + event.getClass().getName().contains("ChestSort"));
  4. if (event.getClass().getName().contains("ChestSort")) return;
  5. Player player = event.getPlayer();
  6. Block clickedBlock = event.getClickedBlock();
  7. if (clickedBlock == null)
  8. return;
  9.  
  10. //System.out.println("is cansel " + event.isCancelled());
  11. if ((clickedBlock.getType() == Material.HOPPER || clickedBlock.getType() == Material.CHEST || clickedBlock.getType() == Material.BARREL)) {
  12. Location blockLocation = event.getClickedBlock().getLocation();
  13. if (plugin.getProtectionProvider().getProvider() != null && !plugin.getProtectionProvider().getProvider().islockedMsg(event.getPlayer(), event.getClickedBlock().getLocation(), event))
  14. return;
  15.  
  16. if (!DatabaseSettings.getInstance().isCachecontainersdata() && DatabaseSettings.getInstance().isCacheLoadWhenOpenContainer())
  17. plugin.getDatabase().getContainerfromSQL(blockLocation);
  18.  
  19. if (registry.isRegistered(blockLocation)) {
  20.  
  21. Location containerLocation = SerializeUtil.deserializeLocation(CompMetadata.getMetadata(player, this.metadataContainer.toString()));
  22.  
  23. InventoryHolders inventory = plugin.getClassinstans().createObjektInventoryHolder(blockLocation, player);
  24.  
  25. PreferenceSettingsRegistery settingsRegistery = PreferenceSettingsRegistery.getInstance();
  26. UUID playerUUID = registry.getPlayerUUID(blockLocation);
  27. switch (this.registry.getTypeofContainer(blockLocation)) {
  28. case CRAFTINGCONTAINER:
  29. if (!player.hasMetadata(metadataAktivateLinkMode.toString()) && (clickedBlock.getType() == Material.BARREL || clickedBlock.getType() == Material.CHEST) && event.getAction() == Action.LEFT_CLICK_BLOCK && player.isSneaking()) {
  30. event.setCancelled(true);
  31. if (player.hasPermission(ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer")) {
  32. if (playerlist(settingsRegistery.getUUIDPlayer(playerUUID), playerUUID, player)) {
  33.  
  34. player.setMetadata(metadataContainer.toString(), new FixedMetadataValue(ChestStorage.getInstance(), SerializeUtil.serializeLoc(blockLocation)));
  35. plugin.getClassinstans().createObjektMenu(blockLocation, player).createMenuForPlayer(player, blockLocation);
  36.  
  37. //todo fix own sound for this gui?
  38. soundWhenOpenContainer(player, blockLocation);
  39. } else
  40. ChatMessages.YOU_ARE_NOT_IN_PARTYLIST.sendMessage(player, registry.getOfflinePlayer(blockLocation).getName());
  41.  
  42. } else if (!(registry.getPlayerUUID(blockLocation) == player.getUniqueId()) && !player.hasPermission(ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer")) {
  43. ChatMessages.NOT_THE_OWNER_OF_THIS_CONTAINER.sendMessage(player);
  44. ChatMessages.NO_PERMISSION_CRAFTINGCONTAINER.sendMessage(player, ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer");
  45. } else
  46. ChatMessages.NO_PERMISSION_CRAFTINGCONTAINER.sendMessage(player, ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer");
  47. if (!player.hasPermission(ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer") && MainSettings.getInstance().getSettingsData().isShowNeedPermissionsInConsole())
  48. Common.log("Missing " + ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer permission");
  49. break;
  50. }
  51. case PAGEDCONTAINER:
  52. case SELLCHEST:
  53. case STORAGEUNIT:
  54. if (!player.hasMetadata(metadataAktivateLinkMode.toString()) && !player.isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
  55. containers(player, blockLocation, inventory);
  56.  
  57. soundWhenOpenContainer(player, blockLocation);
  58. event.setCancelled(true);
  59. break;
  60. }
  61. break;
  62. case LINKEDCONTAINER:
  63. if (player.hasMetadata(metadataAktivateLinkMode.toString()) && !containerLocation.equals(blockLocation))
  64. break;
  65.  
  66. String tittle = YamlSettingsContainers.getDisplayName(registry.getContainerFileName(blockLocation), registry.getCurrentUpdate(blockLocation), "", "", registry.getCurrentUpdate(blockLocation) + "");
  67. int guiSize = YamlSettingsContainers.getGuiSize(registry.getContainerFileName(blockLocation), registry.getCurrentUpdate(blockLocation));
  68.  
  69. linkedContainer(player, blockLocation, event);
  70.  
  71. if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
  72. Common.runLater(0, () -> UpdateTittleContainers.update(player, tittle, event.getClickedBlock().getType(), guiSize));
  73.  
  74. soundWhenOpenContainer(player, blockLocation);
  75. //player.setMetadata(metadataContainer.toString(), new FixedMetadataValue(ChestStorage.getInstance(), SerializeUtil.serializeLoc(blockLocation)));
  76. //player.setMetadata(metadataLinkContainerGui.toString(), new FixedMetadataValue(ChestStorage.getInstance(), metadataLinkContainerGui.toString()));
  77. break;
  78. default:
  79. System.out.println("you are end of the line ");
  80. break;
  81. }
  82. }
  83. if (!player.hasMetadata(metadataAktivateLinkMode.toString()) && !Objects.equals(registry.getTypeofContainer(blockLocation), ContainerRegistry.TypeOfContainer.LINKEDCONTAINER) && event.getAction() == Action.RIGHT_CLICK_BLOCK && registry.isRegistered(blockLocation) && event.getItem() == null)
  84. event.setCancelled(true);
  85.  
  86. }
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement