From 7c5a03afb64884e6974eee58757ab6adda1aa86c Mon Sep 17 00:00:00 2001 From: Zrips Date: Thu, 27 Dec 2018 14:02:47 +0200 Subject: [PATCH] Slab type correct check when running on older versions --- .../gamingmesh/jobs/CMILib/ItemManager.java | 25 +++++++++++-------- .../jobs/Placeholders/Placeholder.java | 4 +++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index 5fd5851d..a2132dd6 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -29,6 +29,7 @@ public class ItemManager { static HashMap byBukkitName = new HashMap<>(); static HashMap byMojangName = new HashMap<>(); static HashMap byMaterial = new HashMap<>(); + static final Version version = Version.getCurrent(); @SuppressWarnings("deprecation") public static void load() { @@ -2655,18 +2656,20 @@ public class ItemManager { if (!isSlab(block.getType())) return SlabType.NOTSLAB; - if (Version.isCurrentEqualOrHigher(Version.v1_13_R1)) { - if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) { - org.bukkit.block.data.type.Slab slab = (org.bukkit.block.data.type.Slab) block.getBlockData(); - switch (slab.getType()) { - case TOP: - return SlabType.TOP; - case BOTTOM: - return SlabType.BOTTOM; - case DOUBLE: - return SlabType.DOUBLE; - } + if (version.isEqualOrHigher(Version.v1_13_R1)) { + try { + if (block.getBlockData() instanceof org.bukkit.block.data.type.Slab) { + org.bukkit.block.data.type.Slab slab = (org.bukkit.block.data.type.Slab) block.getBlockData(); + org.bukkit.block.data.type.Slab.Type t = slab.getType(); + if (t.equals(org.bukkit.block.data.type.Slab.Type.TOP)) + return SlabType.TOP; + if (t.equals(org.bukkit.block.data.type.Slab.Type.BOTTOM)) + return SlabType.BOTTOM; + if (t.equals(org.bukkit.block.data.type.Slab.Type.DOUBLE)) + return SlabType.DOUBLE; + } + } catch (NoClassDefFoundError e) { } return SlabType.NOTSLAB; } diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index 0ab9e7fb..c8e49696 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -443,6 +443,10 @@ public class Placeholder { Job jobs = getJobFromValue(vals.get(0)); return jobs == null ? "" : convert(user.isInJob(jobs)); + case maxjobs: + Double max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max"); + max = max == null ? Jobs.getGCManager().getMaxJobs() : max; + return String.valueOf(max); default: break; }