From 7dbe851d8b2f64e96bd69fb39c72274c4def859a Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Sun, 23 Jan 2022 00:29:15 -0500 Subject: [PATCH] Refactor to core module, part 6 --- .../me/blackvein/quests/player/IQuester.java | 6 ++-- .../me/blackvein/quests/quests/IQuest.java | 6 ++-- .../quests/quests/{Stage.java => IStage.java} | 2 +- .../me/blackvein/quests/CustomObjective.java | 4 +-- .../main/java/me/blackvein/quests/Quest.java | 20 +++++------ .../java/me/blackvein/quests/Quester.java | 36 +++++++++---------- .../main/java/me/blackvein/quests/Quests.java | 16 ++++----- .../{quests/BukkitStage.java => Stage.java} | 5 +-- .../convo/actions/main/ActionMainPrompt.java | 4 +-- .../convo/actions/menu/ActionMenuPrompt.java | 4 +-- .../conditions/main/ConditionMainPrompt.java | 4 +-- .../conditions/menu/ConditionMenuPrompt.java | 4 +-- .../quester/QuesterPostChangeStageEvent.java | 12 +++---- .../quester/QuesterPreChangeStageEvent.java | 12 +++---- .../quests/listeners/BlockListener.java | 4 +-- .../quests/listeners/CmdExecutor.java | 4 +-- .../quests/listeners/PlayerListener.java | 10 +++--- .../quests/logging/QuestsLog4JFilter.java | 6 +++- .../quests/quests/BukkitQuestFactory.java | 2 +- .../file/SeparatedYamlStorage.java | 4 +-- 20 files changed, 85 insertions(+), 80 deletions(-) rename api/src/main/java/me/blackvein/quests/quests/{Stage.java => IStage.java} (99%) rename core/src/main/java/me/blackvein/quests/{quests/BukkitStage.java => Stage.java} (99%) diff --git a/api/src/main/java/me/blackvein/quests/player/IQuester.java b/api/src/main/java/me/blackvein/quests/player/IQuester.java index 9fc3b54f8..3b6be0355 100644 --- a/api/src/main/java/me/blackvein/quests/player/IQuester.java +++ b/api/src/main/java/me/blackvein/quests/player/IQuester.java @@ -1,9 +1,9 @@ package me.blackvein.quests.player; import me.blackvein.quests.quests.IQuest; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.quests.Objective; import me.blackvein.quests.QuestData; -import me.blackvein.quests.quests.Stage; import me.blackvein.quests.enums.ObjectiveType; import me.blackvein.quests.module.ICustomObjective; import net.citizensnpcs.api.npc.NPC; @@ -90,7 +90,7 @@ public interface IQuester extends Comparable { void sendMessage(final String message); - Stage getCurrentStage(final IQuest quest); + IStage getCurrentStage(final IQuest quest); QuestData getQuestData(final IQuest quest); @@ -216,7 +216,7 @@ public interface IQuester extends Comparable { Set dispatchMultiplayerEverything(final IQuest quest, final ObjectiveType type, final BiFunction fun); - Set dispatchMultiplayerObjectives(final IQuest quest, final Stage currentStage, + Set dispatchMultiplayerObjectives(final IQuest quest, final IStage currentStage, final Function fun); List getMultiplayerQuesters(final IQuest quest); diff --git a/api/src/main/java/me/blackvein/quests/quests/IQuest.java b/api/src/main/java/me/blackvein/quests/quests/IQuest.java index 662ebd780..8d04b5fcd 100644 --- a/api/src/main/java/me/blackvein/quests/quests/IQuest.java +++ b/api/src/main/java/me/blackvein/quests/quests/IQuest.java @@ -39,9 +39,9 @@ public interface IQuest extends Comparable { void setGUIDisplay(final ItemStack guiDisplay); - Stage getStage(final int index); + IStage getStage(final int index); - LinkedList getStages(); + LinkedList getStages(); NPC getNpcStart(); @@ -67,7 +67,7 @@ public interface IQuest extends Comparable { void setStage(final IQuester quester, final int stage); - boolean updateCompass(final IQuester quester, final Stage stage); + boolean updateCompass(final IQuester quester, final IStage stage); boolean testRequirements(final IQuester quester); diff --git a/api/src/main/java/me/blackvein/quests/quests/Stage.java b/api/src/main/java/me/blackvein/quests/quests/IStage.java similarity index 99% rename from api/src/main/java/me/blackvein/quests/quests/Stage.java rename to api/src/main/java/me/blackvein/quests/quests/IStage.java index 1f939e5ca..ccd4867c9 100644 --- a/api/src/main/java/me/blackvein/quests/quests/Stage.java +++ b/api/src/main/java/me/blackvein/quests/quests/IStage.java @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; import java.util.LinkedList; import java.util.Map; -public interface Stage { +public interface IStage { LinkedList getBlocksToBreak(); boolean addBlockToBreak(ItemStack blockToBreak); diff --git a/core/src/main/java/me/blackvein/quests/CustomObjective.java b/core/src/main/java/me/blackvein/quests/CustomObjective.java index b81c23434..22ee6e15b 100644 --- a/core/src/main/java/me/blackvein/quests/CustomObjective.java +++ b/core/src/main/java/me/blackvein/quests/CustomObjective.java @@ -18,7 +18,7 @@ import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent; import me.blackvein.quests.module.ICustomObjective; import me.blackvein.quests.player.IQuester; import me.blackvein.quests.quests.BukkitObjective; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.Listener; @@ -163,7 +163,7 @@ public abstract class CustomObjective implements ICustomObjective, Listener { final Quest quest) { final IQuester quester = plugin.getQuester(player.getUniqueId()); if (quester != null) { - final Stage currentStage = quester.getCurrentStage(quest); + final IStage currentStage = quester.getCurrentStage(quest); if (currentStage == null) { return null; } diff --git a/core/src/main/java/me/blackvein/quests/Quest.java b/core/src/main/java/me/blackvein/quests/Quest.java index 244368fdf..1469ba9ea 100644 --- a/core/src/main/java/me/blackvein/quests/Quest.java +++ b/core/src/main/java/me/blackvein/quests/Quest.java @@ -37,11 +37,11 @@ import me.blackvein.quests.quests.BukkitPlanner; import me.blackvein.quests.quests.BukkitRequirements; import me.blackvein.quests.quests.BukkitRewards; import me.blackvein.quests.quests.IQuest; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.quests.Options; import me.blackvein.quests.quests.Planner; import me.blackvein.quests.quests.Requirements; import me.blackvein.quests.quests.Rewards; -import me.blackvein.quests.quests.Stage; import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.InventoryUtil; import me.blackvein.quests.util.ItemUtil; @@ -82,7 +82,7 @@ public class Quest implements IQuest { protected String description; protected String finished; protected ItemStack guiDisplay = null; - private final LinkedList orderedStages = new LinkedList<>(); + private final LinkedList orderedStages = new LinkedList<>(); protected UUID npcStart; protected Location blockStart; protected String regionStart = null; @@ -174,7 +174,7 @@ public class Quest implements IQuest { } @Override - public Stage getStage(final int index) { + public IStage getStage(final int index) { try { return orderedStages.get(index); } catch (final Exception e) { @@ -183,7 +183,7 @@ public class Quest implements IQuest { } @Override - public LinkedList getStages() { + public LinkedList getStages() { return orderedStages; } @@ -247,7 +247,7 @@ public class Quest implements IQuest { * @param allowSharedProgress Whether to distribute progress to fellow questers */ public void nextStage(final IQuester quester, final boolean allowSharedProgress) { - final Stage currentStage = quester.getCurrentStage(this); + final IStage currentStage = quester.getCurrentStage(this); if (currentStage == null) { plugin.getLogger().severe("Current stage was null for quester " + quester.getPlayer().getUniqueId()); return; @@ -299,7 +299,7 @@ public class Quest implements IQuest { * Force player to proceed to the specified stage * * @param quester Player to force - * @param stage Stage number to specify + * @param stage IStage number to specify * @throws IndexOutOfBoundsException if stage does not exist */ public void setStage(final IQuester quester, final int stage) throws IndexOutOfBoundsException { @@ -309,8 +309,8 @@ public class Quest implements IQuest { + player.getName(); throw new IndexOutOfBoundsException(msg); } - final Stage currentStage = quester.getCurrentStage(this); - final Stage nextStage = getStage(stage); + final IStage currentStage = quester.getCurrentStage(this); + final IStage nextStage = getStage(stage); if (player.isOnline()) { final QuesterPreChangeStageEvent preEvent = new QuesterPreChangeStageEvent((Quester) quester, this, currentStage, nextStage); @@ -422,7 +422,7 @@ public class Quest implements IQuest { * @param stage The stage to process for targets * @return true if an attempt was made successfully */ - public boolean updateCompass(final IQuester quester, final Stage stage) { + public boolean updateCompass(final IQuester quester, final IStage stage) { if (quester == null) { return false; } @@ -1139,7 +1139,7 @@ public class Quest implements IQuest { } final Player player = quester.getPlayer(); if (!ignoreFailAction) { - final Stage stage = quester.getCurrentStage(this); + final IStage stage = quester.getCurrentStage(this); if (stage != null && stage.getFailAction() != null) { quester.getCurrentStage(this).getFailAction().fire(quester, this); } diff --git a/core/src/main/java/me/blackvein/quests/Quester.java b/core/src/main/java/me/blackvein/quests/Quester.java index ff7713ade..0c2b91db5 100644 --- a/core/src/main/java/me/blackvein/quests/Quester.java +++ b/core/src/main/java/me/blackvein/quests/Quester.java @@ -30,10 +30,10 @@ import me.blackvein.quests.item.QuestJournal; import me.blackvein.quests.player.IQuester; import me.blackvein.quests.quests.BukkitObjective; import me.blackvein.quests.quests.IQuest; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.quests.Objective; import me.blackvein.quests.quests.Planner; import me.blackvein.quests.quests.Requirements; -import me.blackvein.quests.quests.Stage; import me.blackvein.quests.storage.Storage; import me.blackvein.quests.tasks.StageTimer; import me.blackvein.quests.util.ConfigUtil; @@ -393,7 +393,7 @@ public class Quester implements IQuester { } @Override - public Stage getCurrentStage(final IQuest quest) { + public IStage getCurrentStage(final IQuest quest) { if (currentQuests.containsKey(quest)) { return quest.getStage(currentQuests.get(quest)); } @@ -574,7 +574,7 @@ public class Quester implements IQuester { plugin.getLogger().severe("Unable to add quest" + quest.getName() + " for player " + offlinePlayer.getName() + ". Consider resetting player data or report on Github"); } - final Stage stage = quest.getStage(0); + final IStage stage = quest.getStage(0); if (!ignoreRequirements) { final Requirements requirements = quest.getRequirements(); if (requirements.getMoney() > 0) { @@ -908,7 +908,7 @@ public class Quester implements IQuester { return objectives; } final QuestData data = getQuestData(quest); - final Stage stage = getCurrentStage(quest); + final IStage stage = getCurrentStage(quest); final LinkedList objectives = new LinkedList<>(); for (final ItemStack e : stage.getBlocksToBreak()) { for (final ItemStack e2 : data.blocksBroken) { @@ -1367,7 +1367,7 @@ public class Quester implements IQuester { * milkCow, catchFish, killMob, deliverItem, killPlayer, talkToNPC, * killNPC, tameMob, shearSheep, password, reachLocation * - * @deprecated Use {@link Stage#containsObjective(ObjectiveType)} + * @deprecated Use {@link IStage#containsObjective(ObjectiveType)} * @param quest The quest to check objectives of * @param name The type of objective to check for * @return true if stage contains specified objective @@ -2386,7 +2386,7 @@ public class Quester implements IQuester { if (questData == null) { return; } - final Stage currentStage = getCurrentStage(quest); + final IStage currentStage = getCurrentStage(quest); if (currentStage == null) { return; } @@ -2435,7 +2435,7 @@ public class Quester implements IQuester { if (questData == null) { return; } - final Stage currentStage = getCurrentStage(quest); + final IStage currentStage = getCurrentStage(quest); if (currentStage == null) { return; } @@ -2486,7 +2486,7 @@ public class Quester implements IQuester { if (entityType == null) { return; } - final Stage currentStage = getCurrentStage(quest); + final IStage currentStage = getCurrentStage(quest); if (currentStage.getMobsToKill() == null) { return; } @@ -2556,7 +2556,7 @@ public class Quester implements IQuester { if (questData == null) { return; } - final Stage currentStage = getCurrentStage(quest); + final IStage currentStage = getCurrentStage(quest); if (currentStage == null) { return; } @@ -2684,7 +2684,7 @@ public class Quester implements IQuester { if (entityType == null) { return; } - final Stage currentStage = getCurrentStage(quest); + final IStage currentStage = getCurrentStage(quest); if (currentStage.getMobsToTame() == null) { return; } @@ -2735,7 +2735,7 @@ public class Quester implements IQuester { if (color == null) { return; } - final Stage currentStage = getCurrentStage(quest); + final IStage currentStage = getCurrentStage(quest); if (currentStage.getSheepToShear() == null) { return; } @@ -3289,7 +3289,7 @@ public class Quester implements IQuester { return; } if (quest.getStage(stage) == null) { - plugin.getLogger().severe("Unable to find Stage " + stage + " of quest ID " + quest.getId()); + plugin.getLogger().severe("Unable to find IStage " + stage + " of quest ID " + quest.getId()); return; } if (!quest.getStage(stage).getBlocksToBreak().isEmpty()) { @@ -3593,7 +3593,7 @@ public class Quester implements IQuester { if (!questData.mobsTamed.isEmpty()) { questSec.set("mob-tame-amounts", questData.mobsTamed); } - final Stage stage = getCurrentStage(quest); + final IStage stage = getCurrentStage(quest); if (stage != null) { if (stage.getFishToCatch() != null) { questSec.set("fish-caught", questData.getFishCaught()); @@ -3754,7 +3754,7 @@ public class Quester implements IQuester { boolean exists = false; for (final IQuest q : plugin.getLoadedQuests()) { if (q.getId().equalsIgnoreCase(quest.getId())) { - final Stage stage = getCurrentStage(quest); + final IStage stage = getCurrentStage(quest); if (stage != null) { quest.updateCompass(this, stage); // TODO - decide whether or not to handle this @@ -3962,7 +3962,7 @@ public class Quester implements IQuester { return; } for (final IQuest quest : currentQuests.keySet()) { - final Stage stage = getCurrentStage(quest); + final IStage stage = getCurrentStage(quest); if (stage != null && quest.updateCompass(this, stage)) { break; } @@ -3995,7 +3995,7 @@ public class Quester implements IQuester { if (list.size() > 0) { final IQuest quest = plugin.getQuestById(list.get(index)); compassTargetQuestId = quest.getId(); - final Stage stage = getCurrentStage(quest); + final IStage stage = getCurrentStage(quest); if (stage != null) { quest.updateCompass(Quester.this, stage); if (notify) { @@ -4081,7 +4081,7 @@ public class Quester implements IQuester { * @param currentStage The current stage of the quest * @param fun The function to execute, the event call */ - public Set dispatchMultiplayerObjectives(final IQuest quest, final Stage currentStage, + public Set dispatchMultiplayerObjectives(final IQuest quest, final IStage currentStage, final Function fun) { final Set appliedQuestIDs = new HashSet<>(); if (quest.getOptions().getShareProgressLevel() == 2) { @@ -4310,7 +4310,7 @@ public class Quester implements IQuester { } public boolean meetsCondition(final IQuest quest, final boolean giveReason) { - final Stage stage = getCurrentStage(quest); + final IStage stage = getCurrentStage(quest); if (stage != null && stage.getCondition() != null && !stage.getCondition().check(this, quest)) { if (stage.getCondition().isFailQuest()) { if (giveReason) { diff --git a/core/src/main/java/me/blackvein/quests/Quests.java b/core/src/main/java/me/blackvein/quests/Quests.java index ee77f6441..57d4fd7d5 100644 --- a/core/src/main/java/me/blackvein/quests/Quests.java +++ b/core/src/main/java/me/blackvein/quests/Quests.java @@ -48,14 +48,13 @@ import me.blackvein.quests.logging.QuestsLog4JFilter; import me.blackvein.quests.module.ICustomObjective; import me.blackvein.quests.player.IQuester; import me.blackvein.quests.quests.BukkitQuestFactory; -import me.blackvein.quests.quests.BukkitStage; import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.quests.Options; import me.blackvein.quests.quests.Planner; import me.blackvein.quests.quests.QuestFactory; import me.blackvein.quests.quests.Requirements; import me.blackvein.quests.quests.Rewards; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.statistics.Metrics; import me.blackvein.quests.storage.Storage; import me.blackvein.quests.storage.StorageFactory; @@ -175,6 +174,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { public void onEnable() { /*----> WARNING: ORDER OF STEPS MATTERS <----*/ + ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()).addFilter(new QuestsLog4JFilter()); + // 1 - Initialize variables bukkitVersion = Bukkit.getServer().getBukkitVersion().split("-")[0]; settings = new Settings(this); @@ -273,7 +274,6 @@ public class Quests extends JavaPlugin implements QuestsAPI { }); // 12 - Delay loading of Quests, Actions and modules - ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()).addFilter(new QuestsLog4JFilter()); delayLoadQuestInfo(); } @@ -1069,7 +1069,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { return; } final QuestData data = quester.getQuestData(quest); - final Stage stage = quester.getCurrentStage(quest); + final IStage stage = quester.getCurrentStage(quest); for (final ItemStack e : stage.getBlocksToBreak()) { for (final ItemStack e2 : data.blocksBroken) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { @@ -2379,10 +2379,10 @@ public class Quests extends JavaPlugin implements QuestsAPI { try { stageNum = Integer.parseInt(stage); } catch (final NumberFormatException e) { - getLogger().severe("Stage key " + stage + "must be a number!"); + getLogger().severe("IStage key " + stage + "must be a number!"); continue; } - final BukkitStage oStage = new BukkitStage(); + final Stage oStage = new Stage(); List breakNames = new LinkedList<>(); List breakAmounts = new LinkedList<>(); List breakDurability = new LinkedList<>(); @@ -3954,7 +3954,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { + " for " + quest.getName() + " was null"); return; } - final Stage oStage = quest.getStage(Integer.parseInt(stageNum) - 1); + final IStage oStage = quest.getStage(Integer.parseInt(stageNum) - 1); oStage.clearCustomObjectives(); oStage.clearCustomObjectiveCounts(); oStage.clearCustomObjectiveData(); @@ -3982,7 +3982,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { oStage.addCustomObjectiveData(data); } } else { - throw new QuestFormatException(name + " custom objective not found for Stage " + throw new QuestFormatException(name + " custom objective not found for IStage " + stageNum, questKey); } } diff --git a/core/src/main/java/me/blackvein/quests/quests/BukkitStage.java b/core/src/main/java/me/blackvein/quests/Stage.java similarity index 99% rename from core/src/main/java/me/blackvein/quests/quests/BukkitStage.java rename to core/src/main/java/me/blackvein/quests/Stage.java index 3acaaddfb..b9830294f 100644 --- a/core/src/main/java/me/blackvein/quests/quests/BukkitStage.java +++ b/core/src/main/java/me/blackvein/quests/Stage.java @@ -10,12 +10,13 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package me.blackvein.quests.quests; +package me.blackvein.quests; import me.blackvein.quests.actions.IAction; import me.blackvein.quests.conditions.ICondition; import me.blackvein.quests.module.ICustomObjective; import me.blackvein.quests.enums.ObjectiveType; +import me.blackvein.quests.quests.IStage; import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.World; @@ -27,7 +28,7 @@ import java.util.LinkedList; import java.util.Map; import java.util.Map.Entry; -public class BukkitStage implements Stage { +public class Stage implements IStage { private LinkedList blocksToBreak = new LinkedList<>(); private LinkedList blocksToDamage = new LinkedList<>(); diff --git a/core/src/main/java/me/blackvein/quests/convo/actions/main/ActionMainPrompt.java b/core/src/main/java/me/blackvein/quests/convo/actions/main/ActionMainPrompt.java index f75333ed0..145d357e3 100644 --- a/core/src/main/java/me/blackvein/quests/convo/actions/main/ActionMainPrompt.java +++ b/core/src/main/java/me/blackvein/quests/convo/actions/main/ActionMainPrompt.java @@ -15,7 +15,7 @@ package me.blackvein.quests.convo.actions.main; import me.blackvein.quests.actions.IAction; import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; @@ -1018,7 +1018,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { if (modifiedName != null) { modName = modifiedName; for (final IQuest q : plugin.getLoadedQuests()) { - for (final Stage s : q.getStages()) { + for (final IStage s : q.getStages()) { if (s.getFinishAction() != null && s.getFinishAction().getName() != null) { if (s.getFinishAction().getName().equalsIgnoreCase(modifiedName)) { modified.add(q.getName()); diff --git a/core/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java b/core/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java index 726201b6f..b0ae955ae 100644 --- a/core/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java +++ b/core/src/main/java/me/blackvein/quests/convo/actions/menu/ActionMenuPrompt.java @@ -15,7 +15,7 @@ package me.blackvein.quests.convo.actions.menu; import me.blackvein.quests.actions.IAction; import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; @@ -296,7 +296,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt { final IAction a = plugin.getAction(input); if (a != null) { for (final IQuest quest : plugin.getLoadedQuests()) { - for (final Stage stage : quest.getStages()) { + for (final IStage stage : quest.getStages()) { if (stage.getFinishAction() != null && stage.getFinishAction().getName().equalsIgnoreCase(a.getName())) { used.add(quest.getName()); diff --git a/core/src/main/java/me/blackvein/quests/convo/conditions/main/ConditionMainPrompt.java b/core/src/main/java/me/blackvein/quests/convo/conditions/main/ConditionMainPrompt.java index 96432efa4..560f8b158 100644 --- a/core/src/main/java/me/blackvein/quests/convo/conditions/main/ConditionMainPrompt.java +++ b/core/src/main/java/me/blackvein/quests/convo/conditions/main/ConditionMainPrompt.java @@ -15,7 +15,7 @@ package me.blackvein.quests.convo.conditions.main; import me.blackvein.quests.conditions.ICondition; import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt; @@ -483,7 +483,7 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt { if (modifiedName != null) { modName = modifiedName; for (final IQuest q : plugin.getLoadedQuests()) { - for (final Stage s : q.getStages()) { + for (final IStage s : q.getStages()) { if (s.getCondition() != null && s.getCondition().getName() != null) { if (s.getCondition().getName().equalsIgnoreCase(modifiedName)) { modified.add(q.getName()); diff --git a/core/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java b/core/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java index 7002971af..650a3d2e1 100644 --- a/core/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java +++ b/core/src/main/java/me/blackvein/quests/convo/conditions/menu/ConditionMenuPrompt.java @@ -15,7 +15,7 @@ package me.blackvein.quests.convo.conditions.menu; import me.blackvein.quests.conditions.ICondition; import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt; @@ -296,7 +296,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt { final ICondition c = plugin.getCondition(input); if (c != null) { for (final IQuest quest : plugin.getLoadedQuests()) { - for (final Stage stage : quest.getStages()) { + for (final IStage stage : quest.getStages()) { if (stage.getCondition() != null && stage.getCondition().getName().equalsIgnoreCase(c.getName())) { used.add(quest.getName()); diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostChangeStageEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostChangeStageEvent.java index da2b850ee..a6906d203 100644 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostChangeStageEvent.java +++ b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPostChangeStageEvent.java @@ -14,7 +14,7 @@ package me.blackvein.quests.events.quester; import me.blackvein.quests.Quester; import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; @@ -24,10 +24,10 @@ import org.jetbrains.annotations.NotNull; public class QuesterPostChangeStageEvent extends QuesterEvent { private static final HandlerList HANDLERS = new HandlerList(); private final IQuest quest; - private final Stage current; - private final Stage next; + private final IStage current; + private final IStage next; - public QuesterPostChangeStageEvent(final Quester quester, final IQuest quest, final Stage current, final Stage next) { + public QuesterPostChangeStageEvent(final Quester quester, final IQuest quest, final IStage current, final IStage next) { super(quester); this.quest = quest; this.current = current; @@ -43,11 +43,11 @@ public class QuesterPostChangeStageEvent extends QuesterEvent { return quest; } - public Stage getCurrentStage() { + public IStage getCurrentStage() { return current; } - public Stage getNextStage() { + public IStage getNextStage() { return next; } diff --git a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreChangeStageEvent.java b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreChangeStageEvent.java index e17ce19dd..d54457b36 100644 --- a/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreChangeStageEvent.java +++ b/core/src/main/java/me/blackvein/quests/events/quester/QuesterPreChangeStageEvent.java @@ -14,7 +14,7 @@ package me.blackvein.quests.events.quester; import me.blackvein.quests.Quester; import me.blackvein.quests.quests.IQuest; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; @@ -25,11 +25,11 @@ import org.jetbrains.annotations.NotNull; public class QuesterPreChangeStageEvent extends QuesterEvent implements Cancellable { private static final HandlerList HANDLERS = new HandlerList(); private final IQuest quest; - private final Stage current; - private final Stage next; + private final IStage current; + private final IStage next; private boolean cancel = false;; - public QuesterPreChangeStageEvent(final Quester quester, final IQuest quest, final Stage current, final Stage next) { + public QuesterPreChangeStageEvent(final Quester quester, final IQuest quest, final IStage current, final IStage next) { super(quester); this.quest = quest; this.current = current; @@ -45,11 +45,11 @@ public class QuesterPreChangeStageEvent extends QuesterEvent implements Cancella return quest; } - public Stage getCurrentStage() { + public IStage getCurrentStage() { return current; } - public Stage getNextStage() { + public IStage getNextStage() { return next; } diff --git a/core/src/main/java/me/blackvein/quests/listeners/BlockListener.java b/core/src/main/java/me/blackvein/quests/listeners/BlockListener.java index 4149a9f3d..b81b3904c 100644 --- a/core/src/main/java/me/blackvein/quests/listeners/BlockListener.java +++ b/core/src/main/java/me/blackvein/quests/listeners/BlockListener.java @@ -16,7 +16,7 @@ import me.blackvein.quests.Quester; import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.player.IQuester; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.enums.ObjectiveType; import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent; import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent; @@ -69,7 +69,7 @@ public class BlockListener implements Listener { continue; } if (quester.getCurrentQuests().containsKey(quest)) { - final Stage currentStage = quester.getCurrentStage(quest); + final IStage currentStage = quester.getCurrentStage(quest); if (currentStage == null) { plugin.getLogger().severe("Player " + player.getName() + " (" + player.getUniqueId() + ") has invalid stage for quest " + quest.getName() + " (" + quest.getId() + ")"); diff --git a/core/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java b/core/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java index e5a9f2f31..db4239743 100644 --- a/core/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java +++ b/core/src/main/java/me/blackvein/quests/listeners/CmdExecutor.java @@ -15,8 +15,8 @@ package me.blackvein.quests.listeners; import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.player.IQuester; import me.blackvein.quests.Quests; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.quests.Requirements; -import me.blackvein.quests.quests.Stage; import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent; import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent; import me.blackvein.quests.events.command.QuestsCommandPreQuestsListEvent; @@ -200,7 +200,7 @@ public class CmdExecutor implements CommandExecutor { final IQuester quester = plugin.getQuester(player.getUniqueId()); if (!quester.getCurrentQuests().isEmpty()) { for (final IQuest q : quester.getCurrentQuests().keySet()) { - final Stage stage = quester.getCurrentStage(q); + final IStage stage = quester.getCurrentStage(q); q.updateCompass(quester, stage); if (plugin.getQuester(player.getUniqueId()).getQuestData(q).getDelayStartTime() == 0) { final String msg = Lang.get(player, "questObjectivesTitle") diff --git a/core/src/main/java/me/blackvein/quests/listeners/PlayerListener.java b/core/src/main/java/me/blackvein/quests/listeners/PlayerListener.java index f9bc66020..1f56edf2b 100644 --- a/core/src/main/java/me/blackvein/quests/listeners/PlayerListener.java +++ b/core/src/main/java/me/blackvein/quests/listeners/PlayerListener.java @@ -15,7 +15,7 @@ package me.blackvein.quests.listeners; import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.player.IQuester; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.enums.ObjectiveType; import me.blackvein.quests.Quester; import me.blackvein.quests.util.ItemUtil; @@ -485,7 +485,7 @@ public class PlayerListener implements Listener { } if (quester.getCurrentQuests().containsKey(quest)) { - final Stage currentStage = quester.getCurrentStage(quest); + final IStage currentStage = quester.getCurrentStage(quest); if (currentStage == null) { continue; } @@ -545,7 +545,7 @@ public class PlayerListener implements Listener { return; } } - final Stage currentStage = quester.getCurrentStage(quest); + final IStage currentStage = quester.getCurrentStage(quest); if (currentStage == null) { plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString() + " on command for quest " + quest.getName()); @@ -734,7 +734,7 @@ public class PlayerListener implements Listener { if (plugin.canUseQuests(target.getUniqueId())) { final IQuester quester = plugin.getQuester(target.getUniqueId()); for (final IQuest quest : quester.getCurrentQuests().keySet()) { - final Stage stage = quester.getCurrentStage(quest); + final IStage stage = quester.getCurrentStage(quest); if (stage != null && stage.getDeathAction() != null) { quester.getCurrentStage(quest).getDeathAction().fire(quester, quest); } @@ -913,7 +913,7 @@ public class PlayerListener implements Listener { if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) { final IQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); for (final IQuest quest : quester.getCurrentQuests().keySet()) { - final Stage currentStage = quester.getCurrentStage(quest); + final IStage currentStage = quester.getCurrentStage(quest); if (currentStage == null) { plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString() + " on quit for quest " + quest.getName()); diff --git a/core/src/main/java/me/blackvein/quests/logging/QuestsLog4JFilter.java b/core/src/main/java/me/blackvein/quests/logging/QuestsLog4JFilter.java index deef9c61c..bdb4d8792 100644 --- a/core/src/main/java/me/blackvein/quests/logging/QuestsLog4JFilter.java +++ b/core/src/main/java/me/blackvein/quests/logging/QuestsLog4JFilter.java @@ -23,8 +23,12 @@ public class QuestsLog4JFilter extends AbstractFilter { if (message == null) { return Result.NEUTRAL; } + // Hikari tries to nag author about unavoidable logger usage + if (message.contains("[PikaMug]")) { + return Result.DENY; + } // Paper outputs errors when dependencies for module events are missing - return message.contains("Plugin Quests") ? Result.DENY : Result.NEUTRAL; + return message.startsWith("Plugin Quests") ? Result.DENY : Result.NEUTRAL; } @Override diff --git a/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java b/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java index 19e1bf224..58ea6677f 100644 --- a/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java +++ b/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java @@ -279,7 +279,7 @@ public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedLi context.setSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS, opt.canHandleOfflinePlayers()); // Stages (Objectives) int index = 1; - for (final Stage stage : q.getStages()) { + for (final IStage stage : q.getStages()) { final String pref = "stage" + index; index++; context.setSessionData(pref, Boolean.TRUE); diff --git a/core/src/main/java/me/blackvein/quests/storage/implementation/file/SeparatedYamlStorage.java b/core/src/main/java/me/blackvein/quests/storage/implementation/file/SeparatedYamlStorage.java index ea77358a1..cd7d025be 100644 --- a/core/src/main/java/me/blackvein/quests/storage/implementation/file/SeparatedYamlStorage.java +++ b/core/src/main/java/me/blackvein/quests/storage/implementation/file/SeparatedYamlStorage.java @@ -15,7 +15,7 @@ package me.blackvein.quests.storage.implementation.file; import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.player.IQuester; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.Stage; +import me.blackvein.quests.quests.IStage; import me.blackvein.quests.Quester; import me.blackvein.quests.storage.implementation.StorageImplementation; import org.bukkit.OfflinePlayer; @@ -159,7 +159,7 @@ public class SeparatedYamlStorage implements StorageImplementation { if (quest == null || !quester.getCurrentQuests().containsKey(quest)) { continue; } - final Stage stage = quester.getCurrentStage(quest); + final IStage stage = quester.getCurrentStage(quest); if (stage == null) { quest.completeQuest(quester); plugin.getLogger().severe("[Quests] Invalid stage number for player: \"" + uniqueId + "\" on Quest \""