diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index bdb9fc42..252a0d4a 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -1476,7 +1476,9 @@ public class Jobs extends JavaPlugin { nextPage = currentPage < pageCount ? nextPage : currentPage; int prevpage = currentPage - 1; - prevpage = currentPage > 1 ? prevpage : currentPage; + if (currentPage <= 1) { + prevpage = currentPage; + } RawMessage rm = new RawMessage() .addText((currentPage > 1 ? lManager.getMessage("command.help.output.prevPage") : lManager.getMessage("command.help.output.prevPageOff"))) diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsWorld.java b/src/main/java/com/gamingmesh/jobs/container/JobsWorld.java index a0a1222b..78bf65c5 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsWorld.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsWorld.java @@ -4,6 +4,7 @@ import org.bukkit.Bukkit; import org.bukkit.World; public class JobsWorld { + private int id = 0; private String name = "Unknown"; private World world; diff --git a/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java b/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java index 2f313738..2cfd4e4c 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java @@ -87,7 +87,7 @@ public class HookManager { } public static boolean checkMythicMobs() { - return Jobs.getGCManager().MythicMobsEnabled && MythicManager != null && MythicManager.Check(); + return Jobs.getGCManager().MythicMobsEnabled && MythicManager != null && MythicManager.check(); } private static boolean setWorldGuard() { @@ -108,9 +108,6 @@ public class HookManager { Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper"); MythicManager = new MythicMobs4(PLUGIN); } catch (ClassNotFoundException ex) { - } - - if (MythicManager == null) { Jobs.consoleMsg("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+"); return; } diff --git a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobInterface.java b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobInterface.java index 28646787..76def9f3 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobInterface.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobInterface.java @@ -4,7 +4,7 @@ import org.bukkit.entity.LivingEntity; public interface MythicMobInterface { - boolean Check(); + boolean check(); boolean isMythicMob(LivingEntity lVictim); diff --git a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4.java b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4.java index 88ce4c62..f189e022 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4.java @@ -1,6 +1,5 @@ package com.gamingmesh.jobs.hooks.MythicMobs; -import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.plugin.Plugin; @@ -12,7 +11,7 @@ import io.lumine.xikage.mythicmobs.mobs.MythicMob; public class MythicMobs4 implements MythicMobInterface { - public BukkitAPIHelper MMAPI; + public BukkitAPIHelper apiHelper; private Jobs plugin; public MythicMobs4(Jobs plugin) { @@ -21,24 +20,23 @@ public class MythicMobs4 implements MythicMobInterface { @Override public void registerListener() { - Bukkit.getServer().getPluginManager().registerEvents(new MythicMobs4Listener(), plugin); + plugin.getServer().getPluginManager().registerEvents(new MythicMobs4Listener(), plugin); } @Override public boolean isMythicMob(LivingEntity lVictim) { - return MMAPI != null && lVictim != null && MMAPI.isMythicMob(lVictim); + return apiHelper != null && lVictim != null && apiHelper.isMythicMob(lVictim); } @Override - public boolean Check() { - Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs"); + public boolean check() { + Plugin mm = plugin.getServer().getPluginManager().getPlugin("MythicMobs"); if (mm == null) return false; try { Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent"); Class.forName("io.lumine.xikage.mythicmobs.mobs.MythicMob"); - Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper"); Class.forName("io.lumine.xikage.mythicmobs.MythicMobs"); } catch (ClassNotFoundException e) { // Disabling @@ -46,8 +44,8 @@ public class MythicMobs4 implements MythicMobInterface { return false; } - MMAPI = ((MythicMobs) mm).getAPIHelper(); - Jobs.consoleMsg("&e[Jobs] &6MythicMobs4 was found - Enabling capabilities."); + apiHelper = ((MythicMobs) mm).getAPIHelper(); + Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - Enabling capabilities."); return true; } @@ -55,10 +53,10 @@ public class MythicMobs4 implements MythicMobInterface { @Override public String getDisplayName(String id) { - if (failed || MMAPI == null) + if (failed || apiHelper == null) return ""; - MythicMob mm = MMAPI.getMythicMob(id); + MythicMob mm = apiHelper.getMythicMob(id); try { if (mm != null && mm.getDisplayName() != null) return mm.getDisplayName().toString(); diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Util.java b/src/main/java/com/gamingmesh/jobs/stuff/Util.java index 3c80cbfb..3f0113f9 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Util.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Util.java @@ -34,7 +34,6 @@ public class Util { private static Map jobsEditorMap = new HashMap<>(), questsEditorMap = new HashMap<>(); private static Map jobsWorlds = new HashMap<>(); - private static Map jobsWorldsId = new HashMap<>(); public static final List LEAVECONFIRM = new ArrayList<>(); @@ -107,28 +106,33 @@ public class Util { } public static Block getTargetBlock(Player player, Material lookingFor, int distance, boolean ignoreNoneSolids) { - if (distance > 15 * 16) - distance = 15 * 16; + int mult = 15 * 16; + if (distance > mult) + distance = mult; + if (distance < 1) distance = 1; - List blocks = new ArrayList<>(); - try { Block bl = player.getTargetBlock(null, distance); + if (!CMIMaterial.isAir(bl.getType())) { return bl; } } catch (Throwable e) { } + List blocks = new ArrayList<>(); Iterator itr = new BlockIterator(player, distance); + while (itr.hasNext()) { Block block = itr.next(); blocks.add(block); + if (distance != 0 && blocks.size() > distance) { blocks.remove(0); } + Material material = block.getType(); if (ignoreNoneSolids && !material.isSolid()) @@ -138,12 +142,11 @@ public class Util { if (!CMIMaterial.isAir(material)) { break; } - } else { - if (lookingFor == material) { - return block; - } + } else if (lookingFor == material) { + return block; } } + return !blocks.isEmpty() ? blocks.get(blocks.size() - 1) : null; } @@ -193,7 +196,13 @@ public class Util { } public static JobsWorld getJobsWorld(int id) { - return jobsWorldsId.get(id); + for (JobsWorld jobsWorld : jobsWorlds.values()) { + if (jobsWorld.getId() == id) { + return jobsWorld; + } + } + + return null; } public static Map getJobsWorlds() { @@ -205,7 +214,6 @@ public class Util { return; jobsWorlds.put(jobsWorld.getName().toLowerCase(), jobsWorld); - jobsWorldsId.put(jobsWorld.getId(), jobsWorld); } public static List getFilesFromPackage(String pckgname) throws ClassNotFoundException {