Various fixed to the interact event.

This commit is contained in:
Brianna 2020-04-08 11:19:27 -04:00
parent ece72cd0e1
commit c82192ef46

View File

@ -1,9 +1,26 @@
package com.songoda.skyblock.listeners;
import java.io.File;
import com.songoda.core.compatibility.CompatibleHand;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandLevel;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
import com.songoda.skyblock.limit.impl.BlockLimitation;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.stackable.Stackable;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.item.InventoryUtil;
import com.songoda.skyblock.utils.structure.StructureUtil;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.world.WorldManager;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@ -28,26 +45,11 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandLevel;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
import com.songoda.skyblock.limit.impl.BlockLimitation;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.stackable.Stackable;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.item.InventoryUtil;
import com.songoda.skyblock.utils.structure.StructureUtil;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.world.WorldManager;
import org.bukkit.permissions.PermissionAttachmentInfo;
import java.io.File;
import java.util.HashMap;
public class Interact implements Listener {
private final SkyBlock skyblock;
@ -123,7 +125,7 @@ public class Interact implements Listener {
}
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR) {
if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.EGG) {
if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.EGG) {
if (!skyblock.getIslandManager().hasPermission(player, "Projectile")) {
event.setCancelled(true);
@ -134,14 +136,15 @@ public class Interact implements Listener {
}
}
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
CompatibleMaterial material = block == null ? null : CompatibleMaterial.getMaterial(block.getType());
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
final CompatibleMaterial blockType = CompatibleMaterial.getBlockMaterial(event.getClickedBlock().getType());
final CompatibleMaterial heldType;
final ItemStack item = event.getItem();
if (item != null && CompatibleMaterial.getMaterial(item.getType()) != CompatibleMaterial.AIR) {
heldType = CompatibleMaterial.getMaterial(event.getItem().getType());
heldType = CompatibleMaterial.getMaterial(event.getItem());
} else {
heldType = CompatibleMaterial.AIR;
}
@ -168,8 +171,6 @@ public class Interact implements Listener {
long limit = limits.getBlockLimit(player, block);
if (limits.isBlockLimitExceeded(block, limit)) {
CompatibleMaterial material = CompatibleMaterial.getBlockMaterial(block.getType());
skyblock.getMessageManager().sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
@ -188,7 +189,6 @@ public class Interact implements Listener {
if (configLoad.getBoolean("Island.Stackable.Limit.Enable")) {
// Add block to stackable
CompatibleMaterial material = CompatibleMaterial.getBlockMaterial(block.getType());
int maxStackSize = getStackLimit(player, material);
if (stackable == null) {
@ -231,7 +231,6 @@ public class Interact implements Listener {
long materialAmmount = 0;
IslandLevel level = island.getLevel();
CompatibleMaterial material = CompatibleMaterial.getBlockMaterial(block.getType());
if (material == null) {
return;
@ -255,13 +254,13 @@ public class Interact implements Listener {
return;
}
if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.BONE_MEAL && !islandManager.hasPermission(player, block.getLocation(), "Place")) {
if (event.getItem() != null && CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BONE_MEAL && !islandManager.hasPermission(player, block.getLocation(), "Place")) {
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setCancelled(true);
return;
}
if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SWEET_BERRY_BUSH) {
if (material == CompatibleMaterial.SWEET_BERRY_BUSH) {
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true);
@ -271,7 +270,7 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ANVIL) {
} else if (material == CompatibleMaterial.ANVIL) {
if (!islandManager.hasPermission(player, block.getLocation(), "Anvil")) {
event.setCancelled(true);
@ -281,15 +280,15 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.WHITE_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ORANGE_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.MAGENTA_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIGHT_BLUE_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.YELLOW_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIME_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.PINK_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.GRAY_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIGHT_GRAY_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CYAN_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CYAN_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.PURPLE_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BLUE_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BROWN_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.GREEN_BED || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.RED_BED
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BLACK_BED
} else if (material == CompatibleMaterial.WHITE_BED || material == CompatibleMaterial.ORANGE_BED
|| material == CompatibleMaterial.MAGENTA_BED || material == CompatibleMaterial.LIGHT_BLUE_BED
|| material == CompatibleMaterial.YELLOW_BED || material == CompatibleMaterial.LIME_BED
|| material == CompatibleMaterial.PINK_BED || material == CompatibleMaterial.GRAY_BED
|| material == CompatibleMaterial.LIGHT_GRAY_BED || material == CompatibleMaterial.CYAN_BED
|| material == CompatibleMaterial.CYAN_BED || material == CompatibleMaterial.PURPLE_BED
|| material == CompatibleMaterial.BLUE_BED || material == CompatibleMaterial.BROWN_BED
|| material == CompatibleMaterial.GREEN_BED || material == CompatibleMaterial.RED_BED
|| material == CompatibleMaterial.BLACK_BED
) {
if (!islandManager.hasPermission(player, block.getLocation(), "Bed")) {
event.setCancelled(true);
@ -300,7 +299,7 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BREWING_STAND) {
} else if (material == CompatibleMaterial.BREWING_STAND) {
if (!islandManager.hasPermission(player, block.getLocation(), "Brewing")) {
event.setCancelled(true);
@ -310,16 +309,16 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CHEST || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.TRAPPED_CHEST
|| (NMSUtil.getVersionNumber() > 9 && (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BLACK_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BLUE_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BROWN_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CYAN_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.GRAY_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.GREEN_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIGHT_BLUE_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIGHT_GRAY_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIME_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.MAGENTA_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ORANGE_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.PINK_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.PURPLE_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.RED_SHULKER_BOX
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.WHITE_SHULKER_BOX || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.YELLOW_SHULKER_BOX))) {
} else if (material == CompatibleMaterial.CHEST || material == CompatibleMaterial.TRAPPED_CHEST
|| (NMSUtil.getVersionNumber() > 9 && (material == CompatibleMaterial.SHULKER_BOX
|| material == CompatibleMaterial.BLACK_SHULKER_BOX || material == CompatibleMaterial.BLUE_SHULKER_BOX
|| material == CompatibleMaterial.BROWN_SHULKER_BOX || material == CompatibleMaterial.CYAN_SHULKER_BOX
|| material == CompatibleMaterial.GRAY_SHULKER_BOX || material == CompatibleMaterial.GREEN_SHULKER_BOX
|| material == CompatibleMaterial.LIGHT_BLUE_SHULKER_BOX || material == CompatibleMaterial.LIGHT_GRAY_SHULKER_BOX
|| material == CompatibleMaterial.LIME_SHULKER_BOX || material == CompatibleMaterial.MAGENTA_SHULKER_BOX
|| material == CompatibleMaterial.ORANGE_SHULKER_BOX || material == CompatibleMaterial.PINK_SHULKER_BOX
|| material == CompatibleMaterial.PURPLE_SHULKER_BOX || material == CompatibleMaterial.RED_SHULKER_BOX
|| material == CompatibleMaterial.WHITE_SHULKER_BOX || material == CompatibleMaterial.YELLOW_SHULKER_BOX))) {
if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
event.setCancelled(true);
@ -329,7 +328,7 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CRAFTING_TABLE) {
} else if (material == CompatibleMaterial.CRAFTING_TABLE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Workbench")) {
event.setCancelled(true);
@ -339,9 +338,9 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BIRCH_DOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ACACIA_DOOR
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DARK_OAK_DOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUNGLE_DOOR
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SPRUCE_DOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OAK_DOOR) {
} else if (material == CompatibleMaterial.BIRCH_DOOR || material == CompatibleMaterial.ACACIA_DOOR
|| material == CompatibleMaterial.DARK_OAK_DOOR || material == CompatibleMaterial.JUNGLE_DOOR
|| material == CompatibleMaterial.SPRUCE_DOOR || material == CompatibleMaterial.OAK_DOOR) {
if (!islandManager.hasPermission(player, block.getLocation(), "Door")) {
event.setCancelled(true);
@ -351,7 +350,7 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ENCHANTING_TABLE) {
} else if (material == CompatibleMaterial.ENCHANTING_TABLE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Enchant")) {
event.setCancelled(true);
@ -361,7 +360,7 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.FURNACE) {
} else if (material == CompatibleMaterial.FURNACE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Furnace")) {
event.setCancelled(true);
@ -371,9 +370,9 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.STONE_BUTTON || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OAK_BUTTON || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SPRUCE_BUTTON
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BIRCH_BUTTON|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUNGLE_BUTTON || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ACACIA_BUTTON
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DARK_OAK_BUTTON || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LEVER) {
} else if (material == CompatibleMaterial.STONE_BUTTON || material == CompatibleMaterial.OAK_BUTTON || material == CompatibleMaterial.SPRUCE_BUTTON
|| material == CompatibleMaterial.BIRCH_BUTTON || material == CompatibleMaterial.JUNGLE_BUTTON || material == CompatibleMaterial.ACACIA_BUTTON
|| material == CompatibleMaterial.DARK_OAK_BUTTON || material == CompatibleMaterial.LEVER) {
if (!islandManager.hasPermission(player, block.getLocation(), "LeverButton")) {
event.setCancelled(true);
@ -383,7 +382,7 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUKEBOX) {
} else if (material == CompatibleMaterial.JUKEBOX) {
if (!islandManager.hasPermission(player, block.getLocation(), "Jukebox")) {
event.setCancelled(true);
@ -393,11 +392,20 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OAK_TRAPDOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SPRUCE_TRAPDOOR
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BIRCH_TRAPDOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUNGLE_TRAPDOOR
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ACACIA_TRAPDOOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DARK_OAK_TRAPDOOR
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.NOTE_BLOCK || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.HOPPER
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.COMPARATOR || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.REPEATER) {
} else if (material == CompatibleMaterial.OAK_TRAPDOOR || material == CompatibleMaterial.SPRUCE_TRAPDOOR
|| material == CompatibleMaterial.BIRCH_TRAPDOOR || material == CompatibleMaterial.JUNGLE_TRAPDOOR
|| material == CompatibleMaterial.ACACIA_TRAPDOOR || material == CompatibleMaterial.DARK_OAK_TRAPDOOR
|| material == CompatibleMaterial.NOTE_BLOCK || material == CompatibleMaterial.HOPPER
|| material == CompatibleMaterial.COMPARATOR || material == CompatibleMaterial.REPEATER) {
if (material == CompatibleMaterial.HOPPER && !islandManager.hasPermission(player, block.getLocation(), "Hopper")) {
event.setCancelled(true);
messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return;
}
if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
event.setCancelled(true);
@ -407,8 +415,8 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OAK_FENCE_GATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ACACIA_FENCE_GATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BIRCH_FENCE_GATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DARK_OAK_FENCE_GATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUNGLE_FENCE_GATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SPRUCE_FENCE_GATE) {
} else if (material == CompatibleMaterial.OAK_FENCE_GATE || material == CompatibleMaterial.ACACIA_FENCE_GATE || material == CompatibleMaterial.BIRCH_FENCE_GATE
|| material == CompatibleMaterial.DARK_OAK_FENCE_GATE || material == CompatibleMaterial.JUNGLE_FENCE_GATE || material == CompatibleMaterial.SPRUCE_FENCE_GATE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Gate")) {
event.setCancelled(true);
@ -418,7 +426,7 @@ public class Interact implements Listener {
return;
}
} else if ((CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DROPPER || (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DISPENSER))) {
} else if ((material == CompatibleMaterial.DROPPER || (material == CompatibleMaterial.DISPENSER))) {
if (!islandManager.hasPermission(player, block.getLocation(), "DropperDispenser")) {
event.setCancelled(true);
@ -428,7 +436,7 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.TNT) {
} else if (material == CompatibleMaterial.TNT) {
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true);
@ -438,7 +446,7 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CAKE) {
} else if (material == CompatibleMaterial.CAKE) {
if (player.getFoodLevel() < 20 && !islandManager.hasPermission(player, block.getLocation(), "Cake")) {
event.setCancelled(true);
@ -448,63 +456,29 @@ public class Interact implements Listener {
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.HOPPER) {
if (!islandManager.hasPermission(player, block.getLocation(), "Hopper")) {
event.setCancelled(true);
messageManager.sendMessage(player,
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return;
}
} else if ((player.getGameMode() == GameMode.SURVIVAL)
&& (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OBSIDIAN) && (event.getItem() != null) && (CompatibleMaterial.getMaterial(event.getItem().getType()) != CompatibleMaterial.AIR)
&& (CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.BUCKET)) {
} else if (player.getGameMode() == GameMode.SURVIVAL
&& material == CompatibleMaterial.OBSIDIAN
&& event.getItem() != null
&& CompatibleMaterial.getMaterial(event.getItem()) != CompatibleMaterial.AIR
&& CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BUCKET) {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Obsidian.Enable")
&& islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
int NMSVersion = NMSUtil.getVersionNumber();
boolean isInventoryFull = false;
if (NMSVersion > 8) {
isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 5, 1, CompatibleMaterial.BUCKET.getBlockMaterial());
} else {
isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 0, 1, CompatibleMaterial.BUCKET.getBlockMaterial());
}
soundManager.playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1.0F, 1.0F);
InventoryUtil.removeItem(player.getInventory(), 1, false, CompatibleMaterial.BUCKET.getBlockMaterial());
CompatibleSound.BLOCK_FIRE_EXTINGUISH.play(block.getWorld(), block.getLocation(), 1.0F, 1.0F);
block.setType(CompatibleMaterial.AIR.getBlockMaterial());
if (isInventoryFull) {
player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(CompatibleMaterial.LAVA_BUCKET.getBlockMaterial()));
} else {
if (NMSVersion > 8) {
isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 5, 1, CompatibleMaterial.LAVA_BUCKET.getBlockMaterial());
} else {
isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 0, 1, CompatibleMaterial.LAVA_BUCKET.getBlockMaterial());
}
if (isInventoryFull) {
player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(CompatibleMaterial.LAVA_BUCKET.getBlockMaterial()));
} else {
player.getInventory().addItem(new ItemStack(CompatibleMaterial.LAVA_BUCKET.getBlockMaterial()));
}
}
ItemUtils.takeActiveItem(player, CompatibleHand.getHand(event));
HashMap<Integer, ItemStack> overflow = player.getInventory().addItem(CompatibleMaterial.LAVA_BUCKET.getItem());
for (ItemStack i : overflow.values())
block.getWorld().dropItemNaturally(block.getLocation(), i);
event.setCancelled(true);
return;
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.END_PORTAL_FRAME) {
} else if (material == CompatibleMaterial.END_PORTAL_FRAME) {
if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
&& islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
if (NMSUtil.getVersionNumber() > 8 && event.getHand() == EquipmentSlot.OFF_HAND) {
return;
}
if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) {
if (com.songoda.epicanchors.EpicAnchors.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
event.setCancelled(true);
@ -512,11 +486,12 @@ public class Interact implements Listener {
}
}
if (CompatibleHand.getHand(event) == CompatibleHand.OFF_HAND) return;
ItemStack is = event.getPlayer().getItemInHand();
boolean hasEye = ((block.getData() >> 2) & 1) == 1;
if (is == null || CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.AIR) {
if (CompatibleMaterial.getMaterial(is.getType()) == CompatibleMaterial.AIR) {
int size = 1;
if (stackableManager != null && stackableManager.isStacked(block.getLocation())) {
@ -556,7 +531,7 @@ public class Interact implements Listener {
}
}
soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 10.0F, 10.0F);
CompatibleSound.ENTITY_CHICKEN_EGG.play(player, 10.0F, 10.0F);
event.setCancelled(true);
return;
@ -564,10 +539,10 @@ public class Interact implements Listener {
}
}
if ((event.getItem() != null) && (CompatibleMaterial.getMaterial(event.getItem().getType()) != CompatibleMaterial.AIR) && !event.isCancelled()) {
if (CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.BUCKET
|| CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.WATER_BUCKET
|| CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.LAVA_BUCKET) {
if ((event.getItem() != null) && (CompatibleMaterial.getMaterial(event.getItem()) != CompatibleMaterial.AIR) && !event.isCancelled()) {
if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.BUCKET
|| CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.WATER_BUCKET
|| CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.LAVA_BUCKET) {
if (!islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
event.setCancelled(true);
@ -577,8 +552,8 @@ public class Interact implements Listener {
player.updateInventory();
}
} else if (CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.GLASS_BOTTLE) {
if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.WATER || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.CAULDRON) {
} else if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.GLASS_BOTTLE) {
if (material == CompatibleMaterial.WATER || material == CompatibleMaterial.CAULDRON) {
if (!islandManager.hasPermission(player, block.getLocation(), "WaterCollection")) {
event.setCancelled(true);
@ -599,7 +574,7 @@ public class Interact implements Listener {
player.updateInventory();
}
} else if (CompatibleMaterial.getMaterial(event.getItem().getType()) == CompatibleMaterial.ARMOR_STAND || event.getItem().getType().name().contains("BOAT") || event.getItem().getType().name().contains("MINECART")) {
} else if (CompatibleMaterial.getMaterial(event.getItem()) == CompatibleMaterial.ARMOR_STAND || event.getItem().getType().name().contains("BOAT") || event.getItem().getType().name().contains("MINECART")) {
if (!islandManager.hasPermission(player, block.getLocation(), "EntityPlacement")) {
event.setCancelled(true);
@ -623,9 +598,9 @@ public class Interact implements Listener {
}
}
} else if (event.getAction() == Action.PHYSICAL) {
if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.TURTLE_EGG) {
if (material == CompatibleMaterial.TURTLE_EGG) {
event.setCancelled(true);
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.FARMLAND) {
} else if (material == CompatibleMaterial.FARMLAND) {
if (!islandManager.hasPermission(player, block.getLocation(), "Crop")) {
event.setCancelled(true);
@ -633,16 +608,16 @@ public class Interact implements Listener {
skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.STONE_PRESSURE_PLATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.OAK_PRESSURE_PLATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.SPRUCE_PRESSURE_PLATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.BIRCH_PRESSURE_PLATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.JUNGLE_PRESSURE_PLATE || CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.ACACIA_PRESSURE_PLATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.DARK_OAK_PRESSURE_PLATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.LIGHT_WEIGHTED_PRESSURE_PLATE
|| CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE) {
} else if (material == CompatibleMaterial.STONE_PRESSURE_PLATE || material == CompatibleMaterial.OAK_PRESSURE_PLATE
|| material == CompatibleMaterial.SPRUCE_PRESSURE_PLATE || material == CompatibleMaterial.BIRCH_PRESSURE_PLATE
|| material == CompatibleMaterial.JUNGLE_PRESSURE_PLATE || material == CompatibleMaterial.ACACIA_PRESSURE_PLATE
|| material == CompatibleMaterial.DARK_OAK_PRESSURE_PLATE
|| material == CompatibleMaterial.LIGHT_WEIGHTED_PRESSURE_PLATE
|| material == CompatibleMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE) {
if (!islandManager.hasPermission(player, block.getLocation(), "PressurePlate")) {
event.setCancelled(true);
}
} else if (CompatibleMaterial.getMaterial(block.getType()) == CompatibleMaterial.TRIPWIRE) {
} else if (material == CompatibleMaterial.TRIPWIRE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
event.setCancelled(true);