diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f18f2dc..a53cab6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: name: "EpicFurnaces" path: "/builds/$CI_PROJECT_PATH" - version: "4.3" + version: "4.3.1" build: stage: build diff --git a/src/main/java/com/songoda/epicfurnaces/hologram/Hologram.java b/src/main/java/com/songoda/epicfurnaces/hologram/Hologram.java index ff71262..b411e1c 100644 --- a/src/main/java/com/songoda/epicfurnaces/hologram/Hologram.java +++ b/src/main/java/com/songoda/epicfurnaces/hologram/Hologram.java @@ -4,7 +4,7 @@ import com.songoda.epicfurnaces.EpicFurnaces; import com.songoda.epicfurnaces.furnace.Furnace; import com.songoda.epicfurnaces.utils.Methods; import org.bukkit.Location; -import org.bukkit.Material; +import org.bukkit.block.BlockState; import java.util.ArrayList; @@ -52,7 +52,16 @@ public abstract class Hologram { private void format(Furnace furnace, Action action) { - org.bukkit.block.Furnace furnaceBlock = ((org.bukkit.block.Furnace) furnace.getLocation().getBlock().getState()); + Location location = furnace.getLocation(); + + if (!location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4)) + return; + + BlockState state = furnace.getLocation().getBlock().getState(); + + if (!(state instanceof org.bukkit.block.Furnace)) return; + + org.bukkit.block.Furnace furnaceBlock = ((org.bukkit.block.Furnace) state); int performance = (furnaceBlock.getCookTime() - furnace.getPerformanceTotal()) <= 0 ? 0 : furnace.getPerformanceTotal(); @@ -90,8 +99,6 @@ public abstract class Hologram { lines.add(progress); lines.add(stats); - Location location = furnace.getLocation(); - switch (action) { case UPDATE: update(location, lines); diff --git a/src/main/java/com/songoda/epicfurnaces/tasks/FurnaceTask.java b/src/main/java/com/songoda/epicfurnaces/tasks/FurnaceTask.java index c0dd171..d5652f3 100644 --- a/src/main/java/com/songoda/epicfurnaces/tasks/FurnaceTask.java +++ b/src/main/java/com/songoda/epicfurnaces/tasks/FurnaceTask.java @@ -8,6 +8,7 @@ import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.scheduler.BukkitRunnable; import java.util.concurrent.ThreadLocalRandom; @@ -50,10 +51,11 @@ public class FurnaceTask extends BukkitRunnable { continue; } - if (!furnace.getLocation().getBlock().getType().name().contains("FURNACE")) - continue; + BlockState state = furnace.getLocation().getBlock().getState(); - if (((org.bukkit.block.Furnace) furnaceLocation.getBlock().getState()).getBurnTime() == 0) continue; + if (!(state instanceof org.bukkit.block.Furnace)) return; + + if (((org.bukkit.block.Furnace) state).getBurnTime() == 0) continue; if (furnace.getLevel().getOverheat() != 0) { overheat(furnace);