Advertisement
broken-arrow

Untitled

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