From 604d90c0be14951f5770630ce80a40b6bfcfcbbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kriv=C3=A1cs=20Schr=C3=B8der?= Date: Sun, 29 Sep 2013 10:00:27 +0200 Subject: [PATCH] Reduce the usage of deprecated ItemStack constructor. Suppress the warning where not possible. --- .../listeners/EggCatcherEntityListener.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/shansen/EggCatcher/listeners/EggCatcherEntityListener.java b/src/main/java/me/shansen/EggCatcher/listeners/EggCatcherEntityListener.java index d3f4dca..9815d0d 100644 --- a/src/main/java/me/shansen/EggCatcher/listeners/EggCatcherEntityListener.java +++ b/src/main/java/me/shansen/EggCatcher/listeners/EggCatcherEntityListener.java @@ -21,7 +21,9 @@ package me.shansen.EggCatcher.listeners; import me.shansen.EggCatcher.EggCatcher; import me.shansen.EggCatcher.EggType; import me.shansen.EggCatcher.events.EggCaptureEvent; + import org.bukkit.Effect; +import org.bukkit.Material; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; @@ -146,7 +148,7 @@ public class EggCatcherEntityListener implements Listener { if (!player.hasPermission("eggcatcher.catch." + eggType.getFriendlyName().toLowerCase())) { player.sendMessage(config.getString("Messages.PermissionFail")); if (!this.looseEggOnFail) { - player.getInventory().addItem(new ItemStack(344, 1)); + player.getInventory().addItem(new ItemStack(Material.EGG, 1)); EggCatcher.eggs.add(egg); } return; @@ -162,7 +164,7 @@ public class EggCatcherEntityListener implements Listener { player.sendMessage(String.format(this.healthPercentageFailMessage, healthPercentage)); } if (!this.looseEggOnFail) { - player.getInventory().addItem(new ItemStack(344, 1)); + player.getInventory().addItem(new ItemStack(Material.EGG, 1)); EggCatcher.eggs.add(egg); } return; @@ -180,7 +182,7 @@ public class EggCatcherEntityListener implements Listener { player.sendMessage(this.catchChanceFailMessage); } if (!this.looseEggOnFail) { - player.getInventory().addItem(new ItemStack(344, 1)); + player.getInventory().addItem(new ItemStack(Material.EGG, 1)); EggCatcher.eggs.add(egg); } return; @@ -192,7 +194,7 @@ public class EggCatcherEntityListener implements Listener { if (!EggCatcher.economy.has(player.getName(), vaultCost)) { player.sendMessage(String.format(config.getString("Messages.VaultFail"), vaultCost)); if (!this.looseEggOnFail) { - player.getInventory().addItem(new ItemStack(344, 1)); + player.getInventory().addItem(new ItemStack(Material.EGG, 1)); EggCatcher.eggs.add(egg); } return; @@ -211,7 +213,8 @@ public class EggCatcherEntityListener implements Listener { int itemId = config.getInt("ItemCost.ItemId", 266); int itemData = config.getInt("ItemCost.ItemData", 0); int itemAmount = config.getInt("ItemCost.Amount." + eggType.getFriendlyName(), 0); - ItemStack itemStack = new ItemStack(itemId, itemAmount, (short) itemData); + @SuppressWarnings("deprecation") + ItemStack itemStack = new ItemStack(itemId, itemAmount, (short) itemData); if (player.getInventory().containsAtLeast(itemStack, itemStack.getAmount())) { player.sendMessage(String.format(config.getString("Messages.ItemCostSuccess"), String.valueOf(itemAmount))); @@ -220,7 +223,7 @@ public class EggCatcherEntityListener implements Listener { player.sendMessage(String.format(config.getString("Messages.ItemCostFail"), String.valueOf(itemAmount))); if (!this.looseEggOnFail) { - player.getInventory().addItem(new ItemStack(344, 1)); + player.getInventory().addItem(new ItemStack(Material.EGG, 1)); EggCatcher.eggs.add(egg); } return; @@ -247,7 +250,7 @@ public class EggCatcherEntityListener implements Listener { entity.getWorld().playEffect(entity.getLocation(), Effect.SMOKE, 0); } - ItemStack eggStack = new ItemStack(383, 1, eggType.getCreatureId()); + ItemStack eggStack = new ItemStack(Material.MONSTER_EGG, 1, eggType.getCreatureId()); String customName = ((LivingEntity) entity).getCustomName(); @@ -260,7 +263,7 @@ public class EggCatcherEntityListener implements Listener { if(entity instanceof Pig) { if(((Pig)entity).hasSaddle()) { - entity.getWorld().dropItem(entity.getLocation(), new ItemStack(329, 1)); + entity.getWorld().dropItem(entity.getLocation(), new ItemStack(Material.SADDLE, 1)); } }