From 7233e8e819ae68cf15d4e914e73a291e492e73a5 Mon Sep 17 00:00:00 2001 From: Driftay Date: Wed, 17 Jul 2019 11:08:55 -0400 Subject: [PATCH] Updates.. XMaterial added --- .../java/com/massivecraft/factions/Conf.java | 5 +- .../massivecraft/factions/SaberFactions.java | 106 +- .../massivecraft/factions/cmd/CmdBanner.java | 207 +- .../massivecraft/factions/cmd/CmdReload.java | 1 - .../factions/cmd/CmdSeeChunk.java | 3 +- .../listeners/FactionsBlockListener.java | 7 +- .../listeners/FactionsExploitListener.java | 7 +- .../listeners/FactionsPlayerListener.java | 12 +- .../factions/struct/Placeholder.java | 23 + .../factions/struct/Relation.java | 4 +- .../massivecraft/factions/struct/Role.java | 4 +- .../factions/util/MultiversionMaterials.java | 974 ------- .../util/Particles/ParticleEffect.java | 3 +- .../massivecraft/factions/util/XMaterial.java | 1615 +++++++++++ .../zcore/fperms/PermissableAction.java | 10 +- .../fperms/gui/PermissableActionGUI.java | 7 +- .../zcore/fupgrades/CropUpgrades.java | 7 +- .../factions/zcore/persist/MemoryFaction.java | 2542 ++++++++--------- 18 files changed, 3048 insertions(+), 2489 deletions(-) create mode 100644 src/main/java/com/massivecraft/factions/struct/Placeholder.java delete mode 100644 src/main/java/com/massivecraft/factions/util/MultiversionMaterials.java create mode 100644 src/main/java/com/massivecraft/factions/util/XMaterial.java diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index 3576dfa9..31c85584 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -2,6 +2,7 @@ package com.massivecraft.factions; import com.google.common.collect.ImmutableMap; import com.massivecraft.factions.integration.dynmap.DynmapStyle; +import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.fperms.DefaultPermissions; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -365,7 +366,7 @@ public class Conf { // Config is not loading if value is empty ??? territoryBypassProtectedMaterials.add(Material.COOKIE); - territoryDenyUseageMaterials.add(SaberFactions.plugin.FIREBALL); + territoryDenyUseageMaterials.add(XMaterial.FIRE_CHARGE.parseMaterial()); territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL); territoryDenyUseageMaterials.add(Material.BUCKET); territoryDenyUseageMaterials.add(Material.WATER_BUCKET); @@ -377,7 +378,7 @@ public class Conf { territoryProtectedMaterialsWhenOffline.add(Material.BEACON); - territoryDenyUseageMaterialsWhenOffline.add(SaberFactions.plugin.FIREBALL); + territoryDenyUseageMaterialsWhenOffline.add(XMaterial.FIRE_CHARGE.parseMaterial()); territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL); territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET); territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET); diff --git a/src/main/java/com/massivecraft/factions/SaberFactions.java b/src/main/java/com/massivecraft/factions/SaberFactions.java index 3688b673..e8e2b839 100644 --- a/src/main/java/com/massivecraft/factions/SaberFactions.java +++ b/src/main/java/com/massivecraft/factions/SaberFactions.java @@ -70,12 +70,6 @@ public class SaberFactions extends MPlugin { public boolean mc114 = false; public boolean useNonPacketParticles = false; public boolean factionsFlight = false; - //multiversion material fields - public Material SUGAR_CANE_BLOCK, BANNER, CROPS, REDSTONE_LAMP_ON, - STAINED_GLASS, STATIONARY_WATER, STAINED_CLAY, WOOD_BUTTON, - SOIL, MOB_SPANWER, THIN_GLASS, IRON_FENCE, NETHER_FENCE, FENCE, - WOODEN_DOOR, TRAP_DOOR, FENCE_GATE, BURNING_FURNACE, DIODE_BLOCK_OFF, - DIODE_BLOCK_ON, ENCHANTMENT_TABLE, FIREBALL; SkriptAddon skriptAddon; private boolean locked = false; private boolean spam = false; @@ -157,15 +151,12 @@ public class SaberFactions extends MPlugin { case 13: SaberFactions.plugin.log("Minecraft Version 1.13 found, New Items will be used."); mc113 = true; - changeItemIDSInConfig(); break; case 14: SaberFactions.plugin.log("Minecraft Version 1.14 found."); mc114 = true; - changeItemIDSInConfig(); break; } - setupMultiversionMaterials(); migrateFPlayerLeaders(); log("==== End Setup ===="); @@ -284,59 +275,7 @@ public class SaberFactions extends MPlugin { return skriptAddon; } - private void setupMultiversionMaterials() { - if (mc113) { - BANNER = Material.valueOf("LEGACY_BANNER"); - CROPS = Material.valueOf("LEGACY_CROPS"); - SUGAR_CANE_BLOCK = Material.valueOf("LEGACY_SUGAR_CANE_BLOCK"); - REDSTONE_LAMP_ON = Material.valueOf("LEGACY_REDSTONE_LAMP_ON"); - STAINED_GLASS = Material.valueOf("LEGACY_STAINED_GLASS"); - STATIONARY_WATER = Material.valueOf("LEGACY_STATIONARY_WATER"); - STAINED_CLAY = Material.valueOf("LEGACY_STAINED_CLAY"); - WOOD_BUTTON = Material.valueOf("LEGACY_WOOD_BUTTON"); - SOIL = Material.valueOf("LEGACY_SOIL"); - MOB_SPANWER = Material.valueOf("LEGACY_MOB_SPAWNER"); - THIN_GLASS = Material.valueOf("LEGACY_THIN_GLASS"); - IRON_FENCE = Material.valueOf("LEGACY_IRON_FENCE"); - NETHER_FENCE = Material.valueOf("LEGACY_NETHER_FENCE"); - FENCE = Material.valueOf("LEGACY_FENCE"); - WOODEN_DOOR = Material.valueOf("LEGACY_WOODEN_DOOR"); - TRAP_DOOR = Material.valueOf("LEGACY_TRAP_DOOR"); - FENCE_GATE = Material.valueOf("LEGACY_FENCE_GATE"); - BURNING_FURNACE = Material.valueOf("LEGACY_BURNING_FURNACE"); - DIODE_BLOCK_OFF = Material.valueOf("LEGACY_DIODE_BLOCK_OFF"); - DIODE_BLOCK_ON = Material.valueOf("LEGACY_DIODE_BLOCK_ON"); - ENCHANTMENT_TABLE = Material.valueOf("LEGACY_ENCHANTMENT_TABLE"); - FIREBALL = Material.valueOf("LEGACY_FIREBALL"); - } else { - if (!mc17) { - BANNER = Material.valueOf("BANNER"); - } - CROPS = Material.valueOf("CROPS"); - SUGAR_CANE_BLOCK = Material.valueOf("SUGAR_CANE_BLOCK"); - REDSTONE_LAMP_ON = Material.valueOf("REDSTONE_LAMP_ON"); - STAINED_GLASS = Material.valueOf("STAINED_GLASS"); - STATIONARY_WATER = Material.valueOf("STATIONARY_WATER"); - STAINED_CLAY = Material.valueOf("STAINED_CLAY"); - WOOD_BUTTON = Material.valueOf("WOOD_BUTTON"); - SOIL = Material.valueOf("SOIL"); - MOB_SPANWER = Material.valueOf("MOB_SPAWNER"); - THIN_GLASS = Material.valueOf("THIN_GLASS"); - IRON_FENCE = Material.valueOf("IRON_FENCE"); - NETHER_FENCE = Material.valueOf("NETHER_FENCE"); - FENCE = Material.valueOf("FENCE"); - WOODEN_DOOR = Material.valueOf("WOODEN_DOOR"); - TRAP_DOOR = Material.valueOf("TRAP_DOOR"); - FENCE_GATE = Material.valueOf("FENCE_GATE"); - BURNING_FURNACE = Material.valueOf("BURNING_FURNACE"); - DIODE_BLOCK_OFF = Material.valueOf("DIODE_BLOCK_OFF"); - DIODE_BLOCK_ON = Material.valueOf("DIODE_BLOCK_ON"); - ENCHANTMENT_TABLE = Material.valueOf("ENCHANTMENT_TABLE"); - FIREBALL = Material.valueOf("FIREBALL"); - } - - } private void setupPlaceholderAPI() { Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI"); @@ -387,33 +326,6 @@ public class SaberFactions extends MPlugin { } } - public void changeItemIDSInConfig() { - log("Starting conversion of legacy material in config to 1.13 materials."); - - replaceStringInConfig("fperm-gui.relation.materials.recruit", "WOOD_SWORD", "WOODEN_SWORD"); - replaceStringInConfig("fperm-gui.relation.materials.normal", "GOLD_SWORD", "GOLDEN_SWORD"); - replaceStringInConfig("fperm-gui.relation.materials.ally", "GOLD_AXE", "GOLDEN_AXE"); - replaceStringInConfig("fperm-gui.relation.materials.neutral", "WOOD_AXE", "WOODEN_AXE"); - - ConfigurationSection actionMaterialsConfigSection = getConfig().getConfigurationSection("fperm-gui.action.materials"); - Set actionMaterialKeys = actionMaterialsConfigSection.getKeys(true); - - - for (String key : actionMaterialKeys) { - replaceStringInConfig("fperm-gui.action.materials." + key, "STAINED_GLASS", "GRAY_STAINED_GLASS"); - } - - replaceStringInConfig("fperm-gui.dummy-items.0.material", "STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE"); - replaceStringInConfig("fwarp-gui.dummy-items.0.material", "STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE"); - - replaceStringInConfig("fupgrades.MainMenu.DummyItem.Type", "STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE"); - replaceStringInConfig("fupgrades.MainMenu.EXP.EXPItem.Type", "EXP_BOTTLE", "EXPERIENCE_BOTTLE"); - replaceStringInConfig("fupgrades.MainMenu.Spawners.SpawnerItem.Type", "MOB_SPAWNER", "SPAWNER"); - - replaceStringInConfig("fperm-gui.action.access.allow", "LIME", "LIME_STAINED_GLASS"); - replaceStringInConfig("fperm-gui.action.access.deny", "RED", "RED_STAINED_GLASS"); - replaceStringInConfig("fperm-gui.action.access.undefined", "CYAN", "CYAN_STAINED_GLASS"); - } public void replaceStringInConfig(String path, String stringToReplace, String replacementString) { if (getConfig().getString(path).equals(stringToReplace)) { @@ -511,7 +423,7 @@ public class SaberFactions extends MPlugin { } public ItemStack createItem(Material material, int amount, short datavalue, String name, List lore) { - ItemStack item = new ItemStack(MultiversionMaterials.fromString(material.toString()).parseMaterial(), amount, datavalue); + ItemStack item = new ItemStack(XMaterial.matchXMaterial(material.toString()).parseMaterial(), amount, datavalue); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(color(name)); meta.setLore(colorList(lore)); @@ -567,7 +479,7 @@ public class SaberFactions extends MPlugin { MCommand commandEx = cmdBase; List> commandsList = cmdBase.subCommands; - if (Board.getInstance().getFactionAt(new FLocation(fPlayer.getPlayer().getLocation())) == Factions.getInstance().getWarZone()) { + if (Board.getInstance().getFactionAt(new FLocation(fPlayer.getPlayer().getLocation())).isWarZone()) { return new ArrayList<>(); } @@ -595,16 +507,12 @@ public class SaberFactions extends MPlugin { } String lastArg = args[args.length - 1].toLowerCase(); - + for (Player player : Bukkit.getServer().getOnlinePlayers()) { + completions.add(player.getName()); + } completions = completions.stream() - .filter(m -> m.toLowerCase().startsWith(lastArg)) - .collect(Collectors.toList()); - for (Player player : Bukkit.getServer().getOnlinePlayers()) { - completions.add(player.getName()); - } - for (Player player : Bukkit.getServer().getOnlinePlayers()) { - completions.add(player.getName()); - } + .filter(m -> m.toLowerCase().startsWith(lastArg)) + .collect(Collectors.toList()); return completions; } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java b/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java index 30a6e75c..98257813 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.SaberFactions; import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.util.TL; import net.milkbowl.vault.economy.Economy; import org.bukkit.Material; @@ -13,123 +14,121 @@ import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; public class CmdBanner extends FCommand { - public CmdBanner() { - super(); + public CmdBanner() { + super(); - this.aliases.add("banner"); - this.aliases.add("warbanner"); + this.aliases.add("banner"); + this.aliases.add("warbanner"); - this.permission = Permission.BANNER.node; - this.disableOnLock = false; + this.permission = Permission.BANNER.node; + this.disableOnLock = false; - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeModerator = false; - senderMustBeColeader = true; - senderMustBeAdmin = false; - } + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeColeader = true; + senderMustBeAdmin = false; + } - @Override - public void perform() { - if (!SaberFactions.plugin.getConfig().getBoolean("fbanners.Enabled")) { - msg(TL.COMMAND_BANNER_DISABLED); - return; - } - if (!fme.hasMoney(SaberFactions.plugin.getConfig().getInt("fbanners.Banner-Cost", 5000))) { - msg(TL.COMMAND_BANNER_NOTENOUGHMONEY); - return; - } - takeMoney(fme, SaberFactions.plugin.getConfig().getInt("fbanners.Banner-Cost", 5000)); + @Override + public void perform() { + if (!SaberFactions.plugin.getConfig().getBoolean("fbanners.Enabled")) { + msg(TL.COMMAND_BANNER_DISABLED); + return; + } + if (!fme.hasMoney(SaberFactions.plugin.getConfig().getInt("fbanners.Banner-Cost", 5000))) { + msg(TL.COMMAND_BANNER_NOTENOUGHMONEY); + return; + } + takeMoney(fme, SaberFactions.plugin.getConfig().getInt("fbanners.Banner-Cost", 5000)); - //ItemStack warBanner = SaberFactions.plugin.createItem(Material.BANNER, 1, (short) 1, SaberFactions.plugin.getConfig().getString("fbanners.Item.Name"), SaberFactions.plugin.getConfig().getStringList("fbanners.Item.Lore")); - //BannerMeta bannerMeta = (BannerMeta) warBanner.getItemMeta(); - ItemStack warBanner = fme.getFaction().getBanner(); - if (warBanner != null) { - ItemMeta warmeta = warBanner.getItemMeta(); - warmeta.setDisplayName(SaberFactions.plugin.color(SaberFactions.plugin.getConfig().getString("fbanners.Item.Name"))); - warmeta.setLore(SaberFactions.plugin.colorList(SaberFactions.plugin.getConfig().getStringList("fbanners.Item.Lore"))); - warBanner.setItemMeta(warmeta); + //ItemStack warBanner = SaberFactions.plugin.createItem(Material.BANNER, 1, (short) 1, SaberFactions.plugin.getConfig().getString("fbanners.Item.Name"), SaberFactions.plugin.getConfig().getStringList("fbanners.Item.Lore")); + //BannerMeta bannerMeta = (BannerMeta) warBanner.getItemMeta(); + ItemStack warBanner = fme.getFaction().getBanner(); + if (warBanner != null) { + ItemMeta warmeta = warBanner.getItemMeta(); + warmeta.setDisplayName(SaberFactions.plugin.color(SaberFactions.plugin.getConfig().getString("fbanners.Item.Name"))); + warmeta.setLore(SaberFactions.plugin.colorList(SaberFactions.plugin.getConfig().getStringList("fbanners.Item.Lore"))); + warBanner.setItemMeta(warmeta); - } else { + } else { + warBanner = SaberFactions.plugin.createItem(XMaterial.BLACK_BANNER.parseMaterial(), 1, (short) 1, SaberFactions.plugin.getConfig().getString("fbanners.Item.Name"), SaberFactions.plugin.getConfig().getStringList("fbanners.Item.Lore")); + } + fme.msg(TL.COMMAND_BANNER_SUCCESS); + warBanner.setAmount(1); + me.getInventory().addItem(warBanner); + } - warBanner = SaberFactions.plugin.createItem(SaberFactions.plugin.BANNER, 1, (short) 1, SaberFactions.plugin.getConfig().getString("fbanners.Item.Name"), SaberFactions.plugin.getConfig().getStringList("fbanners.Item.Lore")); - } - fme.msg(TL.COMMAND_BANNER_SUCCESS); - warBanner.setAmount(1); - me.getInventory().addItem(warBanner); - } + public boolean hasMoney(FPlayer fme, int amt) { + Economy econ = SaberFactions.plugin.getEcon(); + if (econ.getBalance(fme.getPlayer()) >= amt) { + return true; + } else { + fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY); + return false; + } + } + + public void takeMoney(FPlayer fme, int amt) { + if (hasMoney(fme, amt)) { + Economy econ = SaberFactions.plugin.getEcon(); + econ.withdrawPlayer(fme.getPlayer(), amt); + fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + "")); + } + } + + public boolean inventoryContains(Inventory inventory, ItemStack item) { + int count = 0; + ItemStack[] items = inventory.getContents(); + for (int i = 0; i < items.length; i++) { + if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { + count += items[i].getAmount(); + } + if (count >= item.getAmount()) { + return true; + } + } + return false; + } - public boolean hasMoney(FPlayer fme, int amt) { - Economy econ = SaberFactions.plugin.getEcon(); - if (econ.getBalance(fme.getPlayer()) >= amt) { - return true; - } else { - fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY); - return false; - } - } + public void removeFromInventory(Inventory inventory, ItemStack item) { + int amt = item.getAmount(); + ItemStack[] items = inventory.getContents(); + for (int i = 0; i < items.length; i++) { + if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { + if (items[i].getAmount() > amt) { + items[i].setAmount(items[i].getAmount() - amt); + break; + } else if (items[i].getAmount() == amt) { + items[i] = null; + break; + } else { + amt -= items[i].getAmount(); + items[i] = null; + } + } + } + inventory.setContents(items); + } - public void takeMoney(FPlayer fme, int amt) { - if (hasMoney(fme, amt)) { - Economy econ = SaberFactions.plugin.getEcon(); - econ.withdrawPlayer(fme.getPlayer(), amt); - fme.sendMessage(TL.COMMAND_BANNER_MONEYTAKE.toString().replace("{amount}", amt + "")); - } - } - - public boolean inventoryContains(Inventory inventory, ItemStack item) { - int count = 0; - ItemStack[] items = inventory.getContents(); - for (int i = 0; i < items.length; i++) { - if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { - count += items[i].getAmount(); - } - if (count >= item.getAmount()) { - return true; - } - } - return false; - } + public int getEmptySlots(Player p) { + PlayerInventory inventory = p.getInventory(); + ItemStack[] cont = inventory.getContents(); + int i = 0; + for (ItemStack item : cont) + if (item != null && item.getType() != Material.AIR) { + i++; + } + return 36 - i; + } - public void removeFromInventory(Inventory inventory, ItemStack item) { - int amt = item.getAmount(); - ItemStack[] items = inventory.getContents(); - for (int i = 0; i < items.length; i++) { - if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) { - if (items[i].getAmount() > amt) { - items[i].setAmount(items[i].getAmount() - amt); - break; - } else if (items[i].getAmount() == amt) { - items[i] = null; - break; - } else { - amt -= items[i].getAmount(); - items[i] = null; - } - } - } - inventory.setContents(items); - } - - public int getEmptySlots(Player p) { - PlayerInventory inventory = p.getInventory(); - ItemStack[] cont = inventory.getContents(); - int i = 0; - for (ItemStack item : cont) - if (item != null && item.getType() != Material.AIR) { - i++; - } - return 36 - i; - } - - - @Override - public TL getUsageTranslation() { - return TL.COMMAND_BANNER_DESCRIPTION; - } + @Override + public TL getUsageTranslation() { + return TL.COMMAND_BANNER_DESCRIPTION; + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdReload.java b/src/main/java/com/massivecraft/factions/cmd/CmdReload.java index 742582b5..09f88744 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdReload.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdReload.java @@ -27,7 +27,6 @@ public class CmdReload extends FCommand { Conf.load(); Conf.save(); SaberFactions.plugin.reloadConfig(); - SaberFactions.plugin.changeItemIDSInConfig(); SaberFactions.plugin.loadLang(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java index 376d83f4..3c030a7e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java @@ -6,6 +6,7 @@ import com.massivecraft.factions.SaberFactions; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.util.Particles.ParticleEffect; import com.massivecraft.factions.util.VisualizeUtil; +import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.*; import org.bukkit.entity.Player; @@ -130,7 +131,7 @@ public class CmdSeeChunk extends FCommand { } else { - Material type = blockY % 5 == 0 ? SaberFactions.plugin.REDSTONE_LAMP_ON : SaberFactions.plugin.STAINED_GLASS; + Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial(); VisualizeUtil.addLocation(player, loc, type); } } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java index 783ca512..cbcd6189 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -6,6 +6,7 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.Particles.ParticleEffect; +import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; @@ -288,7 +289,7 @@ public class FactionsBlockListener implements Listener { return; } - if (e.getItemInHand().getType() == SaberFactions.plugin.BANNER) { + if (e.getItemInHand().getType() == XMaterial.BLACK_BANNER.parseMaterial()) { ItemStack bannerInHand = e.getItemInHand(); FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer()); ItemStack warBanner = fme.getFaction().getBanner(); @@ -298,7 +299,7 @@ public class FactionsBlockListener implements Listener { warmeta.setLore(SaberFactions.plugin.colorList(SaberFactions.plugin.getConfig().getStringList("fbanners.Item.Lore"))); warBanner.setItemMeta(warmeta); } else { - warBanner = SaberFactions.plugin.createItem(SaberFactions.plugin.BANNER, 1, (short) 1, SaberFactions.plugin.getConfig().getString("fbanners.Item.Name"), SaberFactions.plugin.getConfig().getStringList("fbanners.Item.Lore")); + warBanner = SaberFactions.plugin.createItem(XMaterial.BLACK_BANNER.parseMaterial(), 1, (short) 1, SaberFactions.plugin.getConfig().getString("fbanners.Item.Name"), SaberFactions.plugin.getConfig().getStringList("fbanners.Item.Lore")); } if (warBanner.isSimilar(bannerInHand)) { @@ -491,7 +492,7 @@ public class FactionsBlockListener implements Listener { if (!fme.hasFaction()) { return; } - if (event.getBlock().getType() == SaberFactions.plugin.MOB_SPANWER) { + if (event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial()) { if (!fme.isAdminBypassing()) { Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER); if (access != Access.ALLOW && fme.getRole() != Role.LEADER) { diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java index 81271761..40f76b62 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java @@ -2,6 +2,7 @@ package com.massivecraft.factions.listeners; import com.massivecraft.factions.Conf; import com.massivecraft.factions.SaberFactions; +import com.massivecraft.factions.util.XMaterial; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -49,9 +50,9 @@ public class FactionsExploitListener implements Listener { // blocks who occupy less than 1 block width or length wise need to be handled differently Material mat = event.getTo().getBlock().getType(); - if (((mat == SaberFactions.plugin.THIN_GLASS - || mat == SaberFactions.plugin.IRON_FENCE) && clippingThrough(target, from, 0.65)) - || ((mat == SaberFactions.plugin.FENCE || mat == SaberFactions.plugin.NETHER_FENCE) && clippingThrough(target, from, 0.45))) { + if (((mat == XMaterial.GLASS_PANE.parseMaterial() + || mat == XMaterial.IRON_BARS.parseMaterial()) && clippingThrough(target, from, 0.65)) + || ((mat == XMaterial.OAK_FENCE.parseMaterial() || mat == XMaterial.NETHER_BRICK_FENCE.parseMaterial()) && clippingThrough(target, from, 0.45))) { event.setTo(from); return; } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 6e2a609f..fd637832 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -15,8 +15,8 @@ import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.FactionGUI; -import com.massivecraft.factions.util.MultiversionMaterials; import com.massivecraft.factions.util.VisualizeUtil; +import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.persist.MemoryFPlayer; @@ -657,9 +657,9 @@ public class FactionsPlayerListener implements Listener { if (event.getPlayer().getItemInHand() != null) { Material handItem = event.getPlayer().getItemInHand().getType(); if (handItem.isEdible() - || handItem.equals(MultiversionMaterials.POTION.parseMaterial()) - || handItem.equals(MultiversionMaterials.LINGERING_POTION.parseMaterial()) - || handItem.equals(MultiversionMaterials.SPLASH_POTION.parseMaterial())) { + || handItem.equals(XMaterial.POTION.parseMaterial()) + || handItem.equals(XMaterial.LINGERING_POTION.parseMaterial()) + || handItem.equals(XMaterial.SPLASH_POTION.parseMaterial())) { return; } } @@ -686,8 +686,8 @@ public class FactionsPlayerListener implements Listener { public void onPlayerBoneMeal(PlayerInteractEvent event) { Block block = event.getClickedBlock(); - if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == MultiversionMaterials.GRASS_BLOCK.parseMaterial() - && event.hasItem() && event.getItem().getType() == MultiversionMaterials.BONE_MEAL.parseMaterial()) { + if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial() + && event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) { FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString()); Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(block.getLocation())); diff --git a/src/main/java/com/massivecraft/factions/struct/Placeholder.java b/src/main/java/com/massivecraft/factions/struct/Placeholder.java new file mode 100644 index 00000000..a1b9a6cc --- /dev/null +++ b/src/main/java/com/massivecraft/factions/struct/Placeholder.java @@ -0,0 +1,23 @@ +package com.massivecraft.factions.struct; + + +public class Placeholder { + + private String tag; + private String replace; + + public Placeholder(String tag, String replace) { + this.tag = tag; + this.replace = replace; + } + + public String getReplace() { + return replace; + } + + public String getTag() { + return tag; + } + + +} diff --git a/src/main/java/com/massivecraft/factions/struct/Relation.java b/src/main/java/com/massivecraft/factions/struct/Relation.java index a20155cd..c903915d 100644 --- a/src/main/java/com/massivecraft/factions/struct/Relation.java +++ b/src/main/java/com/massivecraft/factions/struct/Relation.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.struct; import com.massivecraft.factions.Conf; import com.massivecraft.factions.SaberFactions; -import com.massivecraft.factions.util.MultiversionMaterials; +import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.ChatColor; @@ -204,7 +204,7 @@ public enum Relation implements Permissable { String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); List lore = new ArrayList<>(); - Material material = MultiversionMaterials.fromString(RELATION_CONFIG.getString("materials." + name().toLowerCase())).parseMaterial(); + Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())).parseMaterial(); if (material == null) { return null; } diff --git a/src/main/java/com/massivecraft/factions/struct/Role.java b/src/main/java/com/massivecraft/factions/struct/Role.java index 449ba720..42af855a 100644 --- a/src/main/java/com/massivecraft/factions/struct/Role.java +++ b/src/main/java/com/massivecraft/factions/struct/Role.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.struct; import com.massivecraft.factions.Conf; import com.massivecraft.factions.SaberFactions; -import com.massivecraft.factions.util.MultiversionMaterials; +import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.ChatColor; @@ -118,7 +118,7 @@ public enum Role implements Permissable { String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", "")); List lore = new ArrayList<>(); - Material material = MultiversionMaterials.fromString(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).parseMaterial(); + Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).parseMaterial(); if (material == null) { return null; } diff --git a/src/main/java/com/massivecraft/factions/util/MultiversionMaterials.java b/src/main/java/com/massivecraft/factions/util/MultiversionMaterials.java deleted file mode 100644 index 6ded7b7d..00000000 --- a/src/main/java/com/massivecraft/factions/util/MultiversionMaterials.java +++ /dev/null @@ -1,974 +0,0 @@ -package com.massivecraft.factions.util; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import java.util.HashMap; - -public enum MultiversionMaterials { - - ACACIA_BOAT("BOAT_ACACIA", 0), - ACACIA_BUTTON("WOOD_BUTTON", 0), - ACACIA_DOOR("ACACIA_DOOR", 0), - ACACIA_FENCE("ACACIA_FENCE", 0), - ACACIA_FENCE_GATE("ACACIA_FENCE_GATE", 0), - ACACIA_LEAVES("LEAVES_2", 0), - ACACIA_LOG("LOG_2", 0), - ACACIA_PLANKS("WOOD", 4), - ACACIA_PRESSURE_PLATE("WOOD_PLATE", 0), - ACACIA_SAPLING("SAPLING", 4), - ACACIA_SLAB("WOOD_STEP", 4), - ACACIA_STAIRS("ACACIA_STAIRS", 4), - ACACIA_TRAPDOOR("TRAP_DOOR", 0), - ACACIA_WOOD("LOG_2", 0), - ACTIVATOR_RAIL("ACTIVATOR_RAIL", 0), - AIR("AIR", 0), - ALLIUM("STONE", 0), - ANDESITE("STONE", 5), - ANVIL("ANVIL", 0), - APPLE("APPLE", 0), - ARMOR_STAND("ARMOR_STAND", 0), - ARROW("ARROW", 0), - ATTACHED_MELON_STEM("MELON_STEM", 7), - ATTACHED_PUMPKIN_STEM("PUMPKIN_STEM", 7), - AZURE_BLUET("RED_ROSE", 3), - BAKED_POTATO("BAKED_POTATO", 0), - BARRIER("BARRIER", 0), - BAT_SPAWN_EGG("MONSTER_EGG", 0), - BEACON("BEACON", 0), - BEDROCK("BEDROCK", 0), - BEEF("RAW_BEEF", 0), - BEETROOT("BEETROOT", 0), - BEETROOTS("BEETROOT", 0), - BEETROOT_SEEDS("BEETROOT_SEEDS", 0), - BEETROOT_SOUP("BEETROOT_SOUP", 0), - BIRCH_BOAT("BOAT_BIRCH", 0), - BIRCH_BUTTON("WOOD_BUTTON", 0), - BIRCH_DOOR("BIRCH_DOOR", 0), - BIRCH_FENCE("BIRCH_FENCE", 0), - BIRCH_FENCE_GATE("BIRCH_FENCE_GATE", 0), - BIRCH_LEAVES("LEAVES", 2), - BIRCH_LOG("LOG", 2), - BIRCH_PLANKS("WOOD", 2), - BIRCH_PRESSURE_PLATE("WOOD_PLATE", 0), - BIRCH_SAPLING("SAPLING", 2), - BIRCH_SLAB("WOOD_STEP", 2), - BIRCH_STAIRS("BIRCH_WOOD_STAIRS", 0), - BIRCH_TRAPDOOR("TRAP_DOOR", 0), - BIRCH_WOOD("LOG", 2), - BLACK_BANNER("BANNER", 0), - BLACK_BED("BED", 15), - BLACK_CARPET("CARPET", 15), - BLACK_CONCRETE("CONCRETE", 15), - BLACK_CONCRETE_POWDER("CONCRETE_POWDER", 15), - BLACK_GLAZED_TERRACOTTA("BLACK_GLAZED_TERRACOTTA", 0), - BLACK_SHULKER_BOX("BLACK_SHULKER_BOX", 0), - BLACK_STAINED_GLASS("STAINED_GLASS", 15), - BLACK_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 15), - BLACK_TERRACOTTA("STAINED_CLAY", 15), - BLACK_WALL_BANNER("WALL_BANNER", 0), - BLACK_WOOL("WOOL", 15), - BLAZE_POWDER("BLAZE_POWDER", 0), - BLAZE_ROD("BLAZE_ROD", 0), - BLAZE_SPAWN_EGG("MONSTER_EGG", 0), - BLUE_BANNER("BANNER", 11), - BLUE_BED("BED", 4), - BLUE_CARPET("CARPET", 11), - BLUE_CONCRETE("CONCRETE", 11), - BLUE_CONCRETE_POWDER("CONCRETE_POWDER", 11), - BLUE_GLAZED_TERRACOTTA("BLUE_GLAZED_TERRACOTTA", 0), - BLUE_ICE("PACKED_ICE", 0), - BLUE_ORCHID("RED_ROSE", 1), - BLUE_SHULKER_BOX("BLUE_SHULKER_BOX", 0), - BLUE_STAINED_GLASS("STAINED_GLASS", 11), - BLUE_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 11), - BLUE_TERRACOTTA("STAINED_CLAY", 11), - BLUE_WALL_BANNER("WALL_BANNER", 11), - BLUE_WOOL("WOOL", 11), - BONE("BONE", 0), - BONE_BLOCK("BONE_BLOCK", 0), - BONE_MEAL("INK_SACK", 15), - BOOK("BOOK", 0), - BOOKSHELF("BOOKSHELF", 0), - BOW("BOW", 0), - BOWL("BOWL", 0), - BRAIN_CORAL("STONE", 0), - BRAIN_CORAL_BLOCK("STONE", 0), - BRAIN_CORAL_FAN("STONE", 0), - BREAD("BREAD", 0), - BREWING_STAND("BREWING_STAND", 0), - BRICK("CLAY_BRICK", 0), - BRICKS("BRICK", 0), - BRICK_SLAB("STEP", 4), - BRICK_STAIRS("BRICK_STAIRS", 0), - BROWN_BANNER("BANNER", 3), - BROWN_BED("BED", 12), - BROWN_CARPET("CARPET", 12), - BROWN_CONCRETE("CONCRETE", 12), - BROWN_CONCRETE_POWDER("CONCRETE_POWDER", 12), - BROWN_GLAZED_TERRACOTTA("BROWN_GLAZED_TERRACOTTA", 0), - BROWN_MUSHROOM("BROWN_MUSHROOM", 0), - BROWN_MUSHROOM_BLOCK("BROWN_MUSHROOM", 0), //UNSURE - BROWN_SHULKER_BOX("BROWN_SHULKER_BOX", 0), - BROWN_STAINED_GLASS("STAINED_GLASS", 12), - BROWN_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 12), - BROWN_TERRACOTTA("STAINED_CLAY", 12), - BROWN_WALL_BANNER("WALL_BANNER", 3), - BROWN_WOOL("WOOL", 12), - BUBBLE_COLUMN("STONE", 0), - BUBBLE_CORAL("STONE", 0), - BUBBLE_CORAL_BLOCK("STONE", 0), - BUBBLE_CORAL_FAN("STONE", 0), - BUCKET("BUCKET", 0), - CACTUS("CACTUS", 0), - CACTUS_GREEN("INK_SACK", 2), - CAKE("CAKE", 0), - CARROT("CARROT_ITEM", 0), - CARROTS("CARROT", 0), - CARROT_ON_A_STICK("CARROT_STICK", 0), - CARVED_PUMPKIN("PUMPKIN", 0), - CAULDRON("CAULDRON", 0), - CAVE_AIR("AIR", 0), - CAVE_SPIDER_SPAWN_EGG("MONSTER_EGG", 0), - CHAINMAIL_BOOTS("CHAINMAIL_BOOTS", 0), - CHAINMAIL_CHESTPLATE("CHAINMAIL_CHESTPLATE", 0), - CHAINMAIL_HELMET("CHAINMAIL_HELMET", 0), - CHAINMAIL_LEGGINGS("CHAINMAIL_LEGGINGS", 0), - CHAIN_COMMAND_BLOCK("COMMAND_CHAIN", 0), - CHARCOAL("COAL", 1), - CHEST("CHEST", 0), - CHEST_MINECART("STORAGE_MINECART", 0), - CHICKEN("RAW_CHICKEN", 0), - CHICKEN_SPAWN_EGG("MONSTER_EGG", 0), - CHIPPED_ANVIL("ANVIL", 1), - CHISELED_QUARTZ_BLOCK("QUARTZ_BLOCK", 1), - CHISELED_RED_SANDSTONE("RED_SANDSTONE", 1), - CHISELED_SANDSTONE("SANDSTONE", 1), - CHISELED_STONE_BRICKS("SMOOTH_BRICK", 3), - CHORUS_FLOWER("CHORUS_FLOWER", 0), - CHORUS_FRUIT("CHORUS_FRUIT", 0), - CHORUS_PLANT("CHORUS_PLANT", 0), - CLAY("CLAY", 0), - CLAY_BALL("CLAY_BALL", 0), - CLOCK("WATCH", 0), - COAL("COAL", 0), - COAL_BLOCK("COAL_BLOCK", 0), - COAL_ORE("COAL_ORE", 0), - COARSE_DIRT("DIRT", 1), - COBBLESTONE("COBBLESTONE", 0), - COBBLESTONE_SLAB("STEP", 3), - COBBLESTONE_STAIRS("COBBLESTONE_STAIRS", 0), - COBBLESTONE_WALL("COBBLE_WALL", 0), - COBWEB("WEB", 0), - COCOA("COCOA", 0), - COCOA_BEANS("INK_SACK", 3), - COD("RAW_FISH", 0), - COD_BUCKET("BUCKET", 0), - COD_SPAWN_EGG("MONSTER_EGG", 0), - COMMAND_BLOCK("COMMAND", 0), - COMMAND_BLOCK_MINECART("COMMAND_MINECART", 0), - COMPARATOR("REDSTONE_COMPARATOR", 0), - COMPASS("COMPASS", 0), - CONDUIT("STONE", 0), - COOKED_BEEF("COOKED_BEEF", 0), - COOKED_CHICKEN("COOKED_CHICKEN", 0), - COOKED_COD("COOKED_FISH", 0), - COOKED_MUTTON("COOKED_MUTTON", 0), - COOKED_PORKCHOP("GRILLED_PORK", 0), - COOKED_RABBIT("COOKED_RABBIT", 0), - COOKED_SALMON("COOKED_FISH", 1), - COOKIE("COOKIE", 0), - COW_SPAWN_EGG("MONSTER_EGG", 0), - CRACKED_STONE_BRICKS("SMOOTH_BRICK", 2), - CRAFTING_TABLE("WORKBENCH", 0), - CREEPER_HEAD("SKULL", 0), - CREEPER_SPAWN_EGG("MONSTER_EGG", 0), - CREEPER_WALL_HEAD("SKULL", 0), - CUT_RED_SANDSTONE("STONE", 0), - CUT_SANDSTONE("STONE", 0), - CYAN_BANNER("BANNER", 6), - CYAN_BED("BED", 9), - CYAN_CARPET("CARPET", 9), - CYAN_CONCRETE("CONCRETE", 9), - CYAN_CONCRETE_POWDER("CONCRETE_POWDER", 9), - CYAN_DYE("INK_SACK", 6), - CYAN_GLAZED_TERRACOTTA("CYAN_GLAZED_TERRACOTTA", 0), - CYAN_SHULKER_BOX("CYAN_SHULKER_BOX", 0), - CYAN_STAINED_GLASS("STAINED_GLASS", 9), - CYAN_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 9), - CYAN_TERRACOTTA("STAINED_CLAY", 9), - CYAN_WALL_BANNER("WALL_BANNER", 0), - CYAN_WOOL("WOOL", 9), - DAMAGED_ANVIL("ANVIL", 2), - DANDELION("YELLOW_FLOWER", 0), - DANDELION_YELLOW("INK_SACK", 11), - DARK_OAK_BOAT("BOAT_DARK_OAK", 0), - DARK_OAK_BUTTON("WOOD_BUTTON", 0), - DARK_OAK_DOOR("DARK_OAK_DOOR", 0), - DARK_OAK_FENCE("DARK_OAK_FENCE", 0), - DARK_OAK_FENCE_GATE("DARK_OAK_FENCE_GATE", 0), - DARK_OAK_LEAVES("LEAVES_2", 1), - DARK_OAK_LOG("LOG_2", 1), - DARK_OAK_PLANKS("WOOD", 5), - DARK_OAK_PRESSURE_PLATE("WOOD_PLATE", 0), - DARK_OAK_SAPLING("SAPLING", 5), - DARK_OAK_SLAB("WOOD_STEP", 0), - DARK_OAK_STAIRS("DARK_OAK_STAIRS", 0), - DARK_OAK_TRAPDOOR("TRAP_DOOR", 0), - DARK_OAK_WOOD("LOG_2", 1), - DARK_PRISMARINE("PRISMARINE", 2), - DARK_PRISMARINE_SLAB("STONE", 0), - DARK_PRISMARINE_STAIRS("STONE", 0), - DAYLIGHT_DETECTOR("DAYLIGHT_DETECTOR", 0), - DEAD_BRAIN_CORAL_BLOCK("STONE", 0), - DEAD_BUBBLE_CORAL_BLOCK("STONE", 0), - DEAD_BUSH("DEAD_BUSH", 0), - DEAD_FIRE_CORAL_BLOCK("STONE", 0), - DEAD_HORN_CORAL_BLOCK("STONE", 0), - DEAD_TUBE_CORAL_BLOCK("STONE", 0), - DEBUG_STICK("STICK", 0), - DETECTOR_RAIL("DETECTOR_RAIL", 0), - DIAMOND("DIAMOND", 0), - DIAMOND_AXE("DIAMOND_AXE", 0), - DIAMOND_BLOCK("DIAMOND_BLOCK", 0), - DIAMOND_BOOTS("DIAMOND_BOOTS", 0), - DIAMOND_CHESTPLATE("DIAMOND_CHESTPLATE", 0), - DIAMOND_HELMET("DIAMOND_HELMET", 0), - DIAMOND_HOE("DIAMOND_HOE", 0), - DIAMOND_HORSE_ARMOR("DIAMOND_BARDING", 0), - DIAMOND_LEGGINGS("DIAMOND_LEGGINGS", 0), - DIAMOND_ORE("DIAMOND_ORE", 0), - DIAMOND_PICKAXE("DIAMOND_PICKAXE", 0), - DIAMOND_SHOVEL("DIAMOND_SPADE", 0), - DIAMOND_SWORD("DIAMOND_SWORD", 0), - DIORITE("STONE", 3), - DIRT("DIRT", 0), - DISPENSER("DISPENSER", 0), - DOLPHIN_SPAWN_EGG("MONSTER_EGG", 0), - DONKEY_SPAWN_EGG("MONSTER_EGG", 0), - DRAGON_BREATH("DRAGONS_BREATH", 0), - DRAGON_EGG("DRAGON_EGG", 0), - DRAGON_HEAD("SKULL", 5), - DRAGON_WALL_HEAD("SKULL", 0), - DRIED_KELP("STONE", 0), - DRIED_KELP_BLOCK("STONE", 0), - DROPPER("DROPPER", 0), - DROWNED_SPAWN_EGG("MONSTER_EGG", 0), - EGG("EGG", 0), - ELDER_GUARDIAN_SPAWN_EGG("MONSTER_EGG", 0), - ELYTRA("ELYTRA", 0), - EMERALD("EMERALD", 0), - EMERALD_BLOCK("EMERALD_BLOCK", 0), - EMERALD_ORE("EMERALD_ORE", 0), - ENCHANTED_BOOK("ENCHANTED_BOOK", 0), - ENCHANTED_GOLDEN_APPLE("GOLDEN_APPLE", 1), - ENCHANTING_TABLE("ENCHANTING_TABLE", 0), - ENDERMAN_SPAWN_EGG("MONSTER_EGG", 0), - ENDERMITE_SPAWN_EGG("MONSTER_EGG", 0), - ENDER_CHEST("ENDER_CHEST", 0), - ENDER_EYE("EYE_OF_ENDER", 0), - ENDER_PEARL("ENDER_PEARL", 0), - END_CRYSTAL("END_CRYSTAL", 0), - END_GATEWAY("END_GATEWAY", 0), - END_PORTAL("ENDER_PORTAL", 0), - END_PORTAL_FRAME("ENDER_PORTAL_FRAME", 0), - END_ROD("END_ROD", 0), - END_STONE("ENDER_STONE", 0), - END_STONE_BRICKS("END_BRICKS", 0), - EVOKER_SPAWN_EGG("MONSTER_EGG", 0), - EXPERIENCE_BOTTLE("EXP_BOTTLE", 0), - FARMLAND("SOIL", 0), - FEATHER("FEATHER", 0), - FERMENTED_SPIDER_EYE("FERMENTED_SPIDER_EYE", 0), - FERN("LONG_GRASS", 2), - FILLED_MAP("MAP", 0), - FIRE("FIRE", 0), - FIREWORK_ROCKET("FIREWORK", 0), - FIREWORK_STAR("FIREWORK_CHARGE", 0), - FIRE_CHARGE("FIREBALL", 0), - FIRE_CORAL("STONE", 0), - FIRE_CORAL_BLOCK("STONE", 0), - FIRE_CORAL_FAN("STONE", 0), - FISHING_ROD("FISHING_ROD", 0), - FLINT("FLINT", 0), - FLINT_AND_STEEL("FLINT_AND_STEEL", 0), - FLOWER_POT("FLOWER_POT", 0), - FROSTED_ICE("FROSTED_ICE", 0), - FURNACE("FURNACE", 0), - FURNACE_MINECART("POWERED_MINECART", 0), - GHAST_SPAWN_EGG("MONSTER_EGG", 0), - GHAST_TEAR("GHAST_TEAR", 0), - GLASS("GLASS", 0), - GLASS_BOTTLE("GLASS_BOTTLE", 0), - GLASS_PANE("THIN_GLASS", 0), - GLISTERING_MELON_SLICE("SPECKLED_MELON", 0), - GLOWSTONE("GLOWSTONE", 0), - GLOWSTONE_DUST("GLOWSTONE_DUST", 0), - GOLDEN_APPLE("GOLDEN_APPLE", 0), - GOLDEN_AXE("GOLD_AXE", 0), - GOLDEN_BOOTS("GOLD_BOOTS", 0), - GOLDEN_CARROT("GOLDEN_CARROT", 0), - GOLDEN_CHESTPLATE("GOLD_CHESTPLATE", 0), - GOLDEN_HELMET("GOLD_HELMET", 0), - GOLDEN_HOE("GOLD_HOE", 0), - GOLDEN_HORSE_ARMOR("GOLD_BARDING", 0), - GOLDEN_LEGGINGS("GOLD_LEGGINGS", 0), - GOLDEN_PICKAXE("GOLD_PICKAXE", 0), - GOLDEN_SHOVEL("GOLD_SPADE", 0), - GOLDEN_SWORD("GOLD_SWORD", 0), - GOLD_BLOCK("GOLD_BLOCK", 0), - GOLD_INGOT("GOLD_INGOT", 0), - GOLD_NUGGET("GOLD_NUGGET", 0), - GOLD_ORE("GOLD_ORE", 0), - GRANITE("STONE", 1), - GRASS("GRASS", 0), - GRASS_BLOCK("GRASS", 0), - GRASS_PATH("GRASS_PATH", 0), - GRAVEL("GRAVEL", 0), - GRAY_BANNER("BANNER", 8), - GRAY_BED("BED", 7), - GRAY_CARPET("CARPET", 7), - GRAY_CONCRETE("CONCRETE", 7), - GRAY_CONCRETE_POWDER("CONCRETE_POWDER", 7), - GRAY_DYE("INK_SACK", 8), - GRAY_GLAZED_TERRACOTTA("GRAY_GLAZED_TERRACOTTA", 0), - GRAY_SHULKER_BOX("GRAY_SHULKER_BOX", 0), - GRAY_STAINED_GLASS("STAINED_GLASS", 7), - GRAY_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 7), - GRAY_TERRACOTTA("STAINED_CLAY", 7), - GRAY_WALL_BANNER("WALL_BANNER", 0), - GRAY_WOOL("WOOL", 7), - GREEN_BANNER("BANNER", 2), - GREEN_BED("BED", 13), - GREEN_CARPET("CARPET", 13), - GREEN_CONCRETE("CONCRETE", 13), - GREEN_CONCRETE_POWDER("CONCRETE_POWDER", 13), - GREEN_GLAZED_TERRACOTTA("GREEN_GLAZED_TERRACOTTA", 0), - GREEN_SHULKER_BOX("GREEN_SHULKER_BOX", 0), - GREEN_STAINED_GLASS("STAINED_GLASS", 13), - GREEN_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 13), - GREEN_TERRACOTTA("STAINED_CLAY", 13), - GREEN_WALL_BANNER("WALL_BANNER", 0), - GREEN_WOOL("WOOL", 13), - GUARDIAN_SPAWN_EGG("MONSTER_EGG", 0), - GUNPOWDER("SULPHUR", 0), - HAY_BLOCK("HAY_BLOCK", 0), - HEART_OF_THE_SEA("STONE", 0), - HEAVY_WEIGHTED_PRESSURE_PLATE("IRON_PLATE", 0), - HOPPER("HOPPER", 0), - HOPPER_MINECART("HOPPER_MINECART", 0), - HORN_CORAL("STONE", 0), - HORN_CORAL_BLOCK("STONE", 0), - HORN_CORAL_FAN("STONE", 0), - HORSE_SPAWN_EGG("MONSTER_EGG", 0), - HUSK_SPAWN_EGG("MONSTER_EGG", 0), - ICE("ICE", 0), - INFESTED_CHISELED_STONE_BRICKS("MONSTER_EGGS", 5), - INFESTED_COBBLESTONE("MONSTER_EGGS", 1), - INFESTED_CRACKED_STONE_BRICKS("MONSTER_EGGS", 4), - INFESTED_MOSSY_STONE_BRICKS("MONSTER_EGGS", 3), - INFESTED_STONE("MONSTER_EGGS", 0), - INFESTED_STONE_BRICKS("MONSTER_EGGS", 2), - INK_SAC("INK_SACK", 0), - IRON_AXE("IRON_AXE", 0), - IRON_BARS("IRON_FENCE", 0), - IRON_BLOCK("IRON_BLOCK", 0), - IRON_BOOTS("IRON_BOOTS", 0), - IRON_CHESTPLATE("IRON_CHESTPLATE", 0), - IRON_DOOR("IRON_DOOR", 0), - IRON_HELMET("IRON_HELMET", 0), - IRON_HOE("IRON_HOE", 0), - IRON_HORSE_ARMOR("IRON_BARDING", 0), - IRON_INGOT("IRON_INGOT", 0), - IRON_LEGGINGS("IRON_LEGGINGS", 0), - IRON_NUGGET("IRON_NUGGET", 0), - IRON_ORE("IRON_ORE", 0), - IRON_PICKAXE("IRON_PICKAXE", 0), - IRON_SHOVEL("IRON_SPADE", 0), - IRON_SWORD("IRON_SWORD", 0), - IRON_TRAPDOOR("IRON_TRAPDOOR", 0), - ITEM_FRAME("ITEM_FRAME", 0), - JACK_O_LANTERN("JACK_O_LANTERN", 0), - JUKEBOX("JUKEBOX", 0), - JUNGLE_BOAT("BOAT_JUNGLE", 0), - JUNGLE_BUTTON("WOOD_BUTTON", 0), - JUNGLE_DOOR("JUNGLE_DOOR", 0), - JUNGLE_FENCE("JUNGLE_FENCE", 0), - JUNGLE_FENCE_GATE("JUNGLE_FENCE_GATE", 0), - JUNGLE_LEAVES("LEAVES", 3), - JUNGLE_LOG("LOG", 3), - JUNGLE_PLANKS("WOOD", 3), - JUNGLE_PRESSURE_PLATE("WOOD_PLATE", 0), - JUNGLE_SAPLING("SAPLING", 3), - JUNGLE_SLAB("WOOD_STEP", 3), - JUNGLE_STAIRS("JUNGLE_WOOD_STAIRS", 0), - JUNGLE_TRAPDOOR("TRAP_DOOR", 0), - JUNGLE_WOOD("LOG", 3), - KELP("STONE", 0), - KELP_PLANT("STONE", 0), - KNOWLEDGE_BOOK("KNOWLEDGE_BOOK", 0), - LADDER("LADDER", 0), - LAPIS_BLOCK("LAPIS_BLOCK", 0), - LAPIS_LAZULI("INK_SACK", 4), - LAPIS_ORE("LAPIS_ORE", 0), - LARGE_FERN("DOUBLE_PLANT", 3), - LAVA("LAVA", 0), - LAVA_BUCKET("LAVA_BUCKET", 0), - LEAD("LEASH", 0), - LEATHER("LEATHER", 0), - LEATHER_BOOTS("LEATHER_BOOTS", 0), - LEATHER_CHESTPLATE("LEATHER_CHESTPLATE", 0), - LEATHER_HELMET("LEATHER_HELMET", 0), - LEATHER_LEGGINGS("LEATHER_LEGGINGS", 0), - LEVER("LEVER", 0), - LIGHT_BLUE_BANNER("BANNER", 12), - LIGHT_BLUE_BED("BED", 3), - LIGHT_BLUE_CARPET("CARPET", 3), - LIGHT_BLUE_CONCRETE("CONCRETE", 3), - LIGHT_BLUE_CONCRETE_POWDER("CONCRETE_POWDER", 3), - LIGHT_BLUE_DYE("INK_SACK", 12), - LIGHT_BLUE_GLAZED_TERRACOTTA("LIGHT_BLUE_GLAZED_TERRACOTTA", 0), - LIGHT_BLUE_SHULKER_BOX("LIGHT_BLUE_SHULKER_BOX", 0), - LIGHT_BLUE_STAINED_GLASS("STAINED_GLASS", 3), - LIGHT_BLUE_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 3), - LIGHT_BLUE_TERRACOTTA("STAINED_CLAY", 3), - LIGHT_BLUE_WALL_BANNER("BANNER", 0), - LIGHT_BLUE_WOOL("WOOL", 3), - LIGHT_GRAY_BANNER("BANNER", 7), - LIGHT_GRAY_BED("BED", 8), - LIGHT_GRAY_CARPET("CARPET", 8), - LIGHT_GRAY_CONCRETE("CONCRETE", 8), - LIGHT_GRAY_CONCRETE_POWDER("CONCRETE_POWDER", 8), - LIGHT_GRAY_DYE("INK_SACK", 7), - LIGHT_GRAY_GLAZED_TERRACOTTA("SILVER_GLAZED_TERRACOTTA", 0), - LIGHT_GRAY_SHULKER_BOX("SILVER_SHULKER_BOX", 0), - LIGHT_GRAY_STAINED_GLASS("STAINED_GLASS", 8), - LIGHT_GRAY_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 8), - LIGHT_GRAY_TERRACOTTA("STAINED_CLAY", 8), - LIGHT_GRAY_WALL_BANNER("WALL_BANNER", 0), - LIGHT_GRAY_WOOL("WOOL", 8), - LIGHT_WEIGHTED_PRESSURE_PLATE("GOLD_PLATE", 0), - LILAC("DOUBLE_PLANT", 1), - LILY_PAD("WATER_LILY", 0), - LIME_BANNER("BANNER", 10), - LIME_BED("BED", 5), - LIME_CARPET("CARPET", 5), - LIME_CONCRETE("CONCRETE", 5), - LIME_CONCRETE_POWDER("CONCRETE_POWDER", 5), - LIME_DYE("INK_SACK", 10), - LIME_GLAZED_TERRACOTTA("LIME_GLAZED_TERRACOTTA", 0), - LIME_SHULKER_BOX("LIME_SHULKER_BOX", 0), - LIME_STAINED_GLASS("STAINED_GLASS", 5), - LIME_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 5), - LIME_TERRACOTTA("STAINED_CLAY", 5), - LIME_WALL_BANNER("WALL_BANNER", 0), - LIME_WOOL("WOOL", 5), - LINGERING_POTION("LINGERING_POTION", 0), - LLAMA_SPAWN_EGG("MONSTER_EGG", 0), - MAGENTA_BANNER("BANNER", 13), - MAGENTA_BED("BED", 2), - MAGENTA_CARPET("CARPET", 2), - MAGENTA_CONCRETE("CONCRETE", 2), - MAGENTA_CONCRETE_POWDER("CONCRETE_POWDER", 2), - MAGENTA_DYE("INK_SACK", 13), - MAGENTA_GLAZED_TERRACOTTA("MAGENTA_GLAZED_TERRACOTTA", 0), - MAGENTA_SHULKER_BOX("MAGENTA_SHULKER_BOX", 0), - MAGENTA_STAINED_GLASS("STAINED_GLASS", 2), - MAGENTA_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 2), - MAGENTA_TERRACOTTA("STAINED_CLAY", 2), - MAGENTA_WALL_BANNER("WALL_BANNER", 0), - MAGENTA_WOOL("WOOL", 2), - MAGMA_BLOCK("MAGMA", 0), - MAGMA_CREAM("MAGMA_CREAM", 0), - MAGMA_CUBE_SPAWN_EGG("MONSTER_EGG", 0), - MAP("MAP", 0), - MELON("MELON_BLOCK", 0), - MELON_SEEDS("MELON_SEEDS", 0), - MELON_SLICE("MELON", 0), - MELON_STEM("MELON_STEM", 0), - MILK_BUCKET("MILK_BUCKET", 0), - MINECART("MINECART", 0), - MOOSHROOM_SPAWN_EGG("MONSTER_EGG", 0), - MOSSY_COBBLESTONE("MOSSY_COBBLESTONE", 0), - MOSSY_COBBLESTONE_WALL("COBBLE_WALL", 1), - MOSSY_STONE_BRICKS("SMOOTH_BRICK", 1), - MOVING_PISTON("PISTON_MOVING_PIECE", 0), - MULE_SPAWN_EGG("MONSTER_EGG", 0), - MUSHROOM_STEM("BROWN_MUSHROOM", 0), - MUSHROOM_STEW("MUSHROOM_SOUP", 0), - MUSIC_DISC_11("GOLD_RECORD", 0), - MUSIC_DISC_13("GREEN_RECORD", 0), - MUSIC_DISC_BLOCKS("RECORD_3", 0), - MUSIC_DISC_CAT("RECORD_4", 0), - MUSIC_DISC_CHIRP("RECORD_5", 0), - MUSIC_DISC_FAR("RECORD_6", 0), - MUSIC_DISC_MALL("RECORD_7", 0), - MUSIC_DISC_MELLOHI("RECORD_8", 0), - MUSIC_DISC_STAL("RECORD_9", 0), - MUSIC_DISC_STRAD("RECORD_10", 0), - MUSIC_DISC_WAIT("RECORD_11", 0), - MUSIC_DISC_WARD("RECORD_12", 0), - MUTTON("MUTTON", 0), - MYCELIUM("MYCEL", 0), - NAME_TAG("NAME_TAG", 0), - NAUTILUS_SHELL("STONE", 0), - NETHERRACK("NETHERRACK", 0), - NETHER_BRICK("NETHER_BRICK", 0), - NETHER_BRICKS("NETHER_BRICK", 0), - NETHER_BRICK_FENCE("NETHER_FENCE", 0), - NETHER_BRICK_SLAB("STEP", 6), - NETHER_BRICK_STAIRS("NETHER_BRICK_STAIRS", 0), - NETHER_PORTAL("PORTAL", 0), - NETHER_QUARTZ_ORE("QUARTZ_ORE", 0), - NETHER_STAR("NETHER_STAR", 0), - NETHER_WART("NETHER_STALK", 0), - NETHER_WART_BLOCK("NETHER_WART_BLOCK", 0), - NOTE_BLOCK("NOTE_BLOCK", 0), - OAK_BOAT("BOAT", 0), - OAK_BUTTON("WOOD_BUTTON", 0), - OAK_DOOR("WOOD_DOOR", 0), - OAK_FENCE("FENCE", 0), - OAK_FENCE_GATE("FENCE_GATE", 0), - OAK_LEAVES("LEAVES", 0), - OAK_LOG("LOG", 0), - OAK_PLANKS("WOOD", 0), - OAK_PRESSURE_PLATE("WOOD_PLATE", 0), - OAK_SAPLING("SAPLING", 0), - OAK_SLAB("WOOD_STEP", 0), - OAK_STAIRS("WOOD_STAIRS", 0), - OAK_TRAPDOOR("TRAP_DOOR", 0), - OAK_WOOD("LOG", 0), - OBSERVER("OBSERVER", 0), - OBSIDIAN("OBSIDIAN", 0), - OCELOT_SPAWN_EGG("RECORD_12", 0), - ORANGE_BANNER("BANNER", 14), - ORANGE_BED("BED", 1), - ORANGE_CARPET("CARPET", 1), - ORANGE_CONCRETE("CONCRETE", 1), - ORANGE_CONCRETE_POWDER("CONCRETE_POWDER", 1), - ORANGE_DYE("INK_SACK", 14), - ORANGE_GLAZED_TERRACOTTA("ORANGE_GLAZED_TERRACOTTA", 0), - ORANGE_SHULKER_BOX("ORANGE_SHULKER_BOX", 0), - ORANGE_STAINED_GLASS("STAINED_GLASS", 1), - ORANGE_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 1), - ORANGE_TERRACOTTA("STAINED_CLAY", 1), - ORANGE_TULIP("RED_ROSE", 5), - ORANGE_WALL_BANNER("WALL_BANNER", 0), - ORANGE_WOOL("WOOL", 1), - OXEYE_DAISY("RED_ROSE", 8), - PACKED_ICE("PACKED_ICE", 0), - PAINTING("PAINTING", 0), - PAPER("PAPER", 0), - PARROT_SPAWN_EGG("MONSTER_EGG", 0), - PEONY("DOUBLE_PLANT", 5), - PETRIFIED_OAK_SLAB("STONE", 0), - PHANTOM_MEMBRANE("STONE", 0), - PHANTOM_SPAWN_EGG("MONSTER_EGG", 0), - PIG_SPAWN_EGG("MONSTER_EGG", 0), - PINK_BANNER("BANNER", 9), - PINK_BED("BED", 6), - PINK_CARPET("CARPET", 6), - PINK_CONCRETE("CONCRETE", 6), - PINK_CONCRETE_POWDER("CONCRETE_POWDER", 6), - PINK_DYE("INK_SACK", 9), - PINK_GLAZED_TERRACOTTA("PINK_GLAZED_TERRACOTTA", 0), - PINK_SHULKER_BOX("PINK_SHULKER_BOX", 0), - PINK_STAINED_GLASS("STAINED_GLASS", 6), - PINK_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 6), - PINK_TERRACOTTA("STAINED_CLAY", 6), - PINK_TULIP("RED_ROSE", 7), - PINK_WALL_BANNER("WALL_BANNER", 0), - PINK_WOOL("WOOL", 6), - PISTON("PISTON_BASE", 0), - PISTON_HEAD("PISTON_EXTENSION", 0), - PLAYER_HEAD("SKULL", 0), - PLAYER_WALL_HEAD("SKULL", 0), - PODZOL("DIRT", 2), - POISONOUS_POTATO("POISONOUS_POTATO", 0), - POLAR_BEAR_SPAWN_EGG("MONSTER_EGG", 0), - POLISHED_ANDESITE("STONE", 6), - POLISHED_DIORITE("STONE", 4), - POLISHED_GRANITE("STONE", 2), - POPPED_CHORUS_FRUIT("CHORUS_FRUIT_POPPED", 0), - POPPY("RED_ROSE", 0), - PORKCHOP("PORK", 0), - POTATO("POTATO_ITEM", 0), - POTATOES("POTATO", 0), - POTION("POTION", 0), - POTTED_ACACIA_SAPLING("FLOWER_POT", 0), - POTTED_ALLIUM("FLOWER_POT", 0), - POTTED_AZURE_BLUET("FLOWER_POT", 0), - POTTED_BIRCH_SAPLING("FLOWER_POT", 0), - POTTED_BLUE_ORCHID("FLOWER_POT", 0), - POTTED_BROWN_MUSHROOM("FLOWER_POT", 0), - POTTED_CACTUS("FLOWER_POT", 0), - POTTED_DANDELION("FLOWER_POT", 0), - POTTED_DARK_OAK_SAPLING("FLOWER_POT", 0), - POTTED_DEAD_BUSH("FLOWER_POT", 0), - POTTED_FERN("FLOWER_POT", 0), - POTTED_JUNGLE_SAPLING("FLOWER_POT", 0), - POTTED_OAK_SAPLING("FLOWER_POT", 0), - POTTED_ORANGE_TULIP("FLOWER_POT", 0), - POTTED_OXEYE_DAISY("FLOWER_POT", 0), - POTTED_PINK_TULIP("FLOWER_POT", 0), - POTTED_POPPY("FLOWER_POT", 0), - POTTED_RED_MUSHROOM("FLOWER_POT", 0), - POTTED_RED_TULIP("FLOWER_POT", 0), - POTTED_SPRUCE_SAPLING("FLOWER_POT", 0), - POTTED_WHITE_TULIP("FLOWER_POT", 0), - POWERED_RAIL("POWERED_RAIL", 0), - PRISMARINE("PRISMARINE", 0), - PRISMARINE_BRICKS("PRISMARINE", 1), - PRISMARINE_BRICK_SLAB("STONE", 0), - PRISMARINE_BRICK_STAIRS("STONE", 0), - PRISMARINE_CRYSTALS("PRISMARINE_CRYSTALS", 0), - PRISMARINE_SHARD("PRISMARINE_SHARD", 0), - PRISMARINE_SLAB("STONE", 0), - PRISMARINE_STAIRS("STONE", 0), - PUFFERFISH("RAW_FISH", 3), - PUFFERFISH_BUCKET("STONE", 0), - PUFFERFISH_SPAWN_EGG("MONSTER_EGG", 0), - PUMPKIN("PUMPKIN", 0), - PUMPKIN_PIE("PUMPKIN_PIE", 0), - PUMPKIN_SEEDS("PUMPKIN_SEEDS", 0), - PUMPKIN_STEM("PUMPKIN_STEM", 0), - PURPLE_BANNER("BANNER", 5), - PURPLE_BED("BED", 10), - PURPLE_CARPET("CARPET", 10), - PURPLE_CONCRETE("CONCRETE", 10), - PURPLE_CONCRETE_POWDER("CONCRETE_POWDER", 10), - PURPLE_DYE("INK_SACK", 5), - PURPLE_GLAZED_TERRACOTTA("PURPLE_GLAZED_TERRACOTTA", 0), - PURPLE_SHULKER_BOX("PURPLE_SHULKER_BOX", 0), - PURPLE_STAINED_GLASS("STAINED_GLASS", 10), - PURPLE_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 10), - PURPLE_TERRACOTTA("STAINED_CLAY", 10), - PURPLE_WALL_BANNER("WALL_BANNER", 0), - PURPLE_WOOL("WOOL", 10), - PURPUR_BLOCK("PURPUR_BLOCK", 0), - PURPUR_PILLAR("PURPUR_PILLAR", 0), - PURPUR_SLAB("PURPUR_SLAB", 0), - PURPUR_STAIRS("PURPUR_STAIRS", 0), - QUARTZ("QUARTZ", 0), - QUARTZ_BLOCK("QUARTZ_BLOCK", 0), - QUARTZ_PILLAR("QUARTZ_BLOCK", 2), - QUARTZ_SLAB("STEP", 7), - QUARTZ_STAIRS("QUARTZ_STAIRS", 0), - RABBIT("RABBIT", 0), - RABBIT_FOOT("RABBIT_FOOT", 0), - RABBIT_HIDE("RABBIT_HIDE", 0), - RABBIT_SPAWN_EGG("MONSTER_EGG", 0), - RABBIT_STEW("RABBIT_STEW", 0), - RAIL("RAILS", 0), - REDSTONE("REDSTONE", 0), - REDSTONE_BLOCK("REDSTONE_BLOCK", 0), - REDSTONE_LAMP("REDSTONE_LAMP_OFF", 0), - REDSTONE_ORE("REDSTONE_ORE", 0), - REDSTONE_TORCH("REDSTONE_TORCH_ON", 0), - REDSTONE_WALL_TORCH("REDSTONE_TORCH_ON", 1), - REDSTONE_WIRE("REDSTONE_WIRE", 0), - RED_BANNER("BANNER", 1), - RED_BED("BED", 14), - RED_CARPET("CARPET", 14), - RED_CONCRETE("CONCRETE", 14), - RED_CONCRETE_POWDER("CONCRETE_POWDER", 14), - RED_GLAZED_TERRACOTTA("RED_GLAZED_TERRACOTTA", 0), - RED_MUSHROOM("RED_MUSHROOM", 0), - RED_MUSHROOM_BLOCK("RED_MUSHROOM", 0), - RED_NETHER_BRICKS("RED_NETHER_BRICK", 0), - RED_SAND("SAND", 1), - RED_SANDSTONE("RED_SANDSTONE", 0), - RED_SANDSTONE_SLAB("STONE_SLAB2", 0), - RED_SANDSTONE_STAIRS("RED_SANDSTONE_STAIRS", 0), - RED_SHULKER_BOX("RED_SHULKER_BOX", 0), - RED_STAINED_GLASS("STAINED_GLASS", 14), - RED_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 14), - RED_TERRACOTTA("STAINED_CLAY", 14), - RED_TULIP("RED_ROSE", 4), - RED_WALL_BANNER("WALL_BANNER", 0), - RED_WOOL("WOOL", 14), - REPEATER("DIODE", 0), - REPEATING_COMMAND_BLOCK("COMMAND_REPEATING", 0), - ROSE_BUSH("DOUBLE_PLANT", 4), - ROSE_RED("INK_SACK", 1), - ROTTEN_FLESH("ROTTEN_FLESH", 0), - SADDLE("SADDLE", 0), - SALMON("RAW_FISH", 1), - SALMON_BUCKET("BUCKET", 0), - SALMON_SPAWN_EGG("MONSTER_EGG", 0), - SAND("SAND", 0), - SANDSTONE("SANDSTONE", 0), - SANDSTONE_SLAB("STEP", 1), - SANDSTONE_STAIRS("SANDSTONE_STAIRS", 0), - SCUTE("STONE", 0), - SEAGRASS("STONE", 0), - SEA_LANTERN("SEA_LANTERN", 0), - SEA_PICKLE("STONE", 0), - SHEARS("SHEARS", 0), - SHEEP_SPAWN_EGG("MONSTER_EGG", 0), - SHIELD("SHIELD", 0), - SHULKER_BOX("PURPLE_SHULKER_BOX", 0), - SHULKER_SHELL("SHULKER_SHELL", 0), - SHULKER_SPAWN_EGG("MONSTER_EGG", 0), - SIGN("SIGN", 0), - SILVERFISH_SPAWN_EGG("MONSTER_EGG", 0), - SKELETON_HORSE_SPAWN_EGG("MONSTER_EGG", 0), - SKELETON_SKULL("SKULL", 0), - SKELETON_SPAWN_EGG("MONSTER_EGG", 0), - SKELETON_WALL_SKULL("SKULL", 0), - SLIME_BALL("SLIME_BALL", 0), - SLIME_BLOCK("SLIME_BLOCK", 0), - SLIME_SPAWN_EGG("MONSTER_EGG", 0), - SMOOTH_QUARTZ("STONE", 0), - SMOOTH_RED_SANDSTONE("RED_SANDSTONE", 2), - SMOOTH_SANDSTONE("SANDSTONE", 2), - SMOOTH_STONE("STEP", 0), - SNOW("SNOW", 0), - SNOWBALL("SNOW_BALL", 0), - SNOW_BLOCK("SNOW_BLOCK", 0), - SOUL_SAND("SOUL_SAND", 0), - SPAWNER("MOB_SPAWNER", 0), - SPECTRAL_ARROW("SPECTRAL_ARROW", 0), - SPIDER_EYE("SPIDER_EYE", 0), - SPIDER_SPAWN_EGG("MONSTER_EGG", 0), - SPLASH_POTION("SPLASH_POTION", 0), - SPONGE("SPONGE", 0), - SPRUCE_BOAT("BOAT_SPRUCE", 0), - SPRUCE_BUTTON("WOOD_BUTTON", 0), - SPRUCE_DOOR("SPRUCE_DOOR", 0), - SPRUCE_FENCE("SPRUCE_FENCE", 0), - SPRUCE_FENCE_GATE("SPRUCE_FENCE_GATE", 0), - SPRUCE_LEAVES("LEAVES", 1), - SPRUCE_LOG("LOG", 1), - SPRUCE_PLANKS("WOOD", 1), - SPRUCE_PRESSURE_PLATE("WOOD_PLATE", 0), - SPRUCE_SAPLING("SAPLING", 1), - SPRUCE_SLAB("WOOD_STEP", 1), - SPRUCE_STAIRS("SPRUCE_WOOD_STAIRS", 0), - SPRUCE_TRAPDOOR("TRAP_DOOR", 0), - SPRUCE_WOOD("LOG", 1), - SQUID_SPAWN_EGG("MONSTER_EGG", 0), - STICK("STICK", 0), - STICKY_PISTON("PISTON_STICKY_BASE", 0), - STONE("STONE", 0), - STONE_AXE("STONE_AXE", 0), - STONE_BRICKS("SMOOTH_BRICK", 0), - STONE_BRICK_SLAB("STEP", 5), - STONE_BRICK_STAIRS("SMOOTH_STAIRS", 0), - STONE_BUTTON("STONE_BUTTON", 0), - STONE_HOE("STONE_HOE", 0), - STONE_PICKAXE("STONE_PICKAXE", 0), - STONE_PRESSURE_PLATE("STONE_PLATE", 0), - STONE_SHOVEL("STONE_SPADE", 0), - STONE_SLAB("STEP", 0), - STONE_SWORD("STONE_SWORD", 0), - STRAY_SPAWN_EGG("MONSTER_EGG", 0), - STRING("STRING", 0), - STRIPPED_ACACIA_LOG("STONE", 0), - STRIPPED_ACACIA_WOOD("STONE", 0), - STRIPPED_BIRCH_LOG("STONE", 0), - STRIPPED_BIRCH_WOOD("STONE", 0), - STRIPPED_DARK_OAK_LOG("STONE", 0), - STRIPPED_DARK_OAK_WOOD("STONE", 0), - STRIPPED_JUNGLE_LOG("STONE", 0), - STRIPPED_JUNGLE_WOOD("STONE", 0), - STRIPPED_OAK_LOG("STONE", 0), - STRIPPED_OAK_WOOD("STONE", 0), - STRIPPED_SPRUCE_LOG("STONE", 0), - STRIPPED_SPRUCE_WOOD("STONE", 0), - STRUCTURE_BLOCK("STRUCTURE_BLOCK", 0), - STRUCTURE_VOID("STRUCTURE_VOID", 0), - SUGAR("SUGAR", 0), - SUGAR_CANE("SUGAR_CANE", 0), - SUNFLOWER("DOUBLE_PLANT", 0), - TALL_GRASS("DOUBLE_PLANT", 2), - TALL_SEAGRASS("STONE", 0), - TERRACOTTA("HARD_CLAY", 0), - TIPPED_ARROW("TIPPED_ARROW", 0), - TNT("TNT", 0), - TNT_MINECART("EXPLOSIVE_MINECART", 0), - TORCH("TORCH", 0), - TOTEM_OF_UNDYING("TOTEM", 0), - TRAPPED_CHEST("TRAPPED_CHEST", 0), - TRIDENT("STONE", 0), - TRIPWIRE("TRIPWIRE", 0), - TRIPWIRE_HOOK("TRIPWIRE_HOOK", 0), - TROPICAL_FISH("RAW_FISH", 0), - TROPICAL_FISH_BUCKET("BUCKET", 0), - TROPICAL_FISH_SPAWN_EGG("MONSTER_EGG", 0), - TUBE_CORAL("STONE", 0), - TUBE_CORAL_BLOCK("STONE", 0), - TUBE_CORAL_FAN("STONE", 0), - TURTLE_EGG("MONSTER_EGG", 0), - TURTLE_HELMET("STONE", 0), - TURTLE_SPAWN_EGG("MONSTER_EGG", 0), - VEX_SPAWN_EGG("MONSTER_EGG", 0), - VILLAGER_SPAWN_EGG("MONSTER_EGG", 0), - VINDICATOR_SPAWN_EGG("MONSTER_EGG", 0), - VINE("VINE", 0), - VOID_AIR("AIR", 0), - WALL_SIGN("WALL_SIGN", 0), - WALL_TORCH("TORCH", 1), - WATER("WATER", 0), - WATER_BUCKET("WATER_BUCKET", 0), - WET_SPONGE("SPONGE", 1), - WHEAT("WHEAT", 0), - WHEAT_SEEDS("SEEDS", 0), - WHITE_BANNER("BANNER", 15), - WHITE_BED("BED", 0), - WHITE_CARPET("CARPET", 0), - WHITE_CONCRETE("CONCRETE", 0), - WHITE_CONCRETE_POWDER("CONCRETE_POWDER", 0), - WHITE_GLAZED_TERRACOTTA("WHITE_GLAZED_TERRACOTTA", 0), - WHITE_SHULKER_BOX("WHITE_SHULKER_BOX", 0), - WHITE_STAINED_GLASS("STAINED_GLASS", 0), - WHITE_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 0), - WHITE_TERRACOTTA("TERRACOTTA", 0), - WHITE_TULIP("RED_ROSE", 6), - WHITE_WALL_BANNER("WALL_BANNER", 0), - WHITE_WOOL("WOOL", 0), - WITCH_SPAWN_EGG("MONSTER_EGG", 0), - WITHER_SKELETON_SKULL("SKULL", 0), - WITHER_SKELETON_SPAWN_EGG("MONSTER_EGG", 0), - WITHER_SKELETON_WALL_SKULL("SKULL", 0), - WOLF_SPAWN_EGG("MONSTER_EGG", 0), - WOODEN_AXE("WOOD_AXE", 0), - WOODEN_HOE("WOOD_HOE", 0), - WOODEN_PICKAXE("WOOD_PICKAXE", 0), - WOODEN_SHOVEL("WOOD_SPADE", 0), - WOODEN_SWORD("WOOD_SWORD", 0), - WRITABLE_BOOK("BOOK_AND_QUILL", 0), - WRITTEN_BOOK("WRITTEN_BOOK", 0), - YELLOW_BANNER("BANNER", 11), - YELLOW_BED("BED", 4), - YELLOW_CARPET("CARPET", 4), - YELLOW_CONCRETE("CONCRETE", 4), - YELLOW_CONCRETE_POWDER("CONCRETE_POWDER", 4), - YELLOW_GLAZED_TERRACOTTA("YELLOW_GLAZED_TERRACOTTA", 0), - YELLOW_SHULKER_BOX("YELLOW_SHULKER_BOX", 0), - YELLOW_STAINED_GLASS("STAINED_GLASS", 4), - YELLOW_STAINED_GLASS_PANE("STAINED_GLASS_PANE", 4), - YELLOW_TERRACOTTA("STAINED_CLAY", 4), - YELLOW_WALL_BANNER("WALL_BANNER", 0), - YELLOW_WOOL("WOOL", 4), - ZOMBIE_HEAD("SKULL", 0), - ZOMBIE_HORSE_SPAWN_EGG("MONSTER_EGG", 0), - ZOMBIE_PIGMAN_SPAWN_EGG("MONSTER_EGG", 0), - ZOMBIE_SPAWN_EGG("MONSTER_EGG", 0), - ZOMBIE_VILLAGER_SPAWN_EGG("MONSTER_EGG", 0), - ZOMBIE_WALL_HEAD("SKULL", 0), - ; - - static int newV = -1; - private static HashMap cachedSearch = new HashMap<>(); - String m; - int data; - - MultiversionMaterials(String m, int data) { - this.m = m; - this.data = data; - } - - public static boolean isNewVersion() { - if (newV == 0) return false; - if (newV == 1) return true; - - Material mat = Material.matchMaterial("RED_WOOL"); - if (mat != null) { - newV = 1; - return true; - } - - newV = 0; - return false; - } - - public static MultiversionMaterials requestXMaterial(String name, byte data) { - if (cachedSearch.containsKey(name.toUpperCase() + "," + data)) { - return cachedSearch.get(name.toUpperCase() + "," + data); - } - for (MultiversionMaterials mat : MultiversionMaterials.values()) { - if (name.toUpperCase().equals(mat.m) && ((byte) mat.data) == data) { - cachedSearch.put(mat.m + "," + data, mat); - return mat; - } - } - return null; - } - - public static MultiversionMaterials fromString(String key) { - try { - return MultiversionMaterials.valueOf(key); - } catch (IllegalArgumentException e) { - String[] split = key.split(":"); - - return split.length == 1 ? requestXMaterial(key, (byte) 0) : requestXMaterial(split[0], (byte) Integer.parseInt(split[1])); - } - } - - public ItemStack parseItem() { - Material mat = parseMaterial(); - if (isNewVersion()) { - return new ItemStack(mat); - } - return new ItemStack(mat, 1, (byte) data); - } - - public boolean isSameMaterial(ItemStack comp) { - if (isNewVersion()) { - return comp.getType() == this.parseMaterial(); - } - if (comp.getType() == this.parseMaterial() && - (int) comp.getData().getData() == this.data) { - return true; - } - MultiversionMaterials xmat = fromMaterial(comp.getType()); - if (isDamageable(xmat)) { - return this.parseMaterial() == comp.getType(); - } - return false; - } - - public MultiversionMaterials fromMaterial(Material mat) { - try { - return MultiversionMaterials.valueOf(mat.toString()); - } catch (IllegalArgumentException e) { - for (MultiversionMaterials xmat : MultiversionMaterials.values()) { - if (xmat.m.equals(mat.toString())) { - return xmat; - } - } - } - return null; - } - - public boolean isDamageable(MultiversionMaterials type) { - String[] split = type.toString().split("_"); - - switch (split[split.length - 1]) { - case "HELMET": - case "CHESTPLATE": - case "LEGGINGS": - case "BOOTS": - case "SWORD": - case "AXE": - case "PICKAXE": - case "SHOVEL": - case "HOE": - case "ELYTRA": - case "TURTLE_HELMET": - case "TRIDENT": - case "HORSE_ARMOR": - case "SHEARS": - return true; - default: - return false; - } - } - - public Material parseMaterial() { - Material mat = Material.matchMaterial(this.toString()); - return mat != null ? mat : Material.matchMaterial(m); - } - -} \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java b/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java index 2c81af70..7ffe0846 100644 --- a/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java +++ b/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.util.Particles; import com.massivecraft.factions.SaberFactions; +import com.massivecraft.factions.util.XMaterial; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.Location; @@ -451,7 +452,7 @@ public enum ParticleEffect { */ private static boolean isWater(Location location) { Material material = location.getBlock().getType(); - return material == Material.WATER || material == SaberFactions.plugin.STATIONARY_WATER; + return material == Material.WATER || material == XMaterial.WATER.parseMaterial(); } /** diff --git a/src/main/java/com/massivecraft/factions/util/XMaterial.java b/src/main/java/com/massivecraft/factions/util/XMaterial.java new file mode 100644 index 00000000..4d6f8fb5 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/util/XMaterial.java @@ -0,0 +1,1615 @@ +package com.massivecraft.factions.util; + +/* + * The MIT License (MIT) + * + * Original work Copyright (c) 2018 Hex_27 + * v2.0 Copyright (c) 2019 Crypto Morin + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +import java.util.*; +import java.util.regex.Pattern; + +/* + * References + * + * * * GitHub: https://github.com/CryptoMorin/XMaterial/blob/master/XMaterial.java + * * Thread: https://www.spigotmc.org/threads/378136/ + * https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening + * https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html + * http://docs.codelanx.com/Bukkit/1.8/org/bukkit/Material.html + * https://www.spigotmc.org/threads/1-8-to-1-13-itemstack-material-version-support.329630/ + * https://minecraft-ids.grahamedgecombe.com/ + * v1: https://pastebin.com/Fe65HZnN + * v2: 6/15/2019 + */ + +/** + * XMaterial v2.2 - Data Values/Pre-flattening + * Supports 1.8-1.14 + * 1.13 and above as priority. + */ +public enum XMaterial { + ACACIA_BOAT(0, "BOAT_ACACIA"), + ACACIA_BUTTON(0, "WOOD_BUTTON"), + ACACIA_DOOR(0, "ACACIA_DOOR_ITEM"), + ACACIA_FENCE(0, ""), + ACACIA_FENCE_GATE(0, ""), + ACACIA_LEAVES(0, "LEAVES_2"), + ACACIA_LOG(0, "LOG_2"), + ACACIA_PLANKS(4, "WOOD"), + ACACIA_PRESSURE_PLATE(0, "WOOD_PLATE"), + ACACIA_SAPLING(4, "SAPLING"), + ACACIA_SIGN(0, "SIGN"), + ACACIA_SLAB(4, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), + ACACIA_STAIRS(0, ""), + ACACIA_TRAPDOOR(0, "TRAP_DOOR"), + ACACIA_WALL_SIGN(0, "SIGN_POST", "WALL_SIGN"), + ACACIA_WOOD(0, "LOG_2"), + ACTIVATOR_RAIL(0, ""), + AIR(0, ""), + ALLIUM(2, "RED_ROSE"), + ANDESITE(5, "STONEZ"), + ANDESITE_SLAB(0, ""), + ANDESITE_STAIRS(0, ""), + ANDESITE_WALL(0, ""), + ANVIL(0, ""), + APPLE(0, ""), + ARMOR_STAND(0, ""), + ARROW(0, ""), + ATTACHED_MELON_STEM(7, "MELON_STEM"), + ATTACHED_PUMPKIN_STEM(7, "PUMPKIN_STEM"), + AZURE_BLUET(3, "RED_ROSE"), + BAKED_POTATO(0, ""), + BAMBOO(0, "1.14", "SUGAR_CANE"), + BAMBOO_SAPLING(0, "1.14"), + BARREL(0, "1.14", "CHEST"), + BARRIER(0, ""), + BAT_SPAWN_EGG(65, "MONSTER_EGG"), + BEACON(0, ""), + BEDROCK(0, ""), + BEEF(0, "RAW_BEEF"), + BEETROOT(0, "BEETROOT_BLOCK"), + BEETROOTS(0, "BEETROOT"), + BEETROOT_SEEDS(0, ""), + BEETROOT_SOUP(0, ""), + BELL(0, "1.14"), + BIRCH_BOAT(0, "BOAT_BIRCH"), + BIRCH_BUTTON(0, "WOOD_BUTTON"), + BIRCH_DOOR(0, "BIRCH_DOOR_ITEM"), + BIRCH_FENCE(0, ""), + BIRCH_FENCE_GATE(0, ""), + BIRCH_LEAVES(2, "LEAVES"), + BIRCH_LOG(2, "LOG"), + BIRCH_PLANKS(2, "WOOD"), + BIRCH_PRESSURE_PLATE(0, "WOOD_PLATE"), + BIRCH_SAPLING(2, "SAPLING"), + BIRCH_SIGN(0, "SIGN"), + BIRCH_SLAB(2, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), + BIRCH_STAIRS(0, "BIRCH_WOOD_STAIRS"), + BIRCH_TRAPDOOR(0, "TRAP_DOOR"), + BIRCH_WALL_SIGN(0, "SIGN_POST", "WALL_SIGN"), + BIRCH_WOOD(2, "LOG"), + BLACK_BANNER(0, "BANNER", "STANDING_BANNER"), + BLACK_BED(15, "BED", "BED_BLOCK"), + BLACK_CARPET(15, "CARPET"), + BLACK_CONCRETE(15, "CONCRETE"), + BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"), + BLACK_DYE(0, "1.14", "INK_SACK"), + BLACK_GLAZED_TERRACOTTA(15, "1.12", "HARD_CLAY", "STAINED_CLAY", "BLACK_TERRACOTTA"), + BLACK_SHULKER_BOX(0, ""), + BLACK_STAINED_GLASS(15, "STAINED_GLASS"), + BLACK_STAINED_GLASS_PANE(15, "STAINED_GLASS_PANE"), + BLACK_TERRACOTTA(15, "HARD_CLAY", "STAINED_CLAY"), + BLACK_WALL_BANNER(0, "WALL_BANNER"), + BLACK_WOOL(15, "WOOL"), + BLAST_FURNACE(0, "1.14", "FURNACE"), + BLAZE_POWDER(0, ""), + BLAZE_ROD(0, ""), + BLAZE_SPAWN_EGG(61, "MONSTER_EGG"), + BLUE_BANNER(11, "BANNER", "STANDING_BANNER"), + BLUE_BED(4, "BED", "BED_BLOCK"), + BLUE_CARPET(11, "CARPET"), + BLUE_CONCRETE(11, "CONCRETE"), + BLUE_CONCRETE_POWDER(11, "CONCRETE_POWDER"), + BLUE_DYE(4, "INK_SACK", "LAPIS_LAZULI"), + BLUE_GLAZED_TERRACOTTA(11, "1.12", "HARD_CLAY", "STAINED_CLAY", "BLUE_TERRACOTTA"), + BLUE_ICE(0, "1.13", "PACKED_ICE"), + BLUE_ORCHID(1, "RED_ROSE"), + BLUE_SHULKER_BOX(0, ""), + BLUE_STAINED_GLASS(11, "STAINED_GLASS"), + BLUE_STAINED_GLASS_PANE(11, "THIN_GLASS", "STAINED_GLASS_PANE"), + BLUE_TERRACOTTA(11, "STAINED_CLAY"), + BLUE_WALL_BANNER(11, "WALL_BANNER"), + BLUE_WOOL(11, "WOOL"), + BONE(0, ""), + BONE_BLOCK(0, ""), + BONE_MEAL(15, "INK_SACK"), + BOOK(0, ""), + BOOKSHELF(0, ""), + BOW(0, ""), + BOWL(0, ""), + BRAIN_CORAL(0, "1.13"), + BRAIN_CORAL_BLOCK(0, "1.13"), + BRAIN_CORAL_FAN(0, "1.13"), + BRAIN_CORAL_WALL_FAN(0, ""), + BREAD(0, ""), + BREWING_STAND(0, "BREWING_STAND_ITEM"), + BRICK(0, "CLAY_BRICK"), + BRICKS(0, "BRICK"), + BRICK_SLAB(4, "STEP"), + BRICK_STAIRS(0, ""), + BRICK_WALL(0, ""), + BROWN_BANNER(3, "BANNER", "STANDING_BANNER"), + BROWN_BED(12, "BED", "BED_BLOCK"), + BROWN_DYE(3, "INK_SACK", "COCOA", "COCOA_BEANS"), + BROWN_CARPET(12, "CARPET"), + BROWN_CONCRETE(12, "CONCRETE"), + BROWN_CONCRETE_POWDER(12, "CONCRETE_POWDER"), + BROWN_GLAZED_TERRACOTTA(12, "1.12", "HARD_CLAY", "STAINED_CLAY", "BROWN_TERRACOTTA"), + BROWN_MUSHROOM(0, ""), + BROWN_MUSHROOM_BLOCK(0, "BROWN_MUSHROOM", "HUGE_MUSHROOM_1"), + BROWN_SHULKER_BOX(0, ""), + BROWN_STAINED_GLASS(12, "STAINED_GLASS"), + BROWN_STAINED_GLASS_PANE(12, "THIN_GLASS", "STAINED_GLASS_PANE"), + BROWN_TERRACOTTA(12, "STAINED_CLAY"), + BROWN_WALL_BANNER(3, "WALL_BANNER"), + BROWN_WOOL(12, "WOOL"), + BUBBLE_COLUMN(0, "1.13"), + BUBBLE_CORAL(0, "1.13"), + BUBBLE_CORAL_BLOCK(0, "1.13"), + BUBBLE_CORAL_FAN(0, "1.13"), + BUBBLE_CORAL_WALL_FAN(0, ""), + BUCKET(0, ""), + CACTUS(0, ""), + CAKE(0, "CAKE_BLOCK"), + CAMPFIRE(0, "1.14"), + CARROT(0, "CARROT_ITEM"), + CARROTS(0, "CARROT"), + CARROT_ON_A_STICK(0, "CARROT_STICK"), + CARTOGRAPHY_TABLE(0, "1.14", "CRAFTING_TABLE"), + CARVED_PUMPKIN(1, "PUMPKIN"), + CAT_SPAWN_EGG(0, ""), + CAULDRON(0, "CAULDRON_ITEM"), + CAVE_AIR(0, "AIR"), + CAVE_SPIDER_SPAWN_EGG(59, "MONSTER_EGG"), + CHAINMAIL_BOOTS(0, ""), + CHAINMAIL_CHESTPLATE(0, ""), + CHAINMAIL_HELMET(0, ""), + CHAINMAIL_LEGGINGS(0, ""), + CHAIN_COMMAND_BLOCK(0, "COMMAND", "COMMAND_CHAIN"), + CHARCOAL(1, "COAL"), + CHEST(0, "LOCKED_CHEST"), + CHEST_MINECART(0, "STORAGE_MINECART"), + CHICKEN(0, "RAW_CHICKEN"), + CHICKEN_SPAWN_EGG(93, "MONSTER_EGG"), + CHIPPED_ANVIL(1, "ANVIL"), + CHISELED_QUARTZ_BLOCK(1, "QUARTZ_BLOCK"), + CHISELED_RED_SANDSTONE(1, "RED_SANDSTONE"), + CHISELED_SANDSTONE(1, "SANDSTONE"), + CHISELED_STONE_BRICKS(3, "SMOOTH_BRICK"), + CHORUS_FLOWER(0, ""), + CHORUS_FRUIT(0, ""), + CHORUS_PLANT(0, ""), + CLAY(0, ""), + CLAY_BALL(0, ""), + CLOCK(0, "WATCH"), + COAL(0, ""), + COAL_BLOCK(0, ""), + COAL_ORE(0, ""), + COARSE_DIRT(1, "DIRT"), + COBBLESTONE(0, ""), + COBBLESTONE_SLAB(3, "STEP"), + COBBLESTONE_STAIRS(0, ""), + COBBLESTONE_WALL(0, "COBBLE_WALL"), + COBWEB(0, "WEB"), + COCOA_BEANS(3, "INK_SACK", "COCOA"), + COD(0, "RAW_FISH"), + COD_BUCKET(0, "1.13", "BUCKET", "WATER_BUCKET"), + COD_SPAWN_EGG(0, "1.13", "MONSTER_EGG"), + COMMAND_BLOCK(0, "COMMAND"), + COMMAND_BLOCK_MINECART(0, "COMMAND_MINECART"), + COMPARATOR(0, "REDSTONE_COMPARATOR", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR_OFF"), + COMPASS(0, ""), + COMPOSTER(0, "1.14", "CAULDRON"), + CONDUIT(0, "1.13"), + COOKED_BEEF(0, ""), + COOKED_CHICKEN(0, ""), + COOKED_COD(0, "COOKED_FISH"), + COOKED_MUTTON(0, ""), + COOKED_PORKCHOP(0, "PORK", "GRILLED_PORK"), + COOKED_RABBIT(0, ""), + COOKED_SALMON(1, "COOKED_FISH"), + COOKIE(0, ""), + CORNFLOWER(4, "1.14", "BLUE_DYE"), + COW_SPAWN_EGG(92, "MONSTER_EGG"), + CRACKED_STONE_BRICKS(2, "SMOOTH_BRICK"), + CRAFTING_TABLE(0, "WORKBENCH"), + CREEPER_BANNER_PATTERN(0, ""), + CREEPER_HEAD(4, "SKULL", "SKULL_ITEM"), + CREEPER_SPAWN_EGG(50, "MONSTER_EGG"), + CREEPER_WALL_HEAD(4, "SKULL", "SKULL_ITEM"), + CROSSBOW(0, ""), + CUT_RED_SANDSTONE(0, "1.13"), + CUT_RED_SANDSTONE_SLAB(0, "STONE_SLAB2"), + CUT_SANDSTONE(0, "1.13"), + CUT_SANDSTONE_SLAB(0, "STEP"), + CYAN_BANNER(6, "BANNER", "STANDING_BANNER"), + CYAN_BED(9, "BED", "BED_BLOCK"), + CYAN_CARPET(9, "CARPET"), + CYAN_CONCRETE(9, "CONCRETE"), + CYAN_CONCRETE_POWDER(9, "CONCRETE_POWDER"), + CYAN_DYE(6, "INK_SACK"), + CYAN_GLAZED_TERRACOTTA(9, "1.12", "HARD_CLAY", "STAINED_CLAY", "CYAN_TERRACOTTA"), + CYAN_SHULKER_BOX(0, ""), + CYAN_STAINED_GLASS(9, "STAINED_GLASS"), + CYAN_STAINED_GLASS_PANE(9, "STAINED_GLASS_PANE"), + CYAN_TERRACOTTA(9, "HARD_CLAY", "STAINED_CLAY"), + CYAN_WALL_BANNER(6, "WALL_BANNER"), + CYAN_WOOL(9, "WOOL"), + DAMAGED_ANVIL(2, "ANVIL"), + DANDELION(0, "YELLOW_FLOWER"), + DARK_OAK_BOAT(0, "BOAT_DARK_OAK"), + DARK_OAK_BUTTON(0, "WOOD_BUTTON"), + DARK_OAK_DOOR(0, "DARK_OAK_DOOR_ITEM"), + DARK_OAK_FENCE(0, ""), + DARK_OAK_FENCE_GATE(0, ""), + DARK_OAK_LEAVES(1, "LEAVES", "LEAVES_2"), + DARK_OAK_LOG(1, "LOG", "LOG_2"), + DARK_OAK_PLANKS(5, "WOOD"), + DARK_OAK_PRESSURE_PLATE(0, "WOOD_PLATE"), + DARK_OAK_SAPLING(5, "SAPLING"), + DARK_OAK_SIGN(0, "SIGN"), + DARK_OAK_SLAB(0, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), + DARK_OAK_STAIRS(0, ""), + DARK_OAK_TRAPDOOR(0, "TRAP_DOOR"), + DARK_OAK_WALL_SIGN(0, "SIGN_POST", "WALL_SIGN"), + DARK_OAK_WOOD(1, "LOG", "LOG_2"), + DARK_PRISMARINE(1, "PRISMARINE"), + DARK_PRISMARINE_SLAB(0, "1.13"), + DARK_PRISMARINE_STAIRS(0, "1.13"), + DAYLIGHT_DETECTOR(0, "DAYLIGHT_DETECTOR_INVERTED"), + DEAD_BRAIN_CORAL(0, ""), + DEAD_BRAIN_CORAL_BLOCK(0, "1.13"), + DEAD_BRAIN_CORAL_FAN(0, ""), + DEAD_BRAIN_CORAL_WALL_FAN(0, ""), + DEAD_BUBBLE_CORAL(0, ""), + DEAD_BUBBLE_CORAL_BLOCK(0, "1.13"), + DEAD_BUBBLE_CORAL_FAN(0, ""), + DEAD_BUBBLE_CORAL_WALL_FAN(0, ""), + DEAD_BUSH(0, ""), + DEAD_FIRE_CORAL(0, ""), + DEAD_FIRE_CORAL_BLOCK(0, "1.13"), + DEAD_FIRE_CORAL_FAN(0, ""), + DEAD_FIRE_CORAL_WALL_FAN(0, ""), + DEAD_HORN_CORAL(0, ""), + DEAD_HORN_CORAL_BLOCK(0, "1.13"), + DEAD_HORN_CORAL_FAN(0, ""), + DEAD_HORN_CORAL_WALL_FAN(0, ""), + DEAD_TUBE_CORAL(0, ""), + DEAD_TUBE_CORAL_BLOCK(0, "1.13"), + DEAD_TUBE_CORAL_FAN(0, ""), + DEAD_TUBE_CORAL_WALL_FAN(0, ""), + DEBUG_STICK(0, "1.13", "STICK"), + DETECTOR_RAIL(0, ""), + DIAMOND(0, ""), + DIAMOND_AXE(0, ""), + DIAMOND_BLOCK(0, ""), + DIAMOND_BOOTS(0, ""), + DIAMOND_CHESTPLATE(0, ""), + DIAMOND_HELMET(0, ""), + DIAMOND_HOE(0, ""), + DIAMOND_HORSE_ARMOR(0, "DIAMOND_BARDING"), + DIAMOND_LEGGINGS(0, ""), + DIAMOND_ORE(0, ""), + DIAMOND_PICKAXE(0, ""), + DIAMOND_SHOVEL(0, "DIAMOND_SPADE"), + DIAMOND_SWORD(0, ""), + DIORITE(3, "1.13"), + DIORITE_SLAB(0, ""), + DIORITE_STAIRS(0, ""), + DIORITE_WALL(0, ""), + DIRT(0, ""), + DISPENSER(0, ""), + DOLPHIN_SPAWN_EGG(0, "1.13", "MONSTER_EGG"), + DONKEY_SPAWN_EGG(32, "MONSTER_EGG"), + DRAGON_BREATH(0, "DRAGONS_BREATH"), + DRAGON_EGG(0, ""), + DRAGON_HEAD(5, "SKULL", "SKULL_ITEM"), + DRAGON_WALL_HEAD(5, "SKULL", "SKULL_ITEM"), + DRIED_KELP(0, "1.13"), + DRIED_KELP_BLOCK(0, "1.13"), + DROPPER(0, ""), + DROWNED_SPAWN_EGG(0, "1.13", "MONSTER_EGG"), + EGG(0, ""), + ELDER_GUARDIAN_SPAWN_EGG(4, "MONSTER_EGG"), + ELYTRA(0, ""), + EMERALD(0, ""), + EMERALD_BLOCK(0, ""), + EMERALD_ORE(0, ""), + ENCHANTED_BOOK(0, ""), + ENCHANTED_GOLDEN_APPLE(1, "GOLDEN_APPLE"), + ENCHANTING_TABLE(0, "ENCHANTMENT_TABLE"), + ENDERMAN_SPAWN_EGG(58, "MONSTER_EGG"), + ENDERMITE_SPAWN_EGG(67, "MONSTER_EGG"), + ENDER_CHEST(0, ""), + ENDER_EYE(0, "EYE_OF_ENDER"), + ENDER_PEARL(0, ""), + END_CRYSTAL(0, ""), + END_GATEWAY(0, ""), + END_PORTAL(0, "ENDER_PORTAL"), + END_PORTAL_FRAME(0, "ENDER_PORTAL_FRAME"), + END_ROD(0, ""), + END_STONE(0, "ENDER_STONE"), + END_STONE_BRICKS(0, "END_BRICKS"), + END_STONE_BRICK_SLAB(4, "STEP"), + END_STONE_BRICK_STAIRS(0, "SMOOTH_STAIRS"), + END_STONE_BRICK_WALL(0, ""), + EVOKER_SPAWN_EGG(34, "MONSTER_EGG"), + EXPERIENCE_BOTTLE(0, "EXP_BOTTLE"), + FARMLAND(0, "SOIL"), + FEATHER(0, ""), + FERMENTED_SPIDER_EYE(0, ""), + FERN(2, "LONG_GRASS"), + FILLED_MAP(0, "MAP"), + FIRE(0, ""), + FIREWORK_ROCKET(0, "FIREWORK"), + FIREWORK_STAR(0, "FIREWORK_CHARGE"), + FIRE_CHARGE(0, "FIREBALL"), + FIRE_CORAL(0, "1.13"), + FIRE_CORAL_BLOCK(0, "1.13"), + FIRE_CORAL_FAN(0, "1.13"), + FIRE_CORAL_WALL_FAN(0, ""), + FISHING_ROD(0, ""), + FLETCHING_TABLE(0, "1.14", "CRAFTING_TABLE"), + FLINT(0, ""), + FLINT_AND_STEEL(0, ""), + FLOWER_BANNER_PATTERN(0, ""), + FLOWER_POT(0, "FLOWER_POT_ITEM"), + FOX_SPAWN_EGG(0, "1.14"), + FROSTED_ICE(0, ""), + FURNACE(0, "BURNING_FURNACE"), + FURNACE_MINECART(0, "POWERED_MINECART"), + GHAST_SPAWN_EGG(56, "MONSTER_EGG"), + GHAST_TEAR(0, ""), + GLASS(0, ""), + GLASS_BOTTLE(0, ""), + GLASS_PANE(0, "THIN_GLASS"), + GLISTERING_MELON_SLICE(0, "SPECKLED_MELON"), + GLOBE_BANNER_PATTERN(0, ""), + GLOWSTONE(0, ""), + GLOWSTONE_DUST(0, ""), + GOLDEN_APPLE(0, ""), + GOLDEN_AXE(0, "GOLD_AXE"), + GOLDEN_BOOTS(0, "GOLD_BOOTS"), + GOLDEN_CARROT(0, ""), + GOLDEN_CHESTPLATE(0, "GOLD_CHESTPLATE"), + GOLDEN_HELMET(0, "GOLD_HELMET"), + GOLDEN_HOE(0, "GOLD_HOE"), + GOLDEN_HORSE_ARMOR(0, "GOLD_BARDING"), + GOLDEN_LEGGINGS(0, "GOLD_LEGGINGS"), + GOLDEN_PICKAXE(0, "GOLD_PICKAXE"), + GOLDEN_SHOVEL(0, "GOLD_SPADE"), + GOLDEN_SWORD(0, "GOLD_SWORD"), + GOLD_BLOCK(0, ""), + GOLD_INGOT(0, ""), + GOLD_NUGGET(0, ""), + GOLD_ORE(0, ""), + GRANITE(1, "1.13"), + GRANITE_SLAB(0, ""), + GRANITE_STAIRS(0, ""), + GRANITE_WALL(0, ""), + GRASS(0, ""), + GRASS_BLOCK(0, "GRASS"), + GRASS_PATH(0, ""), + GRAVEL(0, ""), + GRAY_BANNER(8, "BANNER", "STANDING_BANNER"), + GRAY_BED(7, "BED", "BED_BLOCK"), + GRAY_CARPET(7, "CARPET"), + GRAY_CONCRETE(7, "CONCRETE"), + GRAY_CONCRETE_POWDER(7, "CONCRETE_POWDER"), + GRAY_DYE(8, "INK_SACK"), + GRAY_GLAZED_TERRACOTTA(7, "1.12", "HARD_CLAY", "STAINED_CLAY", "GRAY_TERRACOTTA"), + GRAY_SHULKER_BOX(0, ""), + GRAY_STAINED_GLASS(8, "STAINED_GLASS"), + GRAY_STAINED_GLASS_PANE(7, "THIN_GLASS", "STAINED_GLASS_PANE"), + GRAY_TERRACOTTA(7, "HARD_CLAY", "STAINED_CLAY"), + GRAY_WALL_BANNER(8, "WALL_BANNER"), + GRAY_WOOL(8, "WOOL"), + GREEN_BANNER(2, "BANNER", "STANDING_BANNER"), + GREEN_BED(13, "BED", "BED_BLOCK"), + GREEN_CARPET(13, "CARPET"), + GREEN_CONCRETE(13, "CONCRETE"), + GREEN_CONCRETE_POWDER(13, "CONCRETE_POWDER"), + GREEN_DYE(2, "INK_SACK", "CACTUS_GREEN"), + GREEN_GLAZED_TERRACOTTA(13, "1.12", "HARD_CLAY", "STAINED_CLAY", "GREEN_TERRACOTTA"), + GREEN_SHULKER_BOX(0, ""), + GREEN_STAINED_GLASS(13, "STAINED_GLASS"), + GREEN_STAINED_GLASS_PANE(13, "THIN_GLASS", "STAINED_GLASS_PANE"), + GREEN_TERRACOTTA(13, "HARD_CLAY", "STAINED_CLAY"), + GREEN_WALL_BANNER(2, "WALL_BANNER"), + GREEN_WOOL(13, "WOOL"), + GRINDSTONE(0, "1.14", "ANVIL"), + GUARDIAN_SPAWN_EGG(68, "MONSTER_EGG"), + GUNPOWDER(0, "SULPHUR"), + HAY_BLOCK(0, ""), + HEART_OF_THE_SEA(0, "1.13"), + HEAVY_WEIGHTED_PRESSURE_PLATE(0, "IRON_PLATE"), + HOPPER(0, ""), + HOPPER_MINECART(0, ""), + HORN_CORAL(0, "1.13"), + HORN_CORAL_BLOCK(0, "1.13"), + HORN_CORAL_FAN(0, "1.13"), + HORN_CORAL_WALL_FAN(0, ""), + HORSE_SPAWN_EGG(100, "MONSTER_EGG"), + HUSK_SPAWN_EGG(23, "MONSTER_EGG"), + ICE(0, ""), + INFESTED_CHISELED_STONE_BRICKS(5, "MONSTER_EGGS", "SMOOTH_BRICK"), + INFESTED_COBBLESTONE(1, "MONSTER_EGGS"), + INFESTED_CRACKED_STONE_BRICKS(4, "MONSTER_EGGS", "SMOOTH_BRICK"), + INFESTED_MOSSY_STONE_BRICKS(3, "MONSTER_EGGS"), + INFESTED_STONE(0, "MONSTER_EGGS"), + INFESTED_STONE_BRICKS(2, "MONSTER_EGGS", "SMOOTH_BRICK"), + INK_SAC(0, "INK_SACK"), + IRON_AXE(0, ""), + IRON_BARS(0, "IRON_FENCE"), + IRON_BLOCK(0, ""), + IRON_BOOTS(0, ""), + IRON_CHESTPLATE(0, ""), + IRON_DOOR(0, "IRON_DOOR_BLOCK"), + IRON_HELMET(0, ""), + IRON_HOE(0, ""), + IRON_HORSE_ARMOR(0, "IRON_BARDING"), + IRON_INGOT(0, ""), + IRON_LEGGINGS(0, ""), + IRON_NUGGET(0, ""), + IRON_ORE(0, ""), + IRON_PICKAXE(0, ""), + IRON_SHOVEL(0, "IRON_SPADE"), + IRON_SWORD(0, ""), + IRON_TRAPDOOR(0, ""), + ITEM_FRAME(0, ""), + JACK_O_LANTERN(0, ""), + JIGSAW(0, "1.14", "COMMAND_BLOCK", "STRUCTURE_BLOCK"), + JUKEBOX(0, ""), + JUNGLE_BOAT(0, "BOAT_JUNGLE"), + JUNGLE_BUTTON(0, "WOOD_BUTTON"), + JUNGLE_DOOR(0, "JUNGLE_DOOR_ITEM"), + JUNGLE_FENCE(0, ""), + JUNGLE_FENCE_GATE(0, ""), + JUNGLE_LEAVES(3, "LEAVES"), + JUNGLE_LOG(3, "LOG"), + JUNGLE_PLANKS(3, "WOOD"), + JUNGLE_PRESSURE_PLATE(0, "WOOD_PLATE"), + JUNGLE_SAPLING(3, "SAPLING"), + JUNGLE_SIGN(0, "SIGN"), + JUNGLE_SLAB(3, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), + JUNGLE_STAIRS(0, "JUNGLE_WOOD_STAIRS"), + JUNGLE_TRAPDOOR(0, "TRAP_DOOR"), + JUNGLE_WALL_SIGN(0, "SIGN_POST", "WALL_SIGN"), + JUNGLE_WOOD(3, "LOG"), + KELP(0, "1.13"), + KELP_PLANT(0, "1.13"), + KNOWLEDGE_BOOK(0, ""), + LADDER(0, ""), + LANTERN(0, "1.14", "SEA_LANTERN"), + LAPIS_BLOCK(0, ""), + LAPIS_LAZULI(4, "INK_SACK"), + LAPIS_ORE(0, ""), + LARGE_FERN(3, "DOUBLE_PLANT"), + LAVA(0, "STATIONARY_LAVA"), + LAVA_BUCKET(0, ""), + LEAD(0, "LEASH"), + LEATHER(0, ""), + LEATHER_BOOTS(0, ""), + LEATHER_CHESTPLATE(0, ""), + LEATHER_HELMET(0, ""), + LEATHER_HORSE_ARMOR(0, "1.14", "IRON_HORSE_ARMOR"), + LEATHER_LEGGINGS(0, ""), + LECTERN(0, "1.14", "BOOKSHELF"), + LEVER(0, ""), + LIGHT_BLUE_BANNER(11, "BANNER", "STANDING_BANNER"), + LIGHT_BLUE_BED(3, "BED", "BED_BLOCK"), + LIGHT_BLUE_CARPET(3, "CARPET"), + LIGHT_BLUE_CONCRETE(3, "CONCRETE"), + LIGHT_BLUE_CONCRETE_POWDER(3, "CONCRETE_POWDER"), + LIGHT_BLUE_DYE(12, "INK_SACK"), + LIGHT_BLUE_GLAZED_TERRACOTTA(3, "1.12", "HARD_CLAY", "STAINED_CLAY", "LIGHT_BLUE_TERRACOTTA"), + LIGHT_BLUE_SHULKER_BOX(0, ""), + LIGHT_BLUE_STAINED_GLASS(11, "STAINED_GLASS"), + LIGHT_BLUE_STAINED_GLASS_PANE(3, "THIN_GLASS", "STAINED_GLASS_PANE"), + LIGHT_BLUE_TERRACOTTA(3, "STAINED_CLAY"), + LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "BANNER", "STANDING_BANNER"), + LIGHT_BLUE_WOOL(11, "WOOL"), + LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"), + LIGHT_GRAY_BED(7, "BED", "BED_BLOCK"), + LIGHT_GRAY_CARPET(8, "CARPET"), + LIGHT_GRAY_CONCRETE(8, "CONCRETE"), + LIGHT_GRAY_CONCRETE_POWDER(8, "CONCRETE_POWDER"), + LIGHT_GRAY_DYE(7, "INK_SACK"), + LIGHT_GRAY_GLAZED_TERRACOTTA(8, "1.12", "HARD_CLAY", "STAINED_CLAY", "LIGHT_GRAY_TERRACOTTA", "SILVER_GLAZED_TERRACOTTA/1.13"), + LIGHT_GRAY_SHULKER_BOX(0, "SILVER_SHULKER_BOX"), + LIGHT_GRAY_STAINED_GLASS(8, "STAINED_GLASS"), + LIGHT_GRAY_STAINED_GLASS_PANE(8, "THIN_GLASS", "STAINED_GLASS_PANE"), + LIGHT_GRAY_TERRACOTTA(8, "HARD_CLAY", "STAINED_CLAY"), + LIGHT_GRAY_WALL_BANNER(7, "WALL_BANNER"), + LIGHT_GRAY_WOOL(8, "WOOL"), + LIGHT_WEIGHTED_PRESSURE_PLATE(0, "GOLD_PLATE"), + LILAC(1, "DOUBLE_PLANT"), + LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE"), + LILY_PAD(0, "WATER_LILY"), + LIME_BANNER(10, "BANNER", "STANDING_BANNER"), + LIME_BED(5, "BED", "BED_BLOCK"), + LIME_CARPET(5, "CARPET"), + LIME_CONCRETE(5, "CONCRETE"), + LIME_CONCRETE_POWDER(5, "CONCRETE_POWDER"), + LIME_DYE(10, "INK_SACK"), + LIME_GLAZED_TERRACOTTA(5, "1.12", "HARD_CLAY", "STAINED_CLAY", "LIME_TERRACOTTA"), + LIME_SHULKER_BOX(0, ""), + LIME_STAINED_GLASS(5, "STAINED_GLASS"), + LIME_STAINED_GLASS_PANE(5, "STAINED_GLASS_PANE"), + LIME_TERRACOTTA(5, "HARD_CLAY", "STAINED_CLAY"), + LIME_WALL_BANNER(10, "WALL_BANNER"), + LIME_WOOL(5, "WOOL"), + LINGERING_POTION(0, ""), + LLAMA_SPAWN_EGG(103, "MONSTER_EGG"), + LOOM(0, "1.14"), + MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"), + MAGENTA_BED(2, "BED", "BED_BLOCK"), + MAGENTA_CARPET(2, "CARPET"), + MAGENTA_CONCRETE(2, "CONCRETE"), + MAGENTA_CONCRETE_POWDER(2, "CONCRETE_POWDER"), + MAGENTA_DYE(13, "INK_SACK"), + MAGENTA_GLAZED_TERRACOTTA(2, "1.12", "HARD_CLAY", "STAINED_CLAY", "MAGENTA_TERRACOTTA"), + MAGENTA_SHULKER_BOX(0, ""), + MAGENTA_STAINED_GLASS(2, "STAINED_GLASS"), + MAGENTA_STAINED_GLASS_PANE(2, "THIN_GLASS", "STAINED_GLASS_PANE"), + MAGENTA_TERRACOTTA(2, "HARD_CLAY", "STAINED_CLAY"), + MAGENTA_WALL_BANNER(13, "WALL_BANNER"), + MAGENTA_WOOL(2, "WOOL"), + MAGMA_BLOCK(0, "MAGMA"), + MAGMA_CREAM(0, ""), + MAGMA_CUBE_SPAWN_EGG(62, "MONSTER_EGG"), + MAP(0, "EMPTY_MAP"), + MELON(0, "MELON_BLOCK"), + MELON_SEEDS(0, ""), + MELON_SLICE(0, "MELON"), + MELON_STEM(0, ""), + MILK_BUCKET(0, ""), + MINECART(0, ""), + MOJANG_BANNER_PATTERN(0, ""), + MOOSHROOM_SPAWN_EGG(96, "MONSTER_EGG"), + MOSSY_COBBLESTONE(0, ""), + MOSSY_COBBLESTONE_SLAB(3, "STEP"), + MOSSY_COBBLESTONE_STAIRS(0, ""), + MOSSY_COBBLESTONE_WALL(1, "COBBLE_WALL", "COBBLESTONE_WALL"), + MOSSY_STONE_BRICKS(1, "SMOOTH_BRICK"), + MOSSY_STONE_BRICK_SLAB(4, "STEP"), + MOSSY_STONE_BRICK_STAIRS(0, "SMOOTH_STAIRS"), + MOSSY_STONE_BRICK_WALL(0, ""), + MOVING_PISTON(0, "PISTON_BASE", "PISTON_MOVING_PIECE"), + MULE_SPAWN_EGG(32, "MONSTER_EGG"), + MUSHROOM_STEM(0, "BROWN_MUSHROOM"), + MUSHROOM_STEW(0, "MUSHROOM_SOUP"), + MUSIC_DISC_11(0, "GOLD_RECORD"), + MUSIC_DISC_13(0, "GREEN_RECORD"), + MUSIC_DISC_BLOCKS(0, "RECORD_3"), + MUSIC_DISC_CAT(0, "RECORD_4"), + MUSIC_DISC_CHIRP(0, "RECORD_5"), + MUSIC_DISC_FAR(0, "RECORD_6"), + MUSIC_DISC_MALL(0, "RECORD_7"), + MUSIC_DISC_MELLOHI(0, "RECORD_8"), + MUSIC_DISC_STAL(0, "RECORD_9"), + MUSIC_DISC_STRAD(0, "RECORD_10"), + MUSIC_DISC_WAIT(0, "RECORD_11"), + MUSIC_DISC_WARD(0, "RECORD_12"), + MUTTON(0, ""), + MYCELIUM(0, "MYCEL"), + NAME_TAG(0, ""), + NAUTILUS_SHELL(0, "1.13"), + NETHERRACK(0, ""), + NETHER_BRICK(0, "NETHER_BRICK_ITEM"), + NETHER_BRICKS(0, "NETHER_BRICK"), + NETHER_BRICK_FENCE(0, "NETHER_FENCE"), + NETHER_BRICK_SLAB(4, "STEP"), + NETHER_BRICK_STAIRS(0, ""), + NETHER_BRICK_WALL(0, ""), + NETHER_PORTAL(0, "PORTAL"), + NETHER_QUARTZ_ORE(0, "QUARTZ_ORE"), + NETHER_STAR(0, ""), + NETHER_WART(0, "NETHER_STALK"), + NETHER_WART_BLOCK(0, "NETHER_WARTS"), + NOTE_BLOCK(0, ""), + OAK_BOAT(0, "BOAT"), + OAK_BUTTON(0, "WOOD_BUTTON"), + OAK_DOOR(0, "WOOD_DOOR", "WOODEN_DOOR"), + OAK_FENCE(0, "FENCE"), + OAK_FENCE_GATE(0, "FENCE_GATE"), + OAK_LEAVES(0, "LEAVES"), + OAK_LOG(0, "LOG"), + OAK_PLANKS(0, "WOOD"), + OAK_PRESSURE_PLATE(0, "WOOD_PLATE"), + OAK_SAPLING(0, "SAPLING"), + OAK_SIGN(0, "SIGN"), + OAK_SLAB(0, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), + OAK_STAIRS(0, "WOOD_STAIRS"), + OAK_TRAPDOOR(0, "TRAP_DOOR"), + OAK_WALL_SIGN(0, "SIGN_POST", "WALL_SIGN"), + OAK_WOOD(0, "LOG"), + OBSERVER(0, ""), + OBSIDIAN(0, ""), + OCELOT_SPAWN_EGG(98, "MONSTER_EGG"), + ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"), + ORANGE_BED(1, "BED", "BED_BLOCK"), + ORANGE_CARPET(1, "CARPET"), + ORANGE_CONCRETE(1, "CONCRETE"), + ORANGE_CONCRETE_POWDER(1, "CONCRETE_POWDER"), + ORANGE_DYE(14, "INK_SACK"), + ORANGE_GLAZED_TERRACOTTA(1, "1.12", "HARD_CLAY", "STAINED_CLAY", "ORANGE_TERRACOTTA"), + ORANGE_SHULKER_BOX(0, ""), + ORANGE_STAINED_GLASS(1, "STAINED_GLASS"), + ORANGE_STAINED_GLASS_PANE(1, "STAINED_GLASS_PANE"), + ORANGE_TERRACOTTA(1, "HARD_CLAY", "STAINED_CLAY"), + ORANGE_TULIP(5, "RED_ROSE"), + ORANGE_WALL_BANNER(14, "WALL_BANNER"), + ORANGE_WOOL(1, "WOOL"), + OXEYE_DAISY(8, "RED_ROSE"), + PACKED_ICE(0, ""), + PAINTING(0, ""), + PANDA_SPAWN_EGG(0, "1.14"), + PAPER(0, ""), + PARROT_SPAWN_EGG(105, "MONSTER_EGG"), + PEONY(5, "DOUBLE_PLANT"), + PETRIFIED_OAK_SLAB(0, "WOOD_STEP"), + PHANTOM_MEMBRANE(0, "1.13"), + PHANTOM_SPAWN_EGG(0, "1.13", "MONSTER_EGG"), + PIG_SPAWN_EGG(90, "MONSTER_EGG"), + PILLAGER_SPAWN_EGG(0, "1.14"), + PINK_BANNER(9, "BANNER", "STANDING_BANNER"), + PINK_BED(6, "BED", "BED_BLOCK"), + PINK_CARPET(6, "CARPET"), + PINK_CONCRETE(6, "CONCRETE"), + PINK_CONCRETE_POWDER(6, "CONCRETE_POWDER"), + PINK_DYE(9, "INK_SACK"), + PINK_GLAZED_TERRACOTTA(6, "1.12", "HARD_CLAY", "STAINED_CLAY", "PINK_TERRACOTTA"), + PINK_SHULKER_BOX(0, ""), + PINK_STAINED_GLASS(6, "STAINED_GLASS"), + PINK_STAINED_GLASS_PANE(6, "THIN_GLASS", "STAINED_GLASS_PANE"), + PINK_TERRACOTTA(6, "HARD_CLAY", "STAINED_CLAY"), + PINK_TULIP(7, "RED_ROSE"), + PINK_WALL_BANNER(14, "WALL_BANNER"), + PINK_WOOL(6, "WOOL"), + PISTON(0, "PISTON_BASE"), + PISTON_HEAD(0, "PISTON_EXTENSION"), + PLAYER_HEAD(3, "SKULL", "SKULL_ITEM"), + PLAYER_WALL_HEAD(3, "SKULL", "SKULL_ITEM"), + PODZOL(2, "DIRT"), + POISONOUS_POTATO(0, ""), + POLAR_BEAR_SPAWN_EGG(102, "MONSTER_EGG"), + POLISHED_ANDESITE(6, "1.13"), + POLISHED_ANDESITE_SLAB(0, ""), + POLISHED_ANDESITE_STAIRS(0, ""), + POLISHED_DIORITE(4, "1.13"), + POLISHED_DIORITE_SLAB(0, ""), + POLISHED_DIORITE_STAIRS(0, ""), + POLISHED_GRANITE(2, "1.13"), + POLISHED_GRANITE_SLAB(0, ""), + POLISHED_GRANITE_STAIRS(0, ""), + POPPED_CHORUS_FRUIT(0, "CHORUS_FRUIT_POPPED"), + POPPY(0, "RED_ROSE"), + PORKCHOP(0, "PORK"), + POTATO(0, "POTATO_ITEM"), + POTATOES(0, "POTATO"), + POTION(0, ""), + POTTED_ACACIA_SAPLING(4, "SAPLING", "FLOWER_POT"), + POTTED_ALLIUM(2, "RED_ROSE", "FLOWER_POT"), + POTTED_AZURE_BLUET(3, "RED_ROSE", "FLOWER_POT"), + POTTED_BAMBOO(0, ""), + POTTED_BIRCH_SAPLING(2, "SAPLING", "FLOWER_POT"), + POTTED_BLUE_ORCHID(1, "RED_ROSE", "FLOWER_POT"), + POTTED_BROWN_MUSHROOM(0, "FLOWER_POT"), + POTTED_CACTUS(0, "FLOWER_POT"), + POTTED_CORNFLOWER(0, ""), + POTTED_DANDELION(0, "YELLOW_FLOWER", "FLOWER_POT"), + POTTED_DARK_OAK_SAPLING(5, "SAPLING", "FLOWER_POT"), + POTTED_DEAD_BUSH(0, "FLOWER_POT"), + POTTED_FERN(2, "LONG_GRASS", "FLOWER_POT"), + POTTED_JUNGLE_SAPLING(3, "SAPLING", "FLOWER_POT"), + POTTED_LILY_OF_THE_VALLEY(0, ""), + POTTED_OAK_SAPLING(0, "SAPLING", "FLOWER_POT"), + POTTED_ORANGE_TULIP(5, "RED_ROSE", "FLOWER_POT"), + POTTED_OXEYE_DAISY(8, "RED_ROSE", "FLOWER_POT"), + POTTED_PINK_TULIP(7, "RED_ROSE", "FLOWER_POT"), + POTTED_POPPY(0, "RED_ROSE", "FLOWER_POT"), + POTTED_RED_MUSHROOM(0, "FLOWER_POT"), + POTTED_RED_TULIP(4, "RED_ROSE", "FLOWER_POT"), + POTTED_SPRUCE_SAPLING(1, "SAPLING", "FLOWER_POT"), + POTTED_WHITE_TULIP(6, "RED_ROSE", "FLOWER_POT"), + POTTED_WITHER_ROSE(0, ""), + POWERED_RAIL(0, ""), + PRISMARINE(0, ""), + PRISMARINE_BRICKS(2, "PRISMARINE"), + PRISMARINE_BRICK_SLAB(4, "STEP"), + PRISMARINE_BRICK_STAIRS(0, "1.13"), + PRISMARINE_CRYSTALS(0, ""), + PRISMARINE_SHARD(0, ""), + PRISMARINE_SLAB(0, "1.13"), + PRISMARINE_STAIRS(0, "1.13"), + PRISMARINE_WALL(0, ""), + PUFFERFISH(3, "RAW_FISH"), + PUFFERFISH_BUCKET(0, "1.13", "BUCKET", "WATER_BUCKET"), + PUFFERFISH_SPAWN_EGG(0, "1.13", "MONSTER_EGG"), + PUMPKIN(0, ""), + PUMPKIN_PIE(0, ""), + PUMPKIN_SEEDS(0, ""), + PUMPKIN_STEM(0, ""), + PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"), + PURPLE_BED(10, "BED", "BED_BLOCK"), + PURPLE_CARPET(10, "CARPET"), + PURPLE_CONCRETE(10, "CONCRETE"), + PURPLE_CONCRETE_POWDER(10, "CONCRETE_POWDER"), + PURPLE_DYE(5, "INK_SACK"), + PURPLE_GLAZED_TERRACOTTA(10, "1.12", "HARD_CLAY", "STAINED_CLAY", "PURPLE_TERRACOTTA"), + PURPLE_SHULKER_BOX(0, ""), + PURPLE_STAINED_GLASS(10, "STAINED_GLASS"), + PURPLE_STAINED_GLASS_PANE(10, "THIN_GLASS", "STAINED_GLASS_PANE"), + PURPLE_TERRACOTTA(10, "HARD_CLAY", "STAINED_CLAY"), + PURPLE_WALL_BANNER(5, "WALL_BANNER"), + PURPLE_WOOL(10, "WOOL"), + PURPUR_BLOCK(0, ""), + PURPUR_PILLAR(0, ""), + PURPUR_SLAB(0, "PURPUR_DOUBLE_SLAB"), + PURPUR_STAIRS(0, ""), + QUARTZ(0, ""), + QUARTZ_BLOCK(0, ""), + QUARTZ_PILLAR(2, "QUARTZ_BLOCK"), + QUARTZ_SLAB(7, "STEP"), + QUARTZ_STAIRS(0, ""), + RABBIT(0, ""), + RABBIT_FOOT(0, ""), + RABBIT_HIDE(0, ""), + RABBIT_SPAWN_EGG(101, "MONSTER_EGG"), + RABBIT_STEW(0, ""), + RAIL(0, "RAILS"), + RAVAGER_SPAWN_EGG(0, "1.14"), + REDSTONE(0, ""), + REDSTONE_BLOCK(0, ""), + REDSTONE_LAMP(0, "REDSTONE_LAMP_OFF", "REDSTONE_LAMP_ON"), + REDSTONE_ORE(0, "GLOWING_REDSTONE_ORE"), + REDSTONE_TORCH(0, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"), + REDSTONE_WALL_TORCH(1, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"), + REDSTONE_WIRE(0, ""), + RED_BANNER(1, "BANNER", "STANDING_BANNER"), + RED_BED(14, "BED", "BED_BLOCK"), + RED_CARPET(14, "CARPET"), + RED_CONCRETE(14, "CONCRETE"), + RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"), + RED_DYE(1, "ROSE_RED"), + RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"), + RED_MUSHROOM(0, ""), + RED_MUSHROOM_BLOCK(0, "RED_MUSHROOM", "HUGE_MUSHROOM_2"), + RED_NETHER_BRICKS(0, "RED_NETHER_BRICK"), + RED_NETHER_BRICK_SLAB(4, "STEP"), + RED_NETHER_BRICK_STAIRS(0, ""), + RED_NETHER_BRICK_WALL(0, ""), + RED_SAND(1, "SAND"), + RED_SANDSTONE(0, ""), + RED_SANDSTONE_SLAB(0, "STONE_SLAB2", "DOUBLE_STONE_SLAB2"), + RED_SANDSTONE_STAIRS(0, ""), + RED_SANDSTONE_WALL(0, ""), + RED_SHULKER_BOX(0, ""), + RED_STAINED_GLASS(14, "STAINED_GLASS"), + RED_STAINED_GLASS_PANE(14, "THIN_GLASS", "STAINED_GLASS_PANE"), + RED_TERRACOTTA(14, "HARD_CLAY", "STAINED_CLAY"), + RED_TULIP(4, "RED_ROSE"), + RED_WALL_BANNER(1, "WALL_BANNER"), + RED_WOOL(14, "WOOL"), + REPEATER(0, "DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"), + REPEATING_COMMAND_BLOCK(0, "COMMAND", "COMMAND_REPEATING"), + ROSE_BUSH(4, "DOUBLE_PLANT"), + ROTTEN_FLESH(0, ""), + SADDLE(0, ""), + SALMON(1, "RAW_FISH"), + SALMON_BUCKET(0, "1.13", "BUCKET", "WATER_BUCKET"), + SALMON_SPAWN_EGG(0, "1.13", "MONSTER_EGG"), + SAND(0, ""), + SANDSTONE(0, ""), + SANDSTONE_SLAB(1, "STEP", "STONE_SLAB", "DOUBLE_STEP"), + SANDSTONE_STAIRS(0, ""), + SANDSTONE_WALL(0, ""), + SCAFFOLDING(0, "1.14", "SLIME_BLOCK"), + SCUTE(0, "1.13"), + SEAGRASS(0, "1.13"), + SEA_LANTERN(0, ""), + SEA_PICKLE(0, "1.13"), + SHEARS(0, ""), + SHEEP_SPAWN_EGG(91, "MONSTER_EGG"), + SHIELD(0, ""), + SHULKER_BOX(0, "PURPLE_SHULKER_BOX"), + SHULKER_SHELL(0, ""), + SHULKER_SPAWN_EGG(69, "MONSTER_EGG"), + SILVERFISH_SPAWN_EGG(60, "MONSTER_EGG"), + SKELETON_HORSE_SPAWN_EGG(28, "MONSTER_EGG"), + SKELETON_SKULL(0, "SKULL", "SKULL_ITEM"), + SKELETON_SPAWN_EGG(51, "MONSTER_EGG"), + SKELETON_WALL_SKULL(0, "SKULL", "SKULL_ITEM"), + SKULL_BANNER_PATTERN(0, ""), + SLIME_BALL(0, ""), + SLIME_BLOCK(0, ""), + SLIME_SPAWN_EGG(55, "MONSTER_EGG"), + SMITHING_TABLE(0, ""), + SMOKER(0, "1.14", "FURNACE"), + SMOOTH_QUARTZ(0, "1.13"), + SMOOTH_QUARTZ_SLAB(7, "STEP"), + SMOOTH_QUARTZ_STAIRS(0, ""), + SMOOTH_RED_SANDSTONE(2, "RED_SANDSTONE"), + SMOOTH_RED_SANDSTONE_SLAB(0, "STONE_SLAB2"), + SMOOTH_RED_SANDSTONE_STAIRS(0, ""), + SMOOTH_SANDSTONE(2, "SANDSTONE"), + SMOOTH_SANDSTONE_SLAB(0, "STEP"), + SMOOTH_SANDSTONE_STAIRS(0, ""), + SMOOTH_STONE(0, "STEP"), + SMOOTH_STONE_SLAB(0, "STEP"), + SNOW(0, ""), + SNOWBALL(0, "SNOW_BALL"), + SNOW_BLOCK(0, ""), + SOUL_SAND(0, ""), + SPAWNER(0, "MOB_SPAWNER"), + SPECTRAL_ARROW(0, ""), + SPIDER_EYE(0, ""), + SPIDER_SPAWN_EGG(52, "MONSTER_EGG"), + SPLASH_POTION(0, ""), + SPONGE(0, ""), + SPRUCE_BOAT(0, "BOAT_SPRUCE"), + SPRUCE_BUTTON(0, "WOOD_BUTTON"), + SPRUCE_DOOR(0, "SPRUCE_DOOR_ITEM"), + SPRUCE_FENCE(0, ""), + SPRUCE_FENCE_GATE(0, ""), + SPRUCE_LEAVES(1, "LEAVES"), + SPRUCE_LOG(1, "LOG"), + SPRUCE_PLANKS(1, "WOOD"), + SPRUCE_PRESSURE_PLATE(0, "WOOD_PLATE"), + SPRUCE_SAPLING(1, "SAPLING"), + SPRUCE_SIGN(0, "SIGN"), + SPRUCE_SLAB(1, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"), + SPRUCE_STAIRS(0, "SPRUCE_WOOD_STAIRS"), + SPRUCE_TRAPDOOR(0, "TRAP_DOOR"), + SPRUCE_WALL_SIGN(0, "SIGN_POST", "WALL_SIGN"), + SPRUCE_WOOD(1, "LOG"), + SQUID_SPAWN_EGG(94, "MONSTER_EGG"), + STICK(0, ""), + STICKY_PISTON(0, "PISTON_BASE", "PISTON_STICKY_BASE"), + STONE(0, ""), + STONECUTTER(0, "1.14"), + STONE_AXE(0, ""), + STONE_BRICKS(0, "SMOOTH_BRICK"), + STONE_BRICK_SLAB(4, "STEP", "STONE_SLAB", "DOUBLE_STEP"), + STONE_BRICK_STAIRS(0, "SMOOTH_STAIRS"), + STONE_BRICK_WALL(0, ""), + STONE_BUTTON(0, ""), + STONE_HOE(0, ""), + STONE_PICKAXE(0, ""), + STONE_PRESSURE_PLATE(0, "STONE_PLATE"), + STONE_SHOVEL(0, "STONE_SPADE"), + STONE_SLAB(0, "STEP", "DOUBLE_STEP"), + STONE_STAIRS(0, ""), + STONE_SWORD(0, ""), + STRAY_SPAWN_EGG(6, "MONSTER_EGG"), + STRING(0, ""), + STRIPPED_ACACIA_LOG(0, "LOG_2"), + STRIPPED_ACACIA_WOOD(0, "LOG_2"), + STRIPPED_BIRCH_LOG(2, "LOG"), + STRIPPED_BIRCH_WOOD(2, "LOG"), + STRIPPED_DARK_OAK_LOG(0, "LOG"), + STRIPPED_DARK_OAK_WOOD(0, "LOG"), + STRIPPED_JUNGLE_LOG(3, "LOG"), + STRIPPED_JUNGLE_WOOD(3, "LOG"), + STRIPPED_OAK_LOG(0, "LOG"), + STRIPPED_OAK_WOOD(0, "LOG"), + STRIPPED_SPRUCE_LOG(1, "LOG"), + STRIPPED_SPRUCE_WOOD(1, "LOG"), + STRUCTURE_BLOCK(0, ""), + STRUCTURE_VOID(0, "1.10", "BARRIER/1.9"), // Originally developers used barrier blocks for its purpose. + SUGAR(0, ""), + SUGAR_CANE(0, "SUGAR_CANE_BLOCK"), + SUNFLOWER(0, "DOUBLE_PLANT"), + SUSPICIOUS_STEW(0, "1.14", "MUSHROOM_STEW"), + SWEET_BERRIES(0, "1.14"), + SWEET_BERRY_BUSH(0, "1.14", "GRASS"), + TALL_GRASS(2, "DOUBLE_PLANT"), + TALL_SEAGRASS(0, "1.13"), + TERRACOTTA(0, "HARD_CLAY"), + TIPPED_ARROW(0, ""), + TNT(0, ""), + TNT_MINECART(0, "EXPLOSIVE_MINECART"), + TORCH(0, ""), + TOTEM_OF_UNDYING(0, "TOTEM"), + TRADER_LLAMA_SPAWN_EGG(103, "1.14", "MONSTER_EGG"), + TRAPPED_CHEST(0, ""), + TRIDENT(0, "1.13"), + TRIPWIRE(0, ""), + TRIPWIRE_HOOK(0, ""), + TROPICAL_FISH(2, "RAW_FISH"), + TROPICAL_FISH_BUCKET(0, "1.13", "BUCKET", "WATER_BUCKET"), + TROPICAL_FISH_SPAWN_EGG(0, "1.13", "MONSTER_EGG"), + TUBE_CORAL(0, "1.13"), + TUBE_CORAL_BLOCK(0, "1.13"), + TUBE_CORAL_FAN(0, "1.13"), + TUBE_CORAL_WALL_FAN(0, ""), + TURTLE_EGG(0, "1.13", "EGG"), + TURTLE_HELMET(0, "1.13"), + TURTLE_SPAWN_EGG(0, "1.13", "MONSTER_EGG"), + VEX_SPAWN_EGG(35, "MONSTER_EGG"), + VILLAGER_SPAWN_EGG(120, "MONSTER_EGG"), + VINDICATOR_SPAWN_EGG(36, "MONSTER_EGG"), + VINE(0, ""), + VOID_AIR(0, "AIR"), + WALL_TORCH(0, "TORCH"), + WANDERING_TRADER_SPAWN_EGG(0, "1.14", "VILLAGER_SPAWN_EGG"), + WATER(0, "STATIONARY_WATER"), + WATER_BUCKET(0, ""), + WET_SPONGE(1, "SPONGE"), + WHEAT(0, "CROPS"), + WHEAT_SEEDS(0, "SEEDS"), + WHITE_BANNER(15, "BANNER", "STANDING_BANNER"), + WHITE_BED(0, "BED", "BED_BLOCK"), + WHITE_CARPET(0, "CARPET"), + WHITE_CONCRETE(0, "CONCRETE"), + WHITE_CONCRETE_POWDER(0, "CONCRETE_POWDER"), + WHITE_DYE(15, "1.14", "INK_SACK", "BONE_MEAL"), + WHITE_GLAZED_TERRACOTTA(0, "1.12", "HARD_CLAY", "STAINED_CLAY", "WHITE_TERRACOTTA"), + WHITE_SHULKER_BOX(0, ""), + WHITE_STAINED_GLASS(0, "STAINED_GLASS"), + WHITE_STAINED_GLASS_PANE(0, "THIN_GLASS", "STAINED_GLASS_PANE"), + WHITE_TERRACOTTA(0, "HARD_CLAY", "TERRACOTTA"), + WHITE_TULIP(6, "RED_ROSE"), + WHITE_WALL_BANNER(15, "WALL_BANNER"), + WHITE_WOOL(0, "WOOL"), + WITCH_SPAWN_EGG(66, "MONSTER_EGG"), + WITHER_ROSE(0, "1.14", "BLACK_DYE"), + WITHER_SKELETON_SKULL(1, "SKULL", "SKULL_ITEM"), + WITHER_SKELETON_SPAWN_EGG(5, "MONSTER_EGG"), + WITHER_SKELETON_WALL_SKULL(1, "SKULL", "SKULL_ITEM"), + WOLF_SPAWN_EGG(95, "MONSTER_EGG"), + WOODEN_AXE(0, "WOOD_AXE"), + WOODEN_HOE(0, "WOOD_HOE"), + WOODEN_PICKAXE(0, "WOOD_PICKAXE"), + WOODEN_SHOVEL(0, "WOOD_SPADE"), + WOODEN_SWORD(0, "WOOD_SWORD"), + WRITABLE_BOOK(0, "BOOK_AND_QUILL"), + WRITTEN_BOOK(0, ""), + YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"), + YELLOW_BED(4, "BED", "BED_BLOCK"), + YELLOW_CARPET(4, "CARPET"), + YELLOW_CONCRETE(4, "CONCRETE"), + YELLOW_CONCRETE_POWDER(4, "CONCRETE_POWDER"), + YELLOW_DYE(11, "INK_SACK", "DANDELION_YELLOW"), + YELLOW_GLAZED_TERRACOTTA(4, "1.12", "HARD_CLAY", "STAINED_CLAY", "YELLOW_TERRACOTTA"), + YELLOW_SHULKER_BOX(0, ""), + YELLOW_STAINED_GLASS(4, "STAINED_GLASS"), + YELLOW_STAINED_GLASS_PANE(4, "THIN_GLASS", "STAINED_GLASS_PANE"), + YELLOW_TERRACOTTA(4, "HARD_CLAY", "STAINED_CLAY"), + YELLOW_WALL_BANNER(11, "WALL_BANNER"), + YELLOW_WOOL(4, "WOOL"), + ZOMBIE_HEAD(2, "SKULL", "SKULL_ITEM"), + ZOMBIE_HORSE_SPAWN_EGG(29, "MONSTER_EGG"), + ZOMBIE_PIGMAN_SPAWN_EGG(57, "MONSTER_EGG"), + ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"), + ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"), + ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM"); + + + /** + * A list of material names that can be damaged. + * Some names are not complete as this list needs to be + * checked with {@link String#contains}. + */ + public static final String[] DAMAGEABLE = { + "HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS", + "SWORD", "AXE", "PICKAXE", "SHOVEL", "HOE", + "ELYTRA", "TRIDENT", "HORSE_ARMOR", "BARDING", + "SHEARS", "FLINT_AND_STEEL", "BOW", "FISHING_ROD", + "CARROT_ON_A_STICK", "CARROT_STICK" + }; + /** + * A list of duplicated items in 1.13 and 1.12 with different purpose. + * Values are the new material names. + * Duplicates are only checked by keys not values. + * Checked with {@link String#equals} + */ + public static final HashMap DUPLICATED = new HashMap() {{ + put(XMaterial.MELON, XMaterial.MELON_SLICE); + put(XMaterial.CARROT, XMaterial.CARROTS); + put(XMaterial.POTATO, XMaterial.POTATOES); + put(XMaterial.BEETROOT, XMaterial.BEETROOTS); + put(XMaterial.BROWN_MUSHROOM, XMaterial.BROWN_MUSHROOM_BLOCK); + put(XMaterial.BRICK, XMaterial.BRICKS); + put(XMaterial.RED_MUSHROOM, XMaterial.RED_MUSHROOM_BLOCK); + put(XMaterial.MAP, XMaterial.FILLED_MAP); + put(XMaterial.NETHER_BRICK, XMaterial.NETHER_BRICKS); + }}; + public static final XMaterial[] VALUES = XMaterial.values(); + private static final HashMap CACHED_SEARCH = new HashMap<>(); + private static MinecraftVersion version; + private static Boolean isNewVersion; + private final byte data; + private final String[] legacy; + + XMaterial(int data, String... legacy) { + this.data = (byte) data; + this.legacy = legacy; + } + + /** + * Checks if the version is 1.13 (Aquatic Update) or higher. + * + * @return true if 1.13 or higher. + */ + public static boolean isNewVersion() { + if (isNewVersion != null) return isNewVersion; + return isNewVersion = isVersionOrHigher(MinecraftVersion.VERSION_1_13); + } + + public static boolean isOneEight() { + return getVersion() == MinecraftVersion.VERSION_1_8; + } + + /** + * Uses newly added materials to minecraft to detect the server version. + * + * @return the current server version. + */ + public static MinecraftVersion getVersion() { + if (version != null) return version; + return version = valueOfVersion(Bukkit.getVersion()); + } + + /** + * When using newer versions of Minecraft {@link #isNewVersion()} this helps + * to find the old material name with its data using a cached search for optimization. + * + * @see #matchXMaterial(String, byte) + */ + private static XMaterial requestOldXMaterial(String name, byte data) { + XMaterial cached = CACHED_SEARCH.get(name + "," + data); + + if (cached != null) return cached; + Optional search = data == -1 ? Arrays.stream(XMaterial.VALUES).filter(mat -> mat.matchAnyLegacy(name)).findFirst() + : Arrays.stream(XMaterial.VALUES).filter(mat -> mat.matchAnyLegacy(name) && mat.data == data).findFirst(); + + if (search.isPresent()) { + XMaterial found = search.get(); + CACHED_SEARCH.put(found.legacy[0] + "," + found.getData(), found); + return found; + } + return null; + } + + /** + * Checks if XMaterial enum contains a material with this name. + * + * @param name name of the material + * @return true if XMaterial enum has this material. + */ + public static boolean contains(String name) { + String formatted = format(name); + return Arrays.stream(XMaterial.VALUES).anyMatch(mat -> mat.name().equals(formatted)); + } + + /** + * Checks if the given material matches any of the legacy names. + * + * @param name the material name. + * @return true if it's a legacy name. + */ + public static boolean containsLegacy(String name) { + String formatted = format(name); + return Arrays.stream(Arrays.stream(XMaterial.VALUES).map(m -> m.legacy).toArray(String[]::new)).anyMatch(mat + -> parseLegacyVersionMaterialName(mat).equals(formatted)); + } + + /** + * @see #matchXMaterial(String, byte) + */ + public static XMaterial matchXMaterial(Material material) { + return matchXMaterial(material.name()); + } + + /** + * @see #matchXMaterial(String, byte) + */ + public static XMaterial matchXMaterial(String name) { + // -1 Determines whether the item's data is unknown and only the name is given. + // Checking if the item is damageable won't do anything as the data is not going to be checked in requestOldMaterial anyway. + return matchXMaterial(name, (byte) -1); + } + + /** + * Parses the material name and data argument as a {@link Material}. + * + * @param name name of the material + * @param data data of the material + */ + public static Material parseMaterial(String name, byte data) { + return matchXMaterial(name, data).parseMaterial(); + } + + /** + * @param item the ItemStack to match its material and data. + * @see #matchXMaterial(String, byte) + */ + @SuppressWarnings("deprecation") + public static XMaterial matchXMaterial(ItemStack item) { + return isDamageable(item.getType().name()) ? matchXMaterial(item.getType().name(), (byte) 0) : + matchXMaterial(item.getType().name(), (byte) item.getDurability()); + } + + /** + * Matches the argument string and its data with a XMaterial. + * + * @param name the name of the material + * @param data the data byte of the material + * @return a XMaterial from the enum (with the same legacy name and data if in older versions.) + */ + public static XMaterial matchXMaterial(String name, byte data) { + Validate.notEmpty(name, "Material name cannot be null or empty"); + name = format(name); + + if ((contains(name) && data <= 0) && (isNewVersion() || !isDuplicated(name))) + return valueOf(name); + + // TODO Temporary but works - Please find a more reasonable fix for duplicated materials. + if (isDuplicated(name) && !isNewVersion()) + return requestDuplicatedXMaterial(name, data); + + return requestOldXMaterial(name, data); + } + + /** + * Gets the XMaterial based on the Material's ID and data. + * You should avoid using this for performance reasons. + * + * @param id the ID (Magic value) of the material. + * @param data the data of the material. + * @return some XMaterial, or null. + */ + public static XMaterial matchXMaterial(int id, byte data) { + // Looping through Material.values() will take longer. + return Arrays.stream(XMaterial.VALUES).filter(mat -> mat.getId() == id && mat.data == data).findFirst().orElse(null); + } + + /** + * This method is temporary. Do not use this. + * Manually parses the duplicated materials to find the exact material based on the server version. + * + * @param name the name of the material. + * @return the duplicated XMaterial based on the version. + */ + private static XMaterial requestDuplicatedXMaterial(String name, byte data) { + XMaterial mat = requestOldXMaterial(name, data); + return mat == null ? null : mat.name().endsWith("S") ? valueOf(name) : mat; + } + + /** + * Always returns the value. + * + * @param name the name of the material. + * @return the new XMaterial of this duplicated material. + * @see #getXMaterialIfDuplicated(String) + */ + public static XMaterial getNewXMaterialIfDuplicated(String name) { + return DUPLICATED.entrySet().stream() + .filter(m -> m.getKey().name().equals(format(name))) + .findFirst() + .map(Map.Entry::getValue) + .orElse(null); + } + + /** + * Checks if the item is duplicated for a different purpose in new versions from {@link #DUPLICATED}. + * + * @param name the name of the material. + * @return the other XMaterial (key or value) of the XMaterial (key or value) which the name was equals to. + * @see #matchXMaterial(String, byte) + */ + public static XMaterial getXMaterialIfDuplicated(String name) { + String formatted = format(name); + Optional> mat = DUPLICATED.entrySet().stream().filter(m + -> m.getKey().name().equals(formatted) || m.getValue().name().equals(formatted)).findFirst(); + + if (mat.isPresent()) { + Map.Entry found = mat.get(); + return formatted.equals(found.getKey().name()) ? found.getValue() : found.getKey(); + } + return null; + } + + /** + * Attempts to build the string like an enum name. + * + * @param name the material name to modify. + * @return a Material enum name. + */ + private static String format(String name) { + return name.toUpperCase().replace("MINECRAFT:", "").replace('-', '_').replaceAll("\\s+", "_").replaceAll("\\W", ""); + } + + /** + * Parses the material name if the legacy name has a version attached to it. + * + * @param name the material name to parse. + * @return the material name with the version removed. + */ + private static String parseLegacyVersionMaterialName(String name) { + if (!name.contains("/")) return name; + return name.substring(0, name.indexOf('/')); + } + + /** + * Checks if the version argument is the same or higher than the current server version. + * + * @param version the version to be checked. + * @return true of the version is equal or higher than the current version. + */ + public static boolean isVersionOrHigher(MinecraftVersion version) { + MinecraftVersion current = getVersion(); + + if (version == current) return true; + if (version == MinecraftVersion.UNKNOWN) return false; + if (current == MinecraftVersion.UNKNOWN) return true; + + int ver = Integer.parseInt(version.name().replace("VERSION_", "").replace("_", "")); + int currentVer = Integer.parseInt(current.name().replace("VERSION_", "").replace("_", "")); + + return currentVer >= ver; + } + + /** + * Converts the material's name to a string with the first letter uppercase. + * + * @return a converted string. + */ + public static String toWord(Material material) { + return material.name().charAt(0) + material.name().substring(1).toLowerCase(); + } + + /** + * Compares two major versions. The current server version and the given version. + * + * @param version the version to check. + * @return true if is the same as the current version or higher. + */ + public static boolean isVersionOrHigher(String version) { + int currentVer = Integer.parseInt(getExactMajorVersion(Bukkit.getVersion()).replace(".", "")); + int versionNumber = Integer.parseInt(version.replace(".", "")); + + return currentVer >= versionNumber; + } + + /** + * Gets the exact major version (..., 1.9, 1.10, ..., 1.14) + * + * @param version Supports {@link Bukkit#getVersion()}, {@link Bukkit#getBukkitVersion()} and normal formats such as "1.14" + * @return the exact major version. + */ + public static String getExactMajorVersion(String version) { + // getBukkitVersion() + if (version.contains("SNAPSHOT") || version.contains("-R")) version = version.substring(0, version.indexOf("-")); + // getVersion() + if (version.contains("git")) version = version.substring(version.indexOf("MC:") + 4).replace(")", ""); + if (version.split(Pattern.quote(".")).length > 2) version = version.substring(0, version.lastIndexOf(".")); + return version; + } + + /** + * Parses the string arugment to a version. + * Supports {@link Bukkit#getVersion()}, {@link Bukkit#getBukkitVersion()} and normal formats such as "1.14" + * + * @param version the server version. + * @return the Minecraft version represented by the string. + */ + private static MinecraftVersion valueOfVersion(String version) { + version = getExactMajorVersion(version); + if (version.equals("1.10") || version.equals("1.11") || version.equals("1.12")) return MinecraftVersion.VERSION_1_9; + version = version.replace(".", "_"); + if (!version.startsWith("VERSION_")) version = "VERSION_" + version; + String check = version; + return Arrays.stream(MinecraftVersion.VALUES).anyMatch(v -> v.name().equals(check)) ? MinecraftVersion.valueOf(version) : MinecraftVersion.UNKNOWN; + } + + /** + * Checks if the material can be damaged from {@link #DAMAGEABLE}. + * + * @param name the name of the material. + * @return true of the material can be damaged. + */ + public static boolean isDamageable(String name) { + return Arrays.stream(DAMAGEABLE).anyMatch(name::contains); + } + + public static boolean isDuplicated(String name) { + String formatted = format(name); + return DUPLICATED.entrySet().stream().anyMatch(x -> x.getKey().name().equals(formatted)); + } + + /** + * Gets the ID (Magic value) of the material. + * If an {@link IllegalArgumentException} was thrown from this method, + * you should definitely report it. + * + * @return the ID of the material. -1 if it's a new block. + */ + @SuppressWarnings("deprecation") + public int getId() { + return this.isNew() ? -1 : this.parseMaterial().getId(); + } + + public boolean isDuplicated() { + return DUPLICATED.containsKey(this); + } + + /** + * Checks if the given string matches any of this material's legacy material names. + * + * @param name the name to check + * @return true if it's one of the legacy names. + */ + public boolean matchAnyLegacy(String name) { + String formatted = format(name); + return Arrays.asList(this.legacy).contains(formatted); + } + + /** + * Converts the material's name to a string with the first letter uppercase. + * + * @return a converted string. + */ + public String toWord() { + return this.name().charAt(0) + this.name().substring(1).toLowerCase(); + } + + /** + * Checks if the item is duplicated for a different purpose in new versions from {@link #DUPLICATED}. + * + * @return true if the item's name is duplicated. + * @see #matchXMaterial(String, byte) + */ + public XMaterial getXMaterialIfDuplicated() { + Optional> mat = DUPLICATED.entrySet().stream().filter(m -> m.getKey() == this).findFirst(); + return mat.map(Map.Entry::getValue).orElse(null); + } + + /** + * @return true if the item can be damaged. + * @see #isDamageable(String) + */ + public boolean isDamageable() { + return isDamageable(this.name()); + } + + /** + * Get the {@link ItemStack} data of this material in older versions. + * Which can be accessed with {@link ItemStack#getData()} then MaterialData#getData() + * or {@link ItemStack#getDurability()} if not damageable. + * + * @return data of this material. + */ + public int getData() { + return this.data; + } + + /** + * Get a list of materials names that was previously used by older versions. + * + * @return a list of string of legacy material names. + */ + public String[] getLegacy() { + return this.legacy; + } + + /** + * Parses the XMaterial as an {@link ItemStack}. + * + * @return an ItemStack with the same material (and data if in older versions.) + */ + public ItemStack parseItem() { + return parseItem(false); + } + + /** + * Parses the XMaterial as an {@link ItemStack}. + * + * @param suggest if true {@link #parseMaterial(boolean)} + * @return an ItemStack with the same material (and data if in older versions.) + */ + @SuppressWarnings("deprecation") + public ItemStack parseItem(boolean suggest) { + Material material = this.parseMaterial(suggest); + return isNewVersion() ? new ItemStack(material) : new ItemStack(material, 1, this.data); + } + + /** + * Parses the XMaterial as a {@link Material}. + * + * @return the Material related to this XMaterial based on the server version. + */ + public Material parseMaterial() { + return parseMaterial(false); + } + + /** + * Parses the XMaterial as a {@link Material}. + * + * @param suggest Use a suggested material if the material is added in the new version. + * @return the Material related to this XMaterial based on the server version. + * @see #matchXMaterial(String, byte) + */ + public Material parseMaterial(boolean suggest) { + Material newMat = Material.getMaterial(this.name()); + + // If the name is not null it's probably the new version. + // So you can still use this name even if it's a duplicated name. + // Since duplicated names only apply to older versions. + if (newMat != null && (isNewVersion() || !this.isDuplicated())) return newMat; + return requestOldMaterial(suggest); + } + + /** + * Parses from old material names and can accept suggestions. + * + * @param suggest Accept suggestions for newly added blocks + * @return A parsed Material suitable for this minecraft version. + */ + private Material requestOldMaterial(boolean suggest) { + Material oldMat; + boolean isNew = getVersionIfNew() != MinecraftVersion.UNKNOWN; + for (int i = this.legacy.length - 1; i >= 0; i--) { + String legacyName = this.legacy[i]; + // Slash means it's just another name for the material in another version. + if (legacyName.contains("/")) { + oldMat = Material.getMaterial(parseLegacyVersionMaterialName(legacyName)); + + if (oldMat != null) return oldMat; + else continue; + } + if (isNew) { + if (suggest) { + oldMat = Material.getMaterial(legacyName); + if (oldMat != null) return oldMat; + } else return null; + // According to the suggestion format list, all the other names continuing + // from here are considered as a "suggestion" if there's no slash anymore. + } + oldMat = Material.getMaterial(legacyName); + if (oldMat != null) return oldMat; + } + return null; + } + + /** + * Checks if an item is similar to the material and its data (if in older versions.) + * + * @param item item to check. + * @return true if the material is the same as the item's material (and data if in older versions.) + */ + @SuppressWarnings("deprecation") + public boolean isSimilar(ItemStack item) { + Objects.requireNonNull(item, "ItemStack cannot be null"); + Objects.requireNonNull(item.getType(), "ItemStack's material cannot be null"); + return (isNewVersion() || this.isDamageable()) ? item.getType() == this.parseMaterial() : item.getType() == this.parseMaterial() && item.getDurability() == this.data; + } + + /** + * Get the suggested material names that can be used instead of this material. + * + * @return a list of suggested material names. + */ + public String[] getSuggestions() { + if (!this.legacy[0].contains(".")) return new String[0]; + return Arrays.stream(this.legacy).filter(mat -> !mat.contains(".")).toArray(String[]::new); + } + + /** + * Checks if this material is supported in the current version. + * It'll check both the newest matetrial name and for legacy names. + * + * @return true if the material exists in {@link Material} list. + */ + public boolean isSupported() { + return Arrays.stream(Material.values()).anyMatch(mat -> mat.name().equals(this.name()) || this.matchAnyLegacy(mat.name())); + } + + /** + * Gets the added version if the material is newly added after the 1.13 Aquatic Update and higher. + * + * @return the version which the material was added in. {@link MinecraftVersion#UNKNOWN} if not new. + * @see #isNew() + */ + public MinecraftVersion getVersionIfNew() { + return this.isNew() ? valueOfVersion(this.legacy[0]) : MinecraftVersion.UNKNOWN; + } + + /** + * Checks if the material is newly added after the 1.13 Aquatic Update. + * + * @return true if it was newly added. + */ + public boolean isNew() { + return this.legacy[0].contains("."); + } + + /** + * Gets the suggested material instead of returning null for unsupported versions. + * This is somehow similar to what ProtcolSupport and ViaVersion are doing to new materials. + * Don't use this if you want to parse to a {@link Material} + * + * @return The suggested material that is similar. + * @see #parseMaterial() + */ + public XMaterial suggestOldMaterialIfNew() { + if (getVersionIfNew() == MinecraftVersion.UNKNOWN || this.legacy.length == 1) return null; + + // We need a loop because: Newest -> Oldest + for (int i = this.legacy.length - 1; i >= 0; i--) { + String legacyName = this.legacy[i]; + + if (legacyName.contains("/")) continue; + XMaterial mat = matchXMaterial(parseLegacyVersionMaterialName(legacyName), this.data); + if (mat != null && this != mat) return mat; + } + return null; + } + + /** + * Only major versions related to material changes. + */ + public enum MinecraftVersion { + /** + * Bountiful Update + */ + VERSION_1_8, + /** + * Combat Update (Pitiful Update?) + */ + VERSION_1_9, + /** + * Aquatic Update + */ + VERSION_1_13, + /** + * Village Pillage Update + */ + VERSION_1_14, + /** + * 1.7 or below. + * Using {@link #getVersionIfNew()} it means 1.12 or below. + */ + UNKNOWN; + + public static final MinecraftVersion[] VALUES = MinecraftVersion.values(); + } +} diff --git a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java index 947450cd..490d559b 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.zcore.fperms; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.SaberFactions; -import com.massivecraft.factions.util.MultiversionMaterials; +import com.massivecraft.factions.util.XMaterial; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; @@ -105,10 +105,7 @@ public enum PermissableAction { if (section.getString("materials." + name().toLowerCase().replace('_', '-')) == null) { return null; } - Material material = Material.matchMaterial(section.getString("materials." + name().toLowerCase().replace('_', '-'))); - if (material == null) { - material = MultiversionMaterials.fromString(SaberFactions.plugin.getConfig().getString("fperm-gui.action.materials")).parseMaterial(); - } + Material material = XMaterial.matchXMaterial(section.getString("materials." + name().toLowerCase().replace('_', '-'))).parseMaterial(); Access access = fme.getFaction().getAccess(permissable, this); if (access == null) { @@ -125,7 +122,6 @@ public enum PermissableAction { accessValue = "allow"; break; case DENY: - accessValue = "deny"; break; case UNDEFINED: accessValue = "undefined"; @@ -146,7 +142,7 @@ public enum PermissableAction { } } else { // so this is in 1.13 mode, our config will automatically be updated to a material instead of color because of it being removed in the new api - item.setType(Material.valueOf(SaberFactions.plugin.getConfig().getString("fperm-gui.action.access." + accessValue))); + item.setType(XMaterial.matchXMaterial(SaberFactions.plugin.getConfig().getString("fperm-gui.action.access.") + accessValue).parseMaterial()); } for (String loreLine : section.getStringList("placeholder-item.lore")) { diff --git a/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableActionGUI.java b/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableActionGUI.java index 933e5029..858ba63c 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableActionGUI.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/gui/PermissableActionGUI.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.zcore.fperms.gui; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.SaberFactions; import com.massivecraft.factions.util.FactionGUI; +import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.PermissableAction; @@ -184,7 +185,7 @@ public class PermissableActionGUI implements InventoryHolder, FactionGUI { case BACK: ConfigurationSection backButtonConfig = SaberFactions.plugin.getConfig().getConfigurationSection("fperm-gui.back-item"); - ItemStack backButton = new ItemStack(Material.matchMaterial(backButtonConfig.getString("material"))); + ItemStack backButton = new ItemStack(XMaterial.matchXMaterial(backButtonConfig.getString("material")).parseItem()); ItemMeta backButtonMeta = backButton.getItemMeta(); backButtonMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', backButtonConfig.getString("name"))); @@ -255,13 +256,13 @@ public class PermissableActionGUI implements InventoryHolder, FactionGUI { return new ItemStack(Material.AIR); } - Material material = Material.matchMaterial(dummySection.getString("material", "")); + Material material = XMaterial.matchXMaterial(dummySection.getString("material", "")).parseMaterial(); if (material == null) { SaberFactions.plugin.log(Level.WARNING, "Invalid material for dummy item: " + id); return null; } - ItemStack itemStack = new ItemStack(material); + ItemStack itemStack = XMaterial.matchXMaterial(material).parseItem(); DyeColor color; try { diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java index a3dfc37a..14318b29 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java @@ -4,6 +4,7 @@ import com.massivecraft.factions.Board; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; import com.massivecraft.factions.SaberFactions; +import com.massivecraft.factions.util.XMaterial; import org.bukkit.CropState; import org.bukkit.Material; import org.bukkit.block.Block; @@ -50,7 +51,7 @@ public class CropUpgrades implements Listener { private void growCrop(BlockGrowEvent e) { - if (e.getBlock().getType().equals(SaberFactions.plugin.CROPS)) { + if (e.getBlock().getType().equals(XMaterial.WHEAT.parseMaterial())) { e.setCancelled(true); Crops c = new Crops(CropState.RIPE); BlockState bs = e.getBlock().getState(); @@ -60,11 +61,11 @@ public class CropUpgrades implements Listener { Block below = e.getBlock().getLocation().subtract(0, 1, 0).getBlock(); - if (below.getType() == SaberFactions.plugin.SUGAR_CANE_BLOCK) { + if (below.getType() == XMaterial.SUGAR_CANE.parseMaterial()) { Block above = e.getBlock().getLocation().add(0, 1, 0).getBlock(); if (above.getType() == Material.AIR && above.getLocation().add(0, -2, 0).getBlock().getType() != Material.AIR) { - above.setType(SaberFactions.plugin.SUGAR_CANE_BLOCK); + above.setType(XMaterial.SUGAR_CANE.parseMaterial()); } } else if (below.getType() == Material.CACTUS) { diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index 2255df4e..6b6427ef 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -34,1282 +34,1268 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; public abstract class MemoryFaction implements Faction, EconomyParticipator { - public HashMap rules = new HashMap(); - public int tnt; - public Location checkpoint; - public LazyLocation vault; - public HashMap upgrades = new HashMap<>(); - protected String id = null; - protected boolean peacefulExplosionsEnabled; - protected boolean permanent; - protected String tag; - protected String description; - protected boolean open; - protected boolean peaceful; - protected Integer permanentPower; - protected LazyLocation home; - protected long foundedDate; - protected transient long lastPlayerLoggedOffTime; - protected double money; - protected double powerBoost; - protected String paypal; - protected Map relationWish = new HashMap<>(); - protected Map> claimOwnership = new ConcurrentHashMap<>(); - protected transient Set fplayers = new HashSet<>(); - protected transient Set alts = new HashSet<>(); - protected Set invites = new HashSet<>(); - protected Set altinvites = new HashSet<>(); - protected HashMap> announcements = new HashMap<>(); - protected ConcurrentHashMap warps = new ConcurrentHashMap<>(); - protected ConcurrentHashMap warpPasswords = new ConcurrentHashMap<>(); - protected int maxVaults; - protected Role defaultRole; - protected Map> permissions = new HashMap<>(); - protected Set bans = new HashSet<>(); - protected String player; - Inventory chest; - Map bannerSerialized; - private long lastDeath; - private int strikes = 0; - private int points = 0; - - // -------------------------------------------- // - // Construct - // -------------------------------------------- // - public MemoryFaction() { - } - - public MemoryFaction(String id) { - this.id = id; - this.open = Conf.newFactionsDefaultOpen; - this.tag = "???"; - this.description = TL.GENERIC_DEFAULTDESCRIPTION.toString(); - this.lastPlayerLoggedOffTime = 0; - this.peaceful = false; - this.peacefulExplosionsEnabled = false; - this.permanent = false; - this.money = 0.0; - this.powerBoost = 0.0; - this.foundedDate = System.currentTimeMillis(); - this.maxVaults = Conf.defaultMaxVaults; - this.defaultRole = Role.RECRUIT; - - resetPerms(); // Reset on new Faction so it has default values. - } - - public MemoryFaction(MemoryFaction old) { - id = old.id; - peacefulExplosionsEnabled = old.peacefulExplosionsEnabled; - permanent = old.permanent; - tag = old.tag; - description = old.description; - open = old.open; - foundedDate = old.foundedDate; - peaceful = old.peaceful; - permanentPower = old.permanentPower; - home = old.home; - lastPlayerLoggedOffTime = old.lastPlayerLoggedOffTime; - money = old.money; - powerBoost = old.powerBoost; - relationWish = old.relationWish; - claimOwnership = old.claimOwnership; - fplayers = new HashSet<>(); - alts = new HashSet<>(); - invites = old.invites; - announcements = old.announcements; - this.defaultRole = Role.NORMAL; - - resetPerms(); // Reset on new Faction so it has default values. - } - - public int getPoints() { - return points; - } - - public void setPoints(int points) { - this.points = points; - } - - public int getStrikes() { - return strikes; - } - - public void setStrikes(int strikes) { - this.strikes = strikes; - } - - public HashMap> getAnnouncements() { - return this.announcements; - } - - public void addAnnouncement(FPlayer fPlayer, String msg) { - List list = announcements.containsKey(fPlayer.getId()) ? announcements.get(fPlayer.getId()) : new ArrayList(); - list.add(msg); - announcements.put(fPlayer.getId(), list); - } - - public void sendUnreadAnnouncements(FPlayer fPlayer) { - if (!announcements.containsKey(fPlayer.getId())) { - return; - } - fPlayer.msg(TL.FACTIONS_ANNOUNCEMENT_TOP); - for (String s : announcements.get(fPlayer.getPlayer().getUniqueId().toString())) { - fPlayer.sendMessage(s); - } - fPlayer.msg(TL.FACTIONS_ANNOUNCEMENT_BOTTOM); - announcements.remove(fPlayer.getId()); - } - - public void removeAnnouncements(FPlayer fPlayer) { - announcements.remove(fPlayer.getId()); - } - - public ConcurrentHashMap getWarps() { - return this.warps; - } - - public LazyLocation getWarp(String name) { - return this.warps.get(name); - } - - public void setWarp(String name, LazyLocation loc) { - this.warps.put(name, loc); - } - - public boolean isWarp(String name) { - return this.warps.containsKey(name); - } - - public boolean removeWarp(String name) { - warpPasswords.remove(name); // remove password no matter what. - return warps.remove(name) != null; - } - - public boolean isWarpPassword(String warp, String password) { - return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password); - } - - public String getPaypal() { - return this.paypal; - } - - public void paypalSet(String paypal) { - this.paypal = paypal; - } - - public boolean hasWarpPassword(String warp) { - return warpPasswords.containsKey(warp.toLowerCase()); - } - - public void setWarpPassword(String warp, String password) { - warpPasswords.put(warp.toLowerCase(), password); - } - - public void clearWarps() { - warps.clear(); - } - - public int getMaxVaults() { - return this.maxVaults; - } - - public void setMaxVaults(int value) { - this.maxVaults = value; - } - - public String getFocused() { - return this.player; - } - - public void setFocused(String fp) { - this.player = fp; - } - - public Set getInvites() { return invites; } - - public Set getAltInvites() { return altinvites; } - - public void deinviteAlt(FPlayer fplayer) { - altinvites.remove(fplayer.getId()); - } - - public void deinviteAllAlts() { - altinvites.clear(); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public void invite(FPlayer fplayer) { - this.invites.add(fplayer.getId()); - } - - public void altInvite(FPlayer fplayer) { - this.altinvites.add(fplayer.getId()); - } - - public void deinvite(FPlayer fplayer) { - this.invites.remove(fplayer.getId()); - this.altinvites.remove(fplayer.getId()); - } - - public boolean altInvited(FPlayer fplayer) { - if (this.altinvites.contains(fplayer.getId())) - return true; - return false; - } - - public boolean isInvited(FPlayer fplayer) { - if (this.invites.contains(fplayer.getId()) || this.altinvites.contains(fplayer.getId())) { - return true; - } - return false; - } - - public void ban(FPlayer target, FPlayer banner) { - BanInfo info = new BanInfo(banner.getId(), target.getId(), System.currentTimeMillis()); - this.bans.add(info); - } - - public void unban(FPlayer player) { - bans.removeIf(banInfo -> banInfo.getBanned().equalsIgnoreCase(player.getId())); - } - - @Override - public void disband(Player disbander) { - disband(disbander, PlayerDisbandReason.PLUGIN); - } - - @Override - public void disband(Player disbander, PlayerDisbandReason reason) { - - boolean disbanderIsConsole = disbander == null; - FPlayer fdisbander = FPlayers.getInstance().getByOfflinePlayer(disbander); - - FactionDisbandEvent disbandEvent = new FactionDisbandEvent(disbander, this.getId(), reason); - Bukkit.getServer().getPluginManager().callEvent(disbandEvent); - if (disbandEvent.isCancelled()) { - return; - } - - // Send FPlayerLeaveEvent for each player in the faction - for (FPlayer fplayer : this.getFPlayers()) { - Bukkit.getServer().getPluginManager().callEvent(new FPlayerLeaveEvent(fplayer, this, FPlayerLeaveEvent.PlayerLeaveReason.DISBAND)); - } - - if (Conf.logFactionDisband) { - //TODO: Format this correctly and translate. - SaberFactions.plugin.log("The faction " + this.getTag() + " (" + this.getId() + ") was disbanded by " + (disbanderIsConsole ? "console command" : fdisbander.getName()) + "."); - } - - if (Econ.shouldBeUsed() && !disbanderIsConsole) { - // Should we prevent to withdraw money if the faction was just created - if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - this.foundedDate) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) { - msg("Your faction is too young to withdraw money like this"); - } else { - //Give all the faction's money to the disbander - double amount = Econ.getBalance(this.getAccountId()); - Econ.transferMoney(fdisbander, this, fdisbander, amount, false); - - if (amount > 0.0) { - String amountString = Econ.moneyString(amount); - msg(TL.COMMAND_DISBAND_HOLDINGS, amountString); - //TODO: Format this correctly and translate - SaberFactions.plugin.log(fdisbander.getName() + " has been given bank holdings of " + amountString + " from disbanding " + this.getTag() + "."); - } - } - } - - Factions.getInstance().removeFaction(this.getId()); - FTeamWrapper.applyUpdates(this); - } - - public boolean isBanned(FPlayer player) { - for (BanInfo info : bans) { - if (info.getBanned().equalsIgnoreCase(player.getId())) { - return true; - } - } - - return false; - } - - public Set getBannedPlayers() { - return this.bans; - } - - public String getRule(int index) { - if (rules.size() == 0) return null; - return rules.get(index); - } - - public HashMap getRulesMap() { - return rules; - } - - public void setRule(int index, String rule) { - rules.put(index, rule); - } - - public void removeRule(int index) { - HashMap newRule = rules; - newRule.remove(index); - rules = newRule; - } - - public void addTnt(int amt) { - tnt += amt; - } - - public void takeTnt(int amt) { - tnt -= amt; - } - - public int getTnt() { - return tnt; - } - - - public Location getVault() { - if (vault == null) { - return null; - } - return vault.getLocation(); - } - - public void setVault(Location vaultLocation) { - if (vaultLocation == null) { - vault = null; - return; - } - LazyLocation newlocation = new LazyLocation(vaultLocation); - vault = newlocation; - } - - public int getUpgrade(UpgradeType upgrade) { - if (upgrades.keySet().contains(upgrade.toString())) { - return upgrades.get(upgrade.toString()); - } - return 0; - } - - @Override - public Inventory getChestInventory() { - if (chest != null) { - return chest; - } else { - int level = getUpgrade(UpgradeType.CHEST); - int size = 9; - if (level == 1) { - size = SaberFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1") * 9; - } else if (level == 2) { - size = SaberFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2") * 9; - } else if (level == 3) { - size = SaberFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3") * 9; - } - - chest = Bukkit.createInventory(null, size, SaberFactions.plugin.color(SaberFactions.plugin.getConfig().getString("fchest.Inventory-Title"))); - return chest; - - } - - } - - @Override - public void setChestSize(int chestSize) { - ItemStack[] contents = this.getChestInventory().getContents(); - chest = Bukkit.createInventory(null, chestSize, SaberFactions.plugin.color(SaberFactions.plugin.getConfig().getString("fchest.Inventory-Title"))); - chest.setContents(contents); - } - - - @Override - public void setBannerPattern(ItemStack banner) { - bannerSerialized = banner.serialize(); - } - - @Override - public ItemStack getBanner() { - if (bannerSerialized == null) { - return null; - } - return ItemStack.deserialize(bannerSerialized); - } - - public void setUpgrade(UpgradeType upgrade, int level) { - upgrades.put(upgrade.toString(), level); - } - - public Location getCheckpoint() { - return checkpoint; - } - - public void setCheckpoint(Location location) { - checkpoint = location; - } - - public void clearRules() { - rules.clear(); - } - - public void addRule(String rule) { - rules.put(rules.size(), rule); - } - - public boolean getOpen() { - return open; - } - - public void setOpen(boolean isOpen) { - open = isOpen; - } - - public boolean isPeaceful() { - return this.peaceful; - } - - public void setPeaceful(boolean isPeaceful) { - this.peaceful = isPeaceful; - } - - public boolean getPeacefulExplosionsEnabled() { - return this.peacefulExplosionsEnabled; - } - - public void setPeacefulExplosionsEnabled(boolean val) { - peacefulExplosionsEnabled = val; - } - - public boolean noExplosionsInTerritory() { - return this.peaceful && !peacefulExplosionsEnabled; - } - - public boolean isPermanent() { - return permanent || !this.isNormal(); - } - - public void setPermanent(boolean isPermanent) { - permanent = isPermanent; - } - - public String getTag() { - return this.tag; - } - - public void setTag(String str) { - if (Conf.factionTagForceUpperCase) { - str = str.toUpperCase(); - } - this.tag = str; - } - - public String getTag(String prefix) { - return prefix + this.tag; - } - - public String getTag(Faction otherFaction) { - if (otherFaction == null) { - return getTag(); - } - return this.getTag(this.getColorTo(otherFaction).toString()); - } - - public String getTag(FPlayer otherFplayer) { - if (otherFplayer == null) { - return getTag(); - } - return this.getTag(this.getColorTo(otherFplayer).toString()); - } - - public String getComparisonTag() { - return MiscUtil.getComparisonString(this.tag); - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String value) { - this.description = value; - } - - public boolean hasHome() { - return this.getHome() != null; - } - - public Location getHome() { - confirmValidHome(); - return (this.home != null) ? this.home.getLocation() : null; - } - - public void setHome(Location home) { - this.home = new LazyLocation(home); - } - - public long getFoundedDate() { - if (this.foundedDate == 0) { - setFoundedDate(System.currentTimeMillis()); - } - return this.foundedDate; - } - - public void setFoundedDate(long newDate) { - this.foundedDate = newDate; - } - - public void confirmValidHome() { - if (!Conf.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && Board.getInstance().getFactionAt(new FLocation(this.home.getLocation())) == this)) { - return; - } - - msg("Your faction home has been un-set since it is no longer in your territory."); - this.home = null; - } - - public String getAccountId() { - String aid = "faction-" + this.getId(); - - // We need to override the default money given to players. - if (!Econ.hasAccount(aid)) { - Econ.setBalance(aid, 0); - } - - return aid; - } - - public Integer getPermanentPower() { - return this.permanentPower; - } - - public void setPermanentPower(Integer permanentPower) { - this.permanentPower = permanentPower; - } - - public boolean hasPermanentPower() { - return this.permanentPower != null; - } - - public double getPowerBoost() { - return this.powerBoost; - } - - public void setPowerBoost(double powerBoost) { - this.powerBoost = powerBoost; - } - - public boolean isPowerFrozen() { - int freezeSeconds = SaberFactions.plugin.getConfig().getInt("hcf.powerfreeze", 0); - return freezeSeconds != 0 && System.currentTimeMillis() - lastDeath < freezeSeconds * 1000; - - } - - public long getLastDeath() { - return this.lastDeath; - } - - // -------------------------------------------- // - // F Permissions stuff - // -------------------------------------------- // - - public void setLastDeath(long time) { - this.lastDeath = time; - } - - public int getKills() { - int kills = 0; - for (FPlayer fp : getFPlayers()) { - kills += fp.getKills(); - } - - return kills; - } - - public int getDeaths() { - int deaths = 0; - for (FPlayer fp : getFPlayers()) { - deaths += fp.getDeaths(); - } - - return deaths; - } - - public Access getAccess(Permissable permissable, PermissableAction permissableAction) { - if (permissable == null || permissableAction == null) { - return Access.UNDEFINED; - } - - Map accessMap = permissions.get(permissable); - if (accessMap != null && accessMap.containsKey(permissableAction)) { - return accessMap.get(permissableAction); - } - - return Access.UNDEFINED; - } - - /** - * Get the Access of a player. Will use player's Role if they are a faction member. Otherwise, uses their Relation. - * - * @param player - * @param permissableAction - * @return - */ - public Access getAccess(FPlayer player, PermissableAction permissableAction) { - if (player == null || permissableAction == null) { - return Access.UNDEFINED; - } - - Permissable perm; - - if (player.getFaction() == this) { - perm = player.getRole(); - } else { - perm = player.getFaction().getRelationTo(this); - } - - Map accessMap = permissions.get(perm); - if (accessMap != null && accessMap.containsKey(permissableAction)) { - return accessMap.get(permissableAction); - } - - return Access.UNDEFINED; - } - - public void setPermission(Permissable permissable, PermissableAction permissableAction, Access access) { - Map accessMap = permissions.get(permissable); - if (accessMap == null) { - accessMap = new HashMap<>(); - } - - accessMap.put(permissableAction, access); - } - - public void resetPerms() { - SaberFactions.plugin.log(Level.WARNING, "Resetting permissions for Faction: " + tag); - - permissions.clear(); - - // First populate a map with undefined as the permission for each action. - Map freshMap = new HashMap<>(); - for (PermissableAction permissableAction : PermissableAction.values()) { - freshMap.put(permissableAction, Access.UNDEFINED); - } - - // Put the map in there for each relation. - for (Relation relation : Relation.values()) { - if (relation != Relation.MEMBER) { - permissions.put(relation, new HashMap<>(freshMap)); - } - } - - // And each role. - for (Role role : Role.values()) { - if (role != Role.LEADER) { - permissions.put(role, new HashMap<>(freshMap)); - } - } - } - - public void setDefaultPerms() { - if (!Conf.useCustomDefaultPermissions) return; - Map defaultMap = new HashMap<>(); - for (PermissableAction permissableAction : PermissableAction.values()) { - defaultMap.put(permissableAction, Access.UNDEFINED); - } - // Put the map in there for each relation. - for (Relation relation : Relation.values()) { - if (relation != Relation.MEMBER) { - if (!Conf.defaultFactionPermissions.containsKey(relation.nicename.toUpperCase())) - permissions.put(relation, new HashMap<>(defaultMap)); - else - permissions.put(relation, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(relation.nicename.toUpperCase()))); - } - } - - // And each role. - for (Role role : Role.values()) { - if (role != Role.LEADER) { - if (!Conf.defaultFactionPermissions.containsKey(role.nicename.toUpperCase())) - permissions.put(role, new HashMap<>(defaultMap)); - else - permissions.put(role, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(role.nicename.toUpperCase()))); - } - } - } - - /** - * Read only map of Permissions. - * - * @return - */ - public Map> getPermissions() { - return Collections.unmodifiableMap(permissions); - } - - public Role getDefaultRole() { - return this.defaultRole; - } - - public void setDefaultRole(Role role) { - this.defaultRole = role; - } - - // -------------------------------------------- // - // Extra Getters And Setters - // -------------------------------------------- // - public boolean noPvPInTerritory() { - return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisablePVP); - } - - public boolean noMonstersInTerritory() { - return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisableMonsters); - } - - // ------------------------------- - // Understand the types - // ------------------------------- - - public boolean isNormal() { - return !(this.isWilderness() || this.isSafeZone() || this.isWarZone()); - } - - public boolean isNone() { - return this.getId().equals("0"); - } - - public boolean isWilderness() { - return this.getId().equals("0"); - } - - public boolean isSafeZone() { - return this.getId().equals("-1"); - } - - public boolean isWarZone() { - return this.getId().equals("-2"); - } - public boolean isSystemFaction() { return this.isSafeZone() || this.isWarZone() || this.isWilderness(); } - - public boolean isPlayerFreeType() { - return this.isSafeZone() || this.isWarZone(); - } - - // ------------------------------- - // Relation and relation colors - // ------------------------------- - - @Override - public String describeTo(RelationParticipator that, boolean ucfirst) { - return RelationUtil.describeThatToMe(this, that, ucfirst); - } - - @Override - public String describeTo(RelationParticipator that) { - return RelationUtil.describeThatToMe(this, that); - } - - @Override - public Relation getRelationTo(RelationParticipator rp) { - return RelationUtil.getRelationTo(this, rp); - } - - @Override - public Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful) { - return RelationUtil.getRelationTo(this, rp, ignorePeaceful); - } - - @Override - public ChatColor getColorTo(RelationParticipator rp) { - return RelationUtil.getColorOfThatToMe(this, rp); - } - - public Relation getRelationWish(Faction otherFaction) { - if (this.relationWish.containsKey(otherFaction.getId())) { - return this.relationWish.get(otherFaction.getId()); - } - return Relation.fromString(SaberFactions.plugin.getConfig().getString("default-relation", "neutral")); // Always default to old behavior. - } - - public void setRelationWish(Faction otherFaction, Relation relation) { - if (this.relationWish.containsKey(otherFaction.getId()) && relation.equals(Relation.NEUTRAL)) { - this.relationWish.remove(otherFaction.getId()); - } else { - this.relationWish.put(otherFaction.getId(), relation); - } - } - - public int getRelationCount(Relation relation) { - int count = 0; - for (Faction faction : Factions.getInstance().getAllFactions()) { - if (faction.getRelationTo(this) == relation) { - count++; - } - } - return count; - } - - // ----------------------------------------------// - // Power - // ----------------------------------------------// - public double getPower() { - if (this.hasPermanentPower()) { - return this.getPermanentPower(); - } - - double ret = 0; - for (FPlayer fplayer : fplayers) { - ret += fplayer.getPower(); - } - for (FPlayer fplayer : alts) { - ret += fplayer.getPower(); - } - if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax) { - ret = Conf.powerFactionMax; - } - return ret + this.powerBoost; - } - - public double getPowerMax() { - if (this.hasPermanentPower()) { - return this.getPermanentPower(); - } - - double ret = 0; - for (FPlayer fplayer : fplayers) { - ret += fplayer.getPowerMax(); - } - for (FPlayer fplayer : alts) { - ret += fplayer.getPowerMax(); - } - if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax) { - ret = Conf.powerFactionMax; - } - return ret + this.powerBoost; - } - - public int getPowerRounded() { - return (int) Math.round(this.getPower()); - } - - public int getPowerMaxRounded() { - return (int) Math.round(this.getPowerMax()); - } - - public int getLandRounded() { - return Board.getInstance().getFactionCoordCount(this); - } - - public int getLandRoundedInWorld(String worldName) { - return Board.getInstance().getFactionCoordCountInWorld(this, worldName); - } - - public boolean hasLandInflation() { - return this.getLandRounded() > this.getPowerRounded(); - } - - // ------------------------------- - // FPlayers - // ------------------------------- - - // maintain the reference list of FPlayers in this faction - public void refreshFPlayers() { - fplayers.clear(); - alts.clear(); - if (this.isPlayerFreeType()) { - return; - } - - for (FPlayer fplayer : FPlayers.getInstance().getAllFPlayers()) { - if (fplayer.getFactionId().equalsIgnoreCase(id)) { - if (fplayer.isAlt()) { - alts.add(fplayer); - } else { - fplayers.add(fplayer); - } - } - } - } - - public boolean addFPlayer(FPlayer fplayer) { - return !this.isPlayerFreeType() && fplayers.add(fplayer); - } - - public boolean removeFPlayer(FPlayer fplayer) { - return !this.isPlayerFreeType() && fplayers.remove(fplayer); - } - - - public boolean addAltPlayer(FPlayer fplayer) { - return !this.isPlayerFreeType() && alts.add(fplayer); - } - - public boolean removeAltPlayer(FPlayer fplayer) { - return !this.isPlayerFreeType() && alts.remove(fplayer); - } - - public int getSize() { - return fplayers.size() + alts.size(); - } - - public Set getFPlayers() { - // return a shallow copy of the FPlayer list, to prevent tampering and - // concurrency issues - return new HashSet<>(fplayers); - } - - public Set getAltPlayers() { - // return a shallow copy of the FPlayer list, to prevent tampering and - // concurrency issues - return new HashSet<>(alts); - } - - public Set getFPlayersWhereOnline(boolean online) { - Set ret = new HashSet<>(); - if (!this.isNormal()) { - return ret; - } - - for (FPlayer fplayer : fplayers) { - if (fplayer.isOnline() == online) { - ret.add(fplayer); - } - } - - return ret; - } - - public Set getFPlayersWhereOnline(boolean online, FPlayer viewer) { - Set ret = new HashSet<>(); - if (!this.isNormal()) { - return ret; - } - - for (FPlayer viewed : fplayers) { - // Add if their online status is what we want - if (viewed.isOnline() == online) { - // If we want online, check to see if we are able to see this player - // This checks if they are in vanish. - if (online - && viewed.getPlayer() != null - && viewer.getPlayer() != null - && viewer.getPlayer().canSee(viewed.getPlayer())) { - ret.add(viewed); - // If we want offline, just add them. - // Prob a better way to do this but idk. - } else if (!online) { - ret.add(viewed); - } - } - } - - return ret; - } - - - public FPlayer getFPlayerAdmin() { - if (!this.isNormal()) { - return null; - } - - for (FPlayer fplayer : fplayers) { - if (fplayer.getRole() == Role.LEADER) { - return fplayer; - } - } - return null; - } - - public FPlayer getFPlayerLeader() { - return getFPlayerAdmin(); - } - - public ArrayList getFPlayersWhereRole(Role role) { - ArrayList ret = new ArrayList<>(); - if (!this.isNormal()) { - return ret; - } - - for (FPlayer fplayer : fplayers) { - if (fplayer.getRole() == role) { - ret.add(fplayer); - } - } - - return ret; - } - - - public ArrayList getOnlinePlayers() { - ArrayList ret = new ArrayList<>(); - if (this.isPlayerFreeType()) { - return ret; - } - - for (Player player : SaberFactions.plugin.getServer().getOnlinePlayers()) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - if (fplayer.getFaction() == this && !fplayer.isAlt()) { - ret.add(player); - } - } - - return ret; - } - - // slightly faster check than getOnlinePlayers() if you just want to see if - // there are any players online - public boolean hasPlayersOnline() { - // only real factions can have players online, not safe zone / war zone - if (this.isPlayerFreeType()) { - return false; - } - - for (Player player : SaberFactions.plugin.getServer().getOnlinePlayers()) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - if (fplayer != null && fplayer.getFaction() == this) { - return true; - } - } - - // even if all players are technically logged off, maybe someone was on - // recently enough to not consider them officially offline yet - return Conf.considerFactionsReallyOfflineAfterXMinutes > 0 && System.currentTimeMillis() < lastPlayerLoggedOffTime + (Conf.considerFactionsReallyOfflineAfterXMinutes * 60000); - } - - public void memberLoggedOff() { - if (this.isNormal()) { - lastPlayerLoggedOffTime = System.currentTimeMillis(); - } - } - - // used when current leader is about to be removed from the faction; - // promotes new leader, or disbands faction if no other members left - @Override - public void promoteNewLeader() { - promoteNewLeader(false); - } - - @Override - public void promoteNewLeader(boolean autoLeave) { - if (!this.isNormal()) { - return; - } - if (this.isPermanent() && Conf.permanentFactionsDisableLeaderPromotion) { - return; - } - - FPlayer oldLeader = this.getFPlayerAdmin(); - - // get list of moderators, or list of normal members if there are no moderators - ArrayList replacements = this.getFPlayersWhereRole(Role.MODERATOR); - if (replacements == null || replacements.isEmpty()) { - replacements = this.getFPlayersWhereRole(Role.NORMAL); - } - - if (replacements == null || replacements.isEmpty()) { // faction admin is the only member; one-man faction - if (this.isPermanent()) { - if (oldLeader != null) { - oldLeader.setRole(Role.NORMAL); - } - return; - } - - // no members left and faction isn't permanent, so disband it - if (Conf.logFactionDisband) { - SaberFactions.plugin.log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left" + (autoLeave ? " and by inactivity" : "") + "."); - } - - for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - fplayer.msg("The faction %s was disbanded.", this.getTag(fplayer)); - } - - FactionDisbandEvent disbandEvent = new FactionDisbandEvent(null, getId(), autoLeave ? PlayerDisbandReason.INACTIVITY : PlayerDisbandReason.LEAVE); - Bukkit.getPluginManager().callEvent(disbandEvent); - - Factions.getInstance().removeFaction(getId()); - } else { // promote new faction admin - if (oldLeader != null) { - oldLeader.setRole(Role.NORMAL); - } - replacements.get(0).setRole(Role.LEADER); - //TODO:TL - this.msg("Faction admin %s has been removed. %s has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName()); - SaberFactions.plugin.log("Faction " + this.getTag() + " (" + this.getId() + ") admin was removed. Replacement admin: " + replacements.get(0).getName()); - } - } - - // ----------------------------------------------// - // Messages - // ----------------------------------------------// - public void msg(String message, Object... args) { - message = SaberFactions.plugin.txt.parse(message, args); - - for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) { - fplayer.sendMessage(message); - } - } - - public void msg(TL translation, Object... args) { - msg(translation.toString(), args); - } - - public void sendMessage(String message) { - for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) { - fplayer.sendMessage(message); - } - } - - public void sendMessage(List messages) { - for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) { - fplayer.sendMessage(messages); - } - } - - // ----------------------------------------------// - // Ownership of specific claims - // ----------------------------------------------// - - public Map> getClaimOwnership() { - return claimOwnership; - } - - public void clearAllClaimOwnership() { - claimOwnership.clear(); - } - - public void clearClaimOwnership(FLocation loc) { - claimOwnership.remove(loc); - } - - public void clearClaimOwnership(FPlayer player) { - if (id == null || id.isEmpty()) { - return; - } - - Set ownerData; - - for (Entry> entry : claimOwnership.entrySet()) { - ownerData = entry.getValue(); - - if (ownerData == null) { - continue; - } - - ownerData.removeIf(s -> s.equals(player.getId())); - - if (ownerData.isEmpty()) { - claimOwnership.remove(entry.getKey()); - } - } - } - - public int getCountOfClaimsWithOwners() { - return claimOwnership.isEmpty() ? 0 : claimOwnership.size(); - } - - public boolean doesLocationHaveOwnersSet(FLocation loc) { - if (claimOwnership.isEmpty() || !claimOwnership.containsKey(loc)) { - return false; - } - - Set ownerData = claimOwnership.get(loc); - return ownerData != null && !ownerData.isEmpty(); - } - - public boolean isPlayerInOwnerList(FPlayer player, FLocation loc) { - if (claimOwnership.isEmpty()) { - return false; - } - Set ownerData = claimOwnership.get(loc); - return ownerData != null && ownerData.contains(player.getId()); - } - - public void setPlayerAsOwner(FPlayer player, FLocation loc) { - Set ownerData = claimOwnership.get(loc); - if (ownerData == null) { - ownerData = new HashSet<>(); - } - ownerData.add(player.getId()); - claimOwnership.put(loc, ownerData); - } - - public void removePlayerAsOwner(FPlayer player, FLocation loc) { - Set ownerData = claimOwnership.get(loc); - if (ownerData == null) { - return; - } - ownerData.remove(player.getId()); - claimOwnership.put(loc, ownerData); - } - - public Set getOwnerList(FLocation loc) { - return claimOwnership.get(loc); - } - - public String getOwnerListString(FLocation loc) { - Set ownerData = claimOwnership.get(loc); - if (ownerData == null || ownerData.isEmpty()) { - return ""; - } - - StringBuilder ownerList = new StringBuilder(); - - for (String anOwnerData : ownerData) { - if (ownerList.length() > 0) { - ownerList.append(", "); - } - OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(anOwnerData)); - //TODO:TL - ownerList.append(offlinePlayer != null ? offlinePlayer.getName() : "null player"); - } - return ownerList.toString(); - } - - public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) { - // in own faction, with sufficient role or permission to bypass - // ownership? - if (fplayer.getFaction() == this && (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.LEADER) || Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()))) { - return true; - } - - // make sure claimOwnership is initialized - if (claimOwnership.isEmpty()) { - return true; - } - - // need to check the ownership list, then - Set ownerData = claimOwnership.get(loc); - - // if no owner list, owner list is empty, or player is in owner list, - // they're allowed - return ownerData == null || ownerData.isEmpty() || ownerData.contains(fplayer.getId()); - } - - // ----------------------------------------------// - // Persistance and entity management - // ----------------------------------------------// - public void remove() { - if (Econ.shouldBeUsed()) { - Econ.setBalance(getAccountId(), 0); - } - - // Clean the board - ((MemoryBoard) Board.getInstance()).clean(id); - - for (FPlayer fPlayer : fplayers) { - fPlayer.resetFactionData(false); - } - - - for (FPlayer fPlayer : alts) { - fPlayer.resetFactionData(false); - } - } - - public Set getAllClaims() { - return Board.getInstance().getAllClaims(this); - } + public HashMap rules = new HashMap(); + public int tnt; + public Location checkpoint; + public LazyLocation vault; + public HashMap upgrades = new HashMap<>(); + protected String id = null; + protected boolean peacefulExplosionsEnabled; + protected boolean permanent; + protected String tag; + protected String description; + protected boolean open; + protected boolean peaceful; + protected Integer permanentPower; + protected LazyLocation home; + protected long foundedDate; + protected transient long lastPlayerLoggedOffTime; + protected double money; + protected double powerBoost; + protected String paypal; + protected Map relationWish = new HashMap<>(); + protected Map> claimOwnership = new ConcurrentHashMap<>(); + protected transient Set fplayers = new HashSet<>(); + protected transient Set alts = new HashSet<>(); + protected Set invites = new HashSet<>(); + protected Set altinvites = new HashSet<>(); + protected HashMap> announcements = new HashMap<>(); + protected ConcurrentHashMap warps = new ConcurrentHashMap<>(); + protected ConcurrentHashMap warpPasswords = new ConcurrentHashMap<>(); + protected int maxVaults; + protected Role defaultRole; + protected Map> permissions = new HashMap<>(); + protected Set bans = new HashSet<>(); + protected String player; + Inventory chest; + Map bannerSerialized; + private long lastDeath; + private int strikes = 0; + private int points = 0; + + // -------------------------------------------- // + // Construct + // -------------------------------------------- // + public MemoryFaction() { + } + + public MemoryFaction(String id) { + this.id = id; + this.open = Conf.newFactionsDefaultOpen; + this.tag = "???"; + this.description = TL.GENERIC_DEFAULTDESCRIPTION.toString(); + this.lastPlayerLoggedOffTime = 0; + this.peaceful = false; + this.peacefulExplosionsEnabled = false; + this.permanent = false; + this.money = 0.0; + this.powerBoost = 0.0; + this.foundedDate = System.currentTimeMillis(); + this.maxVaults = Conf.defaultMaxVaults; + this.defaultRole = Role.RECRUIT; + + resetPerms(); // Reset on new Faction so it has default values. + } + + public MemoryFaction(MemoryFaction old) { + id = old.id; + peacefulExplosionsEnabled = old.peacefulExplosionsEnabled; + permanent = old.permanent; + tag = old.tag; + description = old.description; + open = old.open; + foundedDate = old.foundedDate; + peaceful = old.peaceful; + permanentPower = old.permanentPower; + home = old.home; + lastPlayerLoggedOffTime = old.lastPlayerLoggedOffTime; + money = old.money; + powerBoost = old.powerBoost; + relationWish = old.relationWish; + claimOwnership = old.claimOwnership; + fplayers = new HashSet<>(); + alts = new HashSet<>(); + invites = old.invites; + announcements = old.announcements; + this.defaultRole = Role.NORMAL; + + resetPerms(); // Reset on new Faction so it has default values. + } + + public int getPoints() { + return points; + } + + public void setPoints(int points) { + this.points = points; + } + + public int getStrikes() { + return strikes; + } + + public void setStrikes(int strikes) { + this.strikes = strikes; + } + + public HashMap> getAnnouncements() { + return this.announcements; + } + + public void addAnnouncement(FPlayer fPlayer, String msg) { + List list = announcements.containsKey(fPlayer.getId()) ? announcements.get(fPlayer.getId()) : new ArrayList(); + list.add(msg); + announcements.put(fPlayer.getId(), list); + } + + public void sendUnreadAnnouncements(FPlayer fPlayer) { + if (!announcements.containsKey(fPlayer.getId())) { + return; + } + fPlayer.msg(TL.FACTIONS_ANNOUNCEMENT_TOP); + for (String s : announcements.get(fPlayer.getPlayer().getUniqueId().toString())) { + fPlayer.sendMessage(s); + } + fPlayer.msg(TL.FACTIONS_ANNOUNCEMENT_BOTTOM); + announcements.remove(fPlayer.getId()); + } + + public void removeAnnouncements(FPlayer fPlayer) { + announcements.remove(fPlayer.getId()); + } + + public ConcurrentHashMap getWarps() { + return this.warps; + } + + public LazyLocation getWarp(String name) { + return this.warps.get(name); + } + + public void setWarp(String name, LazyLocation loc) { + this.warps.put(name, loc); + } + + public boolean isWarp(String name) { + return this.warps.containsKey(name); + } + + public boolean removeWarp(String name) { + warpPasswords.remove(name); // remove password no matter what. + return warps.remove(name) != null; + } + + public boolean isWarpPassword(String warp, String password) { + return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password); + } + + public String getPaypal() { + return this.paypal; + } + + public void paypalSet(String paypal) { + this.paypal = paypal; + } + + public boolean hasWarpPassword(String warp) { + return warpPasswords.containsKey(warp.toLowerCase()); + } + + public void setWarpPassword(String warp, String password) { + warpPasswords.put(warp.toLowerCase(), password); + } + + public void clearWarps() { + warps.clear(); + } + + public int getMaxVaults() { + return this.maxVaults; + } + + public void setMaxVaults(int value) { + this.maxVaults = value; + } + + public String getFocused() { + return this.player; + } + + public void setFocused(String fp) { + this.player = fp; + } + + public Set getInvites() { + return invites; + } + + public Set getAltInvites() { + return altinvites; + } + + public void deinviteAlt(FPlayer fplayer) { + altinvites.remove(fplayer.getId()); + } + + public void deinviteAllAlts() { + altinvites.clear(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public void invite(FPlayer fplayer) { + this.invites.add(fplayer.getId()); + } + + public void altInvite(FPlayer fplayer) { + this.altinvites.add(fplayer.getId()); + } + + public void deinvite(FPlayer fplayer) { + this.invites.remove(fplayer.getId()); + this.altinvites.remove(fplayer.getId()); + } + + public boolean altInvited(FPlayer fplayer) { + if (this.altinvites.contains(fplayer.getId())) + return true; + return false; + } + + public boolean isInvited(FPlayer fplayer) { + if (this.invites.contains(fplayer.getId()) || this.altinvites.contains(fplayer.getId())) { + return true; + } + return false; + } + + public void ban(FPlayer target, FPlayer banner) { + BanInfo info = new BanInfo(banner.getId(), target.getId(), System.currentTimeMillis()); + this.bans.add(info); + } + + public void unban(FPlayer player) { + bans.removeIf(banInfo -> banInfo.getBanned().equalsIgnoreCase(player.getId())); + } + + @Override + public void disband(Player disbander) { + disband(disbander, PlayerDisbandReason.PLUGIN); + } + + @Override + public void disband(Player disbander, PlayerDisbandReason reason) { + + boolean disbanderIsConsole = disbander == null; + FPlayer fdisbander = FPlayers.getInstance().getByOfflinePlayer(disbander); + + FactionDisbandEvent disbandEvent = new FactionDisbandEvent(disbander, this.getId(), reason); + Bukkit.getServer().getPluginManager().callEvent(disbandEvent); + if (disbandEvent.isCancelled()) { + return; + } + + // Send FPlayerLeaveEvent for each player in the faction + for (FPlayer fplayer : this.getFPlayers()) { + Bukkit.getServer().getPluginManager().callEvent(new FPlayerLeaveEvent(fplayer, this, FPlayerLeaveEvent.PlayerLeaveReason.DISBAND)); + } + + if (Conf.logFactionDisband) { + //TODO: Format this correctly and translate. + SaberFactions.plugin.log("The faction " + this.getTag() + " (" + this.getId() + ") was disbanded by " + (disbanderIsConsole ? "console command" : fdisbander.getName()) + "."); + } + + if (Econ.shouldBeUsed() && !disbanderIsConsole) { + // Should we prevent to withdraw money if the faction was just created + if (Conf.econFactionStartingBalance != 0 && (System.currentTimeMillis() - this.foundedDate) <= (Conf.econDenyWithdrawWhenMinutesAgeLessThan * 6000)) { + msg("Your faction is too young to withdraw money like this"); + } else { + //Give all the faction's money to the disbander + double amount = Econ.getBalance(this.getAccountId()); + Econ.transferMoney(fdisbander, this, fdisbander, amount, false); + + if (amount > 0.0) { + String amountString = Econ.moneyString(amount); + msg(TL.COMMAND_DISBAND_HOLDINGS, amountString); + //TODO: Format this correctly and translate + SaberFactions.plugin.log(fdisbander.getName() + " has been given bank holdings of " + amountString + " from disbanding " + this.getTag() + "."); + } + } + } + + Factions.getInstance().removeFaction(this.getId()); + FTeamWrapper.applyUpdates(this); + } + + public boolean isBanned(FPlayer player) { + for (BanInfo info : bans) { + if (info.getBanned().equalsIgnoreCase(player.getId())) { + return true; + } + } + + return false; + } + + public Set getBannedPlayers() { + return this.bans; + } + + public String getRule(int index) { + if (rules.size() == 0) return null; + return rules.get(index); + } + + public HashMap getRulesMap() { + return rules; + } + + public void setRule(int index, String rule) { + rules.put(index, rule); + } + + public void removeRule(int index) { + HashMap newRule = rules; + newRule.remove(index); + rules = newRule; + } + + public void addTnt(int amt) { + tnt += amt; + } + + public void takeTnt(int amt) { + tnt -= amt; + } + + public int getTnt() { + return tnt; + } + + + public Location getVault() { + if (vault == null) { + return null; + } + return vault.getLocation(); + } + + public void setVault(Location vaultLocation) { + if (vaultLocation == null) { + vault = null; + return; + } + LazyLocation newlocation = new LazyLocation(vaultLocation); + vault = newlocation; + } + + public int getUpgrade(UpgradeType upgrade) { + if (upgrades.keySet().contains(upgrade.toString())) return upgrades.get(upgrade.toString()); + return 0; + } + + @Override + public Inventory getChestInventory() { + if (chest != null) return chest; + + int size = 9; + switch (getUpgrade(UpgradeType.CHEST)) { + case 1: + size = SaberFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1") * 9; + break; + case 2: + size = SaberFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2") * 9; + break; + case 3: + size = SaberFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3") * 9; + break; + } + chest = Bukkit.createInventory(null, size, SaberFactions.plugin.color(SaberFactions.plugin.getConfig().getString("fchest.Inventory-Title"))); + return chest; + } + + + @Override + public void setChestSize(int chestSize) { + ItemStack[] contents = this.getChestInventory().getContents(); + chest = Bukkit.createInventory(null, chestSize, SaberFactions.plugin.color(SaberFactions.plugin.getConfig().getString("fchest.Inventory-Title"))); + chest.setContents(contents); + } + + + @Override + public void setBannerPattern(ItemStack banner) { + bannerSerialized = banner.serialize(); + } + + @Override + public ItemStack getBanner() { + if (bannerSerialized == null) { + return null; + } + return ItemStack.deserialize(bannerSerialized); + } + + public void setUpgrade(UpgradeType upgrade, int level) { + upgrades.put(upgrade.toString(), level); + } + + public Location getCheckpoint() { + return checkpoint; + } + + public void setCheckpoint(Location location) { + checkpoint = location; + } + + public void clearRules() { + rules.clear(); + } + + public void addRule(String rule) { + rules.put(rules.size(), rule); + } + + public boolean getOpen() { + return open; + } + + public void setOpen(boolean isOpen) { + open = isOpen; + } + + public boolean isPeaceful() { + return this.peaceful; + } + + public void setPeaceful(boolean isPeaceful) { + this.peaceful = isPeaceful; + } + + public boolean getPeacefulExplosionsEnabled() { + return this.peacefulExplosionsEnabled; + } + + public void setPeacefulExplosionsEnabled(boolean val) { + peacefulExplosionsEnabled = val; + } + + public boolean noExplosionsInTerritory() { + return this.peaceful && !peacefulExplosionsEnabled; + } + + public boolean isPermanent() { + return permanent || !this.isNormal(); + } + + public void setPermanent(boolean isPermanent) { + permanent = isPermanent; + } + + public String getTag() { + return this.tag; + } + + public void setTag(String str) { + if (Conf.factionTagForceUpperCase) { + str = str.toUpperCase(); + } + this.tag = str; + } + + public String getTag(String prefix) { + return prefix + this.tag; + } + + public String getTag(Faction otherFaction) { + if (otherFaction == null) { + return getTag(); + } + return this.getTag(this.getColorTo(otherFaction).toString()); + } + + public String getTag(FPlayer otherFplayer) { + if (otherFplayer == null) { + return getTag(); + } + return this.getTag(this.getColorTo(otherFplayer).toString()); + } + + public String getComparisonTag() { + return MiscUtil.getComparisonString(this.tag); + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String value) { + this.description = value; + } + + public boolean hasHome() { + return this.getHome() != null; + } + + public Location getHome() { + confirmValidHome(); + return (this.home != null) ? this.home.getLocation() : null; + } + + public void setHome(Location home) { + this.home = new LazyLocation(home); + } + + public long getFoundedDate() { + if (this.foundedDate == 0) { + setFoundedDate(System.currentTimeMillis()); + } + return this.foundedDate; + } + + public void setFoundedDate(long newDate) { + this.foundedDate = newDate; + } + + public void confirmValidHome() { + if (!Conf.homesMustBeInClaimedTerritory || this.home == null || (this.home.getLocation() != null && Board.getInstance().getFactionAt(new FLocation(this.home.getLocation())) == this)) { + return; + } + + msg("Your faction home has been un-set since it is no longer in your territory."); + this.home = null; + } + + public String getAccountId() { + String aid = "faction-" + this.getId(); + + // We need to override the default money given to players. + if (!Econ.hasAccount(aid)) { + Econ.setBalance(aid, 0); + } + + return aid; + } + + public Integer getPermanentPower() { + return this.permanentPower; + } + + public void setPermanentPower(Integer permanentPower) { + this.permanentPower = permanentPower; + } + + public boolean hasPermanentPower() { + return this.permanentPower != null; + } + + public double getPowerBoost() { + return this.powerBoost; + } + + public void setPowerBoost(double powerBoost) { + this.powerBoost = powerBoost; + } + + public boolean isPowerFrozen() { + int freezeSeconds = SaberFactions.plugin.getConfig().getInt("hcf.powerfreeze", 0); + return freezeSeconds != 0 && System.currentTimeMillis() - lastDeath < freezeSeconds * 1000; + + } + + public long getLastDeath() { + return this.lastDeath; + } + + // -------------------------------------------- // + // F Permissions stuff + // -------------------------------------------- // + + public void setLastDeath(long time) { + this.lastDeath = time; + } + + public int getKills() { + int kills = 0; + for (FPlayer fp : getFPlayers()) { + kills += fp.getKills(); + } + + return kills; + } + + public int getDeaths() { + int deaths = 0; + for (FPlayer fp : getFPlayers()) { + deaths += fp.getDeaths(); + } + + return deaths; + } + + public Access getAccess(Permissable permissable, PermissableAction permissableAction) { + if (permissable == null || permissableAction == null) { + return Access.UNDEFINED; + } + + Map accessMap = permissions.get(permissable); + if (accessMap != null && accessMap.containsKey(permissableAction)) { + return accessMap.get(permissableAction); + } + + return Access.UNDEFINED; + } + + /** + * Get the Access of a player. Will use player's Role if they are a faction member. Otherwise, uses their Relation. + * + * @param player + * @param permissableAction + * @return + */ + public Access getAccess(FPlayer player, PermissableAction permissableAction) { + if (player == null || permissableAction == null) { + return Access.UNDEFINED; + } + + Permissable perm; + + if (player.getFaction() == this) { + perm = player.getRole(); + } else { + perm = player.getFaction().getRelationTo(this); + } + + Map accessMap = permissions.get(perm); + if (accessMap != null && accessMap.containsKey(permissableAction)) { + return accessMap.get(permissableAction); + } + + return Access.UNDEFINED; + } + + public void setPermission(Permissable permissable, PermissableAction permissableAction, Access access) { + Map accessMap = permissions.get(permissable); + if (accessMap == null) { + accessMap = new HashMap<>(); + } + + accessMap.put(permissableAction, access); + } + + public void resetPerms() { + SaberFactions.plugin.log(Level.WARNING, "Resetting permissions for Faction: " + tag); + + permissions.clear(); + + // First populate a map with undefined as the permission for each action. + Map freshMap = new HashMap<>(); + for (PermissableAction permissableAction : PermissableAction.values()) { + freshMap.put(permissableAction, Access.UNDEFINED); + } + + // Put the map in there for each relation. + for (Relation relation : Relation.values()) { + if (relation != Relation.MEMBER) { + permissions.put(relation, new HashMap<>(freshMap)); + } + } + + // And each role. + for (Role role : Role.values()) { + if (role != Role.LEADER) { + permissions.put(role, new HashMap<>(freshMap)); + } + } + } + + public void setDefaultPerms() { + if (!Conf.useCustomDefaultPermissions) return; + Map defaultMap = new HashMap<>(); + for (PermissableAction permissableAction : PermissableAction.values()) { + defaultMap.put(permissableAction, Access.UNDEFINED); + } + // Put the map in there for each relation. + for (Relation relation : Relation.values()) { + if (relation != Relation.MEMBER) { + if (!Conf.defaultFactionPermissions.containsKey(relation.nicename.toUpperCase())) + permissions.put(relation, new HashMap<>(defaultMap)); + else + permissions.put(relation, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(relation.nicename.toUpperCase()))); + } + } + + // And each role. + for (Role role : Role.values()) { + if (role != Role.LEADER) { + if (!Conf.defaultFactionPermissions.containsKey(role.nicename.toUpperCase())) + permissions.put(role, new HashMap<>(defaultMap)); + else + permissions.put(role, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(role.nicename.toUpperCase()))); + } + } + } + + /** + * Read only map of Permissions. + * + * @return + */ + public Map> getPermissions() { + return Collections.unmodifiableMap(permissions); + } + + public Role getDefaultRole() { + return this.defaultRole; + } + + public void setDefaultRole(Role role) { + this.defaultRole = role; + } + + // -------------------------------------------- // + // Extra Getters And Setters + // -------------------------------------------- // + public boolean noPvPInTerritory() { + return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisablePVP); + } + + public boolean noMonstersInTerritory() { + return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisableMonsters); + } + + // ------------------------------- + // Understand the types + // ------------------------------- + + public boolean isNormal() { + return !(this.isWilderness() || this.isSafeZone() || this.isWarZone()); + } + + public boolean isNone() { + return this.getId().equals("0"); + } + + public boolean isWilderness() { + return this.getId().equals("0"); + } + + public boolean isSafeZone() { + return this.getId().equals("-1"); + } + + public boolean isWarZone() { + return this.getId().equals("-2"); + } + + public boolean isSystemFaction() { + return this.isSafeZone() || this.isWarZone() || this.isWilderness(); + } + + public boolean isPlayerFreeType() { + return this.isSafeZone() || this.isWarZone(); + } + + // ------------------------------- + // Relation and relation colors + // ------------------------------- + + @Override + public String describeTo(RelationParticipator that, boolean ucfirst) { + return RelationUtil.describeThatToMe(this, that, ucfirst); + } + + @Override + public String describeTo(RelationParticipator that) { + return RelationUtil.describeThatToMe(this, that); + } + + @Override + public Relation getRelationTo(RelationParticipator rp) { + return RelationUtil.getRelationTo(this, rp); + } + + @Override + public Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful) { + return RelationUtil.getRelationTo(this, rp, ignorePeaceful); + } + + @Override + public ChatColor getColorTo(RelationParticipator rp) { + return RelationUtil.getColorOfThatToMe(this, rp); + } + + public Relation getRelationWish(Faction otherFaction) { + if (this.relationWish.containsKey(otherFaction.getId())) { + return this.relationWish.get(otherFaction.getId()); + } + return Relation.fromString(SaberFactions.plugin.getConfig().getString("default-relation", "neutral")); // Always default to old behavior. + } + + public void setRelationWish(Faction otherFaction, Relation relation) { + if (this.relationWish.containsKey(otherFaction.getId()) && relation.equals(Relation.NEUTRAL)) { + this.relationWish.remove(otherFaction.getId()); + } else { + this.relationWish.put(otherFaction.getId(), relation); + } + } + + public int getRelationCount(Relation relation) { + int count = 0; + for (Faction faction : Factions.getInstance().getAllFactions()) { + if (faction.getRelationTo(this) == relation) { + count++; + } + } + return count; + } + + // ----------------------------------------------// + // Power + // ----------------------------------------------// + public double getPower() { + if (this.hasPermanentPower()) return this.getPermanentPower(); + + + double ret = 0; + for (FPlayer fplayer : fplayers) ret += fplayer.getPower(); + for (FPlayer fplayer : alts) ret += fplayer.getPower(); + if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax) { + ret = Conf.powerFactionMax; + } + return ret + this.powerBoost; + } + + public double getPowerMax() { + if (this.hasPermanentPower()) return this.getPermanentPower(); + + + double ret = 0; + for (FPlayer fplayer : fplayers) ret += fplayer.getPowerMax(); + + for (FPlayer fplayer : alts) ret += fplayer.getPowerMax(); + + if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax) { + ret = Conf.powerFactionMax; + } + return ret + this.powerBoost; + } + + public int getPowerRounded() { + return (int) Math.round(this.getPower()); + } + + public int getPowerMaxRounded() { + return (int) Math.round(this.getPowerMax()); + } + + public int getLandRounded() { + return Board.getInstance().getFactionCoordCount(this); + } + + public int getLandRoundedInWorld(String worldName) { + return Board.getInstance().getFactionCoordCountInWorld(this, worldName); + } + + public boolean hasLandInflation() { + return this.getLandRounded() > this.getPowerRounded(); + } + + // ------------------------------- + // FPlayers + // ------------------------------- + + // maintain the reference list of FPlayers in this faction + public void refreshFPlayers() { + fplayers.clear(); + alts.clear(); + if (this.isPlayerFreeType()) { + return; + } + + for (FPlayer fplayer : FPlayers.getInstance().getAllFPlayers()) { + if (fplayer.getFactionId().equalsIgnoreCase(id)) { + if (fplayer.isAlt()) { + alts.add(fplayer); + } else { + fplayers.add(fplayer); + } + } + } + } + + public boolean addFPlayer(FPlayer fplayer) { + return !this.isPlayerFreeType() && fplayers.add(fplayer); + } + + public boolean removeFPlayer(FPlayer fplayer) { + return !this.isPlayerFreeType() && fplayers.remove(fplayer); + } + + + public boolean addAltPlayer(FPlayer fplayer) { + return !this.isPlayerFreeType() && alts.add(fplayer); + } + + public boolean removeAltPlayer(FPlayer fplayer) { + return !this.isPlayerFreeType() && alts.remove(fplayer); + } + + public int getSize() { + return fplayers.size() + alts.size(); + } + + public Set getFPlayers() { + // return a shallow copy of the FPlayer list, to prevent tampering and + // concurrency issues + return new HashSet<>(fplayers); + } + + public Set getAltPlayers() { + // return a shallow copy of the FPlayer list, to prevent tampering and + // concurrency issues + return new HashSet<>(alts); + } + + public Set getFPlayersWhereOnline(boolean online) { + Set ret = new HashSet<>(); + if (!this.isNormal()) return ret; + + + for (FPlayer fplayer : fplayers) { + if (fplayer.isOnline() == online) { + ret.add(fplayer); + } + } + + return ret; + } + + public Set getFPlayersWhereOnline(boolean online, FPlayer viewer) { + Set ret = new HashSet<>(); + if (!this.isNormal()) { + return ret; + } + + for (FPlayer viewed : fplayers) { + // Add if their online status is what we want + if (viewed.isOnline() == online) { + // If we want online, check to see if we are able to see this player + // This checks if they are in vanish. + if (online + && viewed.getPlayer() != null + && viewer.getPlayer() != null + && viewer.getPlayer().canSee(viewed.getPlayer())) { + ret.add(viewed); + // If we want offline, just add them. + // Prob a better way to do this but idk. + } else if (!online) { + ret.add(viewed); + } + } + } + + return ret; + } + + + public FPlayer getFPlayerAdmin() { + if (!this.isNormal()) return null; + + + for (FPlayer fplayer : fplayers) { + if (fplayer.getRole() == Role.LEADER) { + return fplayer; + } + } + return null; + } + + public FPlayer getFPlayerLeader() { + return getFPlayerAdmin(); + } + + public ArrayList getFPlayersWhereRole(Role role) { + ArrayList ret = new ArrayList<>(); + if (!this.isNormal()) { + return ret; + } + + for (FPlayer fplayer : fplayers) { + if (fplayer.getRole() == role) { + ret.add(fplayer); + } + } + + return ret; + } + + + public ArrayList getOnlinePlayers() { + ArrayList ret = new ArrayList<>(); + if (this.isPlayerFreeType()) { + return ret; + } + + for (Player player : SaberFactions.plugin.getServer().getOnlinePlayers()) { + FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); + if (fplayer.getFaction() == this && !fplayer.isAlt()) { + ret.add(player); + } + } + + return ret; + } + + // slightly faster check than getOnlinePlayers() if you just want to see if + // there are any players online + public boolean hasPlayersOnline() { + // only real factions can have players online, not safe zone / war zone + if (this.isPlayerFreeType()) { + return false; + } + + for (Player player : SaberFactions.plugin.getServer().getOnlinePlayers()) { + FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); + if (fplayer != null && fplayer.getFaction() == this) { + return true; + } + } + + // even if all players are technically logged off, maybe someone was on + // recently enough to not consider them officially offline yet + return Conf.considerFactionsReallyOfflineAfterXMinutes > 0 && System.currentTimeMillis() < lastPlayerLoggedOffTime + (Conf.considerFactionsReallyOfflineAfterXMinutes * 60000); + } + + public void memberLoggedOff() { + if (this.isNormal()) { + lastPlayerLoggedOffTime = System.currentTimeMillis(); + } + } + + // used when current leader is about to be removed from the faction; + // promotes new leader, or disbands faction if no other members left + @Override + public void promoteNewLeader() { + promoteNewLeader(false); + } + + @Override + public void promoteNewLeader(boolean autoLeave) { + if (!this.isNormal()) { + return; + } + if (this.isPermanent() && Conf.permanentFactionsDisableLeaderPromotion) { + return; + } + + FPlayer oldLeader = this.getFPlayerAdmin(); + + // get list of moderators, or list of normal members if there are no moderators + ArrayList replacements = this.getFPlayersWhereRole(Role.MODERATOR); + if (replacements == null || replacements.isEmpty()) { + replacements = this.getFPlayersWhereRole(Role.NORMAL); + } + + if (replacements == null || replacements.isEmpty()) { // faction admin is the only member; one-man faction + if (this.isPermanent()) { + if (oldLeader != null) { + oldLeader.setRole(Role.NORMAL); + } + return; + } + + // no members left and faction isn't permanent, so disband it + if (Conf.logFactionDisband) { + SaberFactions.plugin.log("The faction " + this.getTag() + " (" + this.getId() + ") has been disbanded since it has no members left" + (autoLeave ? " and by inactivity" : "") + "."); + } + + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + fplayer.msg("The faction %s was disbanded.", this.getTag(fplayer)); + } + + FactionDisbandEvent disbandEvent = new FactionDisbandEvent(null, getId(), autoLeave ? PlayerDisbandReason.INACTIVITY : PlayerDisbandReason.LEAVE); + Bukkit.getPluginManager().callEvent(disbandEvent); + + Factions.getInstance().removeFaction(getId()); + } else { // promote new faction admin + if (oldLeader != null) { + oldLeader.setRole(Role.NORMAL); + } + replacements.get(0).setRole(Role.LEADER); + //TODO:TL + this.msg("Faction admin %s has been removed. %s has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName()); + SaberFactions.plugin.log("Faction " + this.getTag() + " (" + this.getId() + ") admin was removed. Replacement admin: " + replacements.get(0).getName()); + } + } + + // ----------------------------------------------// + // Messages + // ----------------------------------------------// + public void msg(String message, Object... args) { + message = SaberFactions.plugin.txt.parse(message, args); + + for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) { + fplayer.sendMessage(message); + } + } + + public void msg(TL translation, Object... args) { + msg(translation.toString(), args); + } + + public void sendMessage(String message) { + for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) { + fplayer.sendMessage(message); + } + } + + public void sendMessage(List messages) { + for (FPlayer fplayer : this.getFPlayersWhereOnline(true)) { + fplayer.sendMessage(messages); + } + } + + // ----------------------------------------------// + // Ownership of specific claims + // ----------------------------------------------// + + public Map> getClaimOwnership() { + return claimOwnership; + } + + public void clearAllClaimOwnership() { + claimOwnership.clear(); + } + + public void clearClaimOwnership(FLocation loc) { + claimOwnership.remove(loc); + } + + public void clearClaimOwnership(FPlayer player) { + if (id == null || id.isEmpty()) { + return; + } + + Set ownerData; + + for (Entry> entry : claimOwnership.entrySet()) { + ownerData = entry.getValue(); + + if (ownerData == null) { + continue; + } + + ownerData.removeIf(s -> s.equals(player.getId())); + + if (ownerData.isEmpty()) { + claimOwnership.remove(entry.getKey()); + } + } + } + + public int getCountOfClaimsWithOwners() { + return claimOwnership.isEmpty() ? 0 : claimOwnership.size(); + } + + public boolean doesLocationHaveOwnersSet(FLocation loc) { + if (claimOwnership.isEmpty() || !claimOwnership.containsKey(loc)) { + return false; + } + + Set ownerData = claimOwnership.get(loc); + return ownerData != null && !ownerData.isEmpty(); + } + + public boolean isPlayerInOwnerList(FPlayer player, FLocation loc) { + if (claimOwnership.isEmpty()) { + return false; + } + Set ownerData = claimOwnership.get(loc); + return ownerData != null && ownerData.contains(player.getId()); + } + + public void setPlayerAsOwner(FPlayer player, FLocation loc) { + Set ownerData = claimOwnership.get(loc); + if (ownerData == null) { + ownerData = new HashSet<>(); + } + ownerData.add(player.getId()); + claimOwnership.put(loc, ownerData); + } + + public void removePlayerAsOwner(FPlayer player, FLocation loc) { + Set ownerData = claimOwnership.get(loc); + if (ownerData == null) return; + + ownerData.remove(player.getId()); + claimOwnership.put(loc, ownerData); + } + + public Set getOwnerList(FLocation loc) { + return claimOwnership.get(loc); + } + + public String getOwnerListString(FLocation loc) { + Set ownerData = claimOwnership.get(loc); + if (ownerData == null || ownerData.isEmpty()) { + return ""; + } + + StringBuilder ownerList = new StringBuilder(); + + for (String anOwnerData : ownerData) { + if (ownerList.length() > 0) { + ownerList.append(", "); + } + OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(UUID.fromString(anOwnerData)); + //TODO:TL + ownerList.append(offlinePlayer != null ? offlinePlayer.getName() : "null player"); + } + return ownerList.toString(); + } + + public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) { + // in own faction, with sufficient role or permission to bypass + // ownership? + if (fplayer.getFaction() == this && (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.LEADER) || Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()))) return true; + + // make sure claimOwnership is initialized + if (claimOwnership.isEmpty()) return true; + + // need to check the ownership list, then + Set ownerData = claimOwnership.get(loc); + + // if no owner list, owner list is empty, or player is in owner list, + // they're allowed + return ownerData == null || ownerData.isEmpty() || ownerData.contains(fplayer.getId()); + } + + // ----------------------------------------------// + // Persistance and entity management + // ----------------------------------------------// + public void remove() { + if (Econ.shouldBeUsed()) { + Econ.setBalance(getAccountId(), 0); + } + + // Clean the board + ((MemoryBoard) Board.getInstance()).clean(id); + + for (FPlayer fPlayer : fplayers) { + fPlayer.resetFactionData(false); + } + + for (FPlayer fPlayer : alts) { + fPlayer.resetFactionData(false); + } + } + + public Set getAllClaims() { return Board.getInstance().getAllClaims(this); } }