Fixed Brewing Stands not showing the correct Time

Changed some whitespaces
Less String comparisons again
This commit is contained in:
Sn0wStorm
2018-10-30 15:16:17 +01:00
parent 086f5b5c9e
commit d29b8defd4
4 changed files with 147 additions and 126 deletions
-1
View File
@@ -10,7 +10,6 @@ import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.material.Cauldron;
public class BCauldron { public class BCauldron {
public static CopyOnWriteArrayList<BCauldron> bcauldrons = new CopyOnWriteArrayList<>(); public static CopyOnWriteArrayList<BCauldron> bcauldrons = new CopyOnWriteArrayList<>();
+23 -3
View File
@@ -15,6 +15,8 @@ import org.bukkit.material.Wood;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("JavaReflectionMemberAccess") @SuppressWarnings("JavaReflectionMemberAccess")
public class LegacyUtil { public class LegacyUtil {
@@ -32,6 +34,22 @@ public class LegacyUtil {
SET_DATA = Class.forName(Bukkit.getServer().getClass().getPackage().getName() + ".block.CraftBlock").getDeclaredMethod("setData", byte.class); SET_DATA = Class.forName(Bukkit.getServer().getClass().getPackage().getName() + ".block.CraftBlock").getDeclaredMethod("setData", byte.class);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException ignored) { } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ignored) {
} }
List<Material> planks = new ArrayList<>(6);
for (Material m : Material.values()) {
if (m.name().endsWith("PLANKS")) {
planks.add(m);
}
}
PLANKS = planks;
List<Material> fences = new ArrayList<>(7);
for (Material m : Material.values()) {
if (m.name().endsWith("FENCE")) {
fences.add(m);
}
}
FENCES = fences;
} }
public static final Material CLOCK = get("CLOCK", "WATCH"); public static final Material CLOCK = get("CLOCK", "WATCH");
@@ -41,6 +59,8 @@ public class LegacyUtil {
public static final Material JUNGLE_STAIRS = get("JUNGLE_STAIRS", "JUNGLE_WOOD_STAIRS"); public static final Material JUNGLE_STAIRS = get("JUNGLE_STAIRS", "JUNGLE_WOOD_STAIRS");
public static final Material ACACIA_STAIRS = get("ACACIA_STAIRS"); public static final Material ACACIA_STAIRS = get("ACACIA_STAIRS");
public static final Material DARK_OAK_STAIRS = get("DARK_OAK_STAIRS"); public static final Material DARK_OAK_STAIRS = get("DARK_OAK_STAIRS");
public static final List<Material> PLANKS;
public static final List<Material> FENCES;
// Materials removed in 1.13 // Materials removed in 1.13
public static final Material STATIONARY_LAVA = get("STATIONARY_LAVA"); public static final Material STATIONARY_LAVA = get("STATIONARY_LAVA");
@@ -64,7 +84,7 @@ public class LegacyUtil {
} }
public static boolean isWoodPlanks(Material type) { public static boolean isWoodPlanks(Material type) {
return type.name().endsWith("PLANKS") || (WOOD != null && type == WOOD); return (WOOD != null && type == WOOD) || PLANKS.contains(type);
} }
public static boolean isWoodStairs(Material type) { public static boolean isWoodStairs(Material type) {
@@ -73,7 +93,7 @@ public class LegacyUtil {
} }
public static boolean isFence(Material type) { public static boolean isFence(Material type) {
return type.name().endsWith("FENCE"); return FENCES.contains(type);
} }
public static boolean isSign(Material type) { public static boolean isSign(Material type) {
@@ -176,7 +196,7 @@ public class LegacyUtil {
} }
/* /*
* only used in a very rare case to convert a very old Datafile from a very old version * only used to convert a very old Datafile or config from a very old version
*/ */
public static Material getMaterial(int id) { public static Material getMaterial(int id) {
try { try {
@@ -48,7 +48,7 @@ public class InventoryListener implements Listener {
if (!P.use1_9) return; if (!P.use1_9) return;
HumanEntity player = event.getPlayer(); HumanEntity player = event.getPlayer();
Inventory inv = event.getInventory(); Inventory inv = event.getInventory();
if (player == null || inv == null || !(inv instanceof BrewerInventory)) return; if (player == null || !(inv instanceof BrewerInventory)) return;
P.p.debugLog("Starting brew inventory tracking"); P.p.debugLog("Starting brew inventory tracking");
trackedBrewmen.add(player.getUniqueId()); trackedBrewmen.add(player.getUniqueId());
@@ -63,7 +63,7 @@ public class InventoryListener implements Listener {
if (!P.use1_9) return; if (!P.use1_9) return;
HumanEntity player = event.getPlayer(); HumanEntity player = event.getPlayer();
Inventory inv = event.getInventory(); Inventory inv = event.getInventory();
if (player == null || inv == null || !(inv instanceof BrewerInventory)) return; if (player == null || !(inv instanceof BrewerInventory)) return;
P.p.debugLog("Stopping brew inventory tracking"); P.p.debugLog("Stopping brew inventory tracking");
trackedBrewmen.remove(player.getUniqueId()); trackedBrewmen.remove(player.getUniqueId());
@@ -90,7 +90,7 @@ public class InventoryListener implements Listener {
if (!P.use1_9) return; if (!P.use1_9) return;
HumanEntity player = event.getWhoClicked(); HumanEntity player = event.getWhoClicked();
Inventory inv = event.getInventory(); Inventory inv = event.getInventory();
if (player == null || inv == null || !(inv instanceof BrewerInventory)) return; if (player == null || !(inv instanceof BrewerInventory)) return;
UUID puid = player.getUniqueId(); UUID puid = player.getUniqueId();
if (!trackedBrewmen.contains(puid)) return; if (!trackedBrewmen.contains(puid)) return;
@@ -106,6 +106,7 @@ public class InventoryListener implements Listener {
if (curTask != null) { if (curTask != null) {
Bukkit.getScheduler().cancelTask(curTask); // cancel prior Bukkit.getScheduler().cancelTask(curTask); // cancel prior
brewer.getHolder().setBrewingTime(0); // Fixes brewing continuing without fuel for normal potions brewer.getHolder().setBrewingTime(0); // Fixes brewing continuing without fuel for normal potions
brewer.getHolder().update();
} }
final int fuel = brewer.getHolder().getFuelLevel(); final int fuel = brewer.getHolder().getFuelLevel();
@@ -159,6 +160,7 @@ public class InventoryListener implements Listener {
P.p.debugLog("Can distill more! Continuing."); P.p.debugLog("Can distill more! Continuing.");
} }
} }
stand.update();
} else { } else {
this.cancel(); this.cancel();
trackedBrewers.remove(brewery); trackedBrewers.remove(brewery);