1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Removed unnecessarily stored jobs world ids now we uses from the object

This commit is contained in:
montlikadani 2021-05-15 18:40:12 +02:00
parent f61bfab4c4
commit b5318089d9
6 changed files with 34 additions and 28 deletions

View File

@ -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")))

View File

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

View File

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

View File

@ -4,7 +4,7 @@ import org.bukkit.entity.LivingEntity;
public interface MythicMobInterface {
boolean Check();
boolean check();
boolean isMythicMob(LivingEntity lVictim);

View File

@ -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();

View File

@ -34,7 +34,6 @@ public class Util {
private static Map<UUID, String> jobsEditorMap = new HashMap<>(), questsEditorMap = new HashMap<>();
private static Map<String, JobsWorld> jobsWorlds = new HashMap<>();
private static Map<Integer, JobsWorld> jobsWorldsId = new HashMap<>();
public static final List<UUID> 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<Block> blocks = new ArrayList<>();
try {
Block bl = player.getTargetBlock(null, distance);
if (!CMIMaterial.isAir(bl.getType())) {
return bl;
}
} catch (Throwable e) {
}
List<Block> blocks = new ArrayList<>();
Iterator<Block> 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<String, JobsWorld> getJobsWorlds() {
@ -205,7 +214,6 @@ public class Util {
return;
jobsWorlds.put(jobsWorld.getName().toLowerCase(), jobsWorld);
jobsWorldsId.put(jobsWorld.getId(), jobsWorld);
}
public static List<String> getFilesFromPackage(String pckgname) throws ClassNotFoundException {