diff --git a/libs/CMILib1.0.2.12.jar b/libs/CMILib1.0.2.12.jar deleted file mode 100644 index e37542f9..00000000 Binary files a/libs/CMILib1.0.2.12.jar and /dev/null differ diff --git a/libs/CMILib1.1.0.2.jar b/libs/CMILib1.1.0.2.jar new file mode 100644 index 00000000..a84f279a Binary files /dev/null and b/libs/CMILib1.1.0.2.jar differ diff --git a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java index 2f91ee36..fef8d1b4 100644 --- a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java +++ b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java @@ -146,7 +146,7 @@ public class GuiManager { ItemStack guiItem = job.getGuiItem(); ItemMeta meta = guiItem.getItemMeta(); - meta.setDisplayName(job.getJobDisplayName()); + meta.setDisplayName(job.getDisplayName()); meta.setLore(lore); if (Jobs.getGCManager().hideItemAttributes) { @@ -280,7 +280,7 @@ public class GuiManager { continue; ItemMeta meta = guiItem.getItemMeta(); - meta.setDisplayName(job.getJobDisplayName()); + meta.setDisplayName(job.getDisplayName()); meta.setLore(lore); guiItem.setItemMeta(meta); tempInv.setItem(i, guiItem.clone()); @@ -300,7 +300,7 @@ public class GuiManager { } ItemMeta meta = guiItem.getItemMeta(); - meta.setDisplayName(job.getJobDisplayName()); + meta.setDisplayName(job.getDisplayName()); meta.setLore(lore); guiItem.setItemMeta(meta); tempInv.setItem(i, guiItem.clone()); @@ -431,7 +431,7 @@ public class GuiManager { } ItemMeta meta = guiItem.getItemMeta(); - meta.setDisplayName(job.getJobDisplayName()); + meta.setDisplayName(job.getDisplayName()); meta.setLore(lore); guiItem.setItemMeta(meta); tempInv.setItem(i, guiItem.clone()); @@ -450,7 +450,7 @@ public class GuiManager { } ItemMeta meta = guiItem.getItemMeta(); - meta.setDisplayName(job.getJobDisplayName()); + meta.setDisplayName(job.getDisplayName()); meta.setLore(lore); guiItem.setItemMeta(meta); tempInv.setItem(i, guiItem.clone()); diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 43a3348f..acd67409 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -30,7 +30,6 @@ import java.util.Map; import java.util.Optional; import java.util.UUID; import java.util.WeakHashMap; -import java.util.concurrent.CompletableFuture; import java.util.logging.Logger; import org.bukkit.Bukkit; @@ -92,7 +91,6 @@ import com.gamingmesh.jobs.economy.BufferedEconomy; import com.gamingmesh.jobs.economy.BufferedPayment; import com.gamingmesh.jobs.economy.Economy; import com.gamingmesh.jobs.economy.PaymentData; -import com.gamingmesh.jobs.economy.PointsData; import com.gamingmesh.jobs.hooks.HookManager; import com.gamingmesh.jobs.i18n.Language; import com.gamingmesh.jobs.listeners.JobsListener; @@ -116,7 +114,6 @@ import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Container.PageInfo; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.RawMessages.RawMessage; import net.Zrips.CMILib.Version.Version; @@ -174,8 +171,6 @@ public final class Jobs extends JavaPlugin { protected static VersionChecker versionCheckManager; protected static SelectionManager smanager; - private static PointsData pointsDatabase; - public Complement getComplement() { return complement; } @@ -289,23 +284,10 @@ public final class Jobs extends JavaPlugin { public static JobsManager getDBManager() { if (dbManager == null) - dbManager = new JobsManager(instance); + dbManager = new JobsManager(getInstance()); return dbManager; } - /** - * Gets the PointsData - * @deprecated Use {@link JobsPlayer#getPointsData()} - * @return {@link PointsData} - */ - @Deprecated - public static PointsData getPointsData() { - if (pointsDatabase == null) - pointsDatabase = new PointsData(); - - return pointsDatabase; - } - public static ShopManager getShopManager() { if (shopManager == null) { shopManager = new ShopManager(); @@ -330,7 +312,7 @@ public final class Jobs extends JavaPlugin { */ public static PlayerManager getPlayerManager() { if (pManager == null) - pManager = new PlayerManager(instance); + pManager = new PlayerManager(getInstance()); return pManager; } @@ -371,7 +353,7 @@ public final class Jobs extends JavaPlugin { */ public static ScheduleManager getScheduleManager() { if (scheduleManager == null) { - scheduleManager = new ScheduleManager(instance); + scheduleManager = new ScheduleManager(getInstance()); } return scheduleManager; @@ -393,7 +375,7 @@ public final class Jobs extends JavaPlugin { public static JobsCommands getCommandManager() { if (cManager == null) { - cManager = new JobsCommands(instance); + cManager = new JobsCommands(getInstance()); } return cManager; } @@ -404,17 +386,11 @@ public final class Jobs extends JavaPlugin { return exploreManager; } - // TODO Get rid of this entirely from project - // There are better implementations than this - protected static Jobs instance; - /** - * This shouldn't be used. * @return returns this class object instance */ - @Deprecated public static Jobs getInstance() { - return instance; + return JavaPlugin.getPlugin(Jobs.class); } /** @@ -423,7 +399,7 @@ public final class Jobs extends JavaPlugin { */ public static SignUtil getSignUtil() { if (signManager == null) { - signManager = new SignUtil(instance); + signManager = new SignUtil(getInstance()); } return signManager; @@ -452,11 +428,11 @@ public final class Jobs extends JavaPlugin { * @return the plugin logger */ public static Logger getPluginLogger() { - return instance.getLogger(); + return getInstance().getLogger(); } public static File getFolder() { - File folder = instance.getDataFolder(); + File folder = getInstance().getDataFolder(); folder.mkdirs(); return folder; } @@ -544,7 +520,7 @@ public final class Jobs extends JavaPlugin { return placeholderAPIEnabled; } - private void startup() { + private static void startup() { reload(true); // This goes in sync to avoid issues while loading data @@ -686,7 +662,7 @@ public final class Jobs extends JavaPlugin { */ public static PermissionHandler getPermissionHandler() { if (permissionHandler == null) - permissionHandler = new PermissionHandler(instance); + permissionHandler = new PermissionHandler(getInstance()); return permissionHandler; } @@ -701,7 +677,7 @@ public final class Jobs extends JavaPlugin { * @param eco - the economy handler */ public static void setEconomy(Economy eco) { - economy = new BufferedEconomy(instance, eco); + economy = new BufferedEconomy(getInstance(), eco); } /** @@ -718,7 +694,7 @@ public final class Jobs extends JavaPlugin { */ public static VersionChecker getVersionCheckManager() { if (versionCheckManager == null) - versionCheckManager = new VersionChecker(instance); + versionCheckManager = new VersionChecker(getInstance()); return versionCheckManager; } @@ -729,7 +705,6 @@ public final class Jobs extends JavaPlugin { @Override public void onEnable() { CMIMessages.consoleMessage(prefix); - instance = this; try { Class.forName("net.kyori.adventure.text.Component"); @@ -759,7 +734,7 @@ public final class Jobs extends JavaPlugin { // register the listeners if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) { - getServer().getPluginManager().registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), instance); + getServer().getPluginManager().registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), getInstance()); } getServer().getPluginManager().registerEvents(new JobsListener(this), this); @@ -807,22 +782,22 @@ public final class Jobs extends JavaPlugin { public static void reload(boolean startup) { // unregister all registered listeners by this plugin and register again if (!startup) { - org.bukkit.plugin.PluginManager pm = instance.getServer().getPluginManager(); + org.bukkit.plugin.PluginManager pm = getInstance().getServer().getPluginManager(); - HandlerList.unregisterAll(instance); + HandlerList.unregisterAll(getInstance()); if (Version.isCurrentEqualOrHigher(Version.v1_9_R1)) { - pm.registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), instance); + pm.registerEvents(new com.gamingmesh.jobs.listeners.Listener1_9(), getInstance()); } - pm.registerEvents(new JobsListener(instance), instance); - pm.registerEvents(new JobsPaymentListener(instance), instance); + pm.registerEvents(new JobsListener(getInstance()), getInstance()); + pm.registerEvents(new JobsPaymentListener(getInstance()), getInstance()); if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) { - pm.registerEvents(new JobsPayment14Listener(), instance); + pm.registerEvents(new JobsPayment14Listener(), getInstance()); } if (getGCManager().useBlockProtection) { - pm.registerEvents(new PistonProtectionListener(), instance); + pm.registerEvents(new PistonProtectionListener(), getInstance()); } if (HookManager.getMcMMOManager().CheckmcMMO()) { @@ -851,15 +826,15 @@ public final class Jobs extends JavaPlugin { getDBManager().getDB().loadAllJobsNames(); if (Version.isCurrentEqualOrLower(Version.v1_13_R1)) { - instance.getBlockOwnerShip(CMIMaterial.LEGACY_BREWING_STAND).ifPresent(BlockOwnerShip::load); - instance.getBlockOwnerShip(CMIMaterial.LEGACY_BURNING_FURNACE).ifPresent(BlockOwnerShip::load); + getInstance().getBlockOwnerShip(CMIMaterial.LEGACY_BREWING_STAND).ifPresent(BlockOwnerShip::load); + getInstance().getBlockOwnerShip(CMIMaterial.LEGACY_BURNING_FURNACE).ifPresent(BlockOwnerShip::load); } else { - instance.getBlockOwnerShip(CMIMaterial.FURNACE).ifPresent(BlockOwnerShip::load); - instance.getBlockOwnerShip(CMIMaterial.BREWING_STAND).ifPresent(BlockOwnerShip::load); + getInstance().getBlockOwnerShip(CMIMaterial.FURNACE).ifPresent(BlockOwnerShip::load); + getInstance().getBlockOwnerShip(CMIMaterial.BREWING_STAND).ifPresent(BlockOwnerShip::load); } if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) { - instance.getBlockOwnerShip(CMIMaterial.BLAST_FURNACE).ifPresent(BlockOwnerShip::load); - instance.getBlockOwnerShip(CMIMaterial.SMOKER).ifPresent(BlockOwnerShip::load); + getInstance().getBlockOwnerShip(CMIMaterial.BLAST_FURNACE).ifPresent(BlockOwnerShip::load); + getInstance().getBlockOwnerShip(CMIMaterial.SMOKER).ifPresent(BlockOwnerShip::load); } ToggleBarHandling.load(); diff --git a/src/main/java/com/gamingmesh/jobs/PermissionManager.java b/src/main/java/com/gamingmesh/jobs/PermissionManager.java index d1bbaba6..ce2ff7d6 100644 --- a/src/main/java/com/gamingmesh/jobs/PermissionManager.java +++ b/src/main/java/com/gamingmesh/jobs/PermissionManager.java @@ -30,8 +30,6 @@ import org.bukkit.permissions.PermissionAttachmentInfo; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobsPlayer; -import net.Zrips.CMILib.Logs.CMIDebug; - public class PermissionManager { private final Map permDelay = new HashMap<>(); diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index 6bf40409..96329a13 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -650,7 +650,7 @@ public class Placeholder { return null; } - private String convert(boolean state) { + private static String convert(boolean state) { return Jobs.getLanguage().getMessage("general.info." + (state ? "true" : "false")); } } diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index 7a29d675..cee46ae0 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -86,15 +86,6 @@ public class PlayerManager { this.plugin = plugin; } - /** - * @deprecated Use {@link JobsPlayer#getPointsData} instead - * @return {@link com.gamingmesh.jobs.economy.PointsData} - */ - @Deprecated - public com.gamingmesh.jobs.economy.PointsData getPointsData() { - return Jobs.getPointsData(); - } - /** * @return the cached mob spawner meta name */ @@ -677,7 +668,7 @@ public class PlayerManager { if (prog.getLevel() < oldLevel) { String message = Jobs.getLanguage().getMessage("message.leveldown.message"); - message = message.replace("%jobname%", job.getJobDisplayName()); + message = message.replace("%jobname%", job.getDisplayName()); message = message.replace("%playername%", player != null ? plugin.getComplement().getDisplayName(player) : jPlayer.getName()); message = message.replace("%joblevel%", prog.getLevelFormatted()); message = message.replace("%lostLevel%", Integer.toString(oldLevel)); @@ -780,7 +771,7 @@ public class PlayerManager { String message = Jobs.getLanguage().getMessage("message.levelup." + (Jobs.getGCManager().isBroadcastingLevelups() ? "broadcast" : "nobroadcast")); - message = message.replace("%jobname%", job.getJobDisplayName()); + message = message.replace("%jobname%", job.getDisplayName()); if (levelUpEvent.getOldTitle() != null) message = message.replace("%titlename%", levelUpEvent.getOldTitle() @@ -821,7 +812,7 @@ public class PlayerManager { message = message.replace("%playername%", player != null ? plugin.getComplement().getDisplayName(player) : jPlayer.getName()); message = message.replace("%titlename%", levelUpEvent.getNewTitle() .getChatColor().toString() + levelUpEvent.getNewTitle().getName()); - message = message.replace("%jobname%", job.getJobDisplayName()); + message = message.replace("%jobname%", job.getDisplayName()); if (Jobs.getGCManager().isBroadcastingSkillups() || Jobs.getGCManager().TitleChangeActionBar || Jobs.getGCManager().TitleChangeChat) { for (String line : message.split("\n")) { diff --git a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java index b5598f3f..ed5e1d75 100644 --- a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java +++ b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java @@ -22,7 +22,6 @@ import com.gamingmesh.jobs.container.TopList; import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Version.Version; public class SignUtil { @@ -238,7 +237,7 @@ public class SignUtil { } if (Jobs.getJob(jSign.getJobName()) != null) - signJobName = Jobs.getJob(jSign.getJobName()).getJobDisplayName(); + signJobName = Jobs.getJob(jSign.getJobName()).getDisplayName(); if (playerList.isEmpty()) continue; diff --git a/src/main/java/com/gamingmesh/jobs/api/JobsLevelUpEvent.java b/src/main/java/com/gamingmesh/jobs/api/JobsLevelUpEvent.java index 7b03270d..26c699a6 100644 --- a/src/main/java/com/gamingmesh/jobs/api/JobsLevelUpEvent.java +++ b/src/main/java/com/gamingmesh/jobs/api/JobsLevelUpEvent.java @@ -44,7 +44,7 @@ public final class JobsLevelUpEvent extends BaseEvent implements Cancellable { this.titleChangePitch = titleChangePitch; } - private Sound getSound(String soundName) { + private static Sound getSound(String soundName) { if (soundName != null) { for (Sound one : Sound.values()) { if (one.name().equalsIgnoreCase(soundName)) diff --git a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java index 1b9af7d3..2dad91b5 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java @@ -25,7 +25,6 @@ import com.gamingmesh.jobs.stuff.Util; import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.Container.PageInfo; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.RawMessages.RawMessage; public class JobsCommands implements CommandExecutor { @@ -94,15 +93,15 @@ public class JobsCommands implements CommandExecutor { return cmdClass.perform(plugin, sender, myArgs) || help(sender, 1); } - private String[] reduceArgs(String[] args) { + private static String[] reduceArgs(String[] args) { return args.length <= 1 ? new String[0] : Arrays.copyOfRange(args, 1, args.length); } - private boolean hasCommandPermission(CommandSender sender, String cmd) { + private static boolean hasCommandPermission(CommandSender sender, String cmd) { return sender.hasPermission("jobs.command." + cmd); } - private String getUsage(String cmd) { + private static String getUsage(String cmd) { String cmdString = Jobs.getLanguage().getMessage("command.help.output.cmdFormat", "[command]", Jobs.getLanguage().getMessage("command.help.output.label") + " " + cmd); String msg = Jobs.getLanguage().getMessage("command." + cmd + ".help.args"); @@ -179,7 +178,7 @@ public class JobsCommands implements CommandExecutor { } } - private Class getClass(String cmd) { + private static Class getClass(String cmd) { try { return Class.forName(PACKAGEPATH + "." + cmd.toLowerCase()); } catch (ClassNotFoundException e) { @@ -187,7 +186,7 @@ public class JobsCommands implements CommandExecutor { return null; } - private Cmd getCmdClass(String cmd) { + private static Cmd getCmdClass(String cmd) { try { Class nmsClass = getClass(cmd); if (nmsClass != null && Cmd.class.isAssignableFrom(nmsClass)) { @@ -266,7 +265,7 @@ public class JobsCommands implements CommandExecutor { else message.add(m); } else if (!type.isEmpty()) { - message.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".none", "%jobname%", job.getJobDisplayName())); + message.add(Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".none", "%jobname%", job.getDisplayName())); } } } @@ -382,7 +381,7 @@ public class JobsCommands implements CommandExecutor { Title title = Jobs.getTitleManager().getTitle(jobProg.getLevel(), jobProg.getJob().getName()); String message = Jobs.getLanguage().getMessage(path, "%joblevel%", jobProg.getLevelFormatted(), - "%jobname%", jobProg.getJob().getJobDisplayName(), + "%jobname%", jobProg.getJob().getDisplayName(), "%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0, "%jobmaxxp%", jobProg.getMaxExperience(), "%titlename%", title == null ? "Unknown" : title.getName()); @@ -428,7 +427,7 @@ public class JobsCommands implements CommandExecutor { String message = Jobs.getLanguage().getMessage("command.stats.output.message", "%joblevel%", level, - "%jobname%", jobProg.getJob().getJobDisplayName(), + "%jobname%", jobProg.getJob().getDisplayName(), "%jobxp%", Math.round(exp * 100.0) / 100.0, "%jobmaxxp%", maxExperience); return " " + jobProgressMessage(maxExperience, exp) + " " + message; diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/bonus.java b/src/main/java/com/gamingmesh/jobs/commands/list/bonus.java index 351474d9..84671ca6 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/bonus.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/bonus.java @@ -12,7 +12,6 @@ import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.hooks.HookManager; -import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.RawMessages.RawMessage; public class bonus implements Cmd { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/demote.java b/src/main/java/com/gamingmesh/jobs/commands/list/demote.java index fe08734a..ce86a1ef 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/demote.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/demote.java @@ -46,7 +46,7 @@ public class demote implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) { String message = Jobs.getLanguage().getMessage("command.demote.output.target", - "%jobname%", job.getJobDisplayName() + CMIChatColor.WHITE, + "%jobname%", job.getDisplayName() + CMIChatColor.WHITE, "%levelslost%", levelsLost); player.sendMessage(message); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java b/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java index 4db6f2c5..32fe6aec 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java @@ -20,7 +20,6 @@ import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Container.PageInfo; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.RawMessages.RawMessage; import net.Zrips.CMILib.Version.Version; @@ -408,7 +407,7 @@ public class editjobs implements Cmd { if (job != null) { rm = new RawMessage(); - rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getJobDisplayName())) + rm.addText(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", job.getDisplayName())) .addHover(job.getName()).addCommand("jobs editjobs list " + job.getName()); rm.show(player); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/employ.java b/src/main/java/com/gamingmesh/jobs/commands/list/employ.java index 09540284..d7e6e575 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/employ.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/employ.java @@ -31,13 +31,13 @@ public class employ implements Cmd { if (jPlayer.isInJob(job)) { // already in job message - sender.sendMessage(Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getJobDisplayName())); + sender.sendMessage(Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getDisplayName())); return true; } if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) { String message = Jobs.getLanguage().getMessage("command.employ.error.fullslots"); - message = message.replace("%jobname%", job.getJobDisplayName()); + message = message.replace("%jobname%", job.getDisplayName()); sender.sendMessage(message); return true; } @@ -47,7 +47,7 @@ public class employ implements Cmd { Jobs.getPlayerManager().joinJob(jPlayer, job); Player player = jPlayer.getPlayer(); if (player != null) - player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getJobDisplayName())); + player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getDisplayName())); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); } catch (Throwable e) { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/exp.java b/src/main/java/com/gamingmesh/jobs/commands/list/exp.java index ecbeb74e..457f8928 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/exp.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/exp.java @@ -81,7 +81,7 @@ public class exp implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) - player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getJobDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog + player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getDisplayName(), "%level%", prog.getLevelFormatted(), "%exp%", prog .getExperience())); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); } else diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/expboost.java b/src/main/java/com/gamingmesh/jobs/commands/list/expboost.java index 5ac5b355..11b7eb93 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/expboost.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/expboost.java @@ -6,126 +6,76 @@ import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.stuff.Util; public class expboost implements Cmd { - @Override - public boolean perform(Jobs plugin, CommandSender sender, String[] args) { - if (args.length > 3 || args.length <= 1) { - Jobs.getCommandManager().sendUsage(sender, "expboost"); - return true; - } + @Override + public boolean perform(Jobs plugin, CommandSender sender, String[] args) { + if (args.length > 3 || args.length <= 1) { + Jobs.getCommandManager().sendUsage(sender, "expboost"); + return true; + } - double rate = 1.0; - if (args[0].equalsIgnoreCase("all")) { - try { - rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "expboost"); - return true; - } - - int[] times = parseTime(args); - - for (Job job : Jobs.getJobs()) { - job.addBoost(CurrencyType.EXP, rate, times); - } - - sender.sendMessage( - Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate)); - return true; - } - - if (args[0].equalsIgnoreCase("reset")) { - if (args[1].equalsIgnoreCase("all")) { - for (Job one : Jobs.getJobs()) { - one.addBoost(CurrencyType.EXP, 1.0); - } - - sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset")); - } else if (args.length > 1) { - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); - return true; - } - - job.addBoost(CurrencyType.EXP, 1.0); - - sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset", - "%jobname%", job.getName())); - } - - return true; - } - - Job job = Jobs.getJob(args[0]); - if (job == null) { - sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); - return true; - } - - try { - rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "expboost"); - return true; - } - - job.addBoost(CurrencyType.EXP, rate, parseTime(args)); - sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate, - "%jobname%", job.getName())); + double rate = 1.0; + if (args[0].equalsIgnoreCase("all")) { + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "expboost"); return true; + } + + int[] times = Util.parseTime(args); + + for (Job job : Jobs.getJobs()) { + job.addBoost(CurrencyType.EXP, rate, times); + } + + sender.sendMessage( + Jobs.getLanguage().getMessage("command.expboost.output.boostalladded", "%boost%", rate)); + return true; } - private int[] parseTime(String[] args) { - int[] arr = new int[3]; - - if (args.length < 2) { - return arr; + if (args[0].equalsIgnoreCase("reset")) { + if (args[1].equalsIgnoreCase("all")) { + for (Job one : Jobs.getJobs()) { + one.addBoost(CurrencyType.EXP, 1.0); } - String time = args[1].toLowerCase(); - if (time.isEmpty()) { - return arr; + sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.allreset")); + } else if (args.length > 1) { + Job job = Jobs.getJob(args[1]); + if (job == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); + return true; } - String[] split = time.split("h|hour", 2); + job.addBoost(CurrencyType.EXP, 1.0); - if (split.length > 0) { - try { - arr[2] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[2] = 0; - } + sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.jobsboostreset", + "%jobname%", job.getName())); + } - time = time.replaceAll(arr[2] + "+[h|hour]+", ""); - } - - if ((split = time.split("m|minute", 2)).length > 0) { - try { - arr[1] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[1] = 0; - } - - time = time.replaceAll(arr[1] + "+[m|minute]+", ""); - } - - if ((split = time.split("s|second", 2)).length > 0) { - try { - arr[0] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[0] = 0; - } - - time = time.replaceAll(arr[0] + "+[s|second]+", ""); - } - - if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) { - return new int[3]; - } - - return arr; + return true; } + + Job job = Jobs.getJob(args[0]); + if (job == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "expboost"); + return true; + } + + job.addBoost(CurrencyType.EXP, rate, Util.parseTime(args)); + sender.sendMessage(Jobs.getLanguage().getMessage("command.expboost.output.boostadded", "%boost%", rate, + "%jobname%", job.getName())); + return true; + } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/fire.java b/src/main/java/com/gamingmesh/jobs/commands/list/fire.java index 786a15b3..8abeed29 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/fire.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/fire.java @@ -30,14 +30,14 @@ public class fire implements Cmd { } if (!jPlayer.isInJob(job)) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getJobDisplayName())); + sender.sendMessage(Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getDisplayName())); return true; } if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) { Player player = jPlayer.getPlayer(); if (player != null) - player.sendMessage(Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getJobDisplayName())); + player.sendMessage(Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getDisplayName())); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/grantxp.java b/src/main/java/com/gamingmesh/jobs/commands/list/grantxp.java index 44b34908..709ada3b 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/grantxp.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/grantxp.java @@ -48,7 +48,7 @@ public class grantxp implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) { String message = Jobs.getLanguage().getMessage("command.grantxp.output.target", - "%jobname%", job.getJobDisplayName(), + "%jobname%", job.getDisplayName(), "%xpgained%", xpGained); player.sendMessage(message); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/join.java b/src/main/java/com/gamingmesh/jobs/commands/list/join.java index d1e08c81..3b1d737f 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/join.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/join.java @@ -56,12 +56,12 @@ public class join implements Cmd { if (jPlayer.isInJob(job)) { // already in job message - pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getJobDisplayName())); + pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getDisplayName())); return true; } if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) { - pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.fullslots", "%jobname%", job.getJobDisplayName())); + pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.fullslots", "%jobname%", job.getDisplayName())); return true; } @@ -84,7 +84,7 @@ public class join implements Cmd { } Jobs.getPlayerManager().joinJob(jPlayer, job); - pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.success", "%jobname%", job.getJobDisplayName())); + pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.success", "%jobname%", job.getDisplayName())); return true; } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/leave.java b/src/main/java/com/gamingmesh/jobs/commands/list/leave.java index 802fbaec..b0173916 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/leave.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/leave.java @@ -40,10 +40,10 @@ public class leave implements Cmd { Util.LEAVECONFIRM.add(uuid); plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid), - (long) (20 * Jobs.getGCManager().ConfirmExpiryTime)); + 20 * Jobs.getGCManager().ConfirmExpiryTime); pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]", - job.getJobDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime)); + job.getDisplayName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime)); return true; } @@ -53,7 +53,7 @@ public class leave implements Cmd { JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) - pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getJobDisplayName())); + pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getDisplayName())); else pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/leaveall.java b/src/main/java/com/gamingmesh/jobs/commands/list/leaveall.java index eb1c91f6..db080963 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/leaveall.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/leaveall.java @@ -36,7 +36,7 @@ public class leaveall implements Cmd { Util.LEAVECONFIRM.add(uuid); plugin.getServer().getScheduler().runTaskLater(plugin, () -> Util.LEAVECONFIRM.remove(uuid), - (long) (20 * Jobs.getGCManager().ConfirmExpiryTime)); + 20 * Jobs.getGCManager().ConfirmExpiryTime); pSender.sendMessage(Jobs.getLanguage().getMessage("command.leaveall.confirmationNeed", "[time]", Jobs.getGCManager().ConfirmExpiryTime)); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java b/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java index 75f8c753..4d4fb8d7 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/moneyboost.java @@ -6,6 +6,7 @@ import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.stuff.Util; public class moneyboost implements Cmd { @@ -25,7 +26,7 @@ public class moneyboost implements Cmd { return true; } - int[] times = parseTime(args); + int[] times = Util.parseTime(args); for (Job job : Jobs.getJobs()) { job.addBoost(CurrencyType.MONEY, rate, times); @@ -72,60 +73,10 @@ public class moneyboost implements Cmd { return true; } - job.addBoost(CurrencyType.MONEY, rate, parseTime(args)); + job.addBoost(CurrencyType.MONEY, rate, Util.parseTime(args)); sender.sendMessage(Jobs.getLanguage().getMessage("command.moneyboost.output.boostadded", "%boost%", rate, "%jobname%", job.getName())); return true; } - private int[] parseTime(String[] args) { - int[] arr = new int[3]; - - if (args.length < 2) { - return arr; - } - - String time = args[1].toLowerCase(); - if (time.isEmpty()) { - return arr; - } - - String[] split = time.split("h|hour", 2); - - if (split.length > 0) { - try { - arr[2] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[2] = 0; - } - - time = time.replaceAll(arr[2] + "+[h|hour]+", ""); - } - - if ((split = time.split("m|minute", 2)).length > 0) { - try { - arr[1] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[1] = 0; - } - - time = time.replaceAll(arr[1] + "+[m|minute]+", ""); - } - - if ((split = time.split("s|second", 2)).length > 0) { - try { - arr[0] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[0] = 0; - } - - time = time.replaceAll(arr[0] + "+[s|second]+", ""); - } - - if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) { - return new int[3]; - } - - return arr; - } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java b/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java index 5f4fdc3c..065fa8b5 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/pointboost.java @@ -6,126 +6,76 @@ import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.stuff.Util; public class pointboost implements Cmd { - @Override - public boolean perform(Jobs plugin, CommandSender sender, String[] args) { - if (args.length > 3 || args.length <= 1) { - Jobs.getCommandManager().sendUsage(sender, "pointboost"); - return true; - } + @Override + public boolean perform(Jobs plugin, CommandSender sender, String[] args) { + if (args.length > 3 || args.length <= 1) { + Jobs.getCommandManager().sendUsage(sender, "pointboost"); + return true; + } - double rate = 1.0; - if (args[0].equalsIgnoreCase("all")) { - try { - rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "pointboost"); - return true; - } - - int[] times = parseTime(args); - - for (Job job : Jobs.getJobs()) { - job.addBoost(CurrencyType.POINTS, rate, times); - } - - sender.sendMessage( - Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate)); - return true; - } - - if (args[0].equalsIgnoreCase("reset")) { - if (args[1].equalsIgnoreCase("all")) { - for (Job one : Jobs.getJobs()) { - one.addBoost(CurrencyType.POINTS, 1.0); - } - - sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.allreset")); - } else if (args.length > 1) { - Job job = Jobs.getJob(args[1]); - if (job == null) { - sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); - return true; - } - - job.addBoost(CurrencyType.POINTS, 1.0); - - sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset", - "%jobname%", job.getName())); - } - - return true; - } - - Job job = Jobs.getJob(args[0]); - if (job == null) { - sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); - return true; - } - - try { - rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); - } catch (NumberFormatException e) { - Jobs.getCommandManager().sendUsage(sender, "pointboost"); - return true; - } - - job.addBoost(CurrencyType.POINTS, rate, parseTime(args)); - sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate, - "%jobname%", job.getName())); + double rate = 1.0; + if (args[0].equalsIgnoreCase("all")) { + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "pointboost"); return true; + } + + int[] times = Util.parseTime(args); + + for (Job job : Jobs.getJobs()) { + job.addBoost(CurrencyType.POINTS, rate, times); + } + + sender.sendMessage( + Jobs.getLanguage().getMessage("command.pointboost.output.boostalladded", "%boost%", rate)); + return true; } - private int[] parseTime(String[] args) { - int[] arr = new int[3]; - - if (args.length < 2) { - return arr; + if (args[0].equalsIgnoreCase("reset")) { + if (args[1].equalsIgnoreCase("all")) { + for (Job one : Jobs.getJobs()) { + one.addBoost(CurrencyType.POINTS, 1.0); } - String time = args[1].toLowerCase(); - if (time.isEmpty()) { - return arr; + sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.allreset")); + } else if (args.length > 1) { + Job job = Jobs.getJob(args[1]); + if (job == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); + return true; } - String[] split = time.split("h|hour", 2); + job.addBoost(CurrencyType.POINTS, 1.0); - if (split.length > 0) { - try { - arr[2] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[2] = 0; - } + sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.jobsboostreset", + "%jobname%", job.getName())); + } - time = time.replaceAll(arr[2] + "+[h|hour]+", ""); - } - - if ((split = time.split("m|minute", 2)).length > 0) { - try { - arr[1] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[1] = 0; - } - - time = time.replaceAll(arr[1] + "+[m|minute]+", ""); - } - - if ((split = time.split("s|second", 2)).length > 0) { - try { - arr[0] = Integer.parseInt(split[0]); - } catch (NumberFormatException e) { - arr[0] = 0; - } - - time = time.replaceAll(arr[0] + "+[s|second]+", ""); - } - - if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) { - return new int[3]; - } - - return arr; + return true; } + + Job job = Jobs.getJob(args[0]); + if (job == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + + try { + rate = Double.parseDouble(args[args.length > 2 ? 2 : 1]); + } catch (NumberFormatException e) { + Jobs.getCommandManager().sendUsage(sender, "pointboost"); + return true; + } + + job.addBoost(CurrencyType.POINTS, rate, Util.parseTime(args)); + sender.sendMessage(Jobs.getLanguage().getMessage("command.pointboost.output.boostadded", "%boost%", rate, + "%jobname%", job.getName())); + return true; + } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/promote.java b/src/main/java/com/gamingmesh/jobs/commands/list/promote.java index e4f17778..a06a19fe 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/promote.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/promote.java @@ -43,7 +43,7 @@ public class promote implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) player.sendMessage(Jobs.getLanguage().getMessage("command.promote.output.target", - "%jobname%", job.getJobDisplayName(), + "%jobname%", job.getDisplayName(), "%levelsgained%", levelsGained)); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java b/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java index 4629ea2e..6aaeb528 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java @@ -47,7 +47,7 @@ public class removexp implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) { player.sendMessage(Jobs.getLanguage().getMessage("command.removexp.output.target", - "%jobname%", job.getJobDisplayName(), + "%jobname%", job.getDisplayName(), "%xplost%", xpLost)); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java b/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java index f25eadb0..5f8c44ad 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java @@ -42,8 +42,8 @@ public class transfer implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) { player.sendMessage(Jobs.getLanguage().getMessage("command.transfer.output.target", - "%oldjobname%", oldjob.getJobDisplayName(), - "%newjobname%", newjob.getJobDisplayName())); + "%oldjobname%", oldjob.getDisplayName(), + "%newjobname%", newjob.getDisplayName())); } sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); diff --git a/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java b/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java index 2d6a83cc..ea721df2 100644 --- a/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java @@ -1,8 +1,5 @@ package com.gamingmesh.jobs.config; -import java.text.DecimalFormat; -import java.text.NumberFormat; - import org.bukkit.Bukkit; import org.bukkit.boss.BarColor; import org.bukkit.boss.BarStyle; @@ -64,7 +61,7 @@ public class BossBarManager { String message = Jobs.getLanguage().getMessage("command.stats.bossBarOutput", "%joblevel%", jobProg.getLevelFormatted(), - "%jobname%", jobProg.getJob().getJobDisplayName(), + "%jobname%", jobProg.getJob().getDisplayName(), "%jobxp%", String.format(Jobs.getGCManager().getDecimalPlacesMoney(), jobProg.getExperience()), "%jobmaxxp%", jobProg.getMaxExperience(), "%gain%", gain); diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index 0c60e405..42a3230c 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -94,7 +94,6 @@ public class ConfigManager { if (!cfg.getFile().isFile()) return; - cfg.load(); cfg.header(Arrays.asList("Jobs configuration.", "", "Edited by roracle to include 1.13 items and item names, prepping for 1.14 as well.", "", @@ -488,7 +487,7 @@ public class ConfigManager { cfg.save(); } - private void generate(ConfigReader cfg, String pt) { + private static void generate(ConfigReader cfg, String pt) { cfg.get(pt + ".income", 1D); cfg.get(pt + ".points", 1D); cfg.get(pt + ".experience", 1D); diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 4befacea..d870ca90 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -26,7 +26,6 @@ import java.util.Locale; import java.util.Map; import java.util.regex.Pattern; -import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; import org.bukkit.World; diff --git a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java index d1618296..6a525c45 100644 --- a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -24,7 +24,6 @@ import com.gamingmesh.jobs.stuff.Util; import net.Zrips.CMILib.Entities.CMIEntityType; import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; public class NameTranslatorManager { diff --git a/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java b/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java index f60577c4..48196e73 100644 --- a/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java @@ -152,7 +152,7 @@ public class RestrictedAreaManager { return areas; } - private StringBuilder addHeader(StringBuilder header) { + private static StringBuilder addHeader(StringBuilder header) { String sep = System.lineSeparator(); header.append("Restricted area configuration"); diff --git a/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java b/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java index 62606aa3..a53e2070 100644 --- a/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java +++ b/src/main/java/com/gamingmesh/jobs/container/ExploreChunk.java @@ -5,8 +5,6 @@ import java.util.List; import com.gamingmesh.jobs.Jobs; -import net.Zrips.CMILib.Logs.CMIDebug; - public class ExploreChunk { private List playerIds = new ArrayList<>(); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobInfo.java b/src/main/java/com/gamingmesh/jobs/container/JobInfo.java index 4e2c639b..05460f28 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobInfo.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobInfo.java @@ -22,7 +22,6 @@ import com.gamingmesh.jobs.Jobs; import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Equations.Parser; -import net.Zrips.CMILib.Logs.CMIDebug; public class JobInfo { private ActionType actionType; diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index b506decf..5dcf6bea 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -43,7 +43,6 @@ import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.Equations.Parser; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; public class JobsPlayer { @@ -1386,16 +1385,16 @@ public class JobsPlayer { maxV = Jobs.getPermissionManager().getMaxPermission(this, perm); if (maxV == 0D && type == BlockTypes.FURNACE) - maxV = (double) Jobs.getGCManager().getFurnacesMaxDefault(); + maxV = Jobs.getGCManager().getFurnacesMaxDefault(); if (maxV == 0D && type == BlockTypes.BLAST_FURNACE) - maxV = (double) Jobs.getGCManager().BlastFurnacesMaxDefault; + maxV = Jobs.getGCManager().BlastFurnacesMaxDefault; if (maxV == 0D && type == BlockTypes.SMOKER) - maxV = (double) Jobs.getGCManager().SmokersMaxDefault; + maxV = Jobs.getGCManager().SmokersMaxDefault; if (maxV == 0D && type == BlockTypes.BREWING_STAND) - maxV = (double) Jobs.getGCManager().getBrewingStandsMaxDefault(); + maxV = Jobs.getGCManager().getBrewingStandsMaxDefault(); return (int) maxV; } diff --git a/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java b/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java index e9c71744..3efd4ba2 100644 --- a/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java +++ b/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java @@ -156,7 +156,7 @@ public class QuestProgression { this.givenReward = givenReward; } - private boolean objectiveKeyMatches(String objectiveKey, ActionInfo actionInfo) { + private static boolean objectiveKeyMatches(String objectiveKey, ActionInfo actionInfo) { if (actionInfo instanceof EnchantActionInfo) { return Util.enchantMatchesActionInfo(objectiveKey, (EnchantActionInfo) actionInfo); } diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java index 7142917f..45ffa0c5 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java @@ -42,7 +42,6 @@ import com.gamingmesh.jobs.economy.PaymentData; import com.gamingmesh.jobs.stuff.TimeManage; import com.gamingmesh.jobs.stuff.Util; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Messages.CMIMessages; public abstract class JobsDAO { diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index f4da8b6a..86191436 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -125,7 +125,6 @@ import net.Zrips.CMILib.Container.CMILocation; import net.Zrips.CMILib.Entities.CMIEntityType; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Version.Version; public final class JobsPaymentListener implements Listener { @@ -819,11 +818,11 @@ public final class JobsPaymentListener implements Listener { }, 1); } - private boolean hasItems(ItemStack stack) { + private static boolean hasItems(ItemStack stack) { return stack != null && stack.getAmount() > 0; } - private boolean hasSameItem(ItemStack a, ItemStack b) { + private static boolean hasSameItem(ItemStack a, ItemStack b) { if (a == null) return b == null; else if (b == null) diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Util.java b/src/main/java/com/gamingmesh/jobs/stuff/Util.java index a03070b1..ecaab932 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Util.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Util.java @@ -99,6 +99,57 @@ public final class Util { } } + public static int[] parseTime(String[] args) { + int[] arr = new int[3]; + + if (args.length < 2) { + return arr; + } + + String time = args[1].toLowerCase(); + if (time.isEmpty()) { + return arr; + } + + String[] split = time.split("h|hour", 2); + + if (split.length > 0) { + try { + arr[2] = Integer.parseInt(split[0]); + } catch (NumberFormatException e) { + arr[2] = 0; + } + + time = time.replaceAll(arr[2] + "+[h|hour]+", ""); + } + + if ((split = time.split("m|minute", 2)).length > 0) { + try { + arr[1] = Integer.parseInt(split[0]); + } catch (NumberFormatException e) { + arr[1] = 0; + } + + time = time.replaceAll(arr[1] + "+[m|minute]+", ""); + } + + if ((split = time.split("s|second", 2)).length > 0) { + try { + arr[0] = Integer.parseInt(split[0]); + } catch (NumberFormatException e) { + arr[0] = 0; + } + + time = time.replaceAll(arr[0] + "+[s|second]+", ""); + } + + if (arr[0] == 0 && arr[1] == 0 && arr[2] == 0) { + return new int[3]; + } + + return arr; + } + public static String getRealType(Entity entity) { if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) { return entity.getType().name(); @@ -412,10 +463,9 @@ public final class Util { String enchantName = CMIEnchantment.get(actionInfo.getName()).toString(); return ( - // Enchantment without level e.g. silk_touch - enchant.equalsIgnoreCase(enchantName) || - // Enchantment with level e.g. fire_aspect:1 - enchant.equalsIgnoreCase(enchantName + ":" + actionInfo.getLevel()) - ); + // Enchantment without level e.g. silk_touch + enchant.equalsIgnoreCase(enchantName) || + // Enchantment with level e.g. fire_aspect:1 + enchant.equalsIgnoreCase(enchantName + ":" + actionInfo.getLevel())); } }