From 197232cdfc4596405117b8b0b02a5fe20608ed64 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Fri, 3 May 2019 16:35:23 +0200 Subject: [PATCH] Fixed ClassCastException when put a new sign - Fixed issue when a player use the [toplist] line in sign, then randomly hide from sign --- .../gamingmesh/jobs/CMILib/ItemManager.java | 24 +++++++++++++++++++ .../com/gamingmesh/jobs/Signs/SignUtil.java | 19 ++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index 9379f934..9eff6d69 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -3240,6 +3240,30 @@ public class ItemManager { return false; } + public static boolean isWallSign(Material mat) { + CMIMaterial m = CMIMaterial.get(mat); + if (m == null) + return false; + return m.isWallSign(); + } + + public boolean isWallSign() { + switch (this) { + case WALL_SIGN: + + case ACACIA_WALL_SIGN: + case BIRCH_WALL_SIGN: + case DARK_OAK_WALL_SIGN: + case JUNGLE_WALL_SIGN: + case OAK_WALL_SIGN: + case SPRUCE_WALL_SIGN: + return true; + default: + break; + } + return false; + } + public static boolean isWall(Material mat) { CMIMaterial m = CMIMaterial.get(mat); if (m == null) diff --git a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java index af589e43..ee3f273b 100644 --- a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java +++ b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java @@ -18,6 +18,8 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial; +import com.gamingmesh.jobs.CMILib.VersionChecker.Version; import com.gamingmesh.jobs.config.CommentedYamlConfiguration; import com.gamingmesh.jobs.container.TopList; @@ -173,7 +175,7 @@ public class SignUtil { timelapse--; } else { if (one.GetNumber() > PlayerList.size()) - continue; + return true; TopList pl = PlayerList.get(one.GetNumber() - 1); String PlayerName = pl.getPlayerName(); @@ -227,8 +229,19 @@ public class SignUtil { public boolean UpdateHead(final org.bukkit.block.Sign sign, final String Playername, int timelapse) { try { timelapse = timelapse < 1 ? 1 : timelapse; - org.bukkit.material.Sign signMat = (org.bukkit.material.Sign) sign.getData(); - BlockFace directionFacing = signMat.getFacing(); + BlockFace directionFacing = null; + if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) { + org.bukkit.material.Sign signMat = (org.bukkit.material.Sign) sign.getData(); + directionFacing = signMat.getFacing(); + } else { + if (CMIMaterial.isWallSign(sign.getType())) { + org.bukkit.block.data.type.WallSign data = (org.bukkit.block.data.type.WallSign) sign.getBlockData(); + directionFacing = data.getFacing(); + } else { + org.bukkit.block.data.type.Sign data = (org.bukkit.block.data.type.Sign) sign.getBlockData(); + directionFacing = data.getRotation(); + } + } final Location loc = sign.getLocation().clone(); loc.add(0, 1, 0);