diff --git a/pom.xml b/pom.xml index 38637bc..d93b253 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ md_5-releases - http://repo.md-5.net/content/repositories/releases/ + http://repo.mvdw-software.be/content/groups/public/http://repo.md-5.net/content/repositories/releases/<--> spigot-repo @@ -74,7 +74,7 @@ org.bukkit bukkit - 1.10.2-R0.1-SNAPSHOT + 18w03b-R0.1-SNAPSHOT1.12.2<--> provided diff --git a/src/com/dre/brewery/BCauldron.java b/src/com/dre/brewery/BCauldron.java index 03421ce..5d985b0 100644 --- a/src/com/dre/brewery/BCauldron.java +++ b/src/com/dre/brewery/BCauldron.java @@ -36,7 +36,7 @@ public class BCauldron { public void onUpdate() { // Check if fire still alive - if (!block.getChunk().isLoaded() || block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || block.getRelative(BlockFace.DOWN).getType() == Material.STATIONARY_LAVA + if (!block.getChunk().isLoaded() || block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || block.getRelative(BlockFace.DOWN).getType() == LegacyUtil.LAVA || block.getRelative(BlockFace.DOWN).getType() == Material.LAVA) { // add a minute to cooking time state++; diff --git a/src/com/dre/brewery/BRecipe.java b/src/com/dre/brewery/BRecipe.java index 22830f3..836acfd 100644 --- a/src/com/dre/brewery/BRecipe.java +++ b/src/com/dre/brewery/BRecipe.java @@ -64,7 +64,7 @@ public class BRecipe { if (durability == -1 && vaultItem.getSubTypeId() != 0) { durability = vaultItem.getSubTypeId(); } - if (mat == Material.LEAVES) { + if (mat.name().contains("LEAVES")) { if (durability > 3) { durability -= 4; // Vault has leaves with higher durability } diff --git a/src/com/dre/brewery/Barrel.java b/src/com/dre/brewery/Barrel.java index ae73bb1..5407867 100644 --- a/src/com/dre/brewery/Barrel.java +++ b/src/com/dre/brewery/Barrel.java @@ -161,7 +161,7 @@ public class Barrel implements InventoryHolder { if (plugin != null) { // If the Clicked Block was the Sign, LWC already knows and we dont need to do anything here - if (!isSign(event.getClickedBlock())) { + if (!LegacyUtil.isSign(event.getClickedBlock().getType())) { Block sign = getSignOfSpigot(); // If the Barrel does not have a Sign, it cannot be locked if (!sign.equals(event.getClickedBlock())) { @@ -272,7 +272,7 @@ public class Barrel implements InventoryHolder { // Returns true if this Block is part of this Barrel public boolean hasBlock(Block block) { if (block != null) { - if (block.getType().equals(Material.WOOD)) { + if (LegacyUtil.isWoodPlanks(block.getType())) { if (hasWoodBlock(block)) { return true; } @@ -398,7 +398,7 @@ public class Barrel implements InventoryHolder { // Get the barrel by its corpus (Wood Planks, Stairs) public static Barrel getByWood(Block wood) { - if (wood.getType().equals(Material.WOOD)) { + if (LegacyUtil.isWoodPlanks(wood.getType())) { for (Barrel barrel : barrels) { if (barrel.hasWoodBlock(wood)) { return barrel; @@ -427,7 +427,7 @@ public class Barrel implements InventoryHolder { if (barrel == null) { barrel = new Barrel(spigot, signoffset); if (barrel.getBrokenBlock(true) == null) { - if (isSign(spigot)) { + if (LegacyUtil.isSign(spigot.getType())) { if (!player.hasPermission("brewery.createbarrel.small")) { P.p.msg(player, P.p.languageReader.get("Perms_NoSmallBarrelCreate")); return false; @@ -582,11 +582,11 @@ public class Barrel implements InventoryHolder { public static int getDirection(Block spigot) { int direction = 0;// 1=x+ 2=x- 3=z+ 4=z- Material type = spigot.getRelative(0, 0, 1).getType(); - if (type == Material.WOOD || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { direction = 3; } type = spigot.getRelative(0, 0, -1).getType(); - if (type == Material.WOOD || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { if (direction == 0) { direction = 4; } else { @@ -594,7 +594,7 @@ public class Barrel implements InventoryHolder { } } type = spigot.getRelative(1, 0, 0).getType(); - if (type == Material.WOOD || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { if (direction == 0) { direction = 1; } else { @@ -602,7 +602,7 @@ public class Barrel implements InventoryHolder { } } type = spigot.getRelative(-1, 0, 0).getType(); - if (type == Material.WOOD || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { if (direction == 0) { direction = 2; } else { @@ -614,12 +614,7 @@ public class Barrel implements InventoryHolder { // is this a Large barrel? public boolean isLarge() { - return !isSign(spigot); - } - - // true for small barrels - public static boolean isSign(Block spigot) { - return spigot.getType() == Material.WALL_SIGN || spigot.getType() == Material.SIGN_POST; + return !LegacyUtil.isSign(spigot.getType()); } // woodtype of the block the spigot is attached to @@ -695,11 +690,11 @@ public class Barrel implements InventoryHolder { // returns the Sign of a large barrel, the spigot if there is none public Block getSignOfSpigot() { if (signoffset != 0) { - if (isSign(spigot)) { + if (LegacyUtil.isSign(spigot.getType())) { return spigot; } - if (isSign(spigot.getRelative(0, signoffset, 0))) { + if (LegacyUtil.isSign(spigot.getRelative(0, signoffset, 0).getType())) { return spigot.getRelative(0, signoffset, 0); } else { signoffset = 0; @@ -759,7 +754,7 @@ public class Barrel implements InventoryHolder { public Block getBrokenBlock(boolean force) { if (force || spigot.getChunk().isLoaded()) { spigot = getSpigotOfSign(spigot); - if (isSign(spigot)) { + if (LegacyUtil.isSign(spigot.getType())) { return checkSBarrel(); } else { return checkLBarrel(); @@ -906,8 +901,8 @@ public class Barrel implements InventoryHolder { continue; } } - if (type == Material.WOOD || isStairs(type)) { - if (type == Material.WOOD) { + if (LegacyUtil.isWoodPlanks(type) || isStairs(type)) { + if (LegacyUtil.isWoodPlanks(type)) { woods.add(block.getX()); woods.add(block.getY()); woods.add(block.getZ()); diff --git a/src/com/dre/brewery/LegacyUtil.java b/src/com/dre/brewery/LegacyUtil.java new file mode 100644 index 0000000..b82b5c4 --- /dev/null +++ b/src/com/dre/brewery/LegacyUtil.java @@ -0,0 +1,19 @@ +package com.dre.brewery; + +import org.bukkit.Material; + +public class LegacyUtil { + + public static final Material FLOWING_LAVA = Material.valueOf(P.use1_13 ? "FLOWING_LAVA" : "LAVA"); + public static final Material LAVA = Material.valueOf(P.use1_13 ? "LAVA" : "STATIONARY_LAVA"); + public static final Material CLOCK = Material.valueOf(P.use1_13 ? "CLOCK" : "WATCH"); + + public static boolean isWoodPlanks(Material type) { + return type.name().contains("PLANKS") || type.name().equals("WOOD"); + } + + public static boolean isSign(Material type) { + return type.name().equals("LEGACY_SIGN_POST") || type == Material.SIGN || type == Material.WALL_SIGN; + } + +} diff --git a/src/com/dre/brewery/P.java b/src/com/dre/brewery/P.java index 45df16c..d8cf2ab 100644 --- a/src/com/dre/brewery/P.java +++ b/src/com/dre/brewery/P.java @@ -39,6 +39,7 @@ public class P extends JavaPlugin { public static boolean debug; public static boolean useUUID; public static boolean use1_9; + public static boolean use1_13; public static boolean updateCheck; // Third Party Enabled @@ -70,6 +71,7 @@ public class P extends JavaPlugin { String v = Bukkit.getBukkitVersion(); useUUID = !v.matches("(^|.*[^\\.\\d])1\\.[0-6]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.7\\.[0-5]([^\\d].*|$)"); use1_9 = !v.matches("(^|.*[^\\.\\d])1\\.[0-8]([^\\d].*|$)"); + use1_13 = !v.matches("(^|.*[^\\.\\d])1\\.1[0-2]([^\\d].*|$)") && !v.matches("(^|.*[^\\.\\d])1\\.[0-9]([^\\d].*|$)"); // load the Config try { diff --git a/src/com/dre/brewery/listeners/PlayerListener.java b/src/com/dre/brewery/listeners/PlayerListener.java index abf6911..f62c1c2 100644 --- a/src/com/dre/brewery/listeners/PlayerListener.java +++ b/src/com/dre/brewery/listeners/PlayerListener.java @@ -42,7 +42,7 @@ public class PlayerListener implements Listener { if (materialInHand == null || materialInHand == Material.BUCKET) { return; - } else if (materialInHand == Material.WATCH) { + } else if (materialInHand == LegacyUtil.CLOCK) { BCauldron.printTime(player, clickedBlock); return; @@ -78,7 +78,7 @@ public class PlayerListener implements Listener { // Check if fire alive below cauldron when adding ingredients Block down = clickedBlock.getRelative(BlockFace.DOWN); - if (down.getType() == Material.FIRE || down.getType() == Material.STATIONARY_LAVA || down.getType() == Material.LAVA) { + if (down.getType() == Material.FIRE || down.getType() == LegacyUtil.LAVA || down.getType() == LegacyUtil.FLOWING_LAVA) { event.setCancelled(true); boolean handSwap = false; @@ -147,7 +147,7 @@ public class PlayerListener implements Listener { // Access a Barrel Barrel barrel = null; - if (type == Material.WOOD) { + if (LegacyUtil.isWoodPlanks(type)) { if (openEverywhere) { barrel = Barrel.get(clickedBlock); } @@ -160,7 +160,7 @@ public class PlayerListener implements Listener { break; } } - } else if (Barrel.isFence(type) || type == Material.SIGN_POST || type == Material.WALL_SIGN) { + } else if (Barrel.isFence(type) || LegacyUtil.isSign(type)) { barrel = Barrel.getBySpigot(clickedBlock); }