1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-04 23:37:49 +01:00

Slab type correct check when running on older versions

This commit is contained in:
Zrips 2018-12-27 14:02:47 +02:00
parent 98cd4dee23
commit 7c5a03afb6
2 changed files with 18 additions and 11 deletions

View File

@ -29,6 +29,7 @@ public class ItemManager {
static HashMap<String, CMIItemStack> byBukkitName = new HashMap<>();
static HashMap<String, CMIItemStack> byMojangName = new HashMap<>();
static HashMap<CMIMaterial, CMIItemStack> 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;
}

View File

@ -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;
}