From 8fc9ed73959db3fb2191cc26b9ba6240dcf200b5 Mon Sep 17 00:00:00 2001 From: ProSavage Date: Mon, 13 Aug 2018 00:33:40 -0500 Subject: [PATCH] Fixed all cross version material issues. --- .../java/com/massivecraft/factions/P.java | 54 +++++++++++++++++++ .../massivecraft/factions/cmd/CmdBanner.java | 9 +--- .../factions/cmd/CmdSeeChunk.java | 2 +- .../listeners/FactionsBlockListener.java | 2 +- .../listeners/FactionsExploitListener.java | 7 +-- .../listeners/FactionsPlayerListener.java | 6 +-- .../util/Particles/ParticleEffect.java | 3 +- .../zcore/fperms/PermissableAction.java | 2 +- .../zcore/fupgrades/CropUpgrades.java | 20 +++---- 9 files changed, 74 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/P.java b/src/main/java/com/massivecraft/factions/P.java index 56b4e7e1..ad20461f 100644 --- a/src/main/java/com/massivecraft/factions/P.java +++ b/src/main/java/com/massivecraft/factions/P.java @@ -69,6 +69,7 @@ public class P extends MPlugin { + public P() { p = this; } @@ -207,6 +208,59 @@ public class P extends MPlugin { this.loadSuccessful = true; } + + //multiversion material fields + public Material SUGAR_CANE_BLOCK; + public Material BANNER; + public Material CROPS; + public Material REDSTONE_LAMP_ON; + public Material STAINED_GLASS; + public Material STATIONARY_WATER; + public Material STAINED_CLAY; + public Material WOOD_BUTTON; + public Material SOIL; + public Material MOB_SPANWER; + public Material THIN_GLASS; + public Material IRON_FENCE; + public Material NETHER_FENCE; + public Material FENCE; + + private void setupMultiversionMaterials() { + if (!mc113) { + BANNER = Material.valueOf("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"); + } else { + BANNER = Material.valueOf("LEGACY_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"); + } + + + } + private void setupPlaceholderAPI() { Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI"); if (clip != null && clip.isEnabled()) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java b/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java index b3457ecd..1371ec9c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBanner.java @@ -52,15 +52,10 @@ public class CmdBanner extends FCommand { } else { - Material banner; - if (!P.p.mc113) { - banner = Material.valueOf("BANNER"); - } else { - banner = Material.valueOf("LEGACY_BANNER"); - } - warBanner = P.p.createItem(banner, 1, (short) 1, P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore")); + + warBanner = P.p.createItem(P.p.BANNER, 1, (short) 1, P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore")); } fme.msg(TL.COMMAND_BANNER_SUCCESS); warBanner.setAmount(1); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java index 26fba199..8fdc970e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSeeChunk.java @@ -131,7 +131,7 @@ public class CmdSeeChunk extends FCommand { } else { - Material type = blockY % 5 == 0 ? Material.LEGACY_REDSTONE_LAMP_ON : Material.LEGACY_STAINED_GLASS; + Material type = blockY % 5 == 0 ? P.p.REDSTONE_LAMP_ON : P.p.STAINED_GLASS; 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 4e48441d..7fb0b14a 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -78,7 +78,7 @@ public class FactionsBlockListener implements Listener { if (!fme.hasFaction()) { return; } - if (event.getBlock().getType() == Material.LEGACY_MOB_SPAWNER) { + if (event.getBlock().getType() == P.p.MOB_SPANWER) { if (!fme.isAdminBypassing()) { Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER); if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) { diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java index 967211a2..1e7beb65 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsExploitListener.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.listeners; import com.massivecraft.factions.Conf; +import com.massivecraft.factions.P; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -47,9 +48,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 == Material.LEGACY_THIN_GLASS - || mat == Material.LEGACY_IRON_FENCE) && clippingThrough(target, from, 0.65)) - || ((mat == Material.LEGACY_FENCE || mat == Material.LEGACY_NETHER_FENCE) && clippingThrough(target, from, 0.45))) { + if (((mat == P.p.THIN_GLASS + || mat == P.p.IRON_FENCE) && clippingThrough(target, from, 0.65)) + || ((mat == P.p.FENCE || mat == P.p.NETHER_FENCE) && 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 e5090f3f..445bef56 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -305,7 +305,7 @@ public class FactionsPlayerListener implements Listener { // You may use any block unless it is another faction's territory... if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials) || (rel.isTruce() && Conf.territoryTruceProtectMaterials)) { if (!justCheck) { - me.msg(TL.PLAYER_USE_TERRITORY, (material == Material.LEGACY_SOIL ? "trample " : "use ") + TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); + me.msg(TL.PLAYER_USE_TERRITORY, (material == P.p.SOIL ? "trample " : "use ") + TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); } return false; } @@ -786,7 +786,7 @@ public class FactionsPlayerListener implements Listener { return; } - if (e.getItemInHand().getType() == Material.LEGACY_BANNER) { + if (e.getItemInHand().getType() == P.p.BANNER) { ItemStack bannerInHand = e.getItemInHand(); FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer()); ItemStack warBanner = fme.getFaction().getBanner(); @@ -796,7 +796,7 @@ public class FactionsPlayerListener implements Listener { warmeta.setLore(P.p.colorList(P.p.getConfig().getStringList("fbanners.Item.Lore"))); warBanner.setItemMeta(warmeta); } else { - warBanner = P.p.createItem(Material.LEGACY_BANNER, 1, (short) 1, P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore")); + warBanner = P.p.createItem(P.p.BANNER, 1, (short) 1, P.p.getConfig().getString("fbanners.Item.Name"), P.p.getConfig().getStringList("fbanners.Item.Lore")); } if (warBanner.isSimilar(bannerInHand)) { 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 226677d9..d4ebd837 100644 --- a/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java +++ b/src/main/java/com/massivecraft/factions/util/Particles/ParticleEffect.java @@ -1,5 +1,6 @@ package com.massivecraft.factions.util.Particles; +import com.massivecraft.factions.P; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.Location; @@ -453,7 +454,7 @@ public enum ParticleEffect { */ private static boolean isWater(Location location) { Material material = location.getBlock().getType(); - return material == Material.WATER || material == Material.LEGACY_STATIONARY_WATER; + return material == Material.WATER || material == P.p.STATIONARY_WATER; } /** 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 aade947c..714f85d6 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java @@ -96,7 +96,7 @@ public enum PermissableAction { } Material material = Material.matchMaterial(section.getString("materials." + name().toLowerCase().replace('_', '-'))); if (material == null) { - material = Material.LEGACY_STAINED_CLAY; + material = P.p.STAINED_CLAY; } Access access = fme.getFaction().getAccess(permissable, this); 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 47864424..4323af65 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/CropUpgrades.java @@ -47,13 +47,9 @@ public class CropUpgrades implements Listener { private void growCrop(BlockGrowEvent e) { Material CROPS; - if (P.p.mc113) { - CROPS = Material.valueOf("LEGACY_CROPS"); - } else { - CROPS = Material.valueOf("CROPS"); - } - if (e.getBlock().getType().equals(CROPS)) { + + if (e.getBlock().getType().equals(P.p.CROPS)) { e.setCancelled(true); Crops c = new Crops(CropState.RIPE); org.bukkit.block.BlockState bs = e.getBlock().getState(); @@ -61,19 +57,15 @@ public class CropUpgrades implements Listener { bs.update(); } org.bukkit.block.Block below = e.getBlock().getLocation().subtract(0, 1, 0).getBlock(); - Material SUGARCANEBLOCK; - if (P.p.mc113) { - SUGARCANEBLOCK = Material.valueOf("LEGACY_SUGAR_CANE_BLOCK"); - } else { - SUGARCANEBLOCK = Material.valueOf("SUGAR_CANE_BLOCK"); - } - if (below.getType() == SUGARCANEBLOCK) { + + + if (below.getType() == P.p.SUGARCANEBLOCK) { org.bukkit.block.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(SUGARCANEBLOCK); + above.setType(P.p.SUGARCANEBLOCK); } }