From 1a820ad9b7d2564d836f3044f770aec56c0b04a1 Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Tue, 12 Dec 2017 22:06:25 -0800 Subject: [PATCH] Initial removal of item IDs. We do not rely on Bukkit's item ids anymore, though we still support them in commands via a mapping built off of the items.csv. --- .../essentials/EssentialsPlayerListener.java | 6 +- .../com/earth2me/essentials/ISettings.java | 5 +- .../src/com/earth2me/essentials/IUser.java | 3 +- .../src/com/earth2me/essentials/ItemDb.java | 83 ++++++++++++++----- .../src/com/earth2me/essentials/Settings.java | 17 ++-- .../src/com/earth2me/essentials/User.java | 5 +- .../src/com/earth2me/essentials/UserData.java | 38 +++++---- .../src/com/earth2me/essentials/Worth.java | 46 +++++++--- .../com/earth2me/essentials/api/IItemDb.java | 5 ++ .../essentials/commands/Commandgive.java | 3 +- .../essentials/commands/Commanditem.java | 5 +- .../essentials/commands/Commanditemdb.java | 8 +- .../essentials/commands/Commandmore.java | 7 +- .../essentials/commands/Commandrepair.java | 15 ++-- .../essentials/commands/Commandsell.java | 2 +- .../essentials/commands/Commandsetworth.java | 4 +- .../essentials/commands/Commandunlimited.java | 12 +-- .../essentials/commands/Commandworth.java | 2 +- .../essentials/storage/BukkitConstructor.java | 30 ++----- .../antibuild/EssentialsAntiBuild.java | 13 +-- .../EssentialsAntiBuildListener.java | 40 ++++----- .../essentials/antibuild/IAntiBuild.java | 5 +- .../essentials/protect/EssentialsProtect.java | 9 +- .../earth2me/essentials/protect/IProtect.java | 3 +- 24 files changed, 225 insertions(+), 141 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 275b05cf6..e2a5df9c0 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -596,7 +596,7 @@ public class EssentialsPlayerListener implements Listener { case LEFT_CLICK_BLOCK: if (event.getItem() != null && event.getItem().getType() != Material.AIR) { final User user = ess.getUser(event.getPlayer()); - if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getTypeId())) { + if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getType())) { event.setCancelled(true); } } @@ -630,8 +630,8 @@ public class EssentialsPlayerListener implements Listener { } } - private boolean usePowertools(final User user, final int id) { - final List commandList = user.getPowertool(id); + private boolean usePowertools(final User user, final Material material) { + final List commandList = user.getPowertool(material); if (commandList == null || commandList.isEmpty()) { return false; } diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 8f6a3eaae..a0385d787 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -5,6 +5,7 @@ import com.earth2me.essentials.signs.EssentialsSign; import com.earth2me.essentials.textreader.IText; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.event.EventPriority; @@ -80,7 +81,7 @@ public interface ISettings extends IConf { int getProtectCreeperMaxHeight(); - List getProtectList(final String configName); + List getProtectList(final String configName); boolean getProtectPreventSpawn(final String creatureName); @@ -120,7 +121,7 @@ public interface ISettings extends IConf { boolean isTradeInStacks(int id); - List itemSpawnBlacklist(); + List itemSpawnBlacklist(); List enabledSigns(); diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java index 6a9c98230..66945addc 100644 --- a/Essentials/src/com/earth2me/essentials/IUser.java +++ b/Essentials/src/com/earth2me/essentials/IUser.java @@ -4,6 +4,7 @@ import com.earth2me.essentials.commands.IEssentialsCommand; import net.ess3.api.ITeleport; import net.ess3.api.MaxMoneyException; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Player; import java.math.BigDecimal; @@ -35,7 +36,7 @@ public interface IUser { boolean canAfford(BigDecimal value); - Boolean canSpawnItem(final int itemId); + Boolean canSpawnItem(final Material material); void setLastLocation(); diff --git a/Essentials/src/com/earth2me/essentials/ItemDb.java b/Essentials/src/com/earth2me/essentials/ItemDb.java index 73d4e1024..2e169409f 100644 --- a/Essentials/src/com/earth2me/essentials/ItemDb.java +++ b/Essentials/src/com/earth2me/essentials/ItemDb.java @@ -20,6 +20,7 @@ import org.bukkit.potion.Potion; import org.bukkit.potion.PotionEffect; import java.util.*; +import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,10 +28,12 @@ import static com.earth2me.essentials.I18n.tl; public class ItemDb implements IConf, net.ess3.api.IItemDb { + protected static final Logger LOGGER = Logger.getLogger("Essentials"); private final transient IEssentials ess; private final transient Map items = new HashMap<>(); private final transient Map> names = new HashMap<>(); private final transient Map primaryName = new HashMap<>(); + private final transient Map legacyIds = new HashMap<>(); private final transient Map durabilities = new HashMap<>(); private final transient Map nbtData = new HashMap<>(); private final transient ManagedFile file; @@ -95,13 +98,19 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { if (itemName == null || numeric < 0) { continue; } + + Material material = Material.matchMaterial(itemName); + if (material == null) { + LOGGER.warning(String.format("Failed to find material for %s", itemName)); + continue; + } durabilities.put(itemName, data); items.put(itemName, numeric); if (nbt != null) { nbtData.put(itemName, nbt); } - ItemData itemData = new ItemData(numeric, data); + ItemData itemData = new ItemData(material, numeric, data); if (names.containsKey(itemData)) { List nameList = names.get(itemData); nameList.add(itemName); @@ -111,6 +120,8 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { names.put(itemData, nameList); primaryName.put(itemData, itemName); } + + legacyIds.put(numeric, itemData); } for (List nameList : names.values()) { @@ -152,16 +163,6 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { if (durabilities.containsKey(itemname) && metaData == 0) { metaData = durabilities.get(itemname); } - } else if (Material.getMaterial(itemname.toUpperCase(Locale.ENGLISH)) != null) { - Material bMaterial = Material.getMaterial(itemname.toUpperCase(Locale.ENGLISH)); - itemid = bMaterial.getId(); - } else { - try { - Material bMaterial = Bukkit.getUnsafe().getMaterialFromInternalName(itemname.toLowerCase(Locale.ENGLISH)); - itemid = bMaterial.getId(); - } catch (Throwable throwable) { - throw new Exception(tl("unknownItemName", itemname), throwable); - } } } @@ -169,10 +170,12 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { throw new Exception(tl("unknownItemName", itemname)); } - final Material mat = Material.getMaterial(itemid); - if (mat == null) { + ItemData data = legacyIds.get(itemid); + if (data == null) { throw new Exception(tl("unknownItemId", itemid)); } + + Material mat = data.getMaterial(); ItemStack retval = new ItemStack(mat); if (nbtData.containsKey(itemname)) { String nbt = nbtData.get(itemname); @@ -241,10 +244,10 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { @Override public String names(ItemStack item) { - ItemData itemData = new ItemData(item.getTypeId(), item.getDurability()); + ItemData itemData = new ItemData(item.getType(), item.getDurability()); List nameList = names.get(itemData); if (nameList == null) { - itemData = new ItemData(item.getTypeId(), (short) 0); + itemData = new ItemData(item.getType(), (short) 0); nameList = names.get(itemData); if (nameList == null) { return null; @@ -259,10 +262,10 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { @Override public String name(ItemStack item) { - ItemData itemData = new ItemData(item.getTypeId(), item.getDurability()); + ItemData itemData = new ItemData(item.getType(), item.getDurability()); String name = primaryName.get(itemData); if (name == null) { - itemData = new ItemData(item.getTypeId(), (short) 0); + itemData = new ItemData(item.getType(), (short) 0); name = primaryName.get(itemData); if (name == null) { return null; @@ -415,22 +418,56 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { return sb.toString().trim().replaceAll("ยง", "&"); } + @Override + public Material getFromLegacyId(int id) { + ItemData data = this.legacyIds.get(id); + if(data == null) { + return null; + } + + return data.getMaterial(); + } + + @Override + public int getLegacyId(Material material) throws Exception { + for(Map.Entry entry : items.entrySet()) { + if(material.name().toLowerCase(Locale.ENGLISH).equalsIgnoreCase(entry.getKey())) { + return entry.getValue(); + } + } + + throw new Exception("Itemid not found for material: " + material.name()); + } + @Override public Collection listNames() { return primaryName.values(); } static class ItemData { - final private int itemNo; + final private Material material; + private int legacyId; final private short itemData; - ItemData(final int itemNo, final short itemData) { - this.itemNo = itemNo; + ItemData(Material material, short itemData) { + this.material = material; this.itemData = itemData; } + @Deprecated + ItemData(Material material, final int legacyId, final short itemData) { + this.material = material; + this.legacyId = legacyId; + this.itemData = itemData; + } + + public Material getMaterial() { + return material; + } + + @Deprecated public int getItemNo() { - return itemNo; + return legacyId; } public short getItemData() { @@ -439,7 +476,7 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { @Override public int hashCode() { - return (31 * itemNo) ^ itemData; + return (31 * material.hashCode()) ^ itemData; } @Override @@ -451,7 +488,7 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb { return false; } ItemData pairo = (ItemData) o; - return this.itemNo == pairo.getItemNo() && this.itemData == pairo.getItemData(); + return this.material == pairo.getMaterial() && this.itemData == pairo.getItemData(); } } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index d924653d6..61bd9ada6 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -10,6 +10,7 @@ import com.earth2me.essentials.utils.NumberUtil; import net.ess3.api.IEssentials; import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.MemoryConfiguration; import org.bukkit.event.EventPriority; @@ -555,15 +556,15 @@ public class Settings implements net.ess3.api.ISettings { unprotectedSigns = _getUnprotectedSign(); } - private List itemSpawnBl = new ArrayList(); + private List itemSpawnBl = new ArrayList(); @Override - public List itemSpawnBlacklist() { + public List itemSpawnBlacklist() { return itemSpawnBl; } - private List _getItemSpawnBlacklist() { - final List epItemSpwn = new ArrayList(); + private List _getItemSpawnBlacklist() { + final List epItemSpwn = new ArrayList<>(); if (ess.getItemDb() == null) { logger.log(Level.FINE, "Aborting ItemSpawnBL read, itemDB not yet loaded."); return epItemSpwn; @@ -575,7 +576,7 @@ public class Settings implements net.ess3.api.ISettings { } try { final ItemStack iStack = ess.getItemDb().get(itemName); - epItemSpwn.add(iStack.getTypeId()); + epItemSpwn.add(iStack.getType()); } catch (Exception ex) { logger.log(Level.SEVERE, tl("unknownItemInList", itemName, "item-spawn-blacklist")); } @@ -685,8 +686,8 @@ public class Settings implements net.ess3.api.ISettings { } @Override - public List getProtectList(final String configName) { - final List list = new ArrayList(); + public List getProtectList(final String configName) { + final List list = new ArrayList<>(); for (String itemName : config.getString(configName, "").split(",")) { itemName = itemName.trim(); if (itemName.isEmpty()) { @@ -695,7 +696,7 @@ public class Settings implements net.ess3.api.ISettings { ItemStack itemStack; try { itemStack = ess.getItemDb().get(itemName); - list.add(itemStack.getTypeId()); + list.add(itemStack.getType()); } catch (Exception ex) { logger.log(Level.SEVERE, tl("unknownItemInList", itemName, configName)); } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index a3213b595..c644eea5e 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -18,6 +18,7 @@ import net.ess3.nms.refl.ReflUtil; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.ItemStack; @@ -222,8 +223,8 @@ public class User extends UserData implements Comparable, IMessageRecipien } @Override - public Boolean canSpawnItem(final int itemId) { - return !ess.getSettings().itemSpawnBlacklist().contains(itemId); + public Boolean canSpawnItem(final Material material) { + return !ess.getSettings().itemSpawnBlacklist().contains(material); } @Override diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 7ea09b3e9..3c7a13bbf 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -7,6 +7,7 @@ import net.ess3.api.IEssentials; import net.ess3.api.InvalidWorldException; import net.ess3.api.MaxMoneyException; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -231,26 +232,35 @@ public abstract class UserData extends PlayerExtension implements IConf { config.save(); } - private List unlimited; + private List unlimited; - private List _getUnlimited() { - return config.getIntegerList("unlimited"); + private List _getUnlimited() { + List retlist = new ArrayList<>(); + List configList = config.getStringList("unlimited"); + for(String s : configList) { + Material mat = Material.matchMaterial(s); + if(mat != null) { + retlist.add(mat); + } + } + + return retlist; } - public List getUnlimited() { + public List getUnlimited() { return unlimited; } public boolean hasUnlimited(ItemStack stack) { - return unlimited.contains(stack.getTypeId()); + return unlimited.contains(stack.getType()); } public void setUnlimited(ItemStack stack, boolean state) { - if (unlimited.contains(stack.getTypeId())) { - unlimited.remove(Integer.valueOf(stack.getTypeId())); + if (unlimited.contains(stack.getType())) { + unlimited.remove(stack.getType()); } if (state) { - unlimited.add(stack.getTypeId()); + unlimited.add(stack.getType()); } config.setProperty("unlimited", unlimited); config.save(); @@ -262,7 +272,7 @@ public abstract class UserData extends PlayerExtension implements IConf { if (config.isConfigurationSection("powertools")) { return config.getConfigurationSection("powertools").getValues(false); } - return new HashMap(); + return new HashMap<>(); } public void clearAllPowertools() { @@ -273,19 +283,19 @@ public abstract class UserData extends PlayerExtension implements IConf { @SuppressWarnings("unchecked") public List getPowertool(ItemStack stack) { - return (List) powertools.get("" + stack.getTypeId()); + return (List) powertools.get(stack.getType().name().toLowerCase(Locale.ENGLISH)); } @SuppressWarnings("unchecked") - public List getPowertool(int id) { - return (List) powertools.get("" + id); + public List getPowertool(Material material) { + return (List) powertools.get(material.name().toLowerCase(Locale.ENGLISH)); } public void setPowertool(ItemStack stack, List commandList) { if (commandList == null || commandList.isEmpty()) { - powertools.remove("" + stack.getTypeId()); + powertools.remove(stack.getType().name().toLowerCase(Locale.ENGLISH)); } else { - powertools.put("" + stack.getTypeId(), commandList); + powertools.put(stack.getType().name().toLowerCase(Locale.ENGLISH), commandList); } config.setProperty("powertools", powertools); config.save(); diff --git a/Essentials/src/com/earth2me/essentials/Worth.java b/Essentials/src/com/earth2me/essentials/Worth.java index d029f3f59..ef3c4c034 100644 --- a/Essentials/src/com/earth2me/essentials/Worth.java +++ b/Essentials/src/com/earth2me/essentials/Worth.java @@ -21,9 +21,17 @@ public class Worth implements IConf { config.load(); } - public BigDecimal getPrice(ItemStack itemStack) { - String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); + public BigDecimal getPrice(IEssentials essentials, ItemStack itemStack) { BigDecimal result; + int itemId; + + try { + itemId = essentials.getItemDb().getLegacyId(itemStack.getType()); + } catch (Exception e) { + return null; + } + + String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); //First check for matches with item name result = config.getBigDecimal("worth." + itemname + "." + itemStack.getDurability(), BigDecimal.ONE.negate()); @@ -42,24 +50,24 @@ public class Worth implements IConf { //Now we should check for item ID if (result.signum() < 0) { - result = config.getBigDecimal("worth." + itemStack.getTypeId() + "." + itemStack.getDurability(), BigDecimal.ONE.negate()); + result = config.getBigDecimal("worth." + itemId + "." + itemStack.getDurability(), BigDecimal.ONE.negate()); } if (result.signum() < 0) { - final ConfigurationSection itemNumberMatch = config.getConfigurationSection("worth." + itemStack.getTypeId()); + final ConfigurationSection itemNumberMatch = config.getConfigurationSection("worth." + itemId); if (itemNumberMatch != null && itemNumberMatch.getKeys(false).size() == 1) { - result = config.getBigDecimal("worth." + itemStack.getTypeId() + ".0", BigDecimal.ONE.negate()); + result = config.getBigDecimal("worth." + itemId + ".0", BigDecimal.ONE.negate()); } } if (result.signum() < 0) { - result = config.getBigDecimal("worth." + itemStack.getTypeId() + ".*", BigDecimal.ONE.negate()); + result = config.getBigDecimal("worth." + itemId + ".*", BigDecimal.ONE.negate()); } if (result.signum() < 0) { - result = config.getBigDecimal("worth." + itemStack.getTypeId(), BigDecimal.ONE.negate()); + result = config.getBigDecimal("worth." + itemId, BigDecimal.ONE.negate()); } //This is to match the old worth syntax if (result.signum() < 0) { - result = config.getBigDecimal("worth-" + itemStack.getTypeId(), BigDecimal.ONE.negate()); + result = config.getBigDecimal("worth-" + itemId, BigDecimal.ONE.negate()); } if (result.signum() < 0) { return null; @@ -71,7 +79,15 @@ public class Worth implements IConf { if (is == null || is.getType() == Material.AIR) { throw new Exception(tl("itemSellAir")); } - int id = is.getTypeId(); + + int id; + + try { + id = ess.getItemDb().getLegacyId(is.getType()); + } catch (Exception e) { + return 0; + } + int amount = 0; if (args.length > 1) { @@ -123,14 +139,22 @@ public class Worth implements IConf { return amount; } - public void setPrice(ItemStack itemStack, double price) { + public void setPrice(IEssentials ess, ItemStack itemStack, double price) { if (itemStack.getType().getData() == null) { config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), price); } else { // Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0. config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "") + "." + itemStack.getDurability(), price); } - config.removeProperty("worth-" + itemStack.getTypeId()); + + int itemId; + try { + itemId = ess.getItemDb().getLegacyId(itemStack.getType()); + } catch (Exception e) { + return; + } + + config.removeProperty("worth-" + itemId); config.save(); } diff --git a/Essentials/src/com/earth2me/essentials/api/IItemDb.java b/Essentials/src/com/earth2me/essentials/api/IItemDb.java index cae937710..00f073d5f 100644 --- a/Essentials/src/com/earth2me/essentials/api/IItemDb.java +++ b/Essentials/src/com/earth2me/essentials/api/IItemDb.java @@ -1,6 +1,7 @@ package com.earth2me.essentials.api; import com.earth2me.essentials.User; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import java.util.Collection; @@ -21,4 +22,8 @@ public interface IItemDb { String serialize(ItemStack is); Collection listNames(); + + Material getFromLegacyId(int id); + + int getLegacyId(Material material) throws Exception; } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index 47f81e7c3..0dfda9505 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -31,9 +31,10 @@ public class Commandgive extends EssentialsCommand { } ItemStack stack = ess.getItemDb().get(args[1]); + int itemId = ess.getItemDb().getLegacyId(stack.getType()); final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); - if (sender.isPlayer() && (ess.getSettings().permissionBasedItemSpawn() ? (!ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-all") && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-" + itemname) && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-" + stack.getTypeId())) : (!ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.exempt") && !ess.getUser(sender.getPlayer()).canSpawnItem(stack.getTypeId())))) { + if (sender.isPlayer() && (ess.getSettings().permissionBasedItemSpawn() ? (!ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-all") && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-" + itemname) && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-" + itemId)) : (!ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.exempt") && !ess.getUser(sender.getPlayer()).canSpawnItem(stack.getType())))) { throw new Exception(tl("cantSpawnItem", itemname)); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java index 2bae7df6a..8e054a84b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java @@ -25,10 +25,13 @@ public class Commanditem extends EssentialsCommand { if (args.length < 1) { throw new NotEnoughArgumentsException(); } + ItemStack stack = ess.getItemDb().get(args[0]); + int itemId = ess.getItemDb().getLegacyId(stack.getType()); + final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); - if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname) && !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId())) : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getTypeId()))) { + if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname) && !user.isAuthorized("essentials.itemspawn.item-" + itemId)) : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getType()))) { throw new Exception(tl("cantSpawnItem", itemname)); } try { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java b/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java index b4015558c..43f29e49a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java @@ -21,9 +21,9 @@ public class Commanditemdb extends EssentialsCommand { ItemStack itemStack = null; boolean itemHeld = false; if (args.length < 1) { - if (sender.isPlayer()) { + if (sender.isPlayer() && sender.getPlayer() != null) { itemHeld = true; - itemStack = sender.getPlayer().getItemInHand(); + itemStack = sender.getPlayer().getInventory().getItemInMainHand(); } if (itemStack == null) { throw new NotEnoughArgumentsException(); @@ -31,7 +31,9 @@ public class Commanditemdb extends EssentialsCommand { } else { itemStack = ess.getItemDb().get(args[0]); } - sender.sendMessage(tl("itemType", itemStack.getType().toString(), itemStack.getTypeId() + ":" + Integer.toString(itemStack.getDurability()))); + + int itemId = ess.getItemDb().getLegacyId(itemStack.getType()); + sender.sendMessage(tl("itemType", itemStack.getType().toString(), itemId + ":" + Integer.toString(itemStack.getDurability()))); if (itemHeld && itemStack.getType() != Material.AIR) { int maxuses = itemStack.getType().getMaxDurability(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java index 3a08a4966..efdb1125f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java @@ -16,15 +16,18 @@ public class Commandmore extends EssentialsCommand { @Override public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - final ItemStack stack = user.getBase().getItemInHand(); + final ItemStack stack = user.getBase().getInventory().getItemInMainHand(); if (stack == null) { throw new Exception(tl("cantSpawnItem", "Air")); } + + int itemId = ess.getItemDb().getLegacyId(stack.getType()); + if (stack.getAmount() >= ((user.isAuthorized("essentials.oversizedstacks")) ? ess.getSettings().getOversizedStackSize() : stack.getMaxStackSize())) { throw new Exception(tl("fullStack")); } final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); - if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname) && !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId())) : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getTypeId()))) { + if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname) && !user.isAuthorized("essentials.itemspawn.item-" + itemId)) : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getType()))) { throw new Exception(tl("cantSpawnItem", itemname)); } if (user.isAuthorized("essentials.oversizedstacks")) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java index 0d4cfbe41..b60ec05df 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java @@ -38,7 +38,7 @@ public class Commandrepair extends EssentialsCommand { } public void repairHand(User user) throws Exception { - final ItemStack item = user.getBase().getItemInHand(); + final ItemStack item = user.getBase().getInventory().getItemInMainHand(); if (item == null || item.getType().isBlock() || item.getDurability() == 0) { throw new Exception(tl("repairInvalidType")); } @@ -47,8 +47,10 @@ public class Commandrepair extends EssentialsCommand { throw new Exception(tl("repairEnchanted")); } + int itemId = ess.getItemDb().getLegacyId(item.getType()); + final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH); - final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + item.getTypeId(), new Trade("repair-item", ess), ess), ess); + final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + itemId, new Trade("repair-item", ess), ess), ess); charge.isAffordableFor(user); @@ -76,7 +78,7 @@ public class Commandrepair extends EssentialsCommand { } private void repairItem(final ItemStack item) throws Exception { - final Material material = Material.getMaterial(item.getTypeId()); + final Material material = item.getType(); if (material.isBlock() || material.getMaxDurability() < 1) { throw new Exception(tl("repairInvalidType")); } @@ -88,13 +90,16 @@ public class Commandrepair extends EssentialsCommand { item.setDurability((short) 0); } - private void repairItems(final ItemStack[] items, final IUser user, final List repaired) { + private void repairItems(final ItemStack[] items, final IUser user, final List repaired) throws Exception { for (ItemStack item : items) { if (item == null || item.getType().isBlock() || item.getDurability() == 0) { continue; } + + int itemId = ess.getItemDb().getLegacyId(item.getType()); + final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH); - final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + item.getTypeId(), new Trade("repair-item", ess), ess), ess); + final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + itemId, new Trade("repair-item", ess), ess), ess); try { charge.isAffordableFor(user); } catch (ChargeException ex) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java index 8c775bcd3..e6c41a98b 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java @@ -69,7 +69,7 @@ public class Commandsell extends EssentialsCommand { private BigDecimal sellItem(User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception { int amount = ess.getWorth().getAmount(ess, user, is, args, isBulkSell); - BigDecimal worth = ess.getWorth().getPrice(is); + BigDecimal worth = ess.getWorth().getPrice(ess, is); if (worth == null) { throw new Exception(tl("itemCannotBeSold")); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java index efde7ee97..d3e61c528 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java @@ -31,7 +31,7 @@ public class Commandsetworth extends EssentialsCommand { price = args[1]; } - ess.getWorth().setPrice(stack, FloatUtil.parseDouble(price)); + ess.getWorth().setPrice(ess, stack, FloatUtil.parseDouble(price)); user.sendMessage(tl("worthSet")); } @@ -42,7 +42,7 @@ public class Commandsetworth extends EssentialsCommand { } ItemStack stack = ess.getItemDb().get(args[0]); - ess.getWorth().setPrice(stack, FloatUtil.parseDouble(args[1])); + ess.getWorth().setPrice(ess, stack, FloatUtil.parseDouble(args[1])); sender.sendMessage(tl("worthSet")); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java index 158da4bc1..67d676af0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java @@ -32,12 +32,12 @@ public class Commandunlimited extends EssentialsCommand { final String list = getList(target); user.sendMessage(list); } else if (args[0].equalsIgnoreCase("clear")) { - final List itemList = target.getUnlimited(); + final List itemList = target.getUnlimited(); int index = 0; while (itemList.size() > index) { - final Integer item = itemList.get(index); - if (toggleUnlimited(user, target, item.toString()) == false) { + final Material item = itemList.get(index); + if (!toggleUnlimited(user, target, item.toString())) { index++; } } @@ -50,16 +50,16 @@ public class Commandunlimited extends EssentialsCommand { final StringBuilder output = new StringBuilder(); output.append(tl("unlimitedItems")).append(" "); boolean first = true; - final List items = target.getUnlimited(); + final List items = target.getUnlimited(); if (items.isEmpty()) { output.append(tl("none")); } - for (Integer integer : items) { + for (Material material : items) { if (!first) { output.append(", "); } first = false; - final String matname = Material.getMaterial(integer).toString().toLowerCase(Locale.ENGLISH).replace("_", ""); + final String matname = material.toString().toLowerCase(Locale.ENGLISH).replace("_", ""); output.append(matname); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java index ec7bd8928..31b55be55 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java @@ -84,7 +84,7 @@ public class Commandworth extends EssentialsCommand { amount = ess.getWorth().getAmount(ess, user, is, args, true); } - BigDecimal worth = ess.getWorth().getPrice(is); + BigDecimal worth = ess.getWorth().getPrice(ess, is); if (worth == null) { throw new Exception(tl("itemCannotBeSold")); diff --git a/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java b/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java index 54f780e52..959d5e3d6 100644 --- a/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java +++ b/Essentials/src/com/earth2me/essentials/storage/BukkitConstructor.java @@ -36,15 +36,9 @@ public class BukkitConstructor extends CustomClassLoaderConstructor { public Object construct(final Node node) { if (node.getType().equals(Material.class)) { final String val = (String) constructScalar((ScalarNode) node); - Material mat; - if (NumberUtil.isInt(val)) { - final int typeId = Integer.parseInt(val); - mat = Material.getMaterial(typeId); - } else { - mat = Material.matchMaterial(val); - } - return mat; + return Material.matchMaterial(val); } + if (node.getType().equals(MaterialData.class)) { final String val = (String) constructScalar((ScalarNode) node); if (val.isEmpty()) { @@ -54,13 +48,9 @@ public class BukkitConstructor extends CustomClassLoaderConstructor { if (split.length == 0) { return null; } - Material mat; - if (NumberUtil.isInt(split[0])) { - final int typeId = Integer.parseInt(split[0]); - mat = Material.getMaterial(typeId); - } else { - mat = Material.matchMaterial(split[0]); - } + + Material mat = Material.matchMaterial(split[0]); + if (mat == null) { return null; } @@ -83,13 +73,9 @@ public class BukkitConstructor extends CustomClassLoaderConstructor { if (split2.length == 0) { return null; } - Material mat; - if (NumberUtil.isInt(split2[0])) { - final int typeId = Integer.parseInt(split2[0]); - mat = Material.getMaterial(typeId); - } else { - mat = Material.matchMaterial(split2[0]); - } + + Material mat = Material.matchMaterial(split2[0]); + if (mat == null) { return null; } diff --git a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuild.java b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuild.java index 41378ad3a..e19078f99 100644 --- a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuild.java +++ b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuild.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.antibuild; +import org.bukkit.Material; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -10,8 +11,8 @@ import java.util.Map; public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild { - private final transient Map settingsBoolean = new EnumMap(AntiBuildConfig.class); - private final transient Map> settingsList = new EnumMap>(AntiBuildConfig.class); + private final transient Map settingsBoolean = new EnumMap<>(AntiBuildConfig.class); + private final transient Map> settingsList = new EnumMap<>(AntiBuildConfig.class); private transient EssentialsConnect ess = null; @Override @@ -28,9 +29,9 @@ public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild { } @Override - public boolean checkProtectionItems(final AntiBuildConfig list, final int id) { - final List itemList = settingsList.get(list); - return itemList != null && !itemList.isEmpty() && itemList.contains(id); + public boolean checkProtectionItems(final AntiBuildConfig list, final Material mat) { + final List itemList = settingsList.get(list); + return itemList != null && !itemList.isEmpty() && itemList.contains(mat); } @Override @@ -44,7 +45,7 @@ public class EssentialsAntiBuild extends JavaPlugin implements IAntiBuild { } @Override - public Map> getSettingsList() { + public Map> getSettingsList() { return settingsList; } diff --git a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java index f60ec5854..1fe6840ce 100644 --- a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java +++ b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java @@ -40,16 +40,16 @@ public class EssentialsAntiBuildListener implements Listener { } return false; } - return metaPermCheck(user, action, block.getTypeId(), block.getData()); + return metaPermCheck(user, action, block.getType(), block.getData()); } - private boolean metaPermCheck(final User user, final String action, final int blockId) { - final String blockPerm = "essentials.build." + action + "." + blockId; + private boolean metaPermCheck(final User user, final String action, final Material material) { + final String blockPerm = "essentials.build." + action + "." + material; return user.isAuthorized(blockPerm); } - private boolean metaPermCheck(final User user, final String action, final int blockId, final short data) { - final String blockPerm = "essentials.build." + action + "." + blockId; + private boolean metaPermCheck(final User user, final String action, final Material material, final short data) { + final String blockPerm = "essentials.build." + action + "." + material; final String dataPerm = blockPerm + ":" + data; if (user.getBase().isPermissionSet(dataPerm)) { @@ -78,7 +78,7 @@ public class EssentialsAntiBuildListener implements Listener { return; } - if (prot.checkProtectionItems(AntiBuildConfig.blacklist_placement, typeId) && !user.isAuthorized("essentials.protect.exemptplacement")) { + if (prot.checkProtectionItems(AntiBuildConfig.blacklist_placement, type) && !user.isAuthorized("essentials.protect.exemptplacement")) { if (ess.getSettings().warnOnBuildDisallow()) { user.sendMessage(tl("antiBuildPlace", type.toString())); } @@ -86,7 +86,7 @@ public class EssentialsAntiBuildListener implements Listener { return; } - if (prot.checkProtectionItems(AntiBuildConfig.alert_on_placement, typeId) && !user.isAuthorized("essentials.protect.alerts.notrigger")) { + if (prot.checkProtectionItems(AntiBuildConfig.alert_on_placement, type) && !user.isAuthorized("essentials.protect.alerts.notrigger")) { prot.getEssentialsConnect().alert(user, type.toString(), tl("alertPlaced")); } } @@ -106,7 +106,7 @@ public class EssentialsAntiBuildListener implements Listener { return; } - if (prot.checkProtectionItems(AntiBuildConfig.blacklist_break, typeId) && !user.isAuthorized("essentials.protect.exemptbreak")) { + if (prot.checkProtectionItems(AntiBuildConfig.blacklist_break, type) && !user.isAuthorized("essentials.protect.exemptbreak")) { if (ess.getSettings().warnOnBuildDisallow()) { user.sendMessage(tl("antiBuildBreak", type.toString())); } @@ -114,7 +114,7 @@ public class EssentialsAntiBuildListener implements Listener { return; } - if (prot.checkProtectionItems(AntiBuildConfig.alert_on_break, typeId) && !user.isAuthorized("essentials.protect.alerts.notrigger")) { + if (prot.checkProtectionItems(AntiBuildConfig.alert_on_break, type) && !user.isAuthorized("essentials.protect.alerts.notrigger")) { prot.getEssentialsConnect().alert(user, type.toString(), tl("alertBroke")); } } @@ -127,12 +127,12 @@ public class EssentialsAntiBuildListener implements Listener { final EntityType type = event.getEntity().getType(); final boolean warn = ess.getSettings().warnOnBuildDisallow(); if (prot.getSettingBool(AntiBuildConfig.disable_build) && !user.canBuild() && !user.isAuthorized("essentials.build")) { - if (type == EntityType.PAINTING && !metaPermCheck(user, "break", Material.PAINTING.getId())) { + if (type == EntityType.PAINTING && !metaPermCheck(user, "break", Material.PAINTING)) { if (warn) { user.sendMessage(tl("antiBuildBreak", Material.PAINTING.toString())); } event.setCancelled(true); - } else if (type == EntityType.ITEM_FRAME && !metaPermCheck(user, "break", Material.ITEM_FRAME.getId())) { + } else if (type == EntityType.ITEM_FRAME && !metaPermCheck(user, "break", Material.ITEM_FRAME)) { if (warn) { user.sendMessage(tl("antiBuildBreak", Material.ITEM_FRAME.toString())); } @@ -145,7 +145,7 @@ public class EssentialsAntiBuildListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockPistonExtend(final BlockPistonExtendEvent event) { for (Block block : event.getBlocks()) { - if (prot.checkProtectionItems(AntiBuildConfig.blacklist_piston, block.getTypeId())) { + if (prot.checkProtectionItems(AntiBuildConfig.blacklist_piston, block.getType())) { event.setCancelled(true); return; } @@ -158,7 +158,7 @@ public class EssentialsAntiBuildListener implements Listener { return; } final Block block = event.getBlock(); - if (prot.checkProtectionItems(AntiBuildConfig.blacklist_piston, block.getTypeId())) { + if (prot.checkProtectionItems(AntiBuildConfig.blacklist_piston, block.getType())) { event.setCancelled(true); } } @@ -169,7 +169,7 @@ public class EssentialsAntiBuildListener implements Listener { final User user = ess.getUser(event.getPlayer()); final ItemStack item = event.getItem(); - if (item != null && prot.checkProtectionItems(AntiBuildConfig.blacklist_usage, item.getTypeId()) && !user.isAuthorized("essentials.protect.exemptusage")) { + if (item != null && prot.checkProtectionItems(AntiBuildConfig.blacklist_usage, item.getType()) && !user.isAuthorized("essentials.protect.exemptusage")) { if (ess.getSettings().warnOnBuildDisallow()) { user.sendMessage(tl("antiBuildUse", item.getType().toString())); } @@ -177,12 +177,12 @@ public class EssentialsAntiBuildListener implements Listener { return; } - if (item != null && prot.checkProtectionItems(AntiBuildConfig.alert_on_use, item.getTypeId()) && !user.isAuthorized("essentials.protect.alerts.notrigger")) { + if (item != null && prot.checkProtectionItems(AntiBuildConfig.alert_on_use, item.getType()) && !user.isAuthorized("essentials.protect.alerts.notrigger")) { prot.getEssentialsConnect().alert(user, item.getType().toString(), tl("alertUsed")); } if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) { - if (event.hasItem() && !metaPermCheck(user, "interact", item.getTypeId(), item.getDurability())) { + if (event.hasItem() && !metaPermCheck(user, "interact", item.getType(), item.getDurability())) { event.setCancelled(true); if (ess.getSettings().warnOnBuildDisallow()) { user.sendMessage(tl("antiBuildUse", item.getType().toString())); @@ -207,7 +207,7 @@ public class EssentialsAntiBuildListener implements Listener { final ItemStack item = event.getRecipe().getResult(); if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) { - if (!metaPermCheck(user, "craft", item.getTypeId(), item.getDurability())) { + if (!metaPermCheck(user, "craft", item.getType(), item.getDurability())) { event.setCancelled(true); if (ess.getSettings().warnOnBuildDisallow()) { user.sendMessage(tl("antiBuildCraft", item.getType().toString())); @@ -224,7 +224,7 @@ public class EssentialsAntiBuildListener implements Listener { final ItemStack item = event.getItem().getItemStack(); if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) { - if (!metaPermCheck(user, "pickup", item.getTypeId(), item.getDurability())) { + if (!metaPermCheck(user, "pickup", item.getType(), item.getDurability())) { event.setCancelled(true); event.getItem().setPickupDelay(50); } @@ -238,7 +238,7 @@ public class EssentialsAntiBuildListener implements Listener { final ItemStack item = event.getItemDrop().getItemStack(); if (prot.getSettingBool(AntiBuildConfig.disable_use) && !user.canBuild() && !user.isAuthorized("essentials.build")) { - if (!metaPermCheck(user, "drop", item.getTypeId(), item.getDurability())) { + if (!metaPermCheck(user, "drop", item.getType(), item.getDurability())) { event.setCancelled(true); user.getBase().updateInventory(); if (ess.getSettings().warnOnBuildDisallow()) { @@ -251,7 +251,7 @@ public class EssentialsAntiBuildListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockDispense(final BlockDispenseEvent event) { final ItemStack item = event.getItem(); - if (prot.checkProtectionItems(AntiBuildConfig.blacklist_dispenser, item.getTypeId())) { + if (prot.checkProtectionItems(AntiBuildConfig.blacklist_dispenser, item.getType())) { event.setCancelled(true); } } diff --git a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/IAntiBuild.java b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/IAntiBuild.java index bfb8facd3..cb19d75de 100644 --- a/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/IAntiBuild.java +++ b/EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/IAntiBuild.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.antibuild; +import org.bukkit.Material; import org.bukkit.plugin.Plugin; import java.util.List; @@ -7,7 +8,7 @@ import java.util.Map; public interface IAntiBuild extends Plugin { - boolean checkProtectionItems(final AntiBuildConfig list, final int id); + boolean checkProtectionItems(final AntiBuildConfig list, final Material mat); boolean getSettingBool(final AntiBuildConfig protectConfig); @@ -15,5 +16,5 @@ public interface IAntiBuild extends Plugin { Map getSettingsBoolean(); - Map> getSettingsList(); + Map> getSettingsList(); } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java index be3679365..964c9972c 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.protect; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; @@ -14,9 +15,9 @@ import java.util.logging.Logger; public class EssentialsProtect extends JavaPlugin implements IProtect { private static final Logger LOGGER = Logger.getLogger("Minecraft"); - private final Map settingsBoolean = new EnumMap(ProtectConfig.class); - private final Map settingsString = new EnumMap(ProtectConfig.class); - private final Map> settingsList = new EnumMap>(ProtectConfig.class); + private final Map settingsBoolean = new EnumMap<>(ProtectConfig.class); + private final Map settingsString = new EnumMap<>(ProtectConfig.class); + private final Map> settingsList = new EnumMap<>(ProtectConfig.class); private EssentialsConnect ess = null; @Override @@ -65,7 +66,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect { } @Override - public Map> getSettingsList() { + public Map> getSettingsList() { return settingsList; } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java index 23ba0cebb..7d12107ad 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.protect; +import org.bukkit.Material; import org.bukkit.plugin.Plugin; import java.util.List; @@ -17,5 +18,5 @@ public interface IProtect extends Plugin { Map getSettingsString(); - Map> getSettingsList(); + Map> getSettingsList(); }