diff --git a/pom.xml b/pom.xml
index 122bbd3..119858c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@
spigot-repo
- http://repo.mvdw-software.be/content/groups/public/
+ https://hub.spigotmc.org/nexus/content/groups/public/
vault-repo
@@ -60,6 +60,10 @@
sk89q-repo
http://maven.sk89q.com/repo/
+
+ jitpack.io
+ https://jitpack.io
+
dre2n-rpo
http://erethon.de/repo/
@@ -70,7 +74,7 @@
org.bukkit
bukkit
- 18w03b-R0.1-SNAPSHOT
+ 1.13-R0.1-SNAPSHOT
provided
@@ -92,7 +96,7 @@
provided
- me.ryanhamshire
+ com.github.TechFortress
GriefPrevention
16.8
provided
diff --git a/resources/plugin.yml b/resources/plugin.yml
index 3e3bd01..25d1d21 100644
--- a/resources/plugin.yml
+++ b/resources/plugin.yml
@@ -1,8 +1,9 @@
name: ${project.name}
version: ${project.version}
main: com.dre.brewery.P
-authors: [Milan Albrecht, Frank Baumann, ProgrammerDan]
+authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention, Vault]
+#api-version: 1.13
commands:
brewery:
description: Command for Administration
diff --git a/src/com/dre/brewery/BCauldron.java b/src/com/dre/brewery/BCauldron.java
index 5d985b0..359295f 100644
--- a/src/com/dre/brewery/BCauldron.java
+++ b/src/com/dre/brewery/BCauldron.java
@@ -9,8 +9,6 @@ import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Effect;
import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.material.Cauldron;
-import org.bukkit.material.MaterialData;
public class BCauldron {
public static CopyOnWriteArrayList bcauldrons = new CopyOnWriteArrayList<>();
@@ -36,8 +34,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() == LegacyUtil.LAVA
- || block.getRelative(BlockFace.DOWN).getType() == Material.LAVA) {
+ if (!block.getChunk().isLoaded() || block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || LegacyUtil.isLava(block.getRelative(BlockFace.DOWN).getType())) {
// add a minute to cooking time
state++;
if (someRemoved) {
@@ -74,7 +71,7 @@ public class BCauldron {
// get cauldron from block and add given ingredient
public static boolean ingredientAdd(Block block, ItemStack ingredient) {
// if not empty
- if (getFillLevel(block) != 0) {
+ if (LegacyUtil.getFillLevel(block) != 0) {
BCauldron bcauldron = get(block);
if (bcauldron != null) {
bcauldron.add(ingredient);
@@ -125,24 +122,6 @@ public class BCauldron {
return false;
}
- // 0 = empty, 1 = something in, 2 = full
- public static byte getFillLevel(Block block) {
- if (block.getType() == Material.CAULDRON) {
- MaterialData data = block.getState().getData();
- if (data instanceof Cauldron) {
- Cauldron cauldron = (Cauldron) data;
- if (cauldron.isEmpty()) {
- return 0;
- } else if (cauldron.isFull()) {
- return 2;
- } else {
- return 1;
- }
- }
- }
- return 0;
- }
-
// prints the current cooking time to the player
public static void printTime(Player player, Block block) {
if (!player.hasPermission("brewery.cauldron.time")) {
@@ -161,7 +140,7 @@ public class BCauldron {
// reset to normal cauldron
public static void remove(Block block) {
- if (getFillLevel(block) != 0) {
+ if (LegacyUtil.getFillLevel(block) != 0) {
BCauldron bcauldron = get(block);
if (bcauldron != null) {
bcauldrons.remove(bcauldron);
diff --git a/src/com/dre/brewery/Barrel.java b/src/com/dre/brewery/Barrel.java
index e32aa6e..4ee0f47 100644
--- a/src/com/dre/brewery/Barrel.java
+++ b/src/com/dre/brewery/Barrel.java
@@ -5,7 +5,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Map;
import org.bukkit.Material;
-import org.bukkit.TreeSpecies;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.block.Block;
@@ -15,10 +14,6 @@ import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.material.MaterialData;
-import org.bukkit.material.Stairs;
-import org.bukkit.material.Tree;
-import org.bukkit.material.Wood;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
@@ -612,50 +607,7 @@ public class Barrel implements InventoryHolder {
default:
wood = spigot.getRelative(0, 0, -1);
}
-
- Material type = wood.getType();
- if (LegacyUtil.isWoodPlanks(type)) {
- MaterialData data = wood.getState().getData();
- TreeSpecies woodType;
- if (data instanceof Tree) {
- woodType = ((Tree) data).getSpecies();
- } else if (data instanceof Wood) {
- woodType = ((Wood) data).getSpecies();
- } else {
- return 0;
- }
-
- switch (woodType) {
- case GENERIC:
- return 2;
- case REDWOOD:
- return 4;
- case BIRCH:
- return 1;
- case JUNGLE:
- return 3;
- case ACACIA:
- return 5;
- case DARK_OAK:
- return 6;
- default:
- return 0;
- }
- } else if (type == LegacyUtil.OAK_STAIRS) {
- return 2;
- } else if (type == LegacyUtil.SPRUCE_STAIRS) {
- return 4;
- } else if (type == LegacyUtil.BIRCH_STAIRS) {
- return 1;
- } else if (type == LegacyUtil.JUNGLE_STAIRS) {
- return 3;
- } else if (type == LegacyUtil.ACACIA_STAIRS) {
- return 5;
- } else if (type == LegacyUtil.DARK_OAK_STAIRS) {
- return 6;
- } else {
- return 0;
- }
+ return LegacyUtil.getWoodType(wood);
}
// returns the Sign of a large barrel, the spigot if there is none
@@ -751,11 +703,8 @@ public class Barrel implements InventoryHolder {
if (LegacyUtil.isWoodStairs(type)) {
if (y == 0) {
// stairs have to be upside down
- MaterialData data = block.getState().getData();
- if (data instanceof Stairs) {
- if (!((Stairs) data).isInverted()) {
- return block;
- }
+ if (!LegacyUtil.areStairsInverted(block)) {
+ return block;
}
}
stairs.add(block.getX());
diff --git a/src/com/dre/brewery/LegacyUtil.java b/src/com/dre/brewery/LegacyUtil.java
index 54bd9f5..3857e2e 100644
--- a/src/com/dre/brewery/LegacyUtil.java
+++ b/src/com/dre/brewery/LegacyUtil.java
@@ -4,7 +4,15 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.bukkit.Location;
import org.bukkit.Material;
+import org.bukkit.TreeSpecies;
import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.block.data.BlockData;
+import org.bukkit.block.data.Levelled;
+import org.bukkit.material.Cauldron;
+import org.bukkit.material.MaterialData;
+import org.bukkit.material.Tree;
+import org.bukkit.material.Wood;
public class LegacyUtil {
@@ -19,8 +27,6 @@ public class LegacyUtil {
}
}
- public static final Material FLOWING_LAVA = get("FLOWING_LAVA", "LAVA");
- public static final Material LAVA = get("LAVA", "STATIONARY_LAVA");
public static final Material CLOCK = get("CLOCK", "WATCH");
public static final Material OAK_STAIRS = get("OAK_STAIRS", "WOOD_STAIRS");
public static final Material SPRUCE_STAIRS = get("SPRUCE_STAIRS", "SPRUCE_WOOD_STAIRS");
@@ -54,14 +60,105 @@ public class LegacyUtil {
|| (type == ACACIA_STAIRS && ACACIA_STAIRS != null) || (type == DARK_OAK_STAIRS && DARK_OAK_STAIRS != null);
}
- public static boolean isFence(Material material) {
- return material.name().endsWith("FENCE");
+ public static boolean isFence(Material type) {
+ return type.name().endsWith("FENCE");
}
public static boolean isSign(Material type) {
return type.name().equals("SIGN_POST") || type == Material.SIGN || type == Material.WALL_SIGN;
}
+ // LAVA and STATIONARY_LAVA are merged as of 1.13
+ public static boolean isLava(Material type) {
+ return type.name().equals("STATIONARY_LAVA") || type == Material.LAVA;
+ }
+
+ public static boolean areStairsInverted(Block block) {
+ if (P.use1_13) {
+ MaterialData data = block.getState().getData();
+ return data instanceof org.bukkit.material.Stairs && (((org.bukkit.material.Stairs) data).isInverted());
+ } else {
+ BlockData data = block.getBlockData();
+ return data instanceof org.bukkit.block.data.type.Stairs && ((org.bukkit.block.data.type.Stairs) data).getHalf() == org.bukkit.block.data.type.Stairs.Half.TOP;
+ }
+ }
+
+ public static byte getWoodType(Block wood) {
+ TreeSpecies woodType = null;
+
+ if (P.use1_13 || isWoodStairs(wood.getType())) {
+ String material = wood.getType().name();
+ if (material.startsWith("OAK")) {
+ woodType = TreeSpecies.GENERIC;
+ } else if (material.startsWith("SPRUCE")) {
+ woodType = TreeSpecies.REDWOOD;
+ } else if (material.startsWith("BIRCH")) {
+ woodType = TreeSpecies.BIRCH;
+ } else if (material.startsWith("JUNGLE")) {
+ woodType = TreeSpecies.JUNGLE;
+ } else if (material.startsWith("ACACIA")) {
+ woodType = TreeSpecies.ACACIA;
+ } else if (material.startsWith("DARK_OAK")) {
+ woodType = TreeSpecies.DARK_OAK;
+ }
+
+ } else {
+ MaterialData data = wood.getState().getData();
+ if (data instanceof Tree) {
+ woodType = ((Tree) data).getSpecies();
+ } else if (data instanceof Wood) {
+ woodType = ((Wood) data).getSpecies();
+ } else {
+ return 0;
+ }
+ }
+
+ switch (woodType) {
+ case GENERIC:
+ return 2;
+ case REDWOOD:
+ return 4;
+ case BIRCH:
+ return 1;
+ case JUNGLE:
+ return 3;
+ case ACACIA:
+ return 5;
+ case DARK_OAK:
+ return 6;
+ default:
+ return 0;
+ }
+ }
+
+ // 0 = empty, 1 = something in, 2 = full
+ public static byte getFillLevel(Block block) {
+ if (block.getType() != Material.CAULDRON) {
+ return 0;
+ }
+
+ if (P.use1_13) {
+ Levelled cauldron = ((Levelled) block);
+ if (cauldron.getLevel() == 0) {
+ return 0;
+ } else if (cauldron.getLevel() == cauldron.getMaximumLevel()) {
+ return 2;
+ } else {
+ return 1;
+ }
+
+ } else {
+ Cauldron cauldron = (Cauldron) block.getState().getData();
+ if (cauldron.isEmpty()) {
+ return 0;
+ } else if (cauldron.isFull()) {
+ return 2;
+ } else {
+ return 1;
+ }
+ }
+ }
+
public static Material getMaterial(int id) {
try {
return GET_MATERIAL != null ? (Material) GET_MATERIAL.invoke(null, id) : null;
diff --git a/src/com/dre/brewery/listeners/PlayerListener.java b/src/com/dre/brewery/listeners/PlayerListener.java
index 457333c..6623fcd 100644
--- a/src/com/dre/brewery/listeners/PlayerListener.java
+++ b/src/com/dre/brewery/listeners/PlayerListener.java
@@ -67,18 +67,17 @@ public class PlayerListener implements Listener {
// reset cauldron when refilling to prevent unlimited source of potions
} else if (materialInHand == Material.WATER_BUCKET) {
if (!P.use1_9) {
- if (BCauldron.getFillLevel(clickedBlock) != 0 && BCauldron.getFillLevel(clickedBlock) < 2) {
+ if (LegacyUtil.getFillLevel(clickedBlock) == 1) {
// will only remove when existing
BCauldron.remove(clickedBlock);
}
}
return;
-
}
// Check if fire alive below cauldron when adding ingredients
Block down = clickedBlock.getRelative(BlockFace.DOWN);
- if (down.getType() == Material.FIRE || down.getType() == LegacyUtil.LAVA || down.getType() == LegacyUtil.FLOWING_LAVA) {
+ if (down.getType() == Material.FIRE || LegacyUtil.isLava(down.getType())) {
event.setCancelled(true);
boolean handSwap = false;