diff --git a/src/com/dre/brewery/BCauldron.java b/src/com/dre/brewery/BCauldron.java index d9af21f..6c5f5fc 100644 --- a/src/com/dre/brewery/BCauldron.java +++ b/src/com/dre/brewery/BCauldron.java @@ -85,7 +85,6 @@ public class BCauldron { } // fills players bottle with cooked brew - @SuppressWarnings("deprecation") public static boolean fill(Player player, Block block) { BCauldron bcauldron = get(block); if (bcauldron != null) { @@ -172,7 +171,7 @@ public class BCauldron { if (cauldron.state != 1) { config.set(prefix + ".state", cauldron.state); } - config.set(prefix + ".ingredients", cauldron.ingredients.serializeIngredients()); + config.set(prefix + ".ingredients", cauldron.ingredients); id++; } } diff --git a/src/com/dre/brewery/BIngredients.java b/src/com/dre/brewery/BIngredients.java index 4700ee3..ab43052 100644 --- a/src/com/dre/brewery/BIngredients.java +++ b/src/com/dre/brewery/BIngredients.java @@ -297,17 +297,17 @@ public class BIngredients { if (cookedTime != 0) { config.set(path + ".cookedTime", cookedTime); } - config.set(path + ".mats", serializeIngredients()); + config.set(path + ".mats", ingredients); return id; } // convert the ingredient Material to id - public Map serializeIngredients() { + /*public Map serializeIngredients() { Map mats = new HashMap(); for (Material mat : ingredients.keySet()) { mats.put(mat.getId(), ingredients.get(mat)); } return mats; - } + }*/ } \ No newline at end of file diff --git a/src/com/dre/brewery/BPlayer.java b/src/com/dre/brewery/BPlayer.java index a39f629..c2490d1 100644 --- a/src/com/dre/brewery/BPlayer.java +++ b/src/com/dre/brewery/BPlayer.java @@ -10,7 +10,6 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.inventory.ItemStack; import org.bukkit.Material; -import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.util.Vector; import org.bukkit.Location; import org.bukkit.potion.PotionEffectType; diff --git a/src/com/dre/brewery/Barrel.java b/src/com/dre/brewery/Barrel.java index 83f9d7f..ae3f193 100644 --- a/src/com/dre/brewery/Barrel.java +++ b/src/com/dre/brewery/Barrel.java @@ -212,7 +212,6 @@ public class Barrel { } // player opens the barrel - @SuppressWarnings("deprecation") public void open(Player player) { if (inventory == null) { if (isLarge()) { @@ -225,7 +224,7 @@ public class Barrel { // if nobody has the inventory opened if (inventory.getViewers().isEmpty()) { // if inventory contains potions - if (inventory.contains(373)) { + if (inventory.contains(Material.POTION)) { byte wood = getWood(); long loadTime = System.nanoTime(); for (ItemStack item : inventory.getContents()) { @@ -328,26 +327,28 @@ public class Barrel { public static Barrel get(Block block) { if (block != null) { switch (block.getType()) { - case FENCE: - case NETHER_FENCE: - case SIGN: - case WALL_SIGN: - Barrel barrel = getBySpigot(block); - if (barrel != null) { - return barrel; - } - return null; - case WOOD: - case WOOD_STAIRS: - case ACACIA_STAIRS: - case BIRCH_WOOD_STAIRS: - case DARK_OAK_STAIRS: - case JUNGLE_WOOD_STAIRS: - case SPRUCE_WOOD_STAIRS: - Barrel barrel2 = getByWood(block); - if (barrel2 != null) { - return barrel2; - } + case FENCE: + case NETHER_FENCE: + case SIGN: + case WALL_SIGN: + Barrel barrel = getBySpigot(block); + if (barrel != null) { + return barrel; + } + return null; + case WOOD: + case WOOD_STAIRS: + case ACACIA_STAIRS: + case BIRCH_WOOD_STAIRS: + case DARK_OAK_STAIRS: + case JUNGLE_WOOD_STAIRS: + case SPRUCE_WOOD_STAIRS: + Barrel barrel2 = getByWood(block); + if (barrel2 != null) { + return barrel2; + } + default: + break; } } return null; @@ -560,31 +561,30 @@ public class Barrel { } // direction of the barrel from the spigot - @SuppressWarnings("deprecation") public static int getDirection(Block spigot) { int direction = 0;// 1=x+ 2=x- 3=z+ 4=z- - int typeId = spigot.getRelative(0, 0, 1).getTypeId(); - if (typeId == 5 || isStairs(typeId)) { + Material type = spigot.getRelative(0, 0, 1).getType(); + if (type == Material.WOOD || isStairs(type)) { direction = 3; } - typeId = spigot.getRelative(0, 0, -1).getTypeId(); - if (typeId == 5 || isStairs(typeId)) { + type = spigot.getRelative(0, 0, -1).getType(); + if (type == Material.WOOD || isStairs(type)) { if (direction == 0) { direction = 4; } else { return 0; } } - typeId = spigot.getRelative(1, 0, 0).getTypeId(); - if (typeId == 5 || isStairs(typeId)) { + type = spigot.getRelative(1, 0, 0).getType(); + if (type == Material.WOOD || isStairs(type)) { if (direction == 0) { direction = 1; } else { return 0; } } - typeId = spigot.getRelative(-1, 0, 0).getTypeId(); - if (typeId == 5 || isStairs(typeId)) { + type = spigot.getRelative(-1, 0, 0).getType(); + if (type == Material.WOOD || isStairs(type)) { if (direction == 0) { direction = 2; } else { @@ -600,13 +600,11 @@ public class Barrel { } // true for small barrels - @SuppressWarnings("deprecation") public static boolean isSign(Block spigot) { - return spigot.getTypeId() == 63 || spigot.getTypeId() == 68; + return spigot.getType() == Material.SIGN || spigot.getType() == Material.SIGN_POST; } // woodtype of the block the spigot is attached to - @SuppressWarnings("deprecation") public byte getWood() { int direction = getDirection(this.spigot);// 1=x+ 2=x- 3=z+ 4=z- Block wood; @@ -621,7 +619,7 @@ public class Barrel { } else { wood = this.spigot.getRelative(0, 0, -1); } - if (wood.getTypeId() == 5) { + if (wood.getType() == Material.WOOD) { byte data = wood.getData(); if (data == 0x0) { return 2; @@ -633,16 +631,16 @@ public class Barrel { return 3; } } - if (wood.getTypeId() == 53) { + if (wood.getType() == Material.WOOD_STAIRS) { return 2; } - if (wood.getTypeId() == 134) { + if (wood.getType() == Material.SPRUCE_WOOD_STAIRS) { return 4; } - if (wood.getTypeId() == 135) { + if (wood.getType() == Material.BIRCH_WOOD_STAIRS) { return 1; } - if (wood.getTypeId() == 136) { + if (wood.getType() == Material.JUNGLE_WOOD_STAIRS) { return 3; } return 0; @@ -665,14 +663,13 @@ public class Barrel { } // returns the fence above/below a block, itself if there is none - @SuppressWarnings("deprecation") public static Block getSpigotOfSign(Block block) { int y = -2; while (y <= 1) { // Fence and Netherfence Block relative = block.getRelative(0, y, 0); - if (relative.getTypeId() == 85 || relative.getTypeId() == 113) { + if (relative.getType() == Material.FENCE || relative.getType() == Material.NETHER_FENCE) { return (relative); } y++; @@ -680,13 +677,8 @@ public class Barrel { return block; } - @SuppressWarnings("deprecation") - public static boolean isStairs(Material mat) { - return isStairs(mat.getId()); - } - - public static boolean isStairs(int id) { - return id == 53 || id == 134 || id == 135 || id == 136 || id == 163 || id == 164; + public static boolean isStairs(Material material) { + return material == Material.WOOD_STAIRS || material == Material.SPRUCE_WOOD_STAIRS || material == Material.BIRCH_WOOD_STAIRS || material == Material.JUNGLE_WOOD_STAIRS || material == Material.ACACIA_STAIRS || material == Material.DARK_OAK_STAIRS; } // returns null if Barrel is correctly placed; the block that is missing when not @@ -704,7 +696,6 @@ public class Barrel { return null; } - @SuppressWarnings("deprecation") public Block checkSBarrel() { int direction = getDirection(spigot);// 1=x+ 2=x- 3=z+ 4=z- if (direction == 0) { @@ -739,7 +730,7 @@ public class Barrel { endZ = startZ + 1; } - int typeId; + Material type; int x = startX; int y = 0; int z = startZ; @@ -747,9 +738,9 @@ public class Barrel { while (x <= endX) { while (z <= endZ) { Block block = spigot.getRelative(x, y, z); - typeId = block.getTypeId(); + type = block.getType(); - if (isStairs(typeId)) { + if (isStairs(type)) { if (y == 0) { // stairs have to be upside down if (block.getData() < 4) { @@ -775,7 +766,6 @@ public class Barrel { return null; } - @SuppressWarnings("deprecation") public Block checkLBarrel() { int direction = getDirection(spigot);// 1=x+ 2=x- 3=z+ 4=z- if (direction == 0) { @@ -811,7 +801,7 @@ public class Barrel { endZ = startZ + 3; } - int typeId; + Material type; int x = startX; int y = 0; int z = startZ; @@ -819,7 +809,7 @@ public class Barrel { while (x <= endX) { while (z <= endZ) { Block block = spigot.getRelative(x, y, z); - typeId = block.getTypeId(); + type = block.getType(); if (direction == 1 || direction == 2) { if (y == 1 && z == 0) { if (x == -1 || x == -4 || x == 1 || x == 4) { @@ -841,8 +831,8 @@ public class Barrel { continue; } } - if (typeId == 5 || isStairs(typeId)) { - if (typeId == 5) { + if (type == Material.WOOD || isStairs(type)) { + if (type == Material.WOOD) { woods.add(block.getX()); woods.add(block.getY()); woods.add(block.getZ()); diff --git a/src/com/dre/brewery/Brew.java b/src/com/dre/brewery/Brew.java index 1f3f56e..6ae0736 100644 --- a/src/com/dre/brewery/Brew.java +++ b/src/com/dre/brewery/Brew.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.ArrayList; import java.util.List; +import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; @@ -73,7 +74,7 @@ public class Brew { // returns a Brew by ItemStack public static Brew get(ItemStack item) { - if (item.getTypeId() == 373) { + if (item.getType() == Material.POTION) { if (item.hasItemMeta()) { PotionMeta potionMeta = (PotionMeta) item.getItemMeta(); return get(potionMeta); diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index 431e9f7..bcbbbc8 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -590,55 +590,57 @@ public class P extends JavaPlugin { // Returns true if the Block can be destroyed by the Player or something else (null) public boolean blockDestroy(Block block, Player player) { switch (block.getType()) { - case CAULDRON: - // will only remove when existing - BCauldron.remove(block); - return true; - case FENCE: - case NETHER_FENCE: - // remove barrel and throw potions on the ground - Barrel barrel = Barrel.getBySpigot(block); - if (barrel != null) { - if (barrel.hasPermsDestroy(player)) { - barrel.remove(null, player); + case CAULDRON: + // will only remove when existing + BCauldron.remove(block); + return true; + case FENCE: + case NETHER_FENCE: + // remove barrel and throw potions on the ground + Barrel barrel = Barrel.getBySpigot(block); + if (barrel != null) { + if (barrel.hasPermsDestroy(player)) { + barrel.remove(null, player); + return true; + } else { + return false; + } + } + return true; + case SIGN: + case WALL_SIGN: + // remove small Barrels + Barrel barrel2 = Barrel.getBySpigot(block); + if (barrel2 != null) { + if (!barrel2.isLarge()) { + if (barrel2.hasPermsDestroy(player)) { + barrel2.remove(null, player); return true; } else { return false; } + } else { + barrel2.destroySign(); } - return true; - case SIGN: - case WALL_SIGN: - // remove small Barrels - Barrel barrel2 = Barrel.getBySpigot(block); - if (barrel2 != null) { - if (!barrel2.isLarge()) { - if (barrel2.hasPermsDestroy(player)) { - barrel2.remove(null, player); - return true; - } else { - return false; - } - } else { - barrel2.destroySign(); - } - } - return true; - case WOOD: - case WOOD_STAIRS: - case ACACIA_STAIRS: - case BIRCH_WOOD_STAIRS: - case DARK_OAK_STAIRS: - case JUNGLE_WOOD_STAIRS: - case SPRUCE_WOOD_STAIRS: - Barrel barrel3 = Barrel.getByWood(block); - if (barrel3 != null) { - if (barrel3.hasPermsDestroy(player)) { - barrel3.remove(block, player); - } else { - return false; - } + } + return true; + case WOOD: + case WOOD_STAIRS: + case ACACIA_STAIRS: + case BIRCH_WOOD_STAIRS: + case DARK_OAK_STAIRS: + case JUNGLE_WOOD_STAIRS: + case SPRUCE_WOOD_STAIRS: + Barrel barrel3 = Barrel.getByWood(block); + if (barrel3 != null) { + if (barrel3.hasPermsDestroy(player)) { + barrel3.remove(block, player); + } else { + return false; } + } + default: + break; } return true; } diff --git a/src/com/dre/brewery/integration/GriefPreventionBarrel.java b/src/com/dre/brewery/integration/GriefPreventionBarrel.java index 0f470f4..a992d16 100644 --- a/src/com/dre/brewery/integration/GriefPreventionBarrel.java +++ b/src/com/dre/brewery/integration/GriefPreventionBarrel.java @@ -1,11 +1,9 @@ package com.dre.brewery.integration; - import org.bukkit.block.Block; import org.bukkit.entity.Player; import com.dre.brewery.P; -import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.Configuration.WorldConfig; import me.ryanhamshire.GriefPrevention.GriefPrevention; import me.ryanhamshire.GriefPrevention.Messages; @@ -13,7 +11,6 @@ import me.ryanhamshire.GriefPrevention.PlayerData; import me.ryanhamshire.GriefPrevention.TextMode; public class GriefPreventionBarrel { - public static boolean checkAccess(Player player, Block sign) { WorldConfig wc = GriefPrevention.instance.getWorldCfg(player.getWorld()); diff --git a/src/com/dre/brewery/integration/LogBlockBarrel.java b/src/com/dre/brewery/integration/LogBlockBarrel.java index a466910..29b42e3 100644 --- a/src/com/dre/brewery/integration/LogBlockBarrel.java +++ b/src/com/dre/brewery/integration/LogBlockBarrel.java @@ -31,7 +31,6 @@ public class LogBlockBarrel { opened.add(this); } - @SuppressWarnings("deprecation") private void compareInv(final ItemStack[] after) { final ItemStack[] diff = compareInventories(items, after); for (final ItemStack item : diff) { @@ -62,7 +61,6 @@ public class LogBlockBarrel { } } - @SuppressWarnings("deprecation") public static void breakBarrel(String playerName, ItemStack[] contents, Location spigotLoc) { if (!isLogging(spigotLoc.getWorld(), Logging.CHESTACCESS)) return; final ItemStack[] items = compressInventory(contents); diff --git a/src/com/dre/brewery/listeners/CommandListener.java b/src/com/dre/brewery/listeners/CommandListener.java index bd0dac4..40462b2 100644 --- a/src/com/dre/brewery/listeners/CommandListener.java +++ b/src/com/dre/brewery/listeners/CommandListener.java @@ -2,6 +2,7 @@ package com.dre.brewery.listeners; import java.util.ArrayList; +import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -346,7 +347,7 @@ public class CommandListener implements CommandExecutor { if (hand != null) { if (Brew.get(hand) != null) { Brew.remove(hand); - player.setItemInHand(new ItemStack(0)); + player.setItemInHand(new ItemStack(Material.AIR)); return; } } diff --git a/src/com/dre/brewery/listeners/EntityListener.java b/src/com/dre/brewery/listeners/EntityListener.java index 8099994..bdcfb36 100644 --- a/src/com/dre/brewery/listeners/EntityListener.java +++ b/src/com/dre/brewery/listeners/EntityListener.java @@ -2,6 +2,7 @@ package com.dre.brewery.listeners; import java.util.ListIterator; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -11,6 +12,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Item; import org.bukkit.inventory.ItemStack; @@ -25,7 +27,7 @@ public class EntityListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onItemDespawn(ItemDespawnEvent event) { ItemStack item = event.getEntity().getItemStack(); - if (item.getTypeId() == 373) { + if (item.getType() == Material.POTION) { Brew.remove(item); } } @@ -33,10 +35,10 @@ public class EntityListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityCombust(EntityCombustEvent event) { Entity entity = event.getEntity(); - if (entity.getType().getTypeId() == 1) { + if (entity.getType() == EntityType.DROPPED_ITEM) { if (entity instanceof Item) { ItemStack item = ((Item) entity).getItemStack(); - if (item.getTypeId() == 373) { + if (item.getType() == Material.POTION) { Brew.remove(item); } } diff --git a/src/com/dre/brewery/listeners/InventoryListener.java b/src/com/dre/brewery/listeners/InventoryListener.java index ea4cb11..c98f318 100644 --- a/src/com/dre/brewery/listeners/InventoryListener.java +++ b/src/com/dre/brewery/listeners/InventoryListener.java @@ -70,7 +70,7 @@ public class InventoryListener implements Listener { ItemStack item = event.getCurrentItem(); if (item != null) { - if (item.getTypeId() == 373) { + if (item.getType() == Material.POTION) { if (item.hasItemMeta()) { PotionMeta meta = (PotionMeta) item.getItemMeta(); Brew brew = Brew.get(meta); diff --git a/src/com/dre/brewery/listeners/PlayerListener.java b/src/com/dre/brewery/listeners/PlayerListener.java index 9f97c21..63b6175 100644 --- a/src/com/dre/brewery/listeners/PlayerListener.java +++ b/src/com/dre/brewery/listeners/PlayerListener.java @@ -24,7 +24,6 @@ import com.dre.brewery.P; public class PlayerListener implements Listener { public static boolean openEverywhere; - @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { Block clickedBlock = event.getClickedBlock(); @@ -53,7 +52,7 @@ public class PlayerListener implements Listener { if (item.getAmount() > 1) { item.setAmount(item.getAmount() - 1); } else { - player.setItemInHand(new ItemStack(0)); + player.setItemInHand(new ItemStack(Material.AIR)); } } } @@ -89,7 +88,7 @@ public class PlayerListener implements Listener { if (isBucket) { player.setItemInHand(new ItemStack(Material.BUCKET)); } else { - player.setItemInHand(new ItemStack(0)); + player.setItemInHand(new ItemStack(Material.AIR)); } } }