From 0eb9c36386d096be78ed6456d7101f494ddffad5 Mon Sep 17 00:00:00 2001 From: PikaMug Date: Tue, 5 Nov 2019 18:32:52 -0500 Subject: [PATCH] Create separate utility class for config --- .../me/blackvein/quests/Dependencies.java | 2 +- .../main/java/me/blackvein/quests/Quest.java | 5 +- .../me/blackvein/quests/QuestFactory.java | 3 +- .../java/me/blackvein/quests/QuestMob.java | 5 +- .../java/me/blackvein/quests/Quester.java | 17 +- .../main/java/me/blackvein/quests/Quests.java | 223 ++++-------------- .../me/blackvein/quests/actions/Action.java | 35 +-- .../quests/actions/ActionFactory.java | 37 +-- .../quests/listeners/CmdExecutor.java | 2 +- .../quests/listeners/PlayerListener.java | 3 +- .../quests/prompts/CreateStagePrompt.java | 6 +- .../quests/prompts/ItemStackPrompt.java | 6 +- .../blackvein/quests/prompts/MobsPrompt.java | 3 +- .../quests/prompts/PlannerPrompt.java | 5 +- .../quests/prompts/QuestOfferPrompt.java | 3 +- .../blackvein/quests/timers/StageTimer.java | 4 +- .../me/blackvein/quests/util/ConfigUtil.java | 193 +++++++++++++++ .../me/blackvein/quests/util/MiscUtil.java | 49 ++++ .../blackvein/quests/util/RomanNumeral.java | 2 - 19 files changed, 362 insertions(+), 241 deletions(-) create mode 100644 main/src/main/java/me/blackvein/quests/util/ConfigUtil.java diff --git a/main/src/main/java/me/blackvein/quests/Dependencies.java b/main/src/main/java/me/blackvein/quests/Dependencies.java index 57ee3c731..94dd2bda0 100644 --- a/main/src/main/java/me/blackvein/quests/Dependencies.java +++ b/main/src/main/java/me/blackvein/quests/Dependencies.java @@ -48,7 +48,7 @@ public class Dependencies { private static mcMMO mcmmo = null; private static Heroes heroes = null; private static PhatLoots phatLoots = null; - private static PlaceholderAPIPlugin placeholder = null; + public static PlaceholderAPIPlugin placeholder = null; private static CitizensPlugin citizens = null; private static DenizenAPI denizenApi = null; private static CitizensBooksAPI citizensBooks = null; diff --git a/main/src/main/java/me/blackvein/quests/Quest.java b/main/src/main/java/me/blackvein/quests/Quest.java index 3e039696f..71b89e5e9 100644 --- a/main/src/main/java/me/blackvein/quests/Quest.java +++ b/main/src/main/java/me/blackvein/quests/Quest.java @@ -41,6 +41,7 @@ import me.blackvein.quests.events.quester.QuesterPreChangeStageEvent; import me.blackvein.quests.events.quester.QuesterPreCompleteQuestEvent; import me.blackvein.quests.events.quester.QuesterPreFailQuestEvent; import me.blackvein.quests.exceptions.InvalidStageException; +import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.Lang; import me.clip.placeholderapi.PlaceholderAPI; @@ -184,7 +185,7 @@ public class Quest { } String stageCompleteMessage = currentStage.completeMessage; if (stageCompleteMessage != null) { - quester.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageCompleteMessage, + quester.getPlayer().sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageCompleteMessage, this, quester.getPlayer())); } if (plugin.getSettings().canUseCompass()) { @@ -260,7 +261,7 @@ public class Quest { plugin.showObjectives(this, quester, false); String stageStartMessage = quester.getCurrentStage(this).startMessage; if (stageStartMessage != null) { - quester.getPlayer().sendMessage(plugin.parseStringWithPossibleLineBreaks(stageStartMessage, this, + quester.getPlayer().sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(stageStartMessage, this, quester.getPlayer())); } quester.updateJournal(); diff --git a/main/src/main/java/me/blackvein/quests/QuestFactory.java b/main/src/main/java/me/blackvein/quests/QuestFactory.java index 10dcfee35..c8bacf496 100644 --- a/main/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/main/src/main/java/me/blackvein/quests/QuestFactory.java @@ -58,6 +58,7 @@ import me.blackvein.quests.prompts.RewardsPrompt; import me.blackvein.quests.prompts.PlannerPrompt; import me.blackvein.quests.prompts.StagesPrompt; import me.blackvein.quests.util.CK; +import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.MiscUtil; @@ -1032,7 +1033,7 @@ public class QuestFactory implements ConversationAbandonedListener { npcStart = (Integer) cc.getSessionData(CK.Q_START_NPC); } if (cc.getSessionData(CK.Q_START_BLOCK) != null) { - blockStart = Quests.getLocationInfo((Location) cc.getSessionData(CK.Q_START_BLOCK)); + blockStart = ConfigUtil.getLocationInfo((Location) cc.getSessionData(CK.Q_START_BLOCK)); } if (cc.getSessionData(CK.REQ_MONEY) != null) { moneyReq = (Integer) cc.getSessionData(CK.REQ_MONEY); diff --git a/main/src/main/java/me/blackvein/quests/QuestMob.java b/main/src/main/java/me/blackvein/quests/QuestMob.java index 19be6ce08..11bc03999 100644 --- a/main/src/main/java/me/blackvein/quests/QuestMob.java +++ b/main/src/main/java/me/blackvein/quests/QuestMob.java @@ -20,6 +20,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; +import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.MiscUtil; @@ -154,7 +155,7 @@ public class QuestMob { string += "::name-" + name; } if (spawnLocation != null) { - string += "::spawn-" + Quests.getLocationInfo(spawnLocation); + string += "::spawn-" + ConfigUtil.getLocationInfo(spawnLocation); } if (spawnAmounts != null) { string += "::amounts-" + spawnAmounts; @@ -196,7 +197,7 @@ public class QuestMob { } else if (string.startsWith("name-")) { name = string.substring(5); } else if (string.startsWith("spawn-")) { - loc = Quests.getLocation(string.substring(6)); + loc = ConfigUtil.getLocation(string.substring(6)); } else if (string.startsWith("amounts-")) { amounts = Integer.parseInt(string.substring(8)); } else if (string.startsWith("hand-")) { diff --git a/main/src/main/java/me/blackvein/quests/Quester.java b/main/src/main/java/me/blackvein/quests/Quester.java index aec5a80cc..7da476ab0 100644 --- a/main/src/main/java/me/blackvein/quests/Quester.java +++ b/main/src/main/java/me/blackvein/quests/Quester.java @@ -55,6 +55,7 @@ import me.blackvein.quests.events.quest.QuestTakeEvent; import me.blackvein.quests.events.quester.QuesterPostStartQuestEvent; import me.blackvein.quests.events.quester.QuesterPreStartQuestEvent; import me.blackvein.quests.timers.StageTimer; +import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.LocaleQuery; @@ -419,7 +420,7 @@ public class Quester { String early = Lang.get("plnTooEarly"); early = early.replace("", ChatColor.AQUA + q.getName() + ChatColor.YELLOW); early = early.replace("