From 6294aece859aa788987e902f8c3eab1edda3823a Mon Sep 17 00:00:00 2001 From: Zrips Date: Fri, 21 Apr 2023 14:36:32 +0300 Subject: [PATCH] Code cleanup --- .../com/gamingmesh/jobs/HookEconomyTask.java | 7 +- .../com/gamingmesh/jobs/ItemBoostManager.java | 3 +- src/main/java/com/gamingmesh/jobs/Jobs.java | 19 +- .../com/gamingmesh/jobs/PlayerManager.java | 29 +- .../com/gamingmesh/jobs/Signs/SignUtil.java | 3 +- .../jobs/commands/list/convert.java | 2 +- .../gamingmesh/jobs/commands/list/glog.java | 5 +- .../gamingmesh/jobs/commands/list/log.java | 4 +- .../jobs/commands/list/placeholders.java | 3 +- .../gamingmesh/jobs/commands/list/quests.java | 1 - .../gamingmesh/jobs/config/ConfigManager.java | 14 +- .../jobs/config/ExploreManager.java | 12 +- .../jobs/config/GeneralConfigManager.java | 6 +- .../jobs/config/NameTranslatorManager.java | 26 +- .../jobs/config/RestrictedAreaManager.java | 292 +++++++++--------- .../jobs/config/RestrictedBlockManager.java | 105 +++---- .../jobs/config/ScheduleManager.java | 10 +- .../gamingmesh/jobs/config/ShopManager.java | 2 +- .../gamingmesh/jobs/config/TitleManager.java | 3 +- .../jobs/container/JobProgression.java | 4 +- .../com/gamingmesh/jobs/container/Log.java | 4 +- .../jobs/container/QuestProgression.java | 7 +- .../blockOwnerShip/BlockOwnerShip.java | 3 +- .../java/com/gamingmesh/jobs/dao/JobsDAO.java | 18 +- .../com/gamingmesh/jobs/dao/JobsManager.java | 8 +- .../com/gamingmesh/jobs/dao/JobsMySQL.java | 28 +- .../com/gamingmesh/jobs/dao/JobsSQLite.java | 22 +- .../gamingmesh/jobs/hooks/HookManager.java | 16 +- .../jobs/hooks/McMMO/McMMOManager.java | 6 +- .../jobs/hooks/MythicMobs/MythicMobs4.java | 7 +- .../jobs/hooks/MythicMobs/MythicMobs5.java | 7 +- .../com/gamingmesh/jobs/i18n/Language.java | 9 +- .../jobs/listeners/JobsPaymentListener.java | 4 +- .../com/gamingmesh/jobs/stuff/Loging.java | 4 +- .../jobs/stuff/PerformCommands.java | 25 -- .../com/gamingmesh/jobs/stuff/Sorting.java | 43 --- .../com/gamingmesh/jobs/stuff/TimeManage.java | 17 - .../java/com/gamingmesh/jobs/stuff/Util.java | 47 +-- .../gamingmesh/jobs/stuff/VersionChecker.java | 6 +- .../jobs/tasks/BufferedPaymentThread.java | 8 +- .../jobs/tasks/DatabaseSaveThread.java | 8 +- 41 files changed, 374 insertions(+), 473 deletions(-) delete mode 100644 src/main/java/com/gamingmesh/jobs/stuff/PerformCommands.java delete mode 100644 src/main/java/com/gamingmesh/jobs/stuff/TimeManage.java diff --git a/src/main/java/com/gamingmesh/jobs/HookEconomyTask.java b/src/main/java/com/gamingmesh/jobs/HookEconomyTask.java index 9c7244ff..ab51d1e7 100644 --- a/src/main/java/com/gamingmesh/jobs/HookEconomyTask.java +++ b/src/main/java/com/gamingmesh/jobs/HookEconomyTask.java @@ -18,13 +18,14 @@ package com.gamingmesh.jobs; -import net.milkbowl.vault.economy.Economy; - import org.bukkit.plugin.RegisteredServiceProvider; import com.gamingmesh.jobs.economy.BlackholeEconomy; import com.gamingmesh.jobs.economy.VaultEconomy; +import net.Zrips.CMILib.Messages.CMIMessages; +import net.milkbowl.vault.economy.Economy; + public class HookEconomyTask implements Runnable { private Jobs plugin; @@ -72,7 +73,7 @@ public class HookEconomyTask implements Runnable { } Jobs.setEconomy(new VaultEconomy(provider.getProvider())); - Jobs.consoleMsg("&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault. (" + provider.getProvider().getName() + ")"); + CMIMessages.consoleMessage("&e[" + plugin.getDescription().getName() + "] Successfully linked with Vault. (" + provider.getProvider().getName() + ")"); return hookResult.pass; } diff --git a/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java b/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java index 100d15fd..2f8ed29e 100644 --- a/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java +++ b/src/main/java/com/gamingmesh/jobs/ItemBoostManager.java @@ -22,6 +22,7 @@ import com.gamingmesh.jobs.container.JobItems; import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Messages.CMIMessages; public final class ItemBoostManager { @@ -228,7 +229,7 @@ public final class ItemBoostManager { } cfg.save(); - Jobs.consoleMsg("&eLoaded &6" + ITEMS.size() + " &eboosted items"); + CMIMessages.consoleMessage("&eLoaded &6" + ITEMS.size() + " &eboosted items"); } /** diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 66c52e3b..f37a750d 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -34,7 +34,6 @@ import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.block.Block; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -112,8 +111,6 @@ import com.gamingmesh.jobs.tasks.BufferedPaymentThread; import com.gamingmesh.jobs.tasks.DatabaseSaveThread; 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.Locale.LC; import net.Zrips.CMILib.Messages.CMIMessages; @@ -267,7 +264,7 @@ public final class Jobs extends JavaPlugin { try { if (Integer.parseInt(papi .getDescription().getVersion().replaceAll("[^\\d]", "")) >= 2100 && new PlaceholderAPIHook(this).register()) { - consoleMsg("&6PlaceholderAPI &ehooked."); + CMIMessages.consoleMessage("&6PlaceholderAPI &ehooked."); } } catch (NumberFormatException ex) { return false; @@ -566,7 +563,7 @@ public final class Jobs extends JavaPlugin { getPlayerManager().addPlayerToCache(jPlayer); } if (!getPlayerManager().getPlayersCache().isEmpty()) - consoleMsg("&ePreloaded &6" + getPlayerManager().getPlayersCache().size() + " &eplayers data in &6" + ((int) ((System.currentTimeMillis() - time) / 1000.0D * 100.0D) / 100.0D)); + CMIMessages.consoleMessage("&ePreloaded &6" + getPlayerManager().getPlayersCache().size() + " &eplayers data in &6" + ((int) ((System.currentTimeMillis() - time) / 1000.0D * 100.0D) / 100.0D)); } public static void convertDatabase() { @@ -596,7 +593,7 @@ public final class Jobs extends JavaPlugin { // Jobs.getJobsDAO().saveBlockProtection(); } catch (SQLException e) { e.printStackTrace(); - Jobs.consoleMsg("&cCan't write data to data base, please send error log to dev's."); + CMIMessages.consoleMessage("&cCan't write data to data base, please send error log to dev's."); return; } @@ -773,7 +770,7 @@ public final class Jobs extends JavaPlugin { getCommandManager().fillCommands(); getDBManager().getDB().triggerTableIdUpdate(); - consoleMsg("&ePlugin has been enabled successfully."); + CMIMessages.consoleMessage("&ePlugin has been enabled successfully."); } catch (Throwable e) { e.printStackTrace(); System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled."); @@ -1257,7 +1254,7 @@ public final class Jobs extends JavaPlugin { jPlayer.getUpdateBossBarFor().add(prog.getJob().getName()); } catch (Throwable e) { e.printStackTrace(); - consoleMsg("&c[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it."); + CMIMessages.consoleMessage("&c[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it."); } Map payments = new HashMap<>(); @@ -1460,12 +1457,6 @@ public final class Jobs extends JavaPlugin { getPlayerManager().performLevelUp(jPlayer, prog.getJob(), oldLevel); } - public static void consoleMsg(String msg) { - if (msg != null) { - Bukkit.getServer().getConsoleSender().sendMessage(CMIChatColor.translate(msg)); - } - } - public static SelectionManager getSelectionManager() { return smanager; } diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index dae17e93..f57c230c 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -31,8 +31,8 @@ import java.util.concurrent.ThreadLocalRandom; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.FireworkEffect; -import org.bukkit.Material; import org.bukkit.FireworkEffect.Type; +import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Firework; import org.bukkit.entity.LivingEntity; @@ -40,8 +40,6 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Tameable; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkMeta; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import com.gamingmesh.jobs.api.JobsJoinEvent; import com.gamingmesh.jobs.api.JobsLeaveEvent; @@ -62,13 +60,11 @@ import com.gamingmesh.jobs.dao.JobsDAO; import com.gamingmesh.jobs.dao.JobsDAOData; import com.gamingmesh.jobs.economy.PaymentData; import com.gamingmesh.jobs.hooks.HookManager; -import com.gamingmesh.jobs.stuff.PerformCommands; import com.gamingmesh.jobs.stuff.Util; import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.NBT.CMINBT; import net.Zrips.CMILib.Version.Version; @@ -336,7 +332,7 @@ public class PlayerManager { i++; if (y++ >= 1000) { - Jobs.consoleMsg("&e[Jobs] Saved " + i + "/" + total + " players data"); + CMIMessages.consoleMessage("&e[Jobs] Saved " + i + "/" + total + " players data"); y = 0; } } @@ -452,6 +448,14 @@ public class PlayerManager { return jPlayer; } + private static void performCommandsOnJoin(JobsPlayer jPlayer, Job job) { + String pName = jPlayer.getName(); + + for (String one : job.getCmdOnJoin()) { + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", pName).replace("[jobname]", job.getName())); + } + } + /** * Causes player to join to the given job. * @@ -476,7 +480,7 @@ public class PlayerManager { Jobs.getJobsDAO().joinJob(jPlayer, jPlayer.getJobProgression(job)); jPlayer.setLeftTime(job); - PerformCommands.performCommandsOnJoin(jPlayer, job); + performCommandsOnJoin(jPlayer, job); Jobs.takeSlot(job); Jobs.getSignUtil().updateAllSign(job); @@ -485,6 +489,13 @@ public class PlayerManager { jPlayer.maxJobsEquation = getMaxJobs(jPlayer); } + private static void performCommandsOnLeave(JobsPlayer jPlayer, Job job) { + String pName = jPlayer.getName(); + for (String one : job.getCmdOnLeave()) { + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", pName).replace("[jobname]", job.getName())); + } + } + /** * Causes player to leave the given job. * @@ -510,7 +521,7 @@ public class PlayerManager { if (!Jobs.getJobsDAO().quitJob(jPlayer, job)) return false; - PerformCommands.performCommandsOnLeave(jPlayer, job); + performCommandsOnLeave(jPlayer, job); Jobs.leaveSlot(job); jPlayer.getLeftTimes().remove(jPlayer.getUniqueId()); @@ -1199,7 +1210,7 @@ public class PlayerManager { for (Job one : Jobs.getJobs()) { if (jPlayer.progression.size() >= playerMaxJobs) return; - + if (one.getMaxSlots() != null && Jobs.getUsedSlots(one) >= one.getMaxSlots()) continue; diff --git a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java index ed5e1d75..77337bb0 100644 --- a/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java +++ b/src/main/java/com/gamingmesh/jobs/Signs/SignUtil.java @@ -22,6 +22,7 @@ import com.gamingmesh.jobs.container.TopList; import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Version.Version; public class SignUtil { @@ -130,7 +131,7 @@ public class SignUtil { } if (!signsByLocation.isEmpty()) { - Jobs.consoleMsg("&e[Jobs] Loaded " + signsByLocation.size() + " top list signs"); + CMIMessages.consoleMessage("&e[Jobs] Loaded " + signsByLocation.size() + " top list signs"); } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/convert.java b/src/main/java/com/gamingmesh/jobs/commands/list/convert.java index 0d691d78..d7b64544 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/convert.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/convert.java @@ -30,7 +30,7 @@ public class convert implements Cmd { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { Jobs.convertDatabase(); - Jobs.consoleMsg("&eDatabase was converted from &2" + from + " &eto &2" + to + "&e!"); + CMIMessages.consoleMessage("&eDatabase was converted from &2" + from + " &eto &2" + to + "&e!"); }); return true; diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/glog.java b/src/main/java/com/gamingmesh/jobs/commands/list/glog.java index 241bc1ad..c1dd523e 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/glog.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/glog.java @@ -16,7 +16,8 @@ import com.gamingmesh.jobs.container.Log; import com.gamingmesh.jobs.container.LogAmounts; import com.gamingmesh.jobs.container.PlayerInfo; import com.gamingmesh.jobs.stuff.Sorting; -import com.gamingmesh.jobs.stuff.TimeManage; + +import net.Zrips.CMILib.Time.CMITimeManager; public class glog implements Cmd { @@ -31,7 +32,7 @@ public class glog implements Cmd { @Override public void run() { Map unsortMap = new HashMap<>(); - int time = TimeManage.timeInInt(); + int time = CMITimeManager.timeInInt(); for (Integer oneP : Jobs.getJobsDAO().getLognameList(time, time)) { PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(oneP); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/log.java b/src/main/java/com/gamingmesh/jobs/commands/list/log.java index 33728b09..52f22058 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/log.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/log.java @@ -15,8 +15,8 @@ import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.Log; import com.gamingmesh.jobs.container.LogAmounts; -import com.gamingmesh.jobs.stuff.Sorting; +import net.Zrips.CMILib.Container.CMISort; import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Messages.CMIMessages; @@ -65,7 +65,7 @@ public class log implements Cmd { } } - unsortMap = Sorting.sortDoubleDESC(unsortMap); + unsortMap = CMISort.sortDoubleDESC(unsortMap); if (unsortMap.isEmpty()) { sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.nodata")); return true; diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java b/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java index da5e4b49..b9f53e37 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java @@ -10,6 +10,7 @@ import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceholderType; import com.gamingmesh.jobs.commands.Cmd; import net.Zrips.CMILib.Container.PageInfo; +import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.RawMessages.RawMessage; public class placeholders implements Cmd { @@ -31,7 +32,7 @@ public class placeholders implements Cmd { } else { player = Bukkit.getPlayer(args[0]); if (player == null) { - Jobs.consoleMsg("&cPlayer cannot be null!"); + CMIMessages.consoleMessage("&cPlayer cannot be null!"); return false; } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/quests.java b/src/main/java/com/gamingmesh/jobs/commands/list/quests.java index 56920dbc..d43557b2 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/quests.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/quests.java @@ -14,7 +14,6 @@ import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.Quest; import com.gamingmesh.jobs.container.QuestObjective; import com.gamingmesh.jobs.container.QuestProgression; -import com.gamingmesh.jobs.stuff.TimeManage; import net.Zrips.CMILib.Locale.LC; import net.Zrips.CMILib.Messages.CMIMessages; diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index 1d043e16..0821b358 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -60,7 +60,7 @@ import net.Zrips.CMILib.Equations.ParseError; import net.Zrips.CMILib.Equations.Parser; import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; +import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Version.Version; public class ConfigManager { @@ -964,7 +964,7 @@ public class ConfigManager { Jobs.setJobs(jobs); if (!jobs.isEmpty()) { - Jobs.consoleMsg("&eLoaded &6" + jobs.size() + " &ejobs"); + CMIMessages.consoleMessage("&eLoaded &6" + jobs.size() + " &ejobs"); } ItemBoostManager.load(); @@ -1314,7 +1314,7 @@ public class ConfigManager { jobItems.put(node.toLowerCase(), new JobItems(node, CMIMaterial.get(id), 1, name, lore, enchants, b, new ArrayList())); } - Jobs.consoleMsg("&cRemove Items section from " + jobKey + " job, as of Jobs 4.10.0 version this was moved to boostedItems.yml file!"); + CMIMessages.consoleMessage("&cRemove Items section from " + jobKey + " job, as of Jobs 4.10.0 version this was moved to boostedItems.yml file!"); } // Limited Items @@ -1415,8 +1415,8 @@ public class ConfigManager { } } - for (String oneObjective : sqsection.getStringList("Objectives")) { - List objectives = QuestObjective.get(oneObjective, jobFullName); + for (String oneObjective : sqsection.getStringList("Objectives")) { + List objectives = QuestObjective.get(oneObjective, jobFullName); quest.addObjectives(objectives); } @@ -1434,13 +1434,13 @@ public class ConfigManager { quests.add(quest); } catch (Exception e) { - Jobs.consoleMsg("&cCan't load &6" + one + " &cquest for &6" + jobFullName); + CMIMessages.consoleMessage("&cCan't load &6" + one + " &cquest for &6" + jobFullName); e.printStackTrace(); } } job.setQuests(quests); - Jobs.consoleMsg("&eLoaded &6" + quests.size() + " &equests for &6" + jobFullName); + CMIMessages.consoleMessage("&eLoaded &6" + quests.size() + " &equests for &6" + jobFullName); } job.setMaxDailyQuests(jobSection.getInt("maxDailyQuests", 1)); diff --git a/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java b/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java index 574e0ee4..f9cf4e75 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ExploreManager.java @@ -17,7 +17,7 @@ import com.gamingmesh.jobs.container.JobsWorld; import com.gamingmesh.jobs.dao.JobsDAO.ExploreDataTableFields; import com.gamingmesh.jobs.stuff.Util; -import net.Zrips.CMILib.Logs.CMIDebug; +import net.Zrips.CMILib.Messages.CMIMessages; public class ExploreManager { @@ -48,11 +48,11 @@ public class ExploreManager { if (!exploreEnabled) return; - Jobs.consoleMsg("&eLoading explorer data"); + CMIMessages.consoleMessage("&eLoading explorer data"); Long time = System.currentTimeMillis(); Jobs.getJobsDAO().loadExplore(); int size = getSize(); - Jobs.consoleMsg("&eLoaded explorer data" + (size != 0 ? " (&6" + size + "&e)" : " ") + " in " + (System.currentTimeMillis() - time) + " ms"); + CMIMessages.consoleMessage("&eLoaded explorer data" + (size != 0 ? " (&6" + size + "&e)" : " ") + " in " + (System.currentTimeMillis() - time) + " ms"); } public Map> getWorlds() { @@ -149,17 +149,17 @@ public class ExploreManager { } public void resetRegion(String worldname) { - Jobs.consoleMsg("&eReseting explorer data. World: " + worldname); + CMIMessages.consoleMessage("&eReseting explorer data. World: " + worldname); Map> worlds = getWorlds(); worlds.put(worldname, new HashMap()); boolean r = Jobs.getJobsDAO().deleteExploredWorld(worldname); if (!r) { - Jobs.consoleMsg("&eFailed in DAO."); + CMIMessages.consoleMessage("&eFailed in DAO."); return; } - Jobs.consoleMsg("&eCompleted to reset explorer data."); + CMIMessages.consoleMessage("&eCompleted to reset explorer data."); } } diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 0340dcec..08e845c1 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -40,12 +40,12 @@ import com.gamingmesh.jobs.container.CurrencyLimit; import com.gamingmesh.jobs.container.CurrencyType; import net.Zrips.CMILib.CMILib; -import net.Zrips.CMILib.Container.CMIArray; import net.Zrips.CMILib.Container.CMIList; import net.Zrips.CMILib.Equations.Parser; import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Messages.CMIMessages; import net.Zrips.CMILib.Version.Version; public class GeneralConfigManager { @@ -543,7 +543,7 @@ public class GeneralConfigManager { CMIMaterial mat = CMIMaterial.get(mName); if (mat == CMIMaterial.NONE) { - Jobs.consoleMsg("Failed to recognize " + one + " entry from config file"); + CMIMessages.consoleMessage("Failed to recognize " + one + " entry from config file"); continue; } @@ -644,7 +644,7 @@ public class GeneralConfigManager { DynamicPaymentEquation.setVariable("totaljobs", 10); DynamicPaymentEquation.setVariable("jobstotalplayers", 10); } catch (Throwable e) { - Jobs.consoleMsg("&cDynamic payment equation has an invalid property. Disabling feature!"); + CMIMessages.consoleMessage("&cDynamic payment equation has an invalid property. Disabling feature!"); useDynamicPayment = false; } diff --git a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java index 62959b50..80b8b77d 100644 --- a/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/NameTranslatorManager.java @@ -26,7 +26,7 @@ import net.Zrips.CMILib.Container.CMIText; import net.Zrips.CMILib.Entities.CMIEntityType; import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.Items.CMIMaterial; -import net.Zrips.CMILib.Logs.CMIDebug; +import net.Zrips.CMILib.Messages.CMIMessages; public class NameTranslatorManager { @@ -231,9 +231,9 @@ public class NameTranslatorManager { } if (listOfNames.size() > 0) - Jobs.consoleMsg("&eLoaded &6" + listOfNames.size() + " &ecustom item names"); + CMIMessages.consoleMessage("&eLoaded &6" + listOfNames.size() + " &ecustom item names"); } else - Jobs.consoleMsg("&cThe ItemList section not found in &6" + itemFile.fileName + " &cfile."); + CMIMessages.consoleMessage("&cThe ItemList section not found in &6" + itemFile.fileName + " &cfile."); if ((section = itemFile.getConfig().getConfigurationSection("EntityList")) != null) { listOfEntities.clear(); @@ -252,9 +252,9 @@ public class NameTranslatorManager { } if (!listOfEntities.isEmpty()) - Jobs.consoleMsg("&eLoaded &6" + listOfEntities.size() + " &ecustom entity names"); + CMIMessages.consoleMessage("&eLoaded &6" + listOfEntities.size() + " &ecustom entity names"); } else - Jobs.consoleMsg("&cThe EntityList section not found in &6" + itemFile.fileName + " &cfile."); + CMIMessages.consoleMessage("&cThe EntityList section not found in &6" + itemFile.fileName + " &cfile."); if ((section = itemFile.getConfig().getConfigurationSection("MythicEntityList")) != null) { listOfMMEntities.clear(); @@ -265,9 +265,9 @@ public class NameTranslatorManager { } if (listOfMMEntities.size() > 0) - Jobs.consoleMsg("&eLoaded &6" + listOfMMEntities.size() + " &ecustom MythicMobs names"); + CMIMessages.consoleMessage("&eLoaded &6" + listOfMMEntities.size() + " &ecustom MythicMobs names"); } else - Jobs.consoleMsg("&cThe MythicEntityList section not found in &6" + itemFile.fileName + " &cfile."); + CMIMessages.consoleMessage("&cThe MythicEntityList section not found in &6" + itemFile.fileName + " &cfile."); if ((section = itemFile.getConfig().getConfigurationSection("EnchantList")) != null) { listOfEnchants.clear(); @@ -277,9 +277,9 @@ public class NameTranslatorManager { } if (listOfEnchants.size() > 0) - Jobs.consoleMsg("&eLoaded &6" + listOfEnchants.size() + " &ecustom enchant names"); + CMIMessages.consoleMessage("&eLoaded &6" + listOfEnchants.size() + " &ecustom enchant names"); } else - Jobs.consoleMsg("&cThe EnchantList section not found in &6" + itemFile.fileName + " &cfile."); + CMIMessages.consoleMessage("&cThe EnchantList section not found in &6" + itemFile.fileName + " &cfile."); if ((section = itemFile.getConfig().getConfigurationSection("PotionEffects")) != null) { listOfPotionEffects.clear(); @@ -289,9 +289,9 @@ public class NameTranslatorManager { } if (listOfPotionEffects.size() > 0) - Jobs.consoleMsg("&eLoaded &6" + listOfPotionEffects.size() + " &ecustom enchant names"); + CMIMessages.consoleMessage("&eLoaded &6" + listOfPotionEffects.size() + " &ecustom enchant names"); } else - Jobs.consoleMsg("&cThe PotionEffects section not found in &6" + itemFile.fileName + " &cfile."); + CMIMessages.consoleMessage("&cThe PotionEffects section not found in &6" + itemFile.fileName + " &cfile."); if ((section = itemFile.getConfig().getConfigurationSection("ColorList")) != null) { listOfColors.clear(); @@ -304,9 +304,9 @@ public class NameTranslatorManager { } if (!listOfColors.isEmpty()) - Jobs.consoleMsg("&eLoaded &6" + listOfColors.size() + " &ecustom color names"); + CMIMessages.consoleMessage("&eLoaded &6" + listOfColors.size() + " &ecustom color names"); } else - Jobs.consoleMsg("&cThe ColorList section not found in &6" + itemFile.fileName + " &cfile."); + CMIMessages.consoleMessage("&cThe ColorList section not found in &6" + itemFile.fileName + " &cfile."); } @SuppressWarnings("deprecation") diff --git a/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java b/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java index 48196e73..47fb4e5a 100644 --- a/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/RestrictedAreaManager.java @@ -20,6 +20,8 @@ import com.gamingmesh.jobs.container.CuboidArea; import com.gamingmesh.jobs.container.RestrictedArea; import com.gamingmesh.jobs.hooks.HookManager; +import net.Zrips.CMILib.Messages.CMIMessages; + public class RestrictedAreaManager { protected final Map restrictedAreas = new HashMap<>(); @@ -27,43 +29,43 @@ public class RestrictedAreaManager { private boolean worldGuardArea = false; public boolean isExist(String name) { - for (String area : restrictedAreas.keySet()) { - if (area.equalsIgnoreCase(name)) - return true; - } - return false; + for (String area : restrictedAreas.keySet()) { + if (area.equalsIgnoreCase(name)) + return true; + } + return false; } public void addNew(RestrictedArea ra) { - addNew(ra, false); + addNew(ra, false); } public void addNew(RestrictedArea ra, boolean save) { - restrictedAreas.put(ra.getName(), ra); - if (save) - save(); + restrictedAreas.put(ra.getName(), ra); + if (save) + save(); } public void remove(String name) { - for (String area : restrictedAreas.keySet()) { - if (area.equalsIgnoreCase(name)) { - restrictedAreas.remove(area); - break; - } - } - File f = new File(Jobs.getFolder(), "restrictedAreas.yml"); - if (f.exists()) { - YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); - conf.options().indent(2); - conf.options().copyDefaults(true); - addHeader(new StringBuilder()); - conf.set("restrictedareas." + name, null); - try { - conf.save(f); - } catch (IOException e) { - e.printStackTrace(); - } - } + for (String area : restrictedAreas.keySet()) { + if (area.equalsIgnoreCase(name)) { + restrictedAreas.remove(area); + break; + } + } + File f = new File(Jobs.getFolder(), "restrictedAreas.yml"); + if (f.exists()) { + YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); + conf.options().indent(2); + conf.options().copyDefaults(true); + addHeader(new StringBuilder()); + conf.set("restrictedareas." + name, null); + try { + conf.save(f); + } catch (IOException e) { + e.printStackTrace(); + } + } } /** @@ -74,44 +76,44 @@ public class RestrictedAreaManager { */ @Deprecated public Map getRestrictedAres() { - return restrictedAreas; + return restrictedAreas; } public Map getRestrictedAreas() { - return restrictedAreas; + return restrictedAreas; } private void save() { - File f = new File(Jobs.getFolder(), "restrictedAreas.yml"); - YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); + File f = new File(Jobs.getFolder(), "restrictedAreas.yml"); + YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); - conf.options().indent(2); - conf.options().copyDefaults(true); + conf.options().indent(2); + conf.options().copyDefaults(true); - addHeader(new StringBuilder()); + addHeader(new StringBuilder()); - for (Entry area : restrictedAreas.entrySet()) { - String areaKey = area.getKey(); - CuboidArea cuboid = area.getValue().getCuboidArea(); - conf.set("restrictedareas." + areaKey + ".multiplier", area.getValue().getMultiplier()); + for (Entry area : restrictedAreas.entrySet()) { + String areaKey = area.getKey(); + CuboidArea cuboid = area.getValue().getCuboidArea(); + conf.set("restrictedareas." + areaKey + ".multiplier", area.getValue().getMultiplier()); - if (area.getValue().getWgName() == null) { - conf.set("restrictedareas." + areaKey + ".world", cuboid.getWorld().getName()); - conf.set("restrictedareas." + areaKey + ".point1.x", cuboid.getLowLoc().getBlockX()); - conf.set("restrictedareas." + areaKey + ".point1.y", cuboid.getLowLoc().getBlockY()); - conf.set("restrictedareas." + areaKey + ".point1.z", cuboid.getLowLoc().getBlockZ()); - conf.set("restrictedareas." + areaKey + ".point2.x", cuboid.getHighLoc().getBlockX()); - conf.set("restrictedareas." + areaKey + ".point2.y", cuboid.getHighLoc().getBlockY()); - conf.set("restrictedareas." + areaKey + ".point2.z", cuboid.getHighLoc().getBlockZ()); - } else - conf.set("restrictedareas." + areaKey + ".WG", true); - } + if (area.getValue().getWgName() == null) { + conf.set("restrictedareas." + areaKey + ".world", cuboid.getWorld().getName()); + conf.set("restrictedareas." + areaKey + ".point1.x", cuboid.getLowLoc().getBlockX()); + conf.set("restrictedareas." + areaKey + ".point1.y", cuboid.getLowLoc().getBlockY()); + conf.set("restrictedareas." + areaKey + ".point1.z", cuboid.getLowLoc().getBlockZ()); + conf.set("restrictedareas." + areaKey + ".point2.x", cuboid.getHighLoc().getBlockX()); + conf.set("restrictedareas." + areaKey + ".point2.y", cuboid.getHighLoc().getBlockY()); + conf.set("restrictedareas." + areaKey + ".point2.z", cuboid.getHighLoc().getBlockZ()); + } else + conf.set("restrictedareas." + areaKey + ".WG", true); + } - try { - conf.save(f); - } catch (IOException e) { - e.printStackTrace(); - } + try { + conf.save(f); + } catch (IOException e) { + e.printStackTrace(); + } } /** @@ -120,74 +122,74 @@ public class RestrictedAreaManager { * @return - the multiplier */ public double getRestrictedMultiplier(Player player) { - if (player == null) - return 0D; - for (RestrictedArea area : getRestrictedAreasByLoc(player.getLocation())) { - if (area.inRestrictedArea(player.getLocation()) || (area.getWgName() != null && HookManager.getWorldGuardManager() != null - && HookManager.getWorldGuardManager().inArea(player.getLocation(), area.getWgName()))) - return area.getMultiplier(); - } - return 0D; + if (player == null) + return 0D; + for (RestrictedArea area : getRestrictedAreasByLoc(player.getLocation())) { + if (area.inRestrictedArea(player.getLocation()) || (area.getWgName() != null && HookManager.getWorldGuardManager() != null + && HookManager.getWorldGuardManager().inArea(player.getLocation(), area.getWgName()))) + return area.getMultiplier(); + } + return 0D; } public List getRestrictedAreasByLoc(Location loc) { - List areas = new ArrayList<>(); - for (RestrictedArea area : restrictedAreas.values()) { - if (area.inRestrictedArea(loc)) - areas.add(area); - } + List areas = new ArrayList<>(); + for (RestrictedArea area : restrictedAreas.values()) { + if (area.inRestrictedArea(loc)) + areas.add(area); + } - if (worldGuardArea && HookManager.getWorldGuardManager() != null) - areas.addAll(HookManager.getWorldGuardManager().getArea(loc)); + if (worldGuardArea && HookManager.getWorldGuardManager() != null) + areas.addAll(HookManager.getWorldGuardManager().getArea(loc)); - return areas; + return areas; } public List getRestrictedAreasByName(String name) { - List areas = new ArrayList<>(); - for (Entry area : restrictedAreas.entrySet()) { - if (area.getKey().equalsIgnoreCase(name)) - areas.add(area.getValue()); - } - return areas; + List areas = new ArrayList<>(); + for (Entry area : restrictedAreas.entrySet()) { + if (area.getKey().equalsIgnoreCase(name)) + areas.add(area.getValue()); + } + return areas; } private static StringBuilder addHeader(StringBuilder header) { - String sep = System.lineSeparator(); + String sep = System.lineSeparator(); - header.append("Restricted area configuration"); - header.append(sep) - .append(sep) - .append("Configures restricted areas where you cannot get experience or money").append(sep) - .append("when performing a job.").append(sep).append(sep) - .append("The multiplier changes the experience/money gains in an area.").append(sep) - .append("A multiplier of 0.0 means no bonus, while 0.5 means you will get 50% more the normal income").append(sep) - .append("While -0.5 means that you will get 50% less the normal income").append(sep) - .append(sep) - .append("restrictedareas:").append(sep) - .append(" area1:").append(sep) - .append(" world: 'world'").append(sep) - .append(" multiplier: 0.0").append(sep) - .append(" point1:").append(sep) - .append(" x: 125").append(sep) - .append(" y: 0").append(sep) - .append(" z: 125").append(sep) - .append(" point2:").append(sep) - .append(" x: 150").append(sep) - .append(" y: 100").append(sep) - .append(" z: 150").append(sep) - .append(" area2:").append(sep) - .append(" world: 'world_nether'").append(sep) - .append(" multiplier: 0.0").append(sep) - .append(" point1:").append(sep) - .append(" x: -100").append(sep) - .append(" y: 0").append(sep) - .append(" z: -100").append(sep) - .append(" point2:").append(sep) - .append(" x: -150").append(sep) - .append(" y: 100").append(sep) - .append(" z: -150"); - return header; + header.append("Restricted area configuration"); + header.append(sep) + .append(sep) + .append("Configures restricted areas where you cannot get experience or money").append(sep) + .append("when performing a job.").append(sep).append(sep) + .append("The multiplier changes the experience/money gains in an area.").append(sep) + .append("A multiplier of 0.0 means no bonus, while 0.5 means you will get 50% more the normal income").append(sep) + .append("While -0.5 means that you will get 50% less the normal income").append(sep) + .append(sep) + .append("restrictedareas:").append(sep) + .append(" area1:").append(sep) + .append(" world: 'world'").append(sep) + .append(" multiplier: 0.0").append(sep) + .append(" point1:").append(sep) + .append(" x: 125").append(sep) + .append(" y: 0").append(sep) + .append(" z: 125").append(sep) + .append(" point2:").append(sep) + .append(" x: 150").append(sep) + .append(" y: 100").append(sep) + .append(" z: 150").append(sep) + .append(" area2:").append(sep) + .append(" world: 'world_nether'").append(sep) + .append(" multiplier: 0.0").append(sep) + .append(" point1:").append(sep) + .append(" x: -100").append(sep) + .append(" y: 0").append(sep) + .append(" z: -100").append(sep) + .append(" point2:").append(sep) + .append(" x: -150").append(sep) + .append(" y: 100").append(sep) + .append(" z: -150"); + return header; } /** @@ -196,47 +198,47 @@ public class RestrictedAreaManager { * loads from Jobs/restrictedAreas.yml */ public void load() { - restrictedAreas.clear(); + restrictedAreas.clear(); - File f = new File(Jobs.getFolder(), "restrictedAreas.yml"); - YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); + File f = new File(Jobs.getFolder(), "restrictedAreas.yml"); + YamlConfiguration conf = YamlConfiguration.loadConfiguration(f); - conf.options().indent(2); - conf.options().copyDefaults(true); + conf.options().indent(2); + conf.options().copyDefaults(true); - StringBuilder header = addHeader(new StringBuilder()); - conf.options().header(header.toString()); + StringBuilder header = addHeader(new StringBuilder()); + conf.options().header(header.toString()); - ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas"); - if (areaSection != null) { - for (String areaKey : areaSection.getKeys(false)) { - double multiplier = areaSection.getDouble(areaKey + ".multiplier"); + ConfigurationSection areaSection = conf.getConfigurationSection("restrictedareas"); + if (areaSection != null) { + for (String areaKey : areaSection.getKeys(false)) { + double multiplier = areaSection.getDouble(areaKey + ".multiplier"); - if (areaSection.isBoolean(areaKey + ".WG")) { - addNew(new RestrictedArea(areaKey, areaKey, multiplier)); - worldGuardArea = true; - } else { - World world = Bukkit.getServer().getWorld(areaSection.getString(areaKey + ".world", "")); - if (world == null) - continue; - Location point1 = new Location(world, areaSection.getDouble(areaKey + ".point1.x"), areaSection.getDouble(areaKey - + ".point1.y"), areaSection.getDouble(areaKey + ".point1.z")); + if (areaSection.isBoolean(areaKey + ".WG")) { + addNew(new RestrictedArea(areaKey, areaKey, multiplier)); + worldGuardArea = true; + } else { + World world = Bukkit.getServer().getWorld(areaSection.getString(areaKey + ".world", "")); + if (world == null) + continue; + Location point1 = new Location(world, areaSection.getDouble(areaKey + ".point1.x"), areaSection.getDouble(areaKey + + ".point1.y"), areaSection.getDouble(areaKey + ".point1.z")); - Location point2 = new Location(world, areaSection.getDouble(areaKey + ".point2.x"), areaSection.getDouble(areaKey - + ".point2.y"), areaSection.getDouble(areaKey + ".point2.z")); - addNew(new RestrictedArea(areaKey, new CuboidArea(point1, point2), multiplier)); - } - } - } + Location point2 = new Location(world, areaSection.getDouble(areaKey + ".point2.x"), areaSection.getDouble(areaKey + + ".point2.y"), areaSection.getDouble(areaKey + ".point2.z")); + addNew(new RestrictedArea(areaKey, new CuboidArea(point1, point2), multiplier)); + } + } + } - int size = restrictedAreas.size(); - if (size > 0) - Jobs.consoleMsg("&e[Jobs] Loaded " + size + " restricted areas!"); + int size = restrictedAreas.size(); + if (size > 0) + CMIMessages.consoleMessage("&e[Jobs] Loaded " + size + " restricted areas!"); - try { - conf.save(f); - } catch (IOException e) { - e.printStackTrace(); - } + try { + conf.save(f); + } catch (IOException e) { + e.printStackTrace(); + } } } diff --git a/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java b/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java index da7584d0..48d75bb3 100644 --- a/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/RestrictedBlockManager.java @@ -8,6 +8,7 @@ import com.gamingmesh.jobs.Jobs; import net.Zrips.CMILib.FileHandler.ConfigReader; import net.Zrips.CMILib.Items.CMIItemStack; import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Messages.CMIMessages; public class RestrictedBlockManager { @@ -18,69 +19,69 @@ public class RestrictedBlockManager { * loads from Jobs/restrictedBlocks.yml */ public void load() { - if (!Jobs.getGCManager().useBlockProtection) - return; + if (!Jobs.getGCManager().useBlockProtection) + return; - ConfigReader cfg = null; - try { - cfg = new ConfigReader(Jobs.getInstance(), "restrictedBlocks.yml"); - } catch (Exception e) { - e.printStackTrace(); - } + ConfigReader cfg = null; + try { + cfg = new ConfigReader(Jobs.getInstance(), "restrictedBlocks.yml"); + } catch (Exception e) { + e.printStackTrace(); + } - if (cfg == null) - return; + if (cfg == null) + return; - cfg.addComment("blocksTimer", "Block protected by timer in sec", - "Category name can be any you like to be easily recognized", - "id can be actual block id (use /jobs blockinfo to get correct id) or use block name", - "By setting time to -1 will keep block protected until global cleanup, mainly used for structure blocks like diamond", - "Set to 0 if you want to disable protection on specific blocks", - "If you want to have default value for all blocks, enable GlobalBlockTimer in generalConfig file"); + cfg.addComment("blocksTimer", "Block protected by timer in sec", + "Category name can be any you like to be easily recognized", + "id can be actual block id (use /jobs blockinfo to get correct id) or use block name", + "By setting time to -1 will keep block protected until global cleanup, mainly used for structure blocks like diamond", + "Set to 0 if you want to disable protection on specific blocks", + "If you want to have default value for all blocks, enable GlobalBlockTimer in generalConfig file"); - org.bukkit.configuration.ConfigurationSection section = cfg.getC().getConfigurationSection("blocksTimer"); - if (section != null) { - for (String one : section.getKeys(false)) { - if ((section.isString(one + ".id") || section.isInt(one + ".id")) && section.isInt(one + ".cd")) { - CMIItemStack cm = CMIMaterial.get(section.getString(one + ".id")).newCMIItemStack(); - CMIMaterial mat = cm == null ? null : cm.getCMIType(); + org.bukkit.configuration.ConfigurationSection section = cfg.getC().getConfigurationSection("blocksTimer"); + if (section != null) { + for (String one : section.getKeys(false)) { + if ((section.isString(one + ".id") || section.isInt(one + ".id")) && section.isInt(one + ".cd")) { + CMIItemStack cm = CMIMaterial.get(section.getString(one + ".id")).newCMIItemStack(); + CMIMaterial mat = cm == null ? null : cm.getCMIType(); - if (mat == null || !mat.isBlock()) { - Jobs.consoleMsg("&eYour defined (&6" + one + "&e) protected block id/name is not correct!"); - continue; - } + if (mat == null || !mat.isBlock()) { + CMIMessages.consoleMessage("&eYour defined (&6" + one + "&e) protected block id/name is not correct!"); + continue; + } - int cd = section.getInt(one + ".cd"); - restrictedBlocksTimer.put(mat, cd); - cfg.set("blocksTimer." + mat.name(), cd); - } else { - CMIMaterial mat = CMIMaterial.get(one); - if (mat == CMIMaterial.NONE) - continue; + int cd = section.getInt(one + ".cd"); + restrictedBlocksTimer.put(mat, cd); + cfg.set("blocksTimer." + mat.name(), cd); + } else { + CMIMaterial mat = CMIMaterial.get(one); + if (mat == CMIMaterial.NONE) + continue; - int timer = cfg.get("blocksTimer." + one, -99); - if (timer == -99) { - cfg.set("blocksTimer." + one, null); - continue; - } + int timer = cfg.get("blocksTimer." + one, -99); + if (timer == -99) { + cfg.set("blocksTimer." + one, null); + continue; + } - cfg.set("blocksTimer." + one, null); - cfg.get("blocksTimer." + mat.name(), timer); + cfg.set("blocksTimer." + one, null); + cfg.get("blocksTimer." + mat.name(), timer); - if (!mat.isBlock()) { - Jobs.consoleMsg("&e[Jobs] Your defined (" + one + ") protected block id/name is not correct!"); - continue; - } + if (!mat.isBlock()) { + CMIMessages.consoleMessage("&e[Jobs] Your defined (" + one + ") protected block id/name is not correct!"); + continue; + } - restrictedBlocksTimer.put(mat, timer); - } - } - } + restrictedBlocksTimer.put(mat, timer); + } + } + } - int size = restrictedBlocksTimer.size(); - if (size > 0) - Jobs.consoleMsg("&eLoaded &6" + size + " &eprotected blocks timers"); + int size = restrictedBlocksTimer.size(); + if (size > 0) + CMIMessages.consoleMessage("&eLoaded &6" + size + " &eprotected blocks timers"); - cfg.save(); + cfg.save(); } } diff --git a/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java b/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java index 4c9cef7f..e2a33536 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ScheduleManager.java @@ -7,20 +7,20 @@ import java.util.Calendar; import java.util.Date; import java.util.List; -import com.gamingmesh.jobs.api.JobsScheduleStartEvent; -import com.gamingmesh.jobs.api.JobsScheduleStopEvent; import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.scheduler.BukkitTask; import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.api.JobsScheduleStartEvent; +import com.gamingmesh.jobs.api.JobsScheduleStopEvent; import com.gamingmesh.jobs.container.BoostMultiplier; import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.Schedule; -import net.Zrips.CMILib.Logs.CMIDebug; +import net.Zrips.CMILib.Messages.CMIMessages; public class ScheduleManager { @@ -180,7 +180,7 @@ public class ScheduleManager { !path.isList("Days") && !path.isString("Days") || !path.isList("Jobs") && !path.isString("Jobs")) { - Jobs.consoleMsg("&cIncorect scheduler format detected for " + oneSection + " scheduler!"); + CMIMessages.consoleMessage("&cIncorect scheduler format detected for " + oneSection + " scheduler!"); continue; } @@ -228,6 +228,6 @@ public class ScheduleManager { } if (!BOOSTSCHEDULE.isEmpty()) - Jobs.consoleMsg("&eLoaded " + BOOSTSCHEDULE.size() + " schedulers!"); + CMIMessages.consoleMessage("&eLoaded " + BOOSTSCHEDULE.size() + " schedulers!"); } } diff --git a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java index b0894df1..75530ae5 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ShopManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ShopManager.java @@ -497,6 +497,6 @@ public class ShopManager { } if (!list.isEmpty()) - Jobs.consoleMsg("&eLoaded &6" + list.size() + " &eshop items"); + CMIMessages.consoleMessage("&eLoaded &6" + list.size() + " &eshop items"); } } diff --git a/src/main/java/com/gamingmesh/jobs/config/TitleManager.java b/src/main/java/com/gamingmesh/jobs/config/TitleManager.java index d46b0293..cdae3322 100644 --- a/src/main/java/com/gamingmesh/jobs/config/TitleManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/TitleManager.java @@ -11,6 +11,7 @@ import com.gamingmesh.jobs.container.Title; import net.Zrips.CMILib.Colors.CMIChatColor; import net.Zrips.CMILib.FileHandler.ConfigReader; +import net.Zrips.CMILib.Messages.CMIMessages; public class TitleManager { @@ -157,6 +158,6 @@ public class TitleManager { int size = titles.size(); if (size > 0) - Jobs.consoleMsg("&eLoaded &6" + size + " &etitles"); + CMIMessages.consoleMessage("&eLoaded &6" + size + " &etitles"); } } diff --git a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java index 6cce09dc..247e3ac9 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java @@ -22,9 +22,9 @@ import java.util.HashMap; import java.util.Map; import com.gamingmesh.jobs.Jobs; -import com.gamingmesh.jobs.stuff.TimeManage; import com.gamingmesh.jobs.stuff.Util; +import net.Zrips.CMILib.Container.CMINumber; import net.Zrips.CMILib.Time.CMITimeManager; public class JobProgression { @@ -146,7 +146,7 @@ public class JobProgression { */ public String getLevelFormatted() { if (Jobs.getGCManager().RomanNumbers) - return Util.toRoman(level); + return CMINumber.toRoman(level); return String.valueOf(level); } diff --git a/src/main/java/com/gamingmesh/jobs/container/Log.java b/src/main/java/com/gamingmesh/jobs/container/Log.java index cec97c5a..998c54b8 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Log.java +++ b/src/main/java/com/gamingmesh/jobs/container/Log.java @@ -3,7 +3,7 @@ package com.gamingmesh.jobs.container; import java.util.HashMap; import java.util.Map; -import com.gamingmesh.jobs.stuff.TimeManage; +import net.Zrips.CMILib.Time.CMITimeManager; public final class Log { @@ -36,7 +36,7 @@ public final class Log { } public void setDate() { - this.day = TimeManage.timeInInt(); + this.day = CMITimeManager.timeInInt(); } public int getDate() { diff --git a/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java b/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java index 4e59859e..6829e3bc 100644 --- a/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java +++ b/src/main/java/com/gamingmesh/jobs/container/QuestProgression.java @@ -4,15 +4,12 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import com.gamingmesh.jobs.actions.EnchantActionInfo; -import com.gamingmesh.jobs.stuff.Util; - -import net.Zrips.CMILib.Logs.CMIDebug; - import org.bukkit.Bukkit; import org.bukkit.event.server.ServerCommandEvent; import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.actions.EnchantActionInfo; +import com.gamingmesh.jobs.stuff.Util; public class QuestProgression { diff --git a/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java b/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java index 8ae0fbe3..2717f1d5 100644 --- a/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java +++ b/src/main/java/com/gamingmesh/jobs/container/blockOwnerShip/BlockOwnerShip.java @@ -24,6 +24,7 @@ import com.gamingmesh.jobs.stuff.blockLoc; import net.Zrips.CMILib.Container.CMILocation; import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Messages.CMIMessages; public class BlockOwnerShip { @@ -380,7 +381,7 @@ public class BlockOwnerShip { } if (total > 0) { - Jobs.consoleMsg("&eLoaded &6" + total + " " + path.toLowerCase() + " &efor reassigning."); + CMIMessages.consoleMessage("&eLoaded &6" + total + " " + path.toLowerCase() + " &efor reassigning."); } } diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java index 191832f7..0ec3d9ec 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java @@ -41,10 +41,10 @@ import com.gamingmesh.jobs.container.PlayerPoints; import com.gamingmesh.jobs.container.TopList; import com.gamingmesh.jobs.dao.JobsManager.DataBaseType; import com.gamingmesh.jobs.economy.PaymentData; -import com.gamingmesh.jobs.stuff.TimeManage; import com.gamingmesh.jobs.stuff.Util; import net.Zrips.CMILib.Messages.CMIMessages; +import net.Zrips.CMILib.Time.CMITimeManager; public abstract class JobsDAO { @@ -819,7 +819,7 @@ public abstract class JobsDAO { PreparedStatement prest = null; ResultSet res = null; try { - int time = TimeManage.timeInInt(); + int time = CMITimeManager.timeInInt(); prest = conn.prepareStatement("SELECT * FROM `" + DBTables.LogTable.getTableName() + "` WHERE `" + LogTableFields.time.getCollumn() + "` = ? ;"); prest.setInt(1, time); res = prest.executeQuery(); @@ -1017,9 +1017,9 @@ public abstract class JobsDAO { // Lets convert old fields if (!converted) { Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> { - Jobs.consoleMsg("&6[Jobs] Converting to new database format"); + CMIMessages.consoleMessage("&6[Jobs] Converting to new database format"); convertID(); - Jobs.consoleMsg("&6[Jobs] Converted to new database format"); + CMIMessages.consoleMessage("&6[Jobs] Converted to new database format"); converted = true; }, 60L); } @@ -2311,7 +2311,7 @@ public abstract class JobsDAO { PreparedStatement prest = null; ResultSet res = null; try { - int time = TimeManage.timeInInt(); + int time = CMITimeManager.timeInInt(); prest = conn.prepareStatement("SELECT * FROM `" + DBTables.LogTable.getTableName() + "` WHERE `" + LogTableFields.userid.getCollumn() + "` = ? AND `" + LogTableFields.time.getCollumn() + "` = ? ;"); prest.setInt(1, player.getUserId()); @@ -2508,12 +2508,12 @@ public abstract class JobsDAO { i++; if (ii++ >= 100000) { - Jobs.consoleMsg("&6[Jobs] Loading (" + i + ") BP"); + CMIMessages.consoleMessage("&6[Jobs] Loading (" + i + ") BP"); ii = 0; } } if (i > 0) { - Jobs.consoleMsg("&e[Jobs] Loaded " + i + " block protection entries. " + (System.currentTimeMillis() - timer) + "ms"); + CMIMessages.consoleMessage("&e[Jobs] Loaded " + i + " block protection entries. " + (System.currentTimeMillis() - timer) + "ms"); } } catch (SQLException e) { e.printStackTrace(); @@ -2577,7 +2577,7 @@ public abstract class JobsDAO { conn.setAutoCommit(true); if (i > 0) - Jobs.consoleMsg("&e[Jobs] Saved " + i + " new explorer entries."); + CMIMessages.consoleMessage("&e[Jobs] Saved " + i + " new explorer entries."); } catch (SQLException e) { e.printStackTrace(); } finally { @@ -2624,7 +2624,7 @@ public abstract class JobsDAO { conn.setAutoCommit(true); if (i > 0) - Jobs.consoleMsg("&e[Jobs] Updated " + i + " explorer entries."); + CMIMessages.consoleMessage("&e[Jobs] Updated " + i + " explorer entries."); } catch (SQLException e) { e.printStackTrace(); diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsManager.java b/src/main/java/com/gamingmesh/jobs/dao/JobsManager.java index 5071a0c3..cb47de79 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsManager.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsManager.java @@ -6,7 +6,7 @@ import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.container.LoadStatus; import net.Zrips.CMILib.FileHandler.ConfigReader; -import net.Zrips.CMILib.Logs.CMIDebug; +import net.Zrips.CMILib.Messages.CMIMessages; public class JobsManager { private JobsDAO dao; @@ -70,9 +70,9 @@ public class JobsManager { public void start() { if (Jobs.getJobsDAO() != null) { - Jobs.consoleMsg("&eClosing existing database connection..."); + CMIMessages.consoleMessage("&eClosing existing database connection..."); Jobs.getJobsDAO().closeConnections(); - Jobs.consoleMsg("&eClosed"); + CMIMessages.consoleMessage("&eClosed"); } ConfigReader c = Jobs.getGCManager().getConfig(); @@ -100,7 +100,7 @@ public class JobsManager { } } else { if (!storageMethod.equalsIgnoreCase("sqlite")) { - Jobs.consoleMsg("&cInvalid storage method! Changing method to sqlite!"); + CMIMessages.consoleMessage("&cInvalid storage method! Changing method to sqlite!"); c.set("storage.method", "sqlite"); } diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java b/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java index fa84c7c6..61856d49 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsMySQL.java @@ -8,7 +8,7 @@ import java.sql.Statement; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.dao.JobsManager.DataBaseType; -import net.Zrips.CMILib.Logs.CMIDebug; +import net.Zrips.CMILib.Messages.CMIMessages; public class JobsMySQL extends JobsDAO { @@ -52,7 +52,7 @@ public class JobsMySQL extends JobsDAO { protected void checkUpdate() throws SQLException { JobsConnection conn = getConnection(); if (conn == null) { - Jobs.consoleMsg("&cCould not run database updates! Could not connect to MySQL!"); + CMIMessages.consoleMessage("&cCould not run database updates! Could not connect to MySQL!"); return; } @@ -77,7 +77,7 @@ public class JobsMySQL extends JobsDAO { @Override public boolean createTable(String query) { if (query == null || query.isEmpty()) { - Jobs.consoleMsg("&cCould not create table: query is empty or null."); + CMIMessages.consoleMessage("&cCould not create table: query is empty or null."); return false; } JobsConnection conn = getConnection(); @@ -88,7 +88,7 @@ public class JobsMySQL extends JobsDAO { statement = conn.createStatement(); statement.execute(query); } catch (SQLException e) { - Jobs.consoleMsg("&cCould not create table, SQLException: " + e.getMessage()); + CMIMessages.consoleMessage("&cCould not create table, SQLException: " + e.getMessage()); return false; } finally { close(statement); @@ -111,7 +111,7 @@ public class JobsMySQL extends JobsDAO { tables.close(); return false; } catch (SQLException e) { - Jobs.consoleMsg("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|"); + CMIMessages.consoleMessage("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|"); } PreparedStatement insert = null; @@ -125,7 +125,7 @@ public class JobsMySQL extends JobsDAO { return true; } } catch (SQLException e) { - Jobs.consoleMsg("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|"); + CMIMessages.consoleMessage("Not a table |" + "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='" + table + "';" + "|"); } finally { close(res); close(insert); @@ -140,14 +140,14 @@ public class JobsMySQL extends JobsDAO { try { statement = getConnection().createStatement(); } catch (SQLException e) { - Jobs.consoleMsg("&cCould not check if its collumn, SQLException: " + e.getMessage()); + CMIMessages.consoleMessage("&cCould not check if its collumn, SQLException: " + e.getMessage()); return false; } try { statement.executeQuery("SELECT `" + collumn + "` FROM `" + table + "`;"); return true; } catch (SQLException e) { - Jobs.consoleMsg("Not a collumn |" + "SELECT " + collumn + " FROM " + table + "|"); + CMIMessages.consoleMessage("Not a collumn |" + "SELECT " + collumn + " FROM " + table + "|"); return false; } finally { close(statement); @@ -160,11 +160,11 @@ public class JobsMySQL extends JobsDAO { try { statement = getConnection().createStatement(); } catch (SQLException e) { - Jobs.consoleMsg("&cCould not add new collumn, SQLException: " + e.getMessage()); + CMIMessages.consoleMessage("&cCould not add new collumn, SQLException: " + e.getMessage()); return false; } try { - Jobs.consoleMsg("Creating collumn |" + "ALTER TABLE `" + table + "` ADD COLUMN `" + collumn + "` " + type + ";" + "|"); + CMIMessages.consoleMessage("Creating collumn |" + "ALTER TABLE `" + table + "` ADD COLUMN `" + collumn + "` " + type + ";" + "|"); statement.executeUpdate("ALTER TABLE `" + table + "` ADD COLUMN `" + collumn + "` " + type + ";"); return true; } catch (SQLException e) { @@ -179,14 +179,14 @@ public class JobsMySQL extends JobsDAO { Statement statement = null; try { if (!isTable(table)) { - Jobs.consoleMsg("&cTable \"" + table + "\" does not exist."); + CMIMessages.consoleMessage("&cTable \"" + table + "\" does not exist."); return false; } statement = getConnection().createStatement(); statement.executeUpdate("DELETE FROM " + table + ";"); return true; } catch (SQLException e) { - Jobs.consoleMsg("&cCould not wipe table, SQLException: " + e.getMessage()); + CMIMessages.consoleMessage("&cCould not wipe table, SQLException: " + e.getMessage()); e.printStackTrace(); return false; } finally { @@ -199,14 +199,14 @@ public class JobsMySQL extends JobsDAO { Statement statement = null; try { if (!isTable(table)) { - Jobs.consoleMsg("&cTable \"" + table + "\" does not exist."); + CMIMessages.consoleMessage("&cTable \"" + table + "\" does not exist."); return false; } statement = getConnection().createStatement(); statement.executeUpdate("DROP TABLE IF EXISTS `" + table + "`;"); return true; } catch (SQLException e) { - Jobs.consoleMsg("&cCould not wipe table, SQLException: " + e.getMessage()); + CMIMessages.consoleMessage("&cCould not wipe table, SQLException: " + e.getMessage()); e.printStackTrace(); return false; } finally { diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsSQLite.java b/src/main/java/com/gamingmesh/jobs/dao/JobsSQLite.java index aafc7d59..537931f6 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsSQLite.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsSQLite.java @@ -8,6 +8,8 @@ import java.sql.Statement; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.dao.JobsManager.DataBaseType; +import net.Zrips.CMILib.Messages.CMIMessages; + public class JobsSQLite extends JobsDAO { public void initialize() { @@ -32,7 +34,7 @@ public class JobsSQLite extends JobsDAO { protected void checkUpdate() throws SQLException { JobsConnection conn = getConnection(); if (conn == null) { - Jobs.consoleMsg("&cCould not run database updates! Could not connect to MySQL!"); + CMIMessages.consoleMessage("&cCould not run database updates! Could not connect to MySQL!"); return; } @@ -59,7 +61,7 @@ public class JobsSQLite extends JobsDAO { Statement statement = null; try { if (query == null || query.isEmpty()) { - Jobs.consoleMsg("&cCould not create table: query is empty or null."); + CMIMessages.consoleMessage("&cCould not create table: query is empty or null."); return false; } @@ -67,7 +69,7 @@ public class JobsSQLite extends JobsDAO { statement.execute(query); return true; } catch (SQLException e) { - Jobs.consoleMsg("&cCould not create table, SQLException: " + e.getMessage()); + CMIMessages.consoleMessage("&cCould not create table, SQLException: " + e.getMessage()); return false; } finally { close(statement); @@ -85,7 +87,7 @@ public class JobsSQLite extends JobsDAO { tables.close(); return false; } catch (SQLException e) { - Jobs.consoleMsg("&cCould not check if table \"" + table + "\" exists, SQLException: " + e.getMessage()); + CMIMessages.consoleMessage("&cCould not check if table \"" + table + "\" exists, SQLException: " + e.getMessage()); return false; } } @@ -101,7 +103,7 @@ public class JobsSQLite extends JobsDAO { tables.close(); return false; } catch (SQLException e) { - Jobs.consoleMsg("&cCould not check if table \"" + table + "\" exists, SQLException: " + e.getMessage()); + CMIMessages.consoleMessage("&cCould not check if table \"" + table + "\" exists, SQLException: " + e.getMessage()); return false; } } @@ -112,7 +114,7 @@ public class JobsSQLite extends JobsDAO { try { statement = getConnection().createStatement(); } catch (SQLException e) { - Jobs.consoleMsg("&cCould not add new collumn, SQLException: " + e.getMessage()); + CMIMessages.consoleMessage("&cCould not add new collumn, SQLException: " + e.getMessage()); return false; } try { @@ -130,7 +132,7 @@ public class JobsSQLite extends JobsDAO { Statement statement = null; try { if (!isTable(table)) { - Jobs.consoleMsg("&cTable \"" + table + "\" does not exist."); + CMIMessages.consoleMessage("&cTable \"" + table + "\" does not exist."); return false; } statement = getConnection().createStatement(); @@ -139,7 +141,7 @@ public class JobsSQLite extends JobsDAO { } catch (SQLException e) { if (!(e.getMessage().toLowerCase().contains("locking") || e.getMessage().toLowerCase().contains("locked")) && !e.toString().contains("not return ResultSet")) - Jobs.consoleMsg("&cError in wipeTable() query: " + e); + CMIMessages.consoleMessage("&cError in wipeTable() query: " + e); return false; } finally { close(statement); @@ -151,7 +153,7 @@ public class JobsSQLite extends JobsDAO { Statement statement = null; try { if (!isTable(table)) { - Jobs.consoleMsg("&cTable \"" + table + "\" does not exist."); + CMIMessages.consoleMessage("&cTable \"" + table + "\" does not exist."); return false; } statement = getConnection().createStatement(); @@ -160,7 +162,7 @@ public class JobsSQLite extends JobsDAO { } catch (SQLException e) { if (!(e.getMessage().toLowerCase().contains("locking") || e.getMessage().toLowerCase().contains("locked")) && !e.toString().contains("not return ResultSet")) - Jobs.consoleMsg("&cError in dropTable() query: " + e); + CMIMessages.consoleMessage("&cError in dropTable() query: " + e); return false; } finally { close(statement); diff --git a/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java b/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java index 3f6c8868..7f5c65c1 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java @@ -15,6 +15,8 @@ import com.gamingmesh.jobs.hooks.WorldGuard.WorldGuardManager; import com.gamingmesh.jobs.hooks.stackMob.StackMobHandler; import com.gamingmesh.jobs.hooks.wildStacker.WildStackerHandler; +import net.Zrips.CMILib.Messages.CMIMessages; + public class HookManager { private static McMMOManager McMMOManager; @@ -88,7 +90,7 @@ public class HookManager { private static boolean setWorldGuard() { if (JobsHook.WorldGuard.isEnabled()) { worldGuardManager = new WorldGuardManager(); - Jobs.consoleMsg("&eWorldGuard detected."); + CMIMessages.consoleMessage("&eWorldGuard detected."); return true; } @@ -102,14 +104,14 @@ public class HookManager { try { Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper"); MythicManager = new MythicMobs4(PLUGIN); - Jobs.consoleMsg("&eMythicMobs 4.x detected."); + CMIMessages.consoleMessage("&eMythicMobs 4.x detected."); } catch (ClassNotFoundException ex) { try { Class.forName("io.lumine.mythic.bukkit.BukkitAPIHelper"); MythicManager = new MythicMobs5(PLUGIN); - Jobs.consoleMsg("&eMythicMobs 5.x detected."); + CMIMessages.consoleMessage("&eMythicMobs 5.x detected."); } catch (ClassNotFoundException e) { - Jobs.consoleMsg("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+"); + CMIMessages.consoleMessage("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+"); } } } @@ -118,17 +120,17 @@ public class HookManager { try { Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType"); pm.registerEvents(new McMMO2_X_listener(), PLUGIN); - Jobs.consoleMsg("&eRegistered McMMO 2.x listener"); + CMIMessages.consoleMessage("&eRegistered McMMO 2.x listener"); } catch (ClassNotFoundException e) { pm.registerEvents(new McMMO1_X_listener(), PLUGIN); - Jobs.consoleMsg("&eRegistered McMMO 1.x listener"); + CMIMessages.consoleMessage("&eRegistered McMMO 1.x listener"); } } private static void setMyPetManager() { if (JobsHook.MyPet.isEnabled()) { myPetManager = new MyPetManager(); - Jobs.consoleMsg("&eMyPet detected."); + CMIMessages.consoleMessage("&eMyPet detected."); } } diff --git a/src/main/java/com/gamingmesh/jobs/hooks/McMMO/McMMOManager.java b/src/main/java/com/gamingmesh/jobs/hooks/McMMO/McMMOManager.java index e73576cf..3044e189 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/McMMO/McMMOManager.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/McMMO/McMMOManager.java @@ -10,6 +10,8 @@ import org.bukkit.plugin.Plugin; import com.gamingmesh.jobs.Jobs; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; +import net.Zrips.CMILib.Messages.CMIMessages; + public class McMMOManager { public boolean mcMMOPresent = false; @@ -100,13 +102,13 @@ public class McMMOManager { mcMMOPresent = false; } if (!mcMMOPresent) - Jobs.consoleMsg("&6mcMMO was found - &cBut your McMMO version is outdated, please update for full support."); + CMIMessages.consoleMessage("&6mcMMO was found - &cBut your McMMO version is outdated, please update for full support."); // Still enabling event listener for repair return true; } - Jobs.consoleMsg("&6mcMMO" + McMMO.getDescription().getVersion() + " was found - Enabling capabilities."); + CMIMessages.consoleMessage("&6mcMMO" + McMMO.getDescription().getVersion() + " was found - Enabling capabilities."); return true; } 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 f189e022..13818813 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs4.java @@ -8,6 +8,7 @@ import com.gamingmesh.jobs.Jobs; import io.lumine.xikage.mythicmobs.MythicMobs; import io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper; import io.lumine.xikage.mythicmobs.mobs.MythicMob; +import net.Zrips.CMILib.Messages.CMIMessages; public class MythicMobs4 implements MythicMobInterface { @@ -40,12 +41,12 @@ public class MythicMobs4 implements MythicMobInterface { Class.forName("io.lumine.xikage.mythicmobs.MythicMobs"); } catch (ClassNotFoundException e) { // Disabling - Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support."); + CMIMessages.consoleMessage("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support."); return false; } apiHelper = ((MythicMobs) mm).getAPIHelper(); - Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - Enabling capabilities."); + CMIMessages.consoleMessage("&e[Jobs] &6MythicMobs was found - Enabling capabilities."); return true; } @@ -64,7 +65,7 @@ public class MythicMobs4 implements MythicMobInterface { if (!failed) { failed = true; e.printStackTrace(); - Jobs.consoleMsg("&cEncountered error when checking MythicMob entity name. Support for mythicMobs will be suspended for time beying. Please report this issue."); + CMIMessages.consoleMessage("&cEncountered error when checking MythicMob entity name. Support for mythicMobs will be suspended for time beying. Please report this issue."); } } diff --git a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5.java b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5.java index b842ab2d..21b17a48 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5.java @@ -8,6 +8,7 @@ import com.gamingmesh.jobs.Jobs; import io.lumine.mythic.api.mobs.MythicMob; import io.lumine.mythic.bukkit.BukkitAPIHelper; import io.lumine.mythic.bukkit.MythicBukkit; +import net.Zrips.CMILib.Messages.CMIMessages; //import io.lumine.xikage.mythicmobs.MythicMobs; //import io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper; @@ -44,12 +45,12 @@ public class MythicMobs5 implements MythicMobInterface { Class.forName("io.lumine.mythic.bukkit.events.MythicMobDeathEvent"); } catch (ClassNotFoundException e) { // Disabling - Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support."); + CMIMessages.consoleMessage("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support."); return false; } apiHelper = ((MythicBukkit) mm).getAPIHelper(); - Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - Enabling capabilities."); + CMIMessages.consoleMessage("&e[Jobs] &6MythicMobs was found - Enabling capabilities."); return true; } @@ -68,7 +69,7 @@ public class MythicMobs5 implements MythicMobInterface { if (!failed) { failed = true; e.printStackTrace(); - Jobs.consoleMsg("&cEncountered error when checking MythicMob entity name. Support for mythicMobs will be suspended for time beying. Please report this issue."); + CMIMessages.consoleMessage("&cEncountered error when checking MythicMob entity name. Support for mythicMobs will be suspended for time beying. Please report this issue."); } } diff --git a/src/main/java/com/gamingmesh/jobs/i18n/Language.java b/src/main/java/com/gamingmesh/jobs/i18n/Language.java index 2b3b9420..09a28ad0 100644 --- a/src/main/java/com/gamingmesh/jobs/i18n/Language.java +++ b/src/main/java/com/gamingmesh/jobs/i18n/Language.java @@ -31,6 +31,7 @@ import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.config.YmlMaker; import net.Zrips.CMILib.Colors.CMIChatColor; +import net.Zrips.CMILib.Messages.CMIMessages; public class Language { @@ -71,8 +72,8 @@ public class Language { else msg = customlocale.isString(key) ? CMIChatColor.translate(customlocale.getString(key)) : missing; } catch (Exception e) { - Jobs.consoleMsg("&e[Jobs] &2Can't read language file for: " + key); - Jobs.consoleMsg(e.getLocalizedMessage()); + CMIMessages.consoleMessage("&e[Jobs] &2Can't read language file for: " + key); + CMIMessages.consoleMessage(e.getLocalizedMessage()); return ""; } @@ -96,8 +97,8 @@ public class Language { msg += one; } } catch (Exception e) { - Jobs.consoleMsg("&e[Jobs] &2Can't read language file for: " + key); - Jobs.consoleMsg(e.getLocalizedMessage()); + CMIMessages.consoleMessage("&e[Jobs] &2Can't read language file for: " + key); + CMIMessages.consoleMessage(e.getLocalizedMessage()); return ""; } } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 8c452879..7e5b3aa0 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -398,7 +398,7 @@ public final class JobsPaymentListener implements Listener { if (player == null) return; - if (Jobs.getGCManager().blockOwnershipRange > 0 && Util.getDistance(player.getLocation(), block.getLocation()) > Jobs.getGCManager().blockOwnershipRange) + if (Jobs.getGCManager().blockOwnershipRange > 0 && CMILocation.getDistance(player.getLocation(), block.getLocation()) > Jobs.getGCManager().blockOwnershipRange) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player)) @@ -1222,7 +1222,7 @@ public final class JobsPaymentListener implements Listener { if (bos.isDisabled(uuid, block.getLocation())) return; - if (Jobs.getGCManager().blockOwnershipRange > 0 && Util.getDistance(player.getLocation(), block.getLocation()) > Jobs.getGCManager().blockOwnershipRange) + if (Jobs.getGCManager().blockOwnershipRange > 0 && CMILocation.getDistance(player.getLocation(), block.getLocation()) > Jobs.getGCManager().blockOwnershipRange) return; if (!Jobs.getPermissionHandler().hasWorldPermission(player)) diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Loging.java b/src/main/java/com/gamingmesh/jobs/stuff/Loging.java index a2c8f9e6..9b36a9db 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Loging.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Loging.java @@ -8,6 +8,8 @@ import com.gamingmesh.jobs.container.CurrencyType; import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.Log; +import net.Zrips.CMILib.Time.CMITimeManager; + public class Loging { public void recordToLog(JobsPlayer jPlayer, ActionInfo info, Map amounts) { @@ -17,7 +19,7 @@ public class Loging { public void recordToLog(JobsPlayer jPlayer, String actionName, String item, Map amounts) { Map logList = jPlayer.getLog(); Log l = logList.values().stream().findFirst().orElse(null); - if (l != null && TimeManage.timeInInt() != l.getDate()) { + if (l != null && CMITimeManager.timeInInt() != l.getDate()) { Jobs.getJobsDAO().saveLog(jPlayer); jPlayer.getLog().clear(); } diff --git a/src/main/java/com/gamingmesh/jobs/stuff/PerformCommands.java b/src/main/java/com/gamingmesh/jobs/stuff/PerformCommands.java deleted file mode 100644 index c459b53a..00000000 --- a/src/main/java/com/gamingmesh/jobs/stuff/PerformCommands.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.gamingmesh.jobs.stuff; - -import org.bukkit.Bukkit; - -import com.gamingmesh.jobs.container.Job; -import com.gamingmesh.jobs.container.JobsPlayer; - -public final class PerformCommands { - - public static void performCommandsOnLeave(JobsPlayer jPlayer, Job job) { - String pName = jPlayer.getName(); - - for (String one : job.getCmdOnLeave()) { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", pName).replace("[jobname]", job.getName())); - } - } - - public static void performCommandsOnJoin(JobsPlayer jPlayer, Job job) { - String pName = jPlayer.getName(); - - for (String one : job.getCmdOnJoin()) { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", pName).replace("[jobname]", job.getName())); - } - } -} diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Sorting.java b/src/main/java/com/gamingmesh/jobs/stuff/Sorting.java index cea5046d..8ef7f12f 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Sorting.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Sorting.java @@ -11,49 +11,6 @@ import java.util.Map; import com.gamingmesh.jobs.container.LogAmounts; public class Sorting { - public static Map sortDESC(Map unsortMap) { - - // Convert Map to List - List> list = new LinkedList<>(unsortMap.entrySet()); - - // Sort list with comparator, to compare the Map values - Collections.sort(list, new Comparator>() { - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return (o2.getValue()).compareTo(o1.getValue()); - } - }); - - // Convert sorted map back to a Map - Map sortedMap = new LinkedHashMap<>(); - for (Iterator> it = list.iterator(); it.hasNext();) { - Map.Entry entry = it.next(); - sortedMap.put(entry.getKey(), entry.getValue()); - } - return sortedMap; - } - - public static Map sortDoubleDESC(Map unsortMap) { - - // Convert Map to List - List> list = new LinkedList<>(unsortMap.entrySet()); - - // Sort list with comparator, to compare the Map values - Collections.sort(list, new Comparator>() { - @Override - public int compare(Map.Entry o1, Map.Entry o2) { - return (o2.getValue()).compareTo(o1.getValue()); - } - }); - - // Convert sorted map back to a Map - Map sortedMap = new LinkedHashMap<>(); - for (Iterator> it = list.iterator(); it.hasNext();) { - Map.Entry entry = it.next(); - sortedMap.put(entry.getKey(), entry.getValue()); - } - return sortedMap; - } public static Map sortDoubleDESCByLog(Map unsortMap) { diff --git a/src/main/java/com/gamingmesh/jobs/stuff/TimeManage.java b/src/main/java/com/gamingmesh/jobs/stuff/TimeManage.java deleted file mode 100644 index 9410d2d5..00000000 --- a/src/main/java/com/gamingmesh/jobs/stuff/TimeManage.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.gamingmesh.jobs.stuff; - -import java.text.SimpleDateFormat; -import java.util.Calendar; - -public class TimeManage { - - public static int timeInInt() { - return timeInInt(System.currentTimeMillis()); - } - - public static int timeInInt(Long time) { - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(time); - return Integer.valueOf(new SimpleDateFormat("YYMMdd").format(calendar.getTime())); - } -} diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Util.java b/src/main/java/com/gamingmesh/jobs/stuff/Util.java index 50f47a2b..8f1be8a8 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Util.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Util.java @@ -9,19 +9,15 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.TreeMap; import java.util.UUID; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import com.gamingmesh.jobs.CMILib.CMIEnchantment; -import com.gamingmesh.jobs.actions.EnchantActionInfo; import org.bukkit.Bukkit; import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -import org.bukkit.World; import org.bukkit.attribute.Attribute; import org.bukkit.block.Block; import org.bukkit.entity.Entity; @@ -38,6 +34,8 @@ import org.bukkit.potion.PotionType; import org.bukkit.util.BlockIterator; import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.CMILib.CMIEnchantment; +import com.gamingmesh.jobs.actions.EnchantActionInfo; import com.gamingmesh.jobs.container.JobsWorld; import net.Zrips.CMILib.Items.CMIMaterial; @@ -46,38 +44,12 @@ import net.Zrips.CMILib.Version.Version; @SuppressWarnings("deprecation") public final class Util { - private static Map jobsEditorMap = new HashMap<>(), questsEditorMap = new HashMap<>(); - + private static Map jobsEditorMap = new HashMap<>(); + private static Map questsEditorMap = new HashMap<>(); private static Map jobsWorlds = new HashMap<>(); public static final List LEAVECONFIRM = new ArrayList<>(); - private final static TreeMap map = new TreeMap(); - - static { - map.put(1000, "M"); - map.put(900, "CM"); - map.put(500, "D"); - map.put(400, "CD"); - map.put(100, "C"); - map.put(90, "XC"); - map.put(50, "L"); - map.put(40, "XL"); - map.put(10, "X"); - map.put(9, "IX"); - map.put(5, "V"); - map.put(4, "IV"); - map.put(1, "I"); - } - - public final static String toRoman(int number) { - int l = map.floorKey(number); - if (number == l) { - return map.get(number); - } - return map.get(l) + toRoman(number - l); - } - public static List getPistonRetractBlocks(BlockPistonRetractEvent event) { if (Version.isCurrentEqualOrHigher(Version.v1_8_R1)) { return new ArrayList<>(event.getBlocks()); @@ -88,17 +60,6 @@ public final class Util { return blocks; } - public static double getDistance(Location loc1, Location loc2) { - if (loc1 == null || loc2 == null || loc1.getWorld() != loc2.getWorld()) - return Integer.MAX_VALUE; - - try { - return loc1.distance(loc2); - } catch (Throwable e) { - return Integer.MAX_VALUE; - } - } - public static String getRealType(Entity entity) { if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) { return entity.getType().name(); diff --git a/src/main/java/com/gamingmesh/jobs/stuff/VersionChecker.java b/src/main/java/com/gamingmesh/jobs/stuff/VersionChecker.java index 58fbf75c..7a3843db 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/VersionChecker.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/VersionChecker.java @@ -12,6 +12,8 @@ import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; +import net.Zrips.CMILib.Messages.CMIMessages; + public final class VersionChecker { private Jobs plugin; @@ -44,7 +46,7 @@ public final class VersionChecker { if (player != null) player.sendMessage(one); else - Jobs.consoleMsg(one); + CMIMessages.consoleMessage(one); }); } @@ -55,7 +57,7 @@ public final class VersionChecker { if (version.length() <= 8) return version; } catch (Throwable t) { - Jobs.consoleMsg("&cFailed to check for " + plugin.getDescription().getName() + " update on spigot web page."); + CMIMessages.consoleMessage("&cFailed to check for " + plugin.getDescription().getName() + " update on spigot web page."); } return null; } diff --git a/src/main/java/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java b/src/main/java/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java index 2bf41829..a5fe6949 100644 --- a/src/main/java/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java +++ b/src/main/java/com/gamingmesh/jobs/tasks/BufferedPaymentThread.java @@ -21,6 +21,8 @@ package com.gamingmesh.jobs.tasks; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.economy.BufferedEconomy; +import net.Zrips.CMILib.Messages.CMIMessages; + public class BufferedPaymentThread extends Thread { private volatile boolean running = true; private int sleep; @@ -35,7 +37,7 @@ public class BufferedPaymentThread extends Thread { @Override public void run() { - Jobs.consoleMsg("&eStarted buffered payment thread."); + CMIMessages.consoleMessage("&eStarted buffered payment thread."); while (running) { try { @@ -50,11 +52,11 @@ public class BufferedPaymentThread extends Thread { economy.payAll(); } catch (Throwable t) { t.printStackTrace(); - Jobs.consoleMsg("&c[Jobs] Exception in BufferedPaymentThread, stopping economy payments!"); + CMIMessages.consoleMessage("&c[Jobs] Exception in BufferedPaymentThread, stopping economy payments!"); running = false; } } - Jobs.consoleMsg("&eBuffered payment thread shutdown."); + CMIMessages.consoleMessage("&eBuffered payment thread shutdown."); } public void shutdown() { diff --git a/src/main/java/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java b/src/main/java/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java index d53325e0..0c4994fd 100644 --- a/src/main/java/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java +++ b/src/main/java/com/gamingmesh/jobs/tasks/DatabaseSaveThread.java @@ -20,6 +20,8 @@ package com.gamingmesh.jobs.tasks; import com.gamingmesh.jobs.Jobs; +import net.Zrips.CMILib.Messages.CMIMessages; + public class DatabaseSaveThread extends Thread { private volatile boolean running = true; @@ -33,7 +35,7 @@ public class DatabaseSaveThread extends Thread { @Override public void run() { - Jobs.consoleMsg("&eStarted database save task."); + CMIMessages.consoleMessage("&eStarted database save task."); while (running) { try { @@ -46,12 +48,12 @@ public class DatabaseSaveThread extends Thread { Jobs.getPlayerManager().saveAll(); } catch (Throwable t) { t.printStackTrace(); - Jobs.consoleMsg("&c[Jobs] Exception in DatabaseSaveTask, stopping auto save!"); + CMIMessages.consoleMessage("&c[Jobs] Exception in DatabaseSaveTask, stopping auto save!"); running = false; } } - Jobs.consoleMsg("&eDatabase save task shutdown!"); + CMIMessages.consoleMessage("&eDatabase save task shutdown!"); }