Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onBlockClick(PlayerInteractEvent event) {
- Player player = event.getPlayer();
- Block clickedBlock = event.getClickedBlock();
- if (clickedBlock == null)
- return;
- plugin.getProtectionProvider().getProvider().islocked(player, event.getClickedBlock().getLocation());
- plugin.getProtectionProvider().getProvider().islockedMsg(event.getPlayer(), event.getClickedBlock().getLocation(), event);
- //System.out.println("is cansel " + event.isCancelled());
- if ((clickedBlock.getType() == Material.HOPPER || clickedBlock.getType() == Material.CHEST || clickedBlock.getType() == Material.BARREL)) {
- Location blockLocation = event.getClickedBlock().getLocation();
- if (plugin.getProtectionProvider().getProvider() != null && !plugin.getProtectionProvider().getProvider().islockedMsg(event.getPlayer(), event.getClickedBlock().getLocation(), event))
- return;
- if (!DatabaseSettings.getInstance().isCachecontainersdata() && DatabaseSettings.getInstance().isCacheLoadWhenOpenContainer())
- plugin.getDatabase().getContainerfromSQL(blockLocation);
- if (registry.isRegistered(blockLocation)) {
- Location containerLocation = SerializeUtil.deserializeLocation(CompMetadata.getMetadata(player, this.metadataContainer.toString()));
- InventoryHolders inventory = plugin.getClassinstans().createObjektInventoryHolder(blockLocation, player);
- PreferenceSettingsRegistery settingsRegistery = PreferenceSettingsRegistery.getInstance();
- Player playerUUID = registry.getPlayer(blockLocation);
- switch (this.registry.getTypeofContainer(blockLocation)) {
- case CRAFTINGCONTAINER:
- if (!player.hasMetadata(metadataAktivateLinkMode.toString()) && (clickedBlock.getType() == Material.BARREL || clickedBlock.getType() == Material.CHEST) && event.getAction() == Action.LEFT_CLICK_BLOCK && player.isSneaking()) {
- event.setCancelled(true);
- if (player.hasPermission(ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer")) {
- if (playerlist(settingsRegistery.getPlayers(playerUUID), playerUUID.getUniqueId(), player)) {
- player.setMetadata(metadataContainer.toString(), new FixedMetadataValue(ChestStorage.getInstance(), SerializeUtil.serializeLoc(blockLocation)));
- plugin.getClassinstans().createObjektMenu(blockLocation, player).createMenuForPlayer(player, blockLocation);
- //todo fix own sound for this gui?
- soundWhenOpenContainer(player, blockLocation);
- } else
- ChatMessages.YOU_ARE_NOT_IN_PARTYLIST.sendMessage(player, registry.getOfflinePlayer(blockLocation).getName());
- } else if (!(registry.getPlayerUUID(blockLocation) == player.getUniqueId()) && !player.hasPermission(ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer")) {
- ChatMessages.NOT_THE_OWNER_OF_THIS_CONTAINER.sendMessage(player);
- ChatMessages.NO_PERMISSION_CRAFTINGCONTAINER.sendMessage(player, ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer");
- } else
- ChatMessages.NO_PERMISSION_CRAFTINGCONTAINER.sendMessage(player, ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer");
- if (!player.hasPermission(ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer") && MainSettings.getInstance().getSettingsData().isShowNeedPermissionsInConsole())
- Common.log("Missing " + ChestStorage.getInstance().getName().toLowerCase() + ".open.craftingcontainer permission");
- break;
- }
- case PAGEDCONTAINER:
- case SELLCHEST:
- case STORAGEUNIT:
- if (!player.hasMetadata(metadataAktivateLinkMode.toString()) && !player.isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
- containers(player, blockLocation, inventory);
- soundWhenOpenContainer(player, blockLocation);
- event.setCancelled(true);
- break;
- }
- break;
- case LINKEDCONTAINER:
- if (player.hasMetadata(metadataAktivateLinkMode.toString()) && !containerLocation.equals(blockLocation))
- break;
- String tittle = YamlSettingsContainers.getDisplayName(registry.getContainerFileName(blockLocation), registry.getCurrentUpdate(blockLocation), "", "", registry.getCurrentUpdate(blockLocation) + "");
- int guiSize = YamlSettingsContainers.getGuiSize(registry.getContainerFileName(blockLocation), registry.getCurrentUpdate(blockLocation));
- linkedContainer(player, blockLocation, event);
- if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
- Common.runLater(0, () -> UpdateTittleContainers.update(player, tittle, event.getClickedBlock().getType(), guiSize));
- soundWhenOpenContainer(player, blockLocation);
- //player.setMetadata(metadataContainer.toString(), new FixedMetadataValue(ChestStorage.getInstance(), SerializeUtil.serializeLoc(blockLocation)));
- //player.setMetadata(metadataLinkContainerGui.toString(), new FixedMetadataValue(ChestStorage.getInstance(), metadataLinkContainerGui.toString()));
- break;
- default:
- System.out.println("you are end of the line ");
- break;
- }
- }
- 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)
- event.setCancelled(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement