mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-04 23:37:49 +01:00
Removed unnecessarily stored jobs world ids now we uses from the object
This commit is contained in:
parent
f61bfab4c4
commit
b5318089d9
@ -1476,7 +1476,9 @@ public class Jobs extends JavaPlugin {
|
|||||||
nextPage = currentPage < pageCount ? nextPage : currentPage;
|
nextPage = currentPage < pageCount ? nextPage : currentPage;
|
||||||
|
|
||||||
int prevpage = currentPage - 1;
|
int prevpage = currentPage - 1;
|
||||||
prevpage = currentPage > 1 ? prevpage : currentPage;
|
if (currentPage <= 1) {
|
||||||
|
prevpage = currentPage;
|
||||||
|
}
|
||||||
|
|
||||||
RawMessage rm = new RawMessage()
|
RawMessage rm = new RawMessage()
|
||||||
.addText((currentPage > 1 ? lManager.getMessage("command.help.output.prevPage") : lManager.getMessage("command.help.output.prevPageOff")))
|
.addText((currentPage > 1 ? lManager.getMessage("command.help.output.prevPage") : lManager.getMessage("command.help.output.prevPageOff")))
|
||||||
|
@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
public class JobsWorld {
|
public class JobsWorld {
|
||||||
|
|
||||||
private int id = 0;
|
private int id = 0;
|
||||||
private String name = "Unknown";
|
private String name = "Unknown";
|
||||||
private World world;
|
private World world;
|
||||||
|
@ -87,7 +87,7 @@ public class HookManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkMythicMobs() {
|
public static boolean checkMythicMobs() {
|
||||||
return Jobs.getGCManager().MythicMobsEnabled && MythicManager != null && MythicManager.Check();
|
return Jobs.getGCManager().MythicMobsEnabled && MythicManager != null && MythicManager.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean setWorldGuard() {
|
private static boolean setWorldGuard() {
|
||||||
@ -108,9 +108,6 @@ public class HookManager {
|
|||||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
|
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
|
||||||
MythicManager = new MythicMobs4(PLUGIN);
|
MythicManager = new MythicMobs4(PLUGIN);
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
}
|
|
||||||
|
|
||||||
if (MythicManager == null) {
|
|
||||||
Jobs.consoleMsg("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+");
|
Jobs.consoleMsg("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
|
|
||||||
public interface MythicMobInterface {
|
public interface MythicMobInterface {
|
||||||
|
|
||||||
boolean Check();
|
boolean check();
|
||||||
|
|
||||||
boolean isMythicMob(LivingEntity lVictim);
|
boolean isMythicMob(LivingEntity lVictim);
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ import io.lumine.xikage.mythicmobs.mobs.MythicMob;
|
|||||||
|
|
||||||
public class MythicMobs4 implements MythicMobInterface {
|
public class MythicMobs4 implements MythicMobInterface {
|
||||||
|
|
||||||
public BukkitAPIHelper MMAPI;
|
public BukkitAPIHelper apiHelper;
|
||||||
private Jobs plugin;
|
private Jobs plugin;
|
||||||
|
|
||||||
public MythicMobs4(Jobs plugin) {
|
public MythicMobs4(Jobs plugin) {
|
||||||
@ -21,24 +20,23 @@ public class MythicMobs4 implements MythicMobInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerListener() {
|
public void registerListener() {
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new MythicMobs4Listener(), plugin);
|
plugin.getServer().getPluginManager().registerEvents(new MythicMobs4Listener(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMythicMob(LivingEntity lVictim) {
|
public boolean isMythicMob(LivingEntity lVictim) {
|
||||||
return MMAPI != null && lVictim != null && MMAPI.isMythicMob(lVictim);
|
return apiHelper != null && lVictim != null && apiHelper.isMythicMob(lVictim);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean Check() {
|
public boolean check() {
|
||||||
Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs");
|
Plugin mm = plugin.getServer().getPluginManager().getPlugin("MythicMobs");
|
||||||
if (mm == null)
|
if (mm == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent");
|
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent");
|
||||||
Class.forName("io.lumine.xikage.mythicmobs.mobs.MythicMob");
|
Class.forName("io.lumine.xikage.mythicmobs.mobs.MythicMob");
|
||||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
|
|
||||||
Class.forName("io.lumine.xikage.mythicmobs.MythicMobs");
|
Class.forName("io.lumine.xikage.mythicmobs.MythicMobs");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
// Disabling
|
// Disabling
|
||||||
@ -46,8 +44,8 @@ public class MythicMobs4 implements MythicMobInterface {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MMAPI = ((MythicMobs) mm).getAPIHelper();
|
apiHelper = ((MythicMobs) mm).getAPIHelper();
|
||||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs4 was found - Enabling capabilities.");
|
Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - Enabling capabilities.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,10 +53,10 @@ public class MythicMobs4 implements MythicMobInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayName(String id) {
|
public String getDisplayName(String id) {
|
||||||
if (failed || MMAPI == null)
|
if (failed || apiHelper == null)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
MythicMob mm = MMAPI.getMythicMob(id);
|
MythicMob mm = apiHelper.getMythicMob(id);
|
||||||
try {
|
try {
|
||||||
if (mm != null && mm.getDisplayName() != null)
|
if (mm != null && mm.getDisplayName() != null)
|
||||||
return mm.getDisplayName().toString();
|
return mm.getDisplayName().toString();
|
||||||
|
@ -34,7 +34,6 @@ public class Util {
|
|||||||
private static Map<UUID, String> jobsEditorMap = new HashMap<>(), questsEditorMap = new HashMap<>();
|
private static Map<UUID, String> jobsEditorMap = new HashMap<>(), questsEditorMap = new HashMap<>();
|
||||||
|
|
||||||
private static Map<String, JobsWorld> jobsWorlds = 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<>();
|
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) {
|
public static Block getTargetBlock(Player player, Material lookingFor, int distance, boolean ignoreNoneSolids) {
|
||||||
if (distance > 15 * 16)
|
int mult = 15 * 16;
|
||||||
distance = 15 * 16;
|
if (distance > mult)
|
||||||
|
distance = mult;
|
||||||
|
|
||||||
if (distance < 1)
|
if (distance < 1)
|
||||||
distance = 1;
|
distance = 1;
|
||||||
|
|
||||||
List<Block> blocks = new ArrayList<>();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Block bl = player.getTargetBlock(null, distance);
|
Block bl = player.getTargetBlock(null, distance);
|
||||||
|
|
||||||
if (!CMIMaterial.isAir(bl.getType())) {
|
if (!CMIMaterial.isAir(bl.getType())) {
|
||||||
return bl;
|
return bl;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Block> blocks = new ArrayList<>();
|
||||||
Iterator<Block> itr = new BlockIterator(player, distance);
|
Iterator<Block> itr = new BlockIterator(player, distance);
|
||||||
|
|
||||||
while (itr.hasNext()) {
|
while (itr.hasNext()) {
|
||||||
Block block = itr.next();
|
Block block = itr.next();
|
||||||
blocks.add(block);
|
blocks.add(block);
|
||||||
|
|
||||||
if (distance != 0 && blocks.size() > distance) {
|
if (distance != 0 && blocks.size() > distance) {
|
||||||
blocks.remove(0);
|
blocks.remove(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Material material = block.getType();
|
Material material = block.getType();
|
||||||
|
|
||||||
if (ignoreNoneSolids && !material.isSolid())
|
if (ignoreNoneSolids && !material.isSolid())
|
||||||
@ -138,12 +142,11 @@ public class Util {
|
|||||||
if (!CMIMaterial.isAir(material)) {
|
if (!CMIMaterial.isAir(material)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (lookingFor == material) {
|
||||||
if (lookingFor == material) {
|
return block;
|
||||||
return block;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !blocks.isEmpty() ? blocks.get(blocks.size() - 1) : null;
|
return !blocks.isEmpty() ? blocks.get(blocks.size() - 1) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +196,13 @@ public class Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static JobsWorld getJobsWorld(int id) {
|
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() {
|
public static Map<String, JobsWorld> getJobsWorlds() {
|
||||||
@ -205,7 +214,6 @@ public class Util {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
jobsWorlds.put(jobsWorld.getName().toLowerCase(), jobsWorld);
|
jobsWorlds.put(jobsWorld.getName().toLowerCase(), jobsWorld);
|
||||||
jobsWorldsId.put(jobsWorld.getId(), jobsWorld);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getFilesFromPackage(String pckgname) throws ClassNotFoundException {
|
public static List<String> getFilesFromPackage(String pckgname) throws ClassNotFoundException {
|
||||||
|
Loading…
Reference in New Issue
Block a user