From b45ca9b8d3c08038299ea7d758bc268018098d46 Mon Sep 17 00:00:00 2001 From: PikaMug <2267126+PikaMug@users.noreply.github.com> Date: Wed, 12 Jan 2022 15:10:01 -0500 Subject: [PATCH] Refactor to core module, part 2 --- .../java/me/blackvein/quests/Objective.java | 12 + .../java/me/blackvein/quests/Options.java | 35 ++ .../java/me/blackvein/quests/Planner.java | 16 + .../main/java/me/blackvein/quests/Quest.java | 71 ++- .../java/me/blackvein/quests/QuestData.java | 5 +- .../me/blackvein/quests/QuestFactory.java | 4 + .../java/me/blackvein/quests/Quester.java | 213 +++++++- .../main/java/me/blackvein/quests/Stage.java | 78 +++ .../me/blackvein/quests/actions/Action.java | 1 + .../quests/actions/ActionFactory.java | 48 ++ .../quests/conditions/Condition.java | 55 ++ .../quests/conditions/ConditionFactory.java | 25 + .../quests/convo/QuestsNumericPrompt.java | 0 .../quests/convo/QuestsStringPrompt.java | 0 .../actions/ActionsEditorNumericPrompt.java | 0 .../actions/ActionsEditorStringPrompt.java | 0 .../ConditionsEditorNumericPrompt.java | 0 .../ConditionsEditorStringPrompt.java | 0 .../me/blackvein/quests/entity/QuestMob.java | 45 ++ .../blackvein/quests/enums/ObjectiveType.java | 0 ...ctionsEditorPostOpenStringPromptEvent.java | 3 +- .../me/blackvein/quests/DenizenTrigger.java | 4 +- .../main/java/me/blackvein/quests/Quests.java | 509 +++++++++--------- .../quests/actions/BukkitAction.java | 62 ++- ...nFactory.java => BukkitActionFactory.java} | 93 ++-- .../{Condition.java => BukkitCondition.java} | 71 ++- ...ctory.java => BukkitConditionFactory.java} | 20 +- .../convo/actions/main/ActionMainPrompt.java | 50 +- .../convo/actions/menu/ActionMenuPrompt.java | 20 +- .../conditions/main/ConditionMainPrompt.java | 22 +- .../conditions/menu/ConditionMenuPrompt.java | 12 +- .../quests/QuestsEditorNumericPrompt.java | 8 +- .../quests/QuestsEditorStringPrompt.java | 8 +- .../convo/quests/stages/StageMainPrompt.java | 8 +- .../BukkitQuestMob.java} | 12 +- .../exceptions/StageFormatException.java | 8 +- .../quests/player/BukkitQuester.java | 352 ++++++------ .../blackvein/quests/quests/BukkitQuest.java | 100 ++-- .../BukkitQuestFactory.java} | 37 +- .../blackvein/quests/quests/BukkitStage.java | 187 ++++++- .../me/blackvein/quests/storage/Storage.java | 8 +- .../implementation/StorageImplementation.java | 6 +- .../file/SeparatedYamlStorage.java | 29 +- .../implementation/sql/SqlStorage.java | 66 +-- .../blackvein/quests/tasks/ActionTimer.java | 13 +- .../me/blackvein/quests/tasks/StageTimer.java | 10 +- .../me/blackvein/quests/util/ConfigUtil.java | 10 +- 47 files changed, 1569 insertions(+), 767 deletions(-) rename {core => api}/src/main/java/me/blackvein/quests/QuestData.java (99%) create mode 100644 api/src/main/java/me/blackvein/quests/QuestFactory.java create mode 100644 api/src/main/java/me/blackvein/quests/actions/ActionFactory.java create mode 100644 api/src/main/java/me/blackvein/quests/conditions/Condition.java create mode 100644 api/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java rename {core => api}/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java (100%) rename {core => api}/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java (100%) rename {core => api}/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorNumericPrompt.java (100%) rename {core => api}/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorStringPrompt.java (100%) rename {core => api}/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java (100%) rename {core => api}/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java (100%) create mode 100644 api/src/main/java/me/blackvein/quests/entity/QuestMob.java rename {core => api}/src/main/java/me/blackvein/quests/enums/ObjectiveType.java (100%) rename core/src/main/java/me/blackvein/quests/actions/{ActionFactory.java => BukkitActionFactory.java} (87%) rename core/src/main/java/me/blackvein/quests/conditions/{Condition.java => BukkitCondition.java} (93%) rename core/src/main/java/me/blackvein/quests/conditions/{ConditionFactory.java => BukkitConditionFactory.java} (95%) rename core/src/main/java/me/blackvein/quests/{QuestMob.java => entity/BukkitQuestMob.java} (96%) rename core/src/main/java/me/blackvein/quests/{QuestFactory.java => quests/BukkitQuestFactory.java} (98%) diff --git a/api/src/main/java/me/blackvein/quests/Objective.java b/api/src/main/java/me/blackvein/quests/Objective.java index 87faa0bf2..3d61ddfb1 100644 --- a/api/src/main/java/me/blackvein/quests/Objective.java +++ b/api/src/main/java/me/blackvein/quests/Objective.java @@ -1,4 +1,16 @@ package me.blackvein.quests; +import me.blackvein.quests.enums.ObjectiveType; +import org.bukkit.inventory.ItemStack; + public interface Objective { + ObjectiveType getType(); + + int getProgress(); + + int getGoal(); + + ItemStack getItemProgress(); + + ItemStack getItemGoal(); } diff --git a/api/src/main/java/me/blackvein/quests/Options.java b/api/src/main/java/me/blackvein/quests/Options.java index 9a774ed88..45728d4f2 100644 --- a/api/src/main/java/me/blackvein/quests/Options.java +++ b/api/src/main/java/me/blackvein/quests/Options.java @@ -1,4 +1,39 @@ package me.blackvein.quests; public interface Options { + boolean canAllowCommands(); + + void setAllowCommands(final boolean allowCommands); + + boolean canAllowQuitting(); + + void setAllowQuitting(final boolean allowQuitting); + + boolean canIgnoreSilkTouch(); + + void setIgnoreSilkTouch(final boolean ignoreSilkTouch); + + String getExternalPartyPlugin(); + + void setExternalPartyPlugin(final String externalPartyPlugin); + + boolean canUsePartiesPlugin(); + + void setUsePartiesPlugin(final boolean usePartiesPlugin); + + int getShareProgressLevel(); + + void setShareProgressLevel(final int shareProgressLevel); + + boolean canShareSameQuestOnly(); + + void setShareSameQuestOnly(final boolean shareSameQuestOnly); + + double getShareDistance(); + + void setShareDistance(final double shareDistance); + + boolean canHandleOfflinePlayers(); + + void setHandleOfflinePlayers(final boolean handleOfflinePlayers); } diff --git a/api/src/main/java/me/blackvein/quests/Planner.java b/api/src/main/java/me/blackvein/quests/Planner.java index a9730b490..fac36eb72 100644 --- a/api/src/main/java/me/blackvein/quests/Planner.java +++ b/api/src/main/java/me/blackvein/quests/Planner.java @@ -1,4 +1,20 @@ package me.blackvein.quests; public interface Planner { + String getStart(); + long getStartInMillis(); + boolean hasStart(); + void setStart(final String start); + String getEnd(); + long getEndInMillis(); + boolean hasEnd(); + void setEnd(final String end); + long getRepeat(); + boolean hasRepeat(); + void setRepeat(final long repeat); + long getCooldown(); + boolean hasCooldown(); + void setCooldown(final long cooldown); + boolean getOverride(); + void setOverride(final boolean override); } diff --git a/api/src/main/java/me/blackvein/quests/Quest.java b/api/src/main/java/me/blackvein/quests/Quest.java index 5df3e7990..af23a92be 100644 --- a/api/src/main/java/me/blackvein/quests/Quest.java +++ b/api/src/main/java/me/blackvein/quests/Quest.java @@ -3,54 +3,77 @@ package me.blackvein.quests; import me.blackvein.quests.actions.Action; import net.citizensnpcs.api.npc.NPC; import org.bukkit.Location; +import org.bukkit.OfflinePlayer; import org.bukkit.inventory.ItemStack; import java.util.LinkedList; -public interface Quest { - public String getId(); +public interface Quest extends Comparable { + String getId(); - public String getName(); + String getName(); - public void setName(final String name); + void setName(final String name); - public String getDescription(); + String getDescription(); - public void setDescription(final String description); + void setDescription(final String description); - public String getFinished(); + String getFinished(); - public void setFinished(final String finished); + void setFinished(final String finished); - public String getRegionStart(); + String getRegionStart(); - public void setRegionStart(final String regionStart); + void setRegionStart(final String regionStart); - public ItemStack getGUIDisplay(); + ItemStack getGUIDisplay(); - public void setGUIDisplay(final ItemStack guiDisplay); + void setGUIDisplay(final ItemStack guiDisplay); - public Stage getStage(final int index); + Stage getStage(final int index); - public LinkedList getStages(); + LinkedList getStages(); - public NPC getNpcStart(); + NPC getNpcStart(); - public void setNpcStart(final NPC npcStart); + void setNpcStart(final NPC npcStart); - public Location getBlockStart(); + Location getBlockStart(); - public void setBlockStart(final Location blockStart); + void setBlockStart(final Location blockStart); - public Action getInitialAction(); + Action getInitialAction(); - public void setInitialAction(final Action initialAction); + void setInitialAction(final Action initialAction); - public Requirements getRequirements(); + Requirements getRequirements(); - public Planner getPlanner(); + Planner getPlanner(); - public Rewards getRewards(); + Rewards getRewards(); - public Options getOptions(); + Options getOptions(); + + void nextStage(final Quester quester, final boolean allowSharedProgress); + + void setStage(final Quester quester, final int stage); + + boolean updateCompass(final Quester quester, final Stage stage); + + boolean testRequirements(final Quester quester); + + boolean testRequirements(final OfflinePlayer player); + + void completeQuest(final Quester quester); + + void completeQuest(final Quester quester, final boolean allowMultiplayer); + + void failQuest(final Quester quester); + + void failQuest(final Quester quester, final boolean ignoreFailAction); + + boolean isInRegion(final Quester quester); + + boolean isInRegionStart(final Quester quester); } diff --git a/core/src/main/java/me/blackvein/quests/QuestData.java b/api/src/main/java/me/blackvein/quests/QuestData.java similarity index 99% rename from core/src/main/java/me/blackvein/quests/QuestData.java rename to api/src/main/java/me/blackvein/quests/QuestData.java index 74542bf78..b21a2806d 100644 --- a/core/src/main/java/me/blackvein/quests/QuestData.java +++ b/api/src/main/java/me/blackvein/quests/QuestData.java @@ -12,7 +12,6 @@ package me.blackvein.quests; -import me.blackvein.quests.player.BukkitQuester; import org.bukkit.inventory.ItemStack; import java.util.Collection; @@ -23,9 +22,9 @@ import java.util.LinkedList; */ public class QuestData { - private final BukkitQuester quester; + private final Quester quester; - public QuestData(final BukkitQuester quester) { + public QuestData(final Quester quester) { this.quester = quester; } diff --git a/api/src/main/java/me/blackvein/quests/QuestFactory.java b/api/src/main/java/me/blackvein/quests/QuestFactory.java new file mode 100644 index 000000000..652b762d5 --- /dev/null +++ b/api/src/main/java/me/blackvein/quests/QuestFactory.java @@ -0,0 +1,4 @@ +package me.blackvein.quests; + +public interface QuestFactory { +} diff --git a/api/src/main/java/me/blackvein/quests/Quester.java b/api/src/main/java/me/blackvein/quests/Quester.java index 7debcb335..29c2acd8b 100644 --- a/api/src/main/java/me/blackvein/quests/Quester.java +++ b/api/src/main/java/me/blackvein/quests/Quester.java @@ -1,63 +1,228 @@ package me.blackvein.quests; +import me.blackvein.quests.enums.ObjectiveType; +import net.citizensnpcs.api.npc.NPC; +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.OfflinePlayer; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentSkipListSet; +import java.util.function.BiFunction; +import java.util.function.Function; -public interface Quester { - public UUID getUUID(); +public interface Quester extends Comparable { + UUID getUUID(); - public void setUUID(final UUID id); + void setUUID(final UUID id); - public String getQuestIdToTake(); + String getQuestIdToTake(); - public void setQuestIdToTake(final String questIdToTake); + void setQuestIdToTake(final String questIdToTake); - public String getLastKnownName(); + String getLastKnownName(); - public void setLastKnownName(final String lastKnownName); + void setLastKnownName(final String lastKnownName); - public int getQuestPoints(); + int getQuestPoints(); - public void setQuestPoints(final int questPoints); + void setQuestPoints(final int questPoints); /** * Get compass target quest. Returns null if not set * * @return Quest or null */ - public Quest getCompassTarget(); + Quest getCompassTarget(); /** * Set compass target quest. Does not update in-game * * @param quest The target quest */ - public void setCompassTarget(final Quest quest); + void setCompassTarget(final Quest quest); - public ConcurrentHashMap getTimers(); + ConcurrentHashMap getTimers(); - public void setTimers(final ConcurrentHashMap timers); + void setTimers(final ConcurrentHashMap timers); - public void removeTimer(final Integer timerId); + void removeTimer(final Integer timerId); - public ConcurrentHashMap getCurrentQuests(); + ConcurrentHashMap getCurrentQuests(); - public void setCurrentQuests(final ConcurrentHashMap currentQuests); + void setCurrentQuests(final ConcurrentHashMap currentQuests); - public ConcurrentSkipListSet getCompletedQuests(); + ConcurrentSkipListSet getCompletedQuests(); - public void setCompletedQuests(final ConcurrentSkipListSet completedQuests); + void setCompletedQuests(final ConcurrentSkipListSet completedQuests); - public ConcurrentHashMap getCompletedTimes(); + ConcurrentHashMap getCompletedTimes(); - public void setCompletedTimes(final ConcurrentHashMap completedTimes); + void setCompletedTimes(final ConcurrentHashMap completedTimes); - public ConcurrentHashMap getAmountsCompleted(); + ConcurrentHashMap getAmountsCompleted(); - public void setAmountsCompleted(final ConcurrentHashMap amountsCompleted); + void setAmountsCompleted(final ConcurrentHashMap amountsCompleted); - public ConcurrentHashMap getQuestData(); + ConcurrentHashMap getQuestData(); - public void setQuestData(final ConcurrentHashMap questData); + void setQuestData(final ConcurrentHashMap questData); + + Player getPlayer(); + + OfflinePlayer getOfflinePlayer(); + + void sendMessage(final String message); + + Stage getCurrentStage(final Quest quest); + + QuestData getQuestData(final Quest quest); + + boolean hasJournal(); + + ItemStack getJournal(); + + int getJournalIndex(); + + void updateJournal(); + + void takeQuest(final Quest quest, final boolean ignoreRequirements); + + void quitQuest(final Quest quest, final String message); + + void quitQuest(final Quest quest, final String[] messages); + + LinkedList getCurrentRequirements(final Quest quest, final boolean ignoreOverrides); + + LinkedList getCurrentObjectives(final Quest quest, final boolean ignoreOverrides); + + LinkedList getObjectives(final Quest quest, final boolean ignoreOverrides); + + boolean containsObjective(final Quest quest, final String name); + + boolean hasCustomObjective(final Quest quest, final String name); + + void breakBlock(final Quest quest, final ItemStack itemStack); + + void damageBlock(final Quest quest, final ItemStack itemStack); + + void placeBlock(final Quest quest, final ItemStack itemStack); + + void useBlock(final Quest quest, final ItemStack itemStack); + + void cutBlock(final Quest quest, final ItemStack itemStack); + + void craftItem(final Quest quest, final ItemStack itemStack); + + void smeltItem(final Quest quest, final ItemStack itemStack); + + void enchantBook(final Quest quest, final ItemStack itemStack, + final Map enchantsToAdd); + + void enchantItem(final Quest quest, final ItemStack itemStack); + + void brewItem(final Quest quest, final ItemStack itemStack); + + void consumeItem(final Quest quest, final ItemStack itemStack); + + void deliverToNPC(final Quest quest, final NPC npc, final ItemStack itemStack); + + void interactWithNPC(final Quest quest, final NPC npc); + + void killNPC(final Quest quest, final NPC npc); + + void milkCow(final Quest quest); + + void catchFish(final Quest quest); + + void killMob(final Quest quest, final Location killedLocation, final EntityType entityType); + + void killPlayer(final Quest quest, final Player player); + + void reachLocation(final Quest quest, final Location location); + + void tameMob(final Quest quest, final EntityType entityType); + + void shearSheep(final Quest quest, final DyeColor color); + + void sayPassword(final Quest quest, final AsyncPlayerChatEvent evt); + + void finishObjective(final Quest quest, final Objective objective, final EntityType mob, + final String extra, final NPC npc, final Location location, final DyeColor color, + final String pass, final CustomObjective co); + + boolean testComplete(final Quest quest); + + void addEmptiesFor(final Quest quest, final int stage); + + boolean saveData(); + + long getCompletionDifference(final Quest quest); + + long getRemainingCooldown(final Quest quest); + + FileConfiguration getBaseData(); + + boolean hasData(); + + boolean hasBaseData(); + + void startStageTimer(final Quest quest); + + void stopStageTimer(final Quest quest); + + long getStageTime(final Quest quest); + + void checkQuest(final Quest quest); + + void showGUIDisplay(final NPC npc, final LinkedList quests); + + void hardQuit(final Quest quest); + + void hardRemove(final Quest quest); + + void hardClear(); + + void hardStagePut(final Quest key, final Integer val); + + void hardDataPut(final Quest key, final QuestData val); + + boolean canUseCompass(); + + void resetCompass(); + + void findCompassTarget(); + + void findNextCompassTarget(final boolean notify); + + boolean hasItem(final ItemStack is); + + Set dispatchMultiplayerEverything(final Quest quest, final ObjectiveType type, + final BiFunction fun); + + Set dispatchMultiplayerObjectives(final Quest quest, final Stage currentStage, + final Function fun); + + List getMultiplayerQuesters(final Quest quest); + + boolean offerQuest(final Quest quest, final boolean giveReason); + + boolean canAcceptOffer(final Quest quest, final boolean giveReason); + + boolean meetsCondition(final Quest quest, final boolean giveReason); + + boolean isSelectingBlock(); + + boolean isInRegion(final String regionID); } diff --git a/api/src/main/java/me/blackvein/quests/Stage.java b/api/src/main/java/me/blackvein/quests/Stage.java index 183a029dc..48d7f815e 100644 --- a/api/src/main/java/me/blackvein/quests/Stage.java +++ b/api/src/main/java/me/blackvein/quests/Stage.java @@ -1,6 +1,8 @@ package me.blackvein.quests; import me.blackvein.quests.actions.Action; +import me.blackvein.quests.conditions.Condition; +import me.blackvein.quests.enums.ObjectiveType; import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.World; @@ -13,110 +15,164 @@ import java.util.Map; public interface Stage { LinkedList getBlocksToBreak(); + boolean addBlockToBreak(ItemStack blockToBreak); + void setBlocksToBreak(final LinkedList blocksToBreak); LinkedList getBlocksToDamage(); + boolean addBlockToDamage(ItemStack blockToDamage); + void setBlocksToDamage(final LinkedList blocksToDamage); LinkedList getBlocksToPlace(); + boolean addBlockToPlace(ItemStack blockToPlace); + void setBlocksToPlace(final LinkedList blocksToPlace); LinkedList getBlocksToUse(); + boolean addBlockToUse(ItemStack blockToUse); + void setBlocksToUse(final LinkedList blocksToUse); LinkedList getBlocksToCut(); + boolean addBlockToCut(ItemStack blockToCut); + void setBlocksToCut(final LinkedList blocksToCut); LinkedList getItemsToCraft(); + boolean addItemToCraft(ItemStack itemToCraft); + void setItemsToCraft(final LinkedList itemsToCraft); LinkedList getItemsToSmelt(); + boolean addItemToSmelt(ItemStack itemToSmelt); + void setItemsToSmelt(final LinkedList itemsToSmelt); LinkedList getItemsToEnchant(); + boolean addItemToEnchant(ItemStack itemToEnchant); + void setItemsToEnchant(final LinkedList itemsToEnchant); LinkedList getItemsToBrew(); + boolean addItemsToBrew(ItemStack itemToBrew); + void setItemsToBrew(final LinkedList itemsToBrew); LinkedList getItemsToConsume(); + boolean addItemToConsume(ItemStack itemToConsume); + void setItemsToConsume(final LinkedList itemsToConsume); LinkedList getItemsToDeliver(); + boolean addItemToDeliver(ItemStack itemToDeliver); + void setItemsToDeliver(final LinkedList itemsToDeliver); LinkedList getItemDeliveryTargets(); + boolean addItemDeliveryTarget(Integer itemDeliveryTarget); + void setItemDeliveryTargets(final LinkedList itemDeliveryTargets); LinkedList getDeliverMessages(); + boolean addDeliverMessage(String deliverMessage); + void setDeliverMessages(final LinkedList deliverMessages); LinkedList getCitizensToInteract(); + boolean addCitizenToInteract(Integer citizenToInteract); + void setCitizensToInteract(final LinkedList citizensToInteract); LinkedList getCitizensToKill(); + boolean addCitizenToKill(Integer citizenToKill); + void setCitizensToKill(final LinkedList citizensToKill); LinkedList getCitizenNumToKill(); + boolean addCitizenNumToKill(Integer citizenNumToKill); + void setCitizenNumToKill(final LinkedList citizenNumToKill); LinkedList getMobsToKill(); + boolean addMobToKill(EntityType mobToKill); + void setMobsToKill(final LinkedList mobsToKill); LinkedList getMobNumToKill(); + boolean addMobNumToKill(Integer mobNumToKill); + void setMobNumToKill(final LinkedList mobNumToKill); LinkedList getLocationsToKillWithin(); + boolean addLocationToKillWithin(Location locationToKillWithin); + void setLocationsToKillWithin(final LinkedList locationsToKillWithin); LinkedList getRadiiToKillWithin(); + boolean addRadiusToKillWithin(Integer radiusToKillWithin); + void setRadiiToKillWithin(final LinkedList radiiToKillWithin); LinkedList getKillNames(); + boolean addKillName(String killName); + void setKillNames(final LinkedList killNames); LinkedList getLocationsToReach(); + boolean addLocationToReach(Location locationToReach); + void setLocationsToReach(final LinkedList locationsToReach); LinkedList getRadiiToReachWithin(); + boolean addRadiusToReachWithin(Integer radiusToReachWithin); + void setRadiiToReachWithin(final LinkedList radiiToReachWithin); LinkedList getWorldsToReachWithin(); + boolean addWorldToReachWithin(World worldToReachWithin); + void setWorldsToReachWithin(final LinkedList worldsToReachWithin); LinkedList getLocationNames(); + boolean addLocationName(String locationName); + void setLocationNames(final LinkedList locationNames); LinkedList getMobsToTame(); + boolean addMobToTame(EntityType mobToTame); + void setMobsToTame(final LinkedList mobsToTame); LinkedList getMobNumToTame(); + boolean addMobNumToTame(Integer mobNumToTame); + void setMobNumToTame(final LinkedList mobNumToTame); Integer getFishToCatch(); @@ -133,18 +189,26 @@ public interface Stage { LinkedList getSheepToShear(); + boolean addSheepToShear(DyeColor sheepToShear); + void setSheepToShear(final LinkedList sheepToShear); LinkedList getSheepNumToShear(); + boolean addSheepNumToShear(Integer sheepNumToShear); + void setSheepNumToShear(final LinkedList sheepNumToShear); LinkedList getPasswordDisplays(); + boolean addPasswordDisplay(String passwordDisplay); + void setPasswordDisplays(final LinkedList passwordDisplays); LinkedList getPasswordPhrases(); + boolean addPasswordPhrase(String passwordPhrase); + void setPasswordPhrases(final LinkedList passwordPhrases); String getScript(); @@ -169,10 +233,14 @@ public interface Stage { Map getChatActions(); + void addChatAction(Map.Entry chatAction); + void setChatActions(final Map chatActions); Map getCommandActions(); + void addCommandAction(Map.Entry commandAction); + void setCommandActions(final Map commandActions); Action getDisconnectAction(); @@ -201,16 +269,26 @@ public interface Stage { LinkedList getObjectiveOverrides(); + boolean addObjectiveOverride(String objectiveOverride); + void setObjectiveOverrides(final LinkedList objectiveOverrides); LinkedList getCustomObjectives(); + void clearCustomObjectives(); + LinkedList getCustomObjectiveCounts(); + void clearCustomObjectiveCounts(); + LinkedList getCustomObjectiveDisplays(); + void clearCustomObjectiveDisplays(); + LinkedList> getCustomObjectiveData(); + void clearCustomObjectiveData(); + /** * Check if stage has at least one objective

* diff --git a/api/src/main/java/me/blackvein/quests/actions/Action.java b/api/src/main/java/me/blackvein/quests/actions/Action.java index dbbf817a2..81755e790 100644 --- a/api/src/main/java/me/blackvein/quests/actions/Action.java +++ b/api/src/main/java/me/blackvein/quests/actions/Action.java @@ -2,6 +2,7 @@ package me.blackvein.quests.actions; import me.blackvein.quests.Quest; import me.blackvein.quests.Quester; +import me.blackvein.quests.entity.QuestMob; import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.World; diff --git a/api/src/main/java/me/blackvein/quests/actions/ActionFactory.java b/api/src/main/java/me/blackvein/quests/actions/ActionFactory.java new file mode 100644 index 000000000..0f098185c --- /dev/null +++ b/api/src/main/java/me/blackvein/quests/actions/ActionFactory.java @@ -0,0 +1,48 @@ +package me.blackvein.quests.actions; + +import org.bukkit.block.Block; +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.ConversationFactory; +import org.bukkit.conversations.Prompt; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public interface ActionFactory { + Map getSelectedExplosionLocations(); + + void setSelectedExplosionLocations(final Map selectedExplosionLocations); + + Map getSelectedEffectLocations(); + + void setSelectedEffectLocations(final Map selectedEffectLocations); + + Map getSelectedMobLocations(); + + void setSelectedMobLocations(final Map selectedMobLocations); + + Map getSelectedLightningLocations(); + + void setSelectedLightningLocations(final Map selectedLightningLocations); + + Map getSelectedTeleportLocations(); + + void setSelectedTeleportLocations(final Map selectedTeleportLocations); + + ConversationFactory getConversationFactory(); + + List getNamesOfActionsBeingEdited(); + + void setNamesOfActionsBeingEdited(final List actionNames); + + Prompt returnToMenu(final ConversationContext context); + + void loadData(final Action event, final ConversationContext context); + + void clearData(final ConversationContext context); + + void deleteAction(final ConversationContext context); + + void saveAction(final ConversationContext context); +} diff --git a/api/src/main/java/me/blackvein/quests/conditions/Condition.java b/api/src/main/java/me/blackvein/quests/conditions/Condition.java new file mode 100644 index 000000000..45fc27c5b --- /dev/null +++ b/api/src/main/java/me/blackvein/quests/conditions/Condition.java @@ -0,0 +1,55 @@ +package me.blackvein.quests.conditions; + +import me.blackvein.quests.Quest; +import me.blackvein.quests.Quester; +import org.bukkit.inventory.ItemStack; + +import java.util.LinkedList; + +public interface Condition { + String getName(); + + void setName(final String name); + + boolean isFailQuest(); + + void setFailQuest(final boolean failQuest); + + LinkedList getEntitiesWhileRiding(); + + void setEntitiesWhileRiding(final LinkedList entitiesWhileRiding); + + LinkedList getNpcsWhileRiding(); + + void setNpcsWhileRiding(final LinkedList npcsWhileRiding); + + LinkedList getPermissions(); + + void setPermissions(final LinkedList permissions); + + LinkedList getItemsWhileHoldingMainHand(); + + void setItemsWhileHoldingMainHand(final LinkedList itemsWhileHoldingMainHand); + + LinkedList getWorldsWhileStayingWithin(); + + void setWorldsWhileStayingWithin(final LinkedList worldsWhileStayingWithin); + + LinkedList getBiomesWhileStayingWithin(); + + void setBiomesWhileStayingWithin(final LinkedList biomesWhileStayingWithin); + + LinkedList getRegionsWhileStayingWithin(); + + void setRegionsWhileStayingWithin(final LinkedList biomesWhileStayingWithin); + + LinkedList getPlaceholdersCheckIdentifier(); + + void setPlaceholdersCheckIdentifier(final LinkedList placeholdersCheckIdentifier); + + LinkedList getPlaceholdersCheckValue(); + + void setPlaceholdersCheckValue(final LinkedList placeholdersCheckValue); + + boolean check(final Quester quester, final Quest quest); +} diff --git a/api/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java b/api/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java new file mode 100644 index 000000000..61a575a9f --- /dev/null +++ b/api/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java @@ -0,0 +1,25 @@ +package me.blackvein.quests.conditions; + +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.ConversationFactory; +import org.bukkit.conversations.Prompt; + +import java.util.List; + +public interface ConditionFactory { + ConversationFactory getConversationFactory(); + + List getNamesOfConditionsBeingEdited(); + + void setNamesOfConditionsBeingEdited(final List conditionNames); + + Prompt returnToMenu(final ConversationContext context); + + void loadData(final Condition condition, final ConversationContext context); + + void clearData(final ConversationContext context); + + void deleteCondition(final ConversationContext context); + + void saveCondition(final ConversationContext context); +} diff --git a/core/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java b/api/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java similarity index 100% rename from core/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java rename to api/src/main/java/me/blackvein/quests/convo/QuestsNumericPrompt.java diff --git a/core/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java b/api/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java similarity index 100% rename from core/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java rename to api/src/main/java/me/blackvein/quests/convo/QuestsStringPrompt.java diff --git a/core/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorNumericPrompt.java b/api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorNumericPrompt.java similarity index 100% rename from core/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorNumericPrompt.java rename to api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorNumericPrompt.java diff --git a/core/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorStringPrompt.java b/api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorStringPrompt.java similarity index 100% rename from core/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorStringPrompt.java rename to api/src/main/java/me/blackvein/quests/convo/actions/ActionsEditorStringPrompt.java diff --git a/core/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java b/api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java similarity index 100% rename from core/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java rename to api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorNumericPrompt.java diff --git a/core/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java b/api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java similarity index 100% rename from core/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java rename to api/src/main/java/me/blackvein/quests/convo/conditions/ConditionsEditorStringPrompt.java diff --git a/api/src/main/java/me/blackvein/quests/entity/QuestMob.java b/api/src/main/java/me/blackvein/quests/entity/QuestMob.java new file mode 100644 index 000000000..f9fc5c1b7 --- /dev/null +++ b/api/src/main/java/me/blackvein/quests/entity/QuestMob.java @@ -0,0 +1,45 @@ +package me.blackvein.quests.entity; + +import org.bukkit.Location; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +public interface QuestMob { + String getName(); + + void setName(final String name); + + EntityType getType(); + + void setType(final EntityType entityType); + + Location getSpawnLocation(); + + void setSpawnLocation(final Location spawnLocation); + + Integer getSpawnAmounts(); + + void setSpawnAmounts(final int spawnAmounts); + + ItemStack[] getInventory(); + + void setInventory(final ItemStack[] inventory); + + Float[] getDropChances(); + + void setDropChances(final Float[] dropChances); + + void setHelmet(final ItemStack helmet, final float dropChance); + + void setChest(final ItemStack chest, final float dropChance); + + void setLeggings(final ItemStack leggings, final float dropChance); + + void setBoots(final ItemStack boots, final float dropChance); + + void setHeldItem(final ItemStack heldItem, final float dropChance); + + void spawn(); + + String serialize(); +} diff --git a/core/src/main/java/me/blackvein/quests/enums/ObjectiveType.java b/api/src/main/java/me/blackvein/quests/enums/ObjectiveType.java similarity index 100% rename from core/src/main/java/me/blackvein/quests/enums/ObjectiveType.java rename to api/src/main/java/me/blackvein/quests/enums/ObjectiveType.java diff --git a/api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java b/api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java index 17471582d..757cfbe3b 100644 --- a/api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java +++ b/api/src/main/java/me/blackvein/quests/events/editor/actions/ActionsEditorPostOpenStringPromptEvent.java @@ -12,10 +12,9 @@ package me.blackvein.quests.events.editor.actions; +import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; import org.bukkit.conversations.ConversationContext; import org.bukkit.event.HandlerList; - -import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; import org.jetbrains.annotations.NotNull; public class ActionsEditorPostOpenStringPromptEvent extends ActionsEditorEvent { diff --git a/core/src/main/java/me/blackvein/quests/DenizenTrigger.java b/core/src/main/java/me/blackvein/quests/DenizenTrigger.java index 97e13ead2..58a4a571e 100644 --- a/core/src/main/java/me/blackvein/quests/DenizenTrigger.java +++ b/core/src/main/java/me/blackvein/quests/DenizenTrigger.java @@ -12,15 +12,13 @@ package me.blackvein.quests; -import me.blackvein.quests.player.BukkitQuester; - public class DenizenTrigger { private final Quests plugin; public DenizenTrigger(final Quests plugin) { this.plugin = plugin; } - public boolean runDenizenScript(final String scriptName, final BukkitQuester quester) { + public boolean runDenizenScript(final String scriptName, final Quester quester) { if (scriptName == null) { return false; } diff --git a/core/src/main/java/me/blackvein/quests/Quests.java b/core/src/main/java/me/blackvein/quests/Quests.java index fc325c61e..9656681b0 100644 --- a/core/src/main/java/me/blackvein/quests/Quests.java +++ b/core/src/main/java/me/blackvein/quests/Quests.java @@ -15,12 +15,17 @@ package me.blackvein.quests; import com.codisimus.plugins.phatloots.PhatLootsAPI; import com.gmail.nossr50.datatypes.skills.SkillType; import com.herocraftonline.heroes.characters.classes.HeroClass; -import me.blackvein.quests.actions.BukkitAction; +import me.blackvein.quests.actions.Action; import me.blackvein.quests.actions.ActionFactory; -import me.blackvein.quests.conditions.Condition; +import me.blackvein.quests.actions.BukkitAction; +import me.blackvein.quests.actions.BukkitActionFactory; +import me.blackvein.quests.conditions.BukkitCondition; +import me.blackvein.quests.conditions.BukkitConditionFactory; import me.blackvein.quests.conditions.ConditionFactory; import me.blackvein.quests.convo.misc.MiscStringPrompt; import me.blackvein.quests.convo.misc.NpcOfferQuestPrompt; +import me.blackvein.quests.entity.BukkitQuestMob; +import me.blackvein.quests.entity.QuestMob; import me.blackvein.quests.events.misc.MiscPostQuestAcceptEvent; import me.blackvein.quests.exceptions.ActionFormatException; import me.blackvein.quests.exceptions.ConditionFormatException; @@ -36,11 +41,7 @@ import me.blackvein.quests.listeners.PartiesListener; import me.blackvein.quests.listeners.PlayerListener; import me.blackvein.quests.listeners.UniteListener; import me.blackvein.quests.player.BukkitQuester; -import me.blackvein.quests.quests.BukkitOptions; -import me.blackvein.quests.quests.BukkitPlanner; -import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.quests.BukkitRequirements; -import me.blackvein.quests.quests.BukkitRewards; +import me.blackvein.quests.quests.BukkitQuestFactory; import me.blackvein.quests.quests.BukkitStage; import me.blackvein.quests.statistics.Metrics; import me.blackvein.quests.storage.Storage; @@ -132,10 +133,10 @@ public class Quests extends JavaPlugin implements QuestsAPI { private final List customObjectives = new LinkedList<>(); private final List customRequirements = new LinkedList<>(); private final List customRewards = new LinkedList<>(); - private Collection questers = new ConcurrentSkipListSet<>(); - private final Collection quests = new ConcurrentSkipListSet<>(); + private Collection questers = new ConcurrentSkipListSet<>(); + private final Collection quests = new ConcurrentSkipListSet<>(); private Collection actions = new ConcurrentSkipListSet<>(); - private Collection conditions = new ConcurrentSkipListSet<>(); + private Collection conditions = new ConcurrentSkipListSet<>(); private LinkedList questNpcIds = new LinkedList<>(); private CommandExecutor cmdExecutor; private ConversationFactory conversationFactory; @@ -178,9 +179,9 @@ public class Quests extends JavaPlugin implements QuestsAPI { partiesListener = new PartiesListener(); effectThread = new NpcEffectThread(this); moveThread = new PlayerMoveThread(this); - questFactory = new QuestFactory(this); - actionFactory = new ActionFactory(this); - conditionFactory = new ConditionFactory(this); + questFactory = new BukkitQuestFactory(this); + actionFactory = new BukkitActionFactory(this); + conditionFactory = new BukkitConditionFactory(this); depends = new Dependencies(this); trigger = new DenizenTrigger(this); final Metrics metrics = new Metrics(this); @@ -265,7 +266,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { public void onDisable() { getLogger().info("Saving Quester data..."); for (final Player p : getServer().getOnlinePlayers()) { - final BukkitQuester quester = getQuester(p.getUniqueId()); + final Quester quester = getQuester(p.getUniqueId()); quester.saveData(); } Bukkit.getScheduler().cancelTasks(this); @@ -340,7 +341,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @return a list of all Quests */ @Deprecated - public LinkedList getQuests() { + public LinkedList getQuests() { return new LinkedList<>(quests); } @@ -349,7 +350,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * * @return a collection of all Quests */ - public Collection getLoadedQuests() { + public Collection getLoadedQuests() { return quests; } @@ -398,7 +399,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @return a list of all Conditions */ @Deprecated - public LinkedList getConditions() { + public LinkedList getConditions() { return new LinkedList<>(conditions); } @@ -407,7 +408,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * * @return a collection of all Conditions */ - public Collection getLoadedConditions() { + public Collection getLoadedConditions() { return conditions; } @@ -417,7 +418,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @deprecated Use {@link #setLoadedConditions(Collection)} */ @Deprecated - public void setConditions(final LinkedList conditions) { + public void setConditions(final LinkedList conditions) { this.conditions = conditions; } @@ -425,7 +426,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * Set every Condition loaded in memory * */ - public void setLoadedConditions(final Collection conditions) { + public void setLoadedConditions(final Collection conditions) { this.conditions = conditions; } @@ -435,23 +436,23 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @param id Player UUID * @return Quester, or null if UUID is null */ - public BukkitQuester getQuester(final UUID id) { + public Quester getQuester(final UUID id) { if (id == null) { return null; } - final ConcurrentSkipListSet set = (ConcurrentSkipListSet) questers; - for (final BukkitQuester q: set) { + final ConcurrentSkipListSet set = (ConcurrentSkipListSet) questers; + for (final Quester q: set) { if (q != null && q.getUUID().equals(id)) { return q; } } - final BukkitQuester quester = new BukkitQuester(this, id); + final Quester quester = new BukkitQuester(this, id); if (depends.getCitizens() != null) { if (depends.getCitizens().getNPCRegistry().getByUniqueId(id) != null) { return quester; } } - final BukkitQuester q = new BukkitQuester(this, id); + final Quester q = new BukkitQuester(this, id); questers.add(q); return q; } @@ -463,7 +464,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @return a list of all Questers */ @Deprecated - public LinkedList getQuesters() { + public LinkedList getQuesters() { return new LinkedList<>(questers); } @@ -474,7 +475,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @param questers a list of Questers */ @Deprecated - public void setQuesters(final LinkedList questers) { + public void setQuesters(final LinkedList questers) { this.questers = new ConcurrentSkipListSet<>(questers); } @@ -483,9 +484,9 @@ public class Quests extends JavaPlugin implements QuestsAPI { * * @return a collection of all online Questers */ - public Collection getOnlineQuesters() { - final Collection questers = new ConcurrentSkipListSet<>(); - for (final BukkitQuester q : getOfflineQuesters()) { + public Collection getOnlineQuesters() { + final Collection questers = new ConcurrentSkipListSet<>(); + for (final Quester q : getOfflineQuesters()) { if (q.getOfflinePlayer().isOnline()) { // Workaround for issues with the compass on fast join q.findCompassTarget(); @@ -500,7 +501,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * * @return a collection of all Questers */ - public Collection getOfflineQuesters() { + public Collection getOfflineQuesters() { return questers; } @@ -509,7 +510,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * * @param questers a collection of Questers */ - public void setOfflineQuesters(final Collection questers) { + public void setOfflineQuesters(final Collection questers) { this.questers = new ConcurrentSkipListSet<>(questers); } @@ -676,7 +677,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { final Player player = (Player) context.getForWhom(); if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("y") || input.equalsIgnoreCase(Lang.get(player, "yesWord"))) { - BukkitQuester quester = getQuester(player.getUniqueId()); + Quester quester = getQuester(player.getUniqueId()); if (quester == null) { // Must be new player quester = new BukkitQuester(Quests.this, player.getUniqueId()); @@ -686,7 +687,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { Lang.send(player, ChatColor.RED + Lang.get(player, "questSaveError")); } } - final String questIdToTake = quester.questIdToTake; + final String questIdToTake = quester.getQuestIdToTake(); try { if (getQuestById(questIdToTake) == null) { getLogger().info(player.getName() + " attempted to take quest ID \"" + questIdToTake @@ -806,7 +807,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { getLogger().log(Level.INFO, "Loaded " + quests.size() + " Quest(s), " + actions.size() + " Action(s), " + conditions.size() + " Condition(s) and " + Lang.size() + " Phrase(s)"); for (final Player p : getServer().getOnlinePlayers()) { - final BukkitQuester quester = new BukkitQuester(Quests.this, p.getUniqueId()); + final Quester quester = new BukkitQuester(Quests.this, p.getUniqueId()); if (!quester.hasData()) { quester.saveData(); } @@ -863,12 +864,12 @@ public class Quests extends JavaPlugin implements QuestsAPI { int count = 0; for (final String questKey : questsSection.getKeys(false)) { try { - for (final BukkitQuest lq : getLoadedQuests()) { + for (final Quest lq : getLoadedQuests()) { if (lq.getId().equals(questKey)) { throw new QuestFormatException("id already exists", questKey); } } - final BukkitQuest quest = loadQuest(config, questKey); + final Quest quest = loadQuest(config, questKey); if (config.contains("quests." + questKey + ".requirements")) { loadQuestRequirements(config, questsSection, quest, questKey); } @@ -1038,7 +1039,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @param ignoreOverrides Whether to ignore objective-overrides */ @SuppressWarnings("deprecation") - public void showObjectives(final BukkitQuest quest, final BukkitQuester quester, final boolean ignoreOverrides) { + public void showObjectives(final Quest quest, final Quester quester, final boolean ignoreOverrides) { if (quest == null) { getLogger().severe("Quest was null when getting objectives for " + quester.getLastKnownName()); return; @@ -1051,8 +1052,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { getLogger().warning("Current stage was null when showing objectives for " + quest.getName()); return; } - if (!ignoreOverrides && !quester.getCurrentStage(quest).objectiveOverrides.isEmpty()) { - for (final String s: quester.getCurrentStage(quest).objectiveOverrides) { + if (!ignoreOverrides && !quester.getCurrentStage(quest).getObjectiveOverrides().isEmpty()) { + for (final String s: quester.getCurrentStage(quest).getObjectiveOverrides()) { String message = ChatColor.GREEN + (s.trim().length() > 0 ? "- " : "") + ConfigUtil .parseString(s, quest, quester.getPlayer()); if (depends.getPlaceholderApi() != null) { @@ -1063,8 +1064,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { return; } final QuestData data = quester.getQuestData(quest); - final BukkitStage stage = quester.getCurrentStage(quest); - for (final ItemStack e : stage.blocksToBreak) { + final Stage 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()) { final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; @@ -1086,7 +1087,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } } - for (final ItemStack e : stage.blocksToDamage) { + for (final ItemStack e : stage.getBlocksToDamage()) { for (final ItemStack e2 : data.blocksDamaged) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; @@ -1108,7 +1109,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } } - for (final ItemStack e : stage.blocksToPlace) { + for (final ItemStack e : stage.getBlocksToPlace()) { for (final ItemStack e2 : data.blocksPlaced) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; @@ -1130,7 +1131,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } } - for (final ItemStack e : stage.blocksToUse) { + for (final ItemStack e : stage.getBlocksToUse()) { for (final ItemStack e2 : data.blocksUsed) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; @@ -1152,7 +1153,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } } - for (final ItemStack e : stage.blocksToCut) { + for (final ItemStack e : stage.getBlocksToCut()) { for (final ItemStack e2 : data.blocksCut) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { final ChatColor color = e2.getAmount() < e.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; @@ -1175,7 +1176,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } int craftIndex = 0; - for (final ItemStack is : stage.itemsToCraft) { + for (final ItemStack is : stage.getItemsToCraft()) { int crafted = 0; if (data.itemsCrafted.size() > craftIndex) { crafted = data.itemsCrafted.get(craftIndex).getAmount(); @@ -1201,7 +1202,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { craftIndex++; } int smeltIndex = 0; - for (final ItemStack is : stage.itemsToSmelt) { + for (final ItemStack is : stage.getItemsToSmelt()) { int smelted = 0; if (data.itemsSmelted.size() > smeltIndex) { smelted = data.itemsSmelted.get(smeltIndex).getAmount(); @@ -1227,7 +1228,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { smeltIndex++; } int enchantIndex = 0; - for (final ItemStack is : stage.itemsToEnchant) { + for (final ItemStack is : stage.getItemsToEnchant()) { int enchanted = 0; if (data.itemsEnchanted.size() > enchantIndex) { enchanted = data.itemsEnchanted.get(enchantIndex).getAmount(); @@ -1270,7 +1271,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { enchantIndex++; } int brewIndex = 0; - for (final ItemStack is : stage.itemsToBrew) { + for (final ItemStack is : stage.getItemsToBrew()) { int brewed = 0; if (data.itemsBrewed.size() > brewIndex) { brewed = data.itemsBrewed.get(brewIndex).getAmount(); @@ -1302,7 +1303,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { brewIndex++; } int consumeIndex = 0; - for (final ItemStack is : stage.itemsToConsume) { + for (final ItemStack is : stage.getItemsToConsume()) { int consumed = 0; if (data.itemsConsumed.size() > consumeIndex) { consumed = data.itemsConsumed.get(consumeIndex).getAmount(); @@ -1334,13 +1335,13 @@ public class Quests extends JavaPlugin implements QuestsAPI { consumeIndex++; } int deliverIndex = 0; - for (final ItemStack is : stage.itemsToDeliver) { + for (final ItemStack is : stage.getItemsToDeliver()) { int delivered = 0; if (data.itemsDelivered.size() > deliverIndex) { delivered = data.itemsDelivered.get(deliverIndex).getAmount(); } final int toDeliver = is.getAmount(); - final Integer npc = stage.itemDeliveryTargets.get(deliverIndex); + final Integer npc = stage.getItemDeliveryTargets().get(deliverIndex); final ChatColor color = delivered < toDeliver ? ChatColor.GREEN : ChatColor.GRAY; String message = color + "- " + Lang.get(quester.getPlayer(), "deliver").replace("", depends.getNPCName(npc)); if (message.contains("")) { @@ -1361,7 +1362,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { deliverIndex++; } int interactIndex = 0; - for (final Integer n : stage.citizensToInteract) { + for (final Integer n : stage.getCitizensToInteract()) { boolean interacted = false; if (data.citizensInteracted.size() > interactIndex) { interacted = data.citizensInteracted.get(interactIndex); @@ -1376,12 +1377,12 @@ public class Quests extends JavaPlugin implements QuestsAPI { interactIndex++; } int npcKillIndex = 0; - for (final Integer n : stage.citizensToKill) { + for (final Integer n : stage.getCitizensToKill()) { int npcKilled = 0; if (data.citizensNumKilled.size() > npcKillIndex) { npcKilled = data.citizensNumKilled.get(npcKillIndex); } - final int toNpcKill = stage.citizenNumToKill.get(npcKillIndex); + final int toNpcKill = stage.getCitizenNumToKill().get(npcKillIndex); final ChatColor color = npcKilled < toNpcKill ? ChatColor.GREEN : ChatColor.GRAY; String message = color + "- " + Lang.get(quester.getPlayer(), "kill"); if (message.contains("")) { @@ -1402,15 +1403,15 @@ public class Quests extends JavaPlugin implements QuestsAPI { npcKillIndex++; } int mobKillIndex = 0; - for (final EntityType e : stage.mobsToKill) { + for (final EntityType e : stage.getMobsToKill()) { int mobKilled = 0; if (data.mobNumKilled.size() > mobKillIndex) { mobKilled = data.mobNumKilled.get(mobKillIndex); } - final int toMobKill = stage.mobNumToKill.get(mobKillIndex); + final int toMobKill = stage.getMobNumToKill().get(mobKillIndex); final ChatColor color = mobKilled < toMobKill ? ChatColor.GREEN : ChatColor.GRAY; String message = color + "- "; - if (stage.locationsToKillWithin.isEmpty()) { + if (stage.getLocationsToKillWithin().isEmpty()) { message += Lang.get(quester.getPlayer(), "kill"); if (message.contains("")) { message = message.replace("", "" + color + mobKilled + "/" + toMobKill); @@ -1420,7 +1421,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } else { message += Lang.get(quester.getPlayer(), "killAtLocation").replace("", - stage.killNames.get(stage.mobsToKill.indexOf(e))); + stage.getKillNames().get(stage.getMobsToKill().indexOf(e))); if (message.contains("")) { message = message.replace("", "" + color + mobKilled + "/" + toMobKill); } else { @@ -1438,7 +1439,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { mobKillIndex++; } int tameIndex = 0; - for (final int toTame : stage.mobNumToTame) { + for (final int toTame : stage.getMobNumToTame()) { int tamed = 0; if (data.mobsTamed.size() > tameIndex) { tamed = data.mobsTamed.get(tameIndex); @@ -1455,35 +1456,35 @@ public class Quests extends JavaPlugin implements QuestsAPI { message += color + ": " + tamed + "/" + toTame; } if (getSettings().canTranslateNames()) { - localeManager.sendMessage(quester.getPlayer(), message, stage.mobsToTame.get(tameIndex), null); + localeManager.sendMessage(quester.getPlayer(), message, stage.getMobsToTame().get(tameIndex), null); } else { quester.sendMessage(message.replace("", - MiscUtil.getProperMobName(stage.mobsToTame.get(tameIndex)))); + MiscUtil.getProperMobName(stage.getMobsToTame().get(tameIndex)))); } tameIndex++; } - if (stage.fishToCatch != null) { - final ChatColor color = data.getFishCaught() < stage.fishToCatch ? ChatColor.GREEN : ChatColor.GRAY; + if (stage.getFishToCatch() != null) { + final ChatColor color = data.getFishCaught() < stage.getFishToCatch() ? ChatColor.GREEN : ChatColor.GRAY; String message = color + "- " + Lang.get(quester.getPlayer(), "catchFish"); if (message.contains("")) { - message = message.replace("", "" + color + data.getFishCaught() + "/" + stage.fishToCatch); + message = message.replace("", "" + color + data.getFishCaught() + "/" + stage.getFishToCatch()); } else { // Legacy - message += color + ": " + data.getFishCaught() + "/" + stage.fishToCatch; + message += color + ": " + data.getFishCaught() + "/" + stage.getFishToCatch(); } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } quester.sendMessage(message); } - if (stage.cowsToMilk != null) { - final ChatColor color = data.getCowsMilked() < stage.cowsToMilk ? ChatColor.GREEN : ChatColor.GRAY; + if (stage.getCowsToMilk() != null) { + final ChatColor color = data.getCowsMilked() < stage.getCowsToMilk() ? ChatColor.GREEN : ChatColor.GRAY; String message = color + "- " + Lang.get(quester.getPlayer(), "milkCow"); if (message.contains("")) { - message = message.replace("", "" + color + data.getCowsMilked() + "/" + stage.cowsToMilk); + message = message.replace("", "" + color + data.getCowsMilked() + "/" + stage.getCowsToMilk()); } else { // Legacy - message += color + ": " + data.getCowsMilked() + "/" + stage.cowsToMilk; + message += color + ": " + data.getCowsMilked() + "/" + stage.getCowsToMilk(); } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); @@ -1491,14 +1492,15 @@ public class Quests extends JavaPlugin implements QuestsAPI { quester.sendMessage(message); } int shearIndex = 0; - for (final int toShear : stage.sheepNumToShear) { + for (final int toShear : stage.getSheepNumToShear()) { int sheared = 0; if (data.sheepSheared.size() > shearIndex) { sheared = data.sheepSheared.get(shearIndex); } final ChatColor color = sheared < toShear ? ChatColor.GREEN : ChatColor.GRAY; String message = color + "- " + Lang.get(quester.getPlayer(), "shearSheep"); - message = message.replace("", MiscUtil.getPrettyDyeColorName(stage.sheepToShear.get(shearIndex))); + message = message.replace("", MiscUtil.getPrettyDyeColorName(stage.getSheepToShear() + .get(shearIndex))); if (message.contains("")) { message = message.replace("", "" + color + sheared + "/" + toShear); } else { @@ -1508,30 +1510,32 @@ public class Quests extends JavaPlugin implements QuestsAPI { quester.sendMessage(message); shearIndex++; } - if (stage.playersToKill != null) { - final ChatColor color = data.getPlayersKilled() < stage.playersToKill ? ChatColor.GREEN : ChatColor.GRAY; + if (stage.getPlayersToKill() != null) { + final ChatColor color = data.getPlayersKilled() < stage.getPlayersToKill() ? ChatColor.GREEN + : ChatColor.GRAY; String message = color + "- " + Lang.get(quester.getPlayer(), "killPlayer"); if (message.contains("")) { - message = message.replace("", "" + color + data.getPlayersKilled() + "/" + stage.playersToKill); + message = message.replace("", "" + color + data.getPlayersKilled() + "/" + + stage.getPlayersToKill()); } else { // Legacy - message += color + ": " + data.getPlayersKilled() + "/" + stage.playersToKill; + message += color + ": " + data.getPlayersKilled() + "/" + stage.getPlayersToKill(); } if (depends.getPlaceholderApi() != null) { message = PlaceholderAPI.setPlaceholders(quester.getPlayer(), message); } quester.sendMessage(message); } - for (int i = 0 ; i < stage.locationsToReach.size(); i++) { + for (int i = 0 ; i < stage.getLocationsToReach().size(); i++) { if (i < data.locationsReached.size()) { final ChatColor color = !data.locationsReached.get(i) ? ChatColor.GREEN : ChatColor.GRAY; String message = color + Lang.get(quester.getPlayer(), "goTo"); - message = message.replace("", stage.locationNames.get(i)); + message = message.replace("", stage.getLocationNames().get(i)); quester.sendMessage(message); } } int passIndex = 0; - for (final String s : stage.passwordDisplays) { + for (final String s : stage.getPasswordDisplays()) { boolean said = false; if (data.passwordsSaid.size() > passIndex) { said = data.passwordsSaid.get(passIndex); @@ -1542,18 +1546,18 @@ public class Quests extends JavaPlugin implements QuestsAPI { passIndex++; } int customIndex = 0; - for (final CustomObjective co : stage.customObjectives) { + for (final CustomObjective co : stage.getCustomObjectives()) { int cleared = 0; if (data.customObjectiveCounts.size() > customIndex) { cleared = data.customObjectiveCounts.get(customIndex); } - final int toClear = stage.customObjectiveCounts.get(customIndex); + final int toClear = stage.getCustomObjectiveCounts().get(customIndex); final ChatColor color = cleared < toClear ? ChatColor.GREEN : ChatColor.GRAY; String message = color + "- " + co.getDisplay(); for (final Entry prompt : co.getData()) { final String replacement = "%" + prompt.getKey() + "%"; try { - for (final Entry e : stage.customObjectiveData) { + for (final Entry e : stage.getCustomObjectiveData()) { if (e.getKey().equals(prompt.getKey())) { if (message.contains(replacement)) { message = message.replace(replacement, ((String) e.getValue())); @@ -1580,14 +1584,14 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @param quester Quester to show the list * @param page Page to display, with 7 quests per page */ - public void listQuests(final BukkitQuester quester, final int page) { + public void listQuests(final Quester quester, final int page) { // Although we could copy the quests list to a new object, we instead opt to // duplicate code to improve efficiency if ignore-locked-quests is set to 'false' final int rows = 7; final Player player = quester.getPlayer(); if (getSettings().canIgnoreLockedQuests()) { - final LinkedList available = new LinkedList<>(); - for (final BukkitQuest q : quests) { + final LinkedList available = new LinkedList<>(); + for (final Quest q : quests) { if (!quester.getCompletedQuests().contains(q)) { if (q.testRequirements(player)) { available.add(q); @@ -1603,14 +1607,14 @@ public class Quests extends JavaPlugin implements QuestsAPI { } else { Lang.send(player, ChatColor.GOLD + Lang.get(player, "questListTitle")); int fromOrder = (page - 1) * rows; - final List subQuests; + final List subQuests; if (available.size() >= (fromOrder + rows)) { subQuests = available.subList((fromOrder), (fromOrder + rows)); } else { subQuests = available.subList((fromOrder), available.size()); } fromOrder++; - for (final BukkitQuest q : subQuests) { + for (final Quest q : subQuests) { if (quester.canAcceptOffer(q, false)) { quester.sendMessage(ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName()); } else { @@ -1630,14 +1634,14 @@ public class Quests extends JavaPlugin implements QuestsAPI { } else { Lang.send(player, ChatColor.GOLD + Lang.get(player, "questListTitle")); int fromOrder = (page - 1) * rows; - final List subQuests; + final List subQuests; if (quests.size() >= (fromOrder + rows)) { subQuests = getQuests().subList((fromOrder), (fromOrder + rows)); } else { subQuests = getQuests().subList((fromOrder), quests.size()); } fromOrder++; - for (final BukkitQuest q : subQuests) { + for (final Quest q : subQuests) { if (quester.canAcceptOffer(q, false)) { Lang.send(player, ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName()); } else { @@ -1678,10 +1682,10 @@ public class Quests extends JavaPlugin implements QuestsAPI { loadConditions(); final CompletableFuture loadFuture = saveFuture.thenRunAsync(() -> { try { - for (final BukkitQuester quester : questers) { - final CompletableFuture cf = getStorage().loadQuester(quester.getUUID()); - final BukkitQuester loaded = cf.get(); - for (final BukkitQuest q : loaded.currentQuests.keySet()) { + for (final Quester quester : questers) { + final CompletableFuture cf = getStorage().loadQuester(quester.getUUID()); + final Quester loaded = cf.get(); + for (final Quest q : loaded.getCurrentQuests().keySet()) { loaded.checkQuest(q); } } @@ -1747,7 +1751,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } for (final String questKey : questsSection.getKeys(false)) { try { - final BukkitQuest quest = loadQuest(config, questKey); + final Quest quest = loadQuest(config, questKey); if (config.contains("quests." + questKey + ".requirements")) { loadQuestRequirements(config, questsSection, quest, questKey); } @@ -1757,7 +1761,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (config.contains("quests." + questKey + ".options")) { loadQuestOptions(config, quest, questKey); } - quest.plugin = this; + quest.setPlugin(this); loadQuestStages(quest, config, questKey); loadQuestRewards(config, quest, questKey); quests.add(quest); @@ -1780,31 +1784,31 @@ public class Quests extends JavaPlugin implements QuestsAPI { } @SuppressWarnings("deprecation") - private BukkitQuest loadQuest(final FileConfiguration config, final String questKey) throws QuestFormatException, + private Quest loadQuest(final FileConfiguration config, final String questKey) throws QuestFormatException, ActionFormatException { - final BukkitQuest quest = new BukkitQuest(); - quest.id = questKey; + final Quest quest = new Quest(); + quest.setId(questKey); if (config.contains("quests." + questKey + ".name")) { quest.setName(ConfigUtil.parseString(config.getString("quests." + questKey + ".name"), quest)); } else { throw new QuestFormatException("name is missing", questKey); } if (config.contains("quests." + questKey + ".ask-message")) { - quest.description = ConfigUtil.parseString(config.getString("quests." + questKey - + ".ask-message"), quest); + quest.setDescription(ConfigUtil.parseString(config.getString("quests." + questKey + + ".ask-message"), quest)); } else { throw new QuestFormatException("ask-message is missing", questKey); } if (config.contains("quests." + questKey + ".finish-message")) { - quest.finished = ConfigUtil.parseString(config.getString("quests." + questKey - + ".finish-message"), quest); + quest.setFinished(ConfigUtil.parseString(config.getString("quests." + questKey + + ".finish-message"), quest)); } else { throw new QuestFormatException("finish-message is missing", questKey); } if (depends.getCitizens() != null && config.contains("quests." + questKey + ".npc-giver-id")) { final int npcId = config.getInt("quests." + questKey + ".npc-giver-id"); if (CitizensAPI.getNPCRegistry().getById(npcId) != null) { - quest.npcStart = CitizensAPI.getNPCRegistry().getById(npcId); + quest.setNpcStart(CitizensAPI.getNPCRegistry().getById(npcId)); questNpcIds.add(npcId); } else { throw new QuestFormatException("npc-giver-id has invalid NPC ID " + npcId, questKey); @@ -1815,7 +1819,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (blockStart != null) { final Location location = ConfigUtil.getLocation(blockStart); if (location != null) { - quest.blockStart = location; + quest.setBlockStart(location); } else { throw new QuestFormatException("block-start has invalid location", questKey); } @@ -1832,7 +1836,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (world != null && getDependencies().getWorldGuardApi().getRegionManager(world) != null) { if (Objects.requireNonNull(getDependencies().getWorldGuardApi().getRegionManager(world)) .hasRegion(region)) { - quest.regionStart = region; + quest.setRegionStart(region); exists = true; break; } @@ -1857,7 +1861,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } if (stack != null) { - quest.guiDisplay = stack; + quest.setGUIDisplay(stack); } else { throw new QuestFormatException("gui-display has invalid item format", questKey); } @@ -1871,16 +1875,16 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } if (config.contains("quests." + questKey + ".action")) { - final BukkitAction action = loadAction(config.getString("quests." + questKey + ".action")); + final Action action = loadAction(config.getString("quests." + questKey + ".action")); if (action != null) { - quest.initialAction = action; + quest.setInitialAction(action); } else { throw new QuestFormatException("action failed to load", questKey); } } else if (config.contains("quests." + questKey + ".event")) { - final BukkitAction action = loadAction(config.getString("quests." + questKey + ".event")); + final Action action = loadAction(config.getString("quests." + questKey + ".event")); if (action != null) { - quest.initialAction = action; + quest.setInitialAction(action); } else { throw new QuestFormatException("action failed to load", questKey); } @@ -1889,9 +1893,9 @@ public class Quests extends JavaPlugin implements QuestsAPI { } @SuppressWarnings({"unchecked", "deprecation"}) - private void loadQuestRewards(final FileConfiguration config, final BukkitQuest quest, final String questKey) + private void loadQuestRewards(final FileConfiguration config, final Quest quest, final String questKey) throws QuestFormatException { - final BukkitRewards rewards = quest.getRewards(); + final Rewards rewards = quest.getRewards(); if (config.contains("quests." + questKey + ".rewards.items")) { final LinkedList temp = new LinkedList<>(); final List stackList = (List) config.get("quests." + questKey + ".rewards.items"); @@ -2076,8 +2080,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { @SuppressWarnings({ "unchecked", "deprecation" }) private void loadQuestRequirements(final FileConfiguration config, final ConfigurationSection questsSection, - final BukkitQuest quest, final String questKey) throws QuestFormatException { - final BukkitRequirements requires = quest.getRequirements(); + final Quest quest, final String questKey) throws QuestFormatException { + final Requirements requires = quest.getRequirements(); if (config.contains("quests." + questKey + ".requirements.fail-requirement-message")) { final Object o = config.get("quests." + questKey + ".requirements.fail-requirement-message"); if (o instanceof List) { @@ -2152,7 +2156,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { final List nodes = config.getStringList("quests." + questKey + ".requirements.quest-blocks"); boolean failed = false; String failedQuest = "NULL"; - final List temp = new LinkedList<>(); + final List temp = new LinkedList<>(); for (final String node : nodes) { boolean done = false; for (final String id : questsSection.getKeys(false)) { @@ -2191,7 +2195,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { final List nodes = config.getStringList("quests." + questKey + ".requirements.quests"); boolean failed = false; String failedQuest = "NULL"; - final List temp = new LinkedList<>(); + final List temp = new LinkedList<>(); for (final String node : nodes) { boolean done = false; for (final String id : questsSection.getKeys(false)) { @@ -2293,9 +2297,9 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } - private void loadQuestPlanner(final FileConfiguration config, final BukkitQuest quest, final String questKey) + private void loadQuestPlanner(final FileConfiguration config, final Quest quest, final String questKey) throws QuestFormatException { - final BukkitPlanner pln = quest.getPlanner(); + final Planner pln = quest.getPlanner(); if (config.contains("quests." + questKey + ".planner.start")) { pln.setStart(config.getString("quests." + questKey + ".planner.start")); } @@ -2321,9 +2325,9 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } - private void loadQuestOptions(final FileConfiguration config, final BukkitQuest quest, final String questKey) + private void loadQuestOptions(final FileConfiguration config, final Quest quest, final String questKey) throws QuestFormatException { - final BukkitOptions opts = quest.getOptions(); + final Options opts = quest.getOptions(); if (config.contains("quests." + questKey + ".options.allow-commands")) { opts.setAllowCommands(config.getBoolean("quests." + questKey + ".options.allow-commands")); } @@ -2357,7 +2361,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } @SuppressWarnings({ "unchecked", "unused", "deprecation" }) - private void loadQuestStages(final BukkitQuest quest, final FileConfiguration config, final String questKey) + private void loadQuestStages(final Quest quest, final FileConfiguration config, final String questKey) throws StageFormatException, ActionFormatException, ConditionFormatException { final ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey + ".stages.ordered"); @@ -2390,7 +2394,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { List cutAmounts = new LinkedList<>(); List cutDurability = new LinkedList<>(); final List mobsToKill = new LinkedList<>(); - final List mobNumToKill = new LinkedList<>(); + final List mobNumsToKill = new LinkedList<>(); final List locationsToKillWithin = new LinkedList<>(); final List radiiToKillWithin = new LinkedList<>(); final List areaNames = new LinkedList<>(); @@ -2409,8 +2413,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".script-to-run")) { if (getDependencies().getDenizenApi().containsScript(config.getString("quests." + questKey + ".stages.ordered." + stageNum + ".script-to-run"))) { - oStage.script = config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".script-to-run"); + oStage.setScript(config.getString("quests." + questKey + ".stages.ordered." + stageNum + + ".script-to-run")); } else { throw new StageFormatException("script-to-run is not a valid Denizen script", quest, stageNum); } @@ -2457,7 +2461,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { is = ItemUtil.processItemStack(s, breakAmounts.get(breakIndex), (short) 0); } if (Material.matchMaterial(s) != null) { - oStage.blocksToBreak.add(is); + oStage.addBlocksToBreak(is); } else { throw new StageFormatException("break-block-names has invalid item name " + s, quest, stageNum); } @@ -2508,7 +2512,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { is = ItemUtil.processItemStack(s, damageAmounts.get(damageIndex), (short) 0); } if (Material.matchMaterial(s) != null) { - oStage.blocksToDamage.add(is); + oStage.addBlockToDamage(is); } else { throw new StageFormatException("damage-block-names has invalid item name " + s, quest, stageNum); } @@ -2556,7 +2560,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { is = ItemUtil.processItemStack(s, placeAmounts.get(placeIndex), (short) 0); } if (Material.matchMaterial(s) != null) { - oStage.blocksToPlace.add(is); + oStage.addBlockToPlace(is); } else { throw new StageFormatException("place-block-names has invalid item name " + s, quest, stageNum); } @@ -2604,7 +2608,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { is = ItemUtil.processItemStack(s, useAmounts.get(useIndex), (short) 0); } if (Material.matchMaterial(s) != null) { - oStage.blocksToUse.add(is); + oStage.addBlockToUse(is); } else { throw new StageFormatException("use-block-names has invalid item name " + s, quest, stageNum); } @@ -2652,7 +2656,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { is = ItemUtil.processItemStack(s, cutAmounts.get(cutIndex), (short) 0); } if (Material.matchMaterial(s) != null) { - oStage.blocksToCut.add(is); + oStage.addBlockToCut(is); } else { throw new StageFormatException("cut-block-names has invalid item name " + s, quest, stageNum); } @@ -2664,7 +2668,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (ConfigUtil.checkList(itemsToCraft, ItemStack.class)) { for (final ItemStack stack : itemsToCraft) { if (stack != null) { - oStage.itemsToCraft.add(stack); + oStage.addItemToCraft(stack); } else { throw new StageFormatException("items-to-craft has invalid formatting", quest, stageNum); } @@ -2677,7 +2681,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { for (final String item : items) { final ItemStack is = ItemUtil.readItemStack("" + item); if (is != null) { - oStage.itemsToCraft.add(is); + oStage.addItemToCraft(is); } else { throw new StageFormatException("Legacy items-to-craft has invalid formatting " + item, quest, stageNum); @@ -2694,7 +2698,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (ConfigUtil.checkList(itemsToSmelt, ItemStack.class)) { for (final ItemStack stack : itemsToSmelt) { if (stack != null) { - oStage.itemsToSmelt.add(stack); + oStage.addItemToSmelt(stack); } else { throw new StageFormatException("items-to-smelt has invalid formatting", quest, stageNum); } @@ -2707,7 +2711,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { for (final String item : items) { final ItemStack is = ItemUtil.readItemStack("" + item); if (is != null) { - oStage.itemsToSmelt.add(is); + oStage.addItemToSmelt(is); } else { throw new StageFormatException("Legacy items-to-smelt has invalid formatting " + item, quest, stageNum); @@ -2725,7 +2729,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (ConfigUtil.checkList(itemsToEnchant, ItemStack.class)) { for (final ItemStack stack : itemsToEnchant) { if (stack != null) { - oStage.itemsToEnchant.add(stack); + oStage.addItemToEnchant(stack); } else { throw new StageFormatException("items-to-enchant has invalid formatting", quest, stageNum); } @@ -2784,7 +2788,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { for (int i = 0; i < enchs.size(); i++) { final ItemStack stack = new ItemStack(types.get(i), amts.get(i)); stack.addEnchantment(enchs.get(0), 1); - oStage.itemsToEnchant.add(stack); + oStage.addItemToEnchant(stack); } } } @@ -2796,7 +2800,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (ConfigUtil.checkList(itemsToBrew, ItemStack.class)) { for (final ItemStack stack : itemsToBrew) { if (stack != null) { - oStage.itemsToBrew.add(stack); + oStage.addItemsToBrew(stack); } else { throw new StageFormatException("items-to-brew has invalid formatting", quest, stageNum); } @@ -2809,7 +2813,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { for (final String item : items) { final ItemStack is = ItemUtil.readItemStack("" + item); if (is != null) { - oStage.itemsToBrew.add(is); + oStage.addItemsToBrew(is); } else { throw new StageFormatException("Legacy items-to-brew has invalid formatting", quest, stageNum); @@ -2826,7 +2830,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (ConfigUtil.checkList(itemsToConsume, ItemStack.class)) { for (final ItemStack stack : itemsToConsume) { if (stack != null) { - oStage.itemsToConsume.add(stack); + oStage.addItemToConsume(stack); } else { throw new StageFormatException("items-to-consume has invalid formatting", quest, stageNum); } @@ -2836,8 +2840,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk")) { if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".cows-to-milk", -999) != -999) { - oStage.cowsToMilk = config.getInt("quests." + questKey + ".stages.ordered." + stageNum - + ".cows-to-milk"); + oStage.setCowsToMilk(config.getInt("quests." + questKey + ".stages.ordered." + stageNum + + ".cows-to-milk")); } else { throw new StageFormatException("cows-to-milk is not a number", quest, stageNum); } @@ -2845,8 +2849,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch")) { if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".fish-to-catch", -999) != -999) { - oStage.fishToCatch = config.getInt("quests." + questKey + ".stages.ordered." + stageNum - + ".fish-to-catch"); + oStage.setFishToCatch(config.getInt("quests." + questKey + ".stages.ordered." + stageNum + + ".fish-to-catch")); } else { throw new StageFormatException("fish-to-catch is not a number", quest, stageNum); } @@ -2854,8 +2858,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill")) { if (config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".players-to-kill", -999) != -999) { - oStage.playersToKill = config.getInt("quests." + questKey + ".stages.ordered." + stageNum - + ".players-to-kill"); + oStage.setPlayersToKill(config.getInt("quests." + questKey + ".stages.ordered." + stageNum + + ".players-to-kill")); } else { throw new StageFormatException("players-to-kill is not a number", quest, stageNum); } @@ -2878,7 +2882,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { stageNum); } } - oStage.citizensToInteract = new LinkedList<>(npcIdsToTalkTo); + oStage.setCitizensToInteract(new LinkedList<>(npcIdsToTalkTo)); } else { throw new StageFormatException("npc-ids-to-talk-to is not a list of numbers", quest, stageNum); } @@ -2907,9 +2911,9 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (getDependencies().getCitizens() != null) { final NPC npc = CitizensAPI.getNPCRegistry().getById(npcId); if (npc != null) { - oStage.itemsToDeliver.add(stack); - oStage.itemDeliveryTargets.add(npcId); - oStage.deliverMessages.add(msg); + oStage.addItemToDeliver(stack); + oStage.addItemDeliveryTarget(npcId); + oStage.addDeliverMessage(msg); } else { throw new StageFormatException("npc-delivery-ids has invalid NPC " + "ID of " + npcId, quest, stageNum); @@ -2940,9 +2944,9 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (getDependencies().getCitizens() != null) { final NPC npc = CitizensAPI.getNPCRegistry().getById(npcId); if (npc != null) { - oStage.itemsToDeliver.add(is); - oStage.itemDeliveryTargets.add(npcId); - oStage.deliverMessages.add(msg); + oStage.addItemToDeliver(is); + oStage.addItemDeliveryTarget(npcId); + oStage.addDeliverMessage(msg); } else { throw new StageFormatException( "npc-delivery-ids has invalid NPC ID of " + npcId, @@ -2989,8 +2993,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { for (final int i : npcIdsToKill) { if (CitizensAPI.getNPCRegistry().getById(i) != null) { if (npcAmountsToKill.get(npcIdsToKill.indexOf(i)) > 0) { - oStage.citizensToKill.add(i); - oStage.citizenNumToKill.add(npcAmountsToKill.get(npcIdsToKill.indexOf(i))); + oStage.addCitizenToKill(i); + oStage.addCitizenNumToKill(npcAmountsToKill.get(npcIdsToKill.indexOf(i))); questNpcIds.add(i); } else { throw new StageFormatException("npc-kill-amounts is not a positive number", @@ -3031,7 +3035,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".mob-amounts")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum + ".mob-amounts"), Integer.class)) { - mobNumToKill.addAll(config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum + mobNumsToKill.addAll(config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum + ".mob-amounts")); } else { throw new StageFormatException("mob-amounts is not a list of numbers", quest, stageNum); @@ -3081,11 +3085,21 @@ public class Quests extends JavaPlugin implements QuestsAPI { throw new StageFormatException("kill-location-names is missing", quest, stageNum); } } - oStage.mobsToKill.addAll(mobsToKill); - oStage.mobNumToKill.addAll(mobNumToKill); - oStage.locationsToKillWithin.addAll(locationsToKillWithin); - oStage.radiiToKillWithin.addAll(radiiToKillWithin); - oStage.killNames.addAll(areaNames); + for (EntityType mobToKill : mobsToKill) { + oStage.addMobToKill(mobToKill); + } + for (Integer mobNumToKill : mobNumsToKill) { + oStage.addMobNumToKill(mobNumToKill); + } + for (Location locationToKillWithin : locationsToKillWithin) { + oStage.addLocationToKillWithin(locationToKillWithin); + } + for (Integer radiusToKillWithin : radiiToKillWithin) { + oStage.addRadiusToKillWithin(radiusToKillWithin); + } + for (String killName : areaNames) { + oStage.addKillName(killName); + } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".locations-to-reach")) { if (ConfigUtil.checkList(config.getList("quests." + questKey + ".stages.ordered." + stageNum + ".locations-to-reach"), String.class)) { @@ -3093,7 +3107,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { + ".locations-to-reach"); for (final String loc : locations) { if (ConfigUtil.getLocation(loc) != null) { - oStage.locationsToReach.add(ConfigUtil.getLocation(loc)); + oStage.addLocationToReach(ConfigUtil.getLocation(loc)); } else { throw new StageFormatException("locations-to-reach has invalid formatting" + loc, quest, stageNum); @@ -3107,7 +3121,9 @@ public class Quests extends JavaPlugin implements QuestsAPI { + ".reach-location-radii"), Integer.class)) { final List radii = config.getIntegerList("quests." + questKey + ".stages.ordered." + stageNum + ".reach-location-radii"); - oStage.radiiToReachWithin.addAll(radii); + for (Integer radius : radii) { + oStage.addRadiusToReachWithin(radius); + } } else { throw new StageFormatException("reach-location-radii is not a list of numbers", quest, stageNum); @@ -3120,7 +3136,9 @@ public class Quests extends JavaPlugin implements QuestsAPI { + ".reach-location-names"), String.class)) { final List locationNames = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum + ".reach-location-names"); - oStage.locationNames.addAll(locationNames); + for (String locationName : locationNames) { + oStage.addLocationName(locationName); + } } else { throw new StageFormatException("reach-location-names is not a list of names", quest, stageNum); } @@ -3143,8 +3161,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { final Class ec = EntityType.valueOf(mob.toUpperCase()) .getEntityClass(); if (ec != null && Tameable.class.isAssignableFrom(ec)) { - oStage.mobsToTame.add(EntityType.valueOf(mob.toUpperCase())); - oStage.mobNumToTame.add(mobAmounts.get(mobs.indexOf(mob))); + oStage.addMobToTame(EntityType.valueOf(mob.toUpperCase())); + oStage.addMobNumToTame(mobAmounts.get(mobs.indexOf(mob))); } else { throw new StageFormatException("mobs-to-tame has invalid tameable mob " + mob, quest, stageNum); @@ -3193,47 +3211,47 @@ public class Quests extends JavaPlugin implements QuestsAPI { // Fail silently } if (dc != null) { - oStage.sheepToShear.add(dc); + oStage.addSheepToShear(dc); // Legacy start --> } else if (color.equalsIgnoreCase(Lang.get("COLOR_BLACK"))) { - oStage.sheepToShear.add(DyeColor.BLACK); + oStage.addSheepToShear(DyeColor.BLACK); } else if (color.equalsIgnoreCase(Lang.get("COLOR_BLUE"))) { - oStage.sheepToShear.add(DyeColor.BLUE); + oStage.addSheepToShear(DyeColor.BLUE); } else if (color.equalsIgnoreCase(Lang.get("COLOR_BROWN"))) { - oStage.sheepToShear.add(DyeColor.BROWN); + oStage.addSheepToShear(DyeColor.BROWN); } else if (color.equalsIgnoreCase(Lang.get("COLOR_CYAN"))) { - oStage.sheepToShear.add(DyeColor.CYAN); + oStage.addSheepToShear(DyeColor.CYAN); } else if (color.equalsIgnoreCase(Lang.get("COLOR_GRAY"))) { - oStage.sheepToShear.add(DyeColor.GRAY); + oStage.addSheepToShear(DyeColor.GRAY); } else if (color.equalsIgnoreCase(Lang.get("COLOR_GREEN"))) { - oStage.sheepToShear.add(DyeColor.GREEN); + oStage.addSheepToShear(DyeColor.GREEN); } else if (color.equalsIgnoreCase(Lang.get("COLOR_LIGHT_BLUE"))) { - oStage.sheepToShear.add(DyeColor.LIGHT_BLUE); + oStage.addSheepToShear(DyeColor.LIGHT_BLUE); } else if (color.equalsIgnoreCase(Lang.get("COLOR_LIME"))) { - oStage.sheepToShear.add(DyeColor.LIME); + oStage.addSheepToShear(DyeColor.LIME); } else if (color.equalsIgnoreCase(Lang.get("COLOR_MAGENTA"))) { - oStage.sheepToShear.add(DyeColor.MAGENTA); + oStage.addSheepToShear(DyeColor.MAGENTA); } else if (color.equalsIgnoreCase(Lang.get("COLOR_ORANGE"))) { - oStage.sheepToShear.add(DyeColor.ORANGE); + oStage.addSheepToShear(DyeColor.ORANGE); } else if (color.equalsIgnoreCase(Lang.get("COLOR_PINK"))) { - oStage.sheepToShear.add(DyeColor.PINK); + oStage.addSheepToShear(DyeColor.PINK); } else if (color.equalsIgnoreCase(Lang.get("COLOR_PURPLE"))) { - oStage.sheepToShear.add(DyeColor.PURPLE); + oStage.addSheepToShear(DyeColor.PURPLE); } else if (color.equalsIgnoreCase(Lang.get("COLOR_RED"))) { - oStage.sheepToShear.add(DyeColor.RED); + oStage.addSheepToShear(DyeColor.RED); } else if (color.equalsIgnoreCase(Lang.get("COLOR_SILVER"))) { // 1.13 changed DyeColor.SILVER -> DyeColor.LIGHT_GRAY - oStage.sheepToShear.add(DyeColor.getByColor(Color.SILVER)); + oStage.addSheepToShear(DyeColor.getByColor(Color.SILVER)); } else if (color.equalsIgnoreCase(Lang.get("COLOR_WHITE"))) { - oStage.sheepToShear.add(DyeColor.WHITE); + oStage.addSheepToShear(DyeColor.WHITE); } else if (color.equalsIgnoreCase(Lang.get("COLOR_YELLOW"))) { - oStage.sheepToShear.add(DyeColor.YELLOW); + oStage.addSheepToShear(DyeColor.YELLOW); // <-- Legacy end } else { throw new StageFormatException("sheep-to-shear has invalid color " + color, quest, stageNum); } - oStage.sheepNumToShear.add(shearAmounts.get(sheep.indexOf(color))); + oStage.addSheepNumToShear(shearAmounts.get(sheep.indexOf(color))); } } else { throw new StageFormatException("sheep-amounts is not a list of numbers", quest, stageNum); @@ -3253,8 +3271,8 @@ public class Quests extends JavaPlugin implements QuestsAPI { + ".password-phrases"); if (displays.size() == phrases.size()) { for (int passIndex = 0; passIndex < displays.size(); passIndex++) { - oStage.passwordDisplays.add(displays.get(passIndex)); - oStage.passwordPhrases.add(phrases.get(passIndex)); + oStage.addPasswordDisplay(displays.get(passIndex)); + oStage.addPasswordPhrase(phrases.get(passIndex)); } } else { throw new StageFormatException("password-displays and password-phrases are not the same size", @@ -3268,20 +3286,22 @@ public class Quests extends JavaPlugin implements QuestsAPI { final Object o = config.get("quests." + questKey + ".stages.ordered." + stageNum + ".objective-override"); if (o instanceof List) { - oStage.objectiveOverrides.addAll(config.getStringList("quests." + questKey - + ".stages.ordered." + stageNum + ".objective-override")); + for (String objectiveOverride : config.getStringList("quests." + questKey + + ".stages.ordered." + stageNum + ".objective-override")) { + oStage.addObjectiveOverride(objectiveOverride); + } } else { // Legacy final String s = config.getString("quests." + questKey + ".stages.ordered." + stageNum + ".objective-override"); - oStage.objectiveOverrides.add(s); + oStage.addObjectiveOverride(s); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-event")) { final BukkitAction action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum + ".start-event")); if (action != null) { - oStage.startAction = action; + oStage.setStartAction(action); } else { throw new StageFormatException("start-event failed to load", quest, stageNum); } @@ -3290,7 +3310,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { final BukkitAction action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum + ".finish-event")); if (action != null) { - oStage.finishAction = action; + oStage.setFinishAction(action); } else { throw new StageFormatException("finish-event failed to load", quest, stageNum); } @@ -3299,7 +3319,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { final BukkitAction action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum + ".fail-event")); if (action != null) { - oStage.failAction = action; + oStage.setFailAction(action); } else { throw new StageFormatException("fail-event failed to load", quest, stageNum); } @@ -3308,7 +3328,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { final BukkitAction action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum + ".death-event")); if (action != null) { - oStage.deathAction = action; + oStage.setDeathAction(action); } else { throw new StageFormatException("death-event failed to load", quest, stageNum); } @@ -3317,7 +3337,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { final BukkitAction action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum + ".disconnect-event")); if (action != null) { - oStage.disconnectAction = action; + oStage.setDisconnectAction(action); } else { throw new StageFormatException("disconnect-event failed to load", quest, stageNum); } @@ -3328,15 +3348,16 @@ public class Quests extends JavaPlugin implements QuestsAPI { + ".chat-event-triggers")) { if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".chat-event-triggers")) { - final List chatEvents = config.getStringList("quests." + questKey + ".stages.ordered." - + stageNum + ".chat-events"); + final List chatEvents = config.getStringList("quests." + questKey + + ".stages.ordered." + stageNum + ".chat-events"); final List chatEventTriggers = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum + ".chat-event-triggers"); for (int i = 0; i < chatEvents.size(); i++) { final BukkitAction action = loadAction(chatEvents.get(i)); if (action != null) { if (i < chatEventTriggers.size()) { - oStage.chatActions.put(chatEventTriggers.get(i), action); + oStage.addChatAction(new AbstractMap.SimpleEntry<>(chatEventTriggers.get(i), + action)); } else { throw new StageFormatException("chat-event-triggers list is too small", quest, stageNum); @@ -3363,15 +3384,16 @@ public class Quests extends JavaPlugin implements QuestsAPI { + ".command-event-triggers")) { if (config.isList("quests." + questKey + ".stages.ordered." + stageNum + ".command-event-triggers")) { - final List commandEvents = config.getStringList("quests." + questKey + ".stages.ordered." - + stageNum + ".command-events"); + final List commandEvents = config.getStringList("quests." + questKey + + ".stages.ordered." + stageNum + ".command-events"); final List commandEventTriggers = config.getStringList("quests." + questKey + ".stages.ordered." + stageNum + ".command-event-triggers"); for (int i = 0; i < commandEvents.size(); i++) { final BukkitAction action = loadAction(commandEvents.get(i)); if (action != null) { if (i < commandEventTriggers.size()) { - oStage.commandActions.put(commandEventTriggers.get(i), action); + oStage.addCommandAction(new AbstractMap.SimpleEntry<>(commandEventTriggers + .get(i), action)); } else { throw new StageFormatException("command-event-triggers list is too small", quest, stageNum); @@ -3393,33 +3415,33 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".condition")) { - final Condition condition = loadCondition(config.getString("quests." + questKey + ".stages.ordered." + final BukkitCondition condition = loadCondition(config.getString("quests." + questKey + ".stages.ordered." + stageNum + ".condition")); if (condition != null) { - oStage.condition = condition; + oStage.setCondition(condition); } else { throw new StageFormatException("condition failed to load", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay")) { if (config.getLong("quests." + questKey + ".stages.ordered." + stageNum + ".delay", -999) != -999) { - oStage.delay = config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay") - * 1000L; + oStage.setDelay(config.getInt("quests." + questKey + ".stages.ordered." + stageNum + ".delay") + * 1000L); } else { throw new StageFormatException("delay is not a number", quest, stageNum); } } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".delay-message")) { - oStage.delayMessage = config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".delay-message"); + oStage.setDelayMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum + + ".delay-message")); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-message")) { - oStage.startMessage = config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".start-message"); + oStage.setStartMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum + + ".start-message")); } if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".complete-message")) { - oStage.completeMessage = config.getString("quests." + questKey + ".stages.ordered." + stageNum - + ".complete-message"); + oStage.setCompleteMessage(config.getString("quests." + questKey + ".stages.ordered." + stageNum + + ".complete-message")); } quest.getStages().add(oStage); } @@ -3619,7 +3641,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { dropChances[3] = (float) section.getDouble(s + ".chest-plate-drop-chance"); inventory[4] = ItemUtil.readItemStack(section.getString(s + ".helmet")); dropChances[4] = (float) section.getDouble(s + ".helmet-drop-chance"); - final QuestMob questMob = new QuestMob(type, spawnLocation, mobAmount); + final QuestMob questMob = new BukkitQuestMob(type, spawnLocation, mobAmount); questMob.setInventory(inventory); questMob.setDropChances(dropChances); questMob.setName(mobName); @@ -3758,7 +3780,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { return action; } - protected Condition loadCondition(final String name) throws ConditionFormatException { + protected BukkitCondition loadCondition(final String name) throws ConditionFormatException { if (name == null) { return null; } @@ -3772,7 +3794,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { e.printStackTrace(); } final String conditionKey = "conditions." + name + "."; - final Condition condition = new Condition(this); + final BukkitCondition condition = new BukkitCondition(this); condition.setName(name); if (data.contains(conditionKey + "fail-quest")) { if (data.isBoolean(conditionKey + "fail-quest")) { @@ -3913,7 +3935,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { return condition; } - private void loadCustomSections(final BukkitQuest quest, final FileConfiguration config, final String questKey) + private void loadCustomSections(final Quest quest, final FileConfiguration config, final String questKey) throws StageFormatException, QuestFormatException { final ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey + ".stages.ordered"); if (questStages != null) { @@ -3927,11 +3949,11 @@ public class Quests extends JavaPlugin implements QuestsAPI { + " for " + quest.getName() + " was null"); return; } - final BukkitStage oStage = quest.getStage(Integer.parseInt(stageNum) - 1); - oStage.customObjectives.clear(); - oStage.customObjectiveCounts.clear(); - oStage.customObjectiveData.clear(); - oStage.customObjectiveDisplays.clear(); + final Stage oStage = quest.getStage(Integer.parseInt(stageNum) - 1); + oStage.clearCustomObjectives(); + oStage.clearCustomObjectiveCounts(); + oStage.clearCustomObjectiveData(); + oStage.clearCustomObjectiveDisplays(); if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".custom-objectives")) { final ConfigurationSection sec = config.getConfigurationSection("quests." + questKey + ".stages.ordered." + stageNum + ".custom-objectives"); @@ -3962,7 +3984,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } } } - final BukkitRewards rews = quest.getRewards(); + final Rewards rews = quest.getRewards(); if (config.contains("quests." + questKey + ".rewards.custom-rewards")) { final ConfigurationSection sec = config.getConfigurationSection("quests." + questKey + ".rewards.custom-rewards"); @@ -3988,7 +4010,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { } rews.setCustomRewards(temp); } - final BukkitRequirements reqs = quest.getRequirements(); + final Requirements reqs = quest.getRequirements(); if (config.contains("quests." + questKey + ".requirements.custom-requirements")) { final ConfigurationSection sec = config.getConfigurationSection("quests." + questKey + ".requirements.custom-requirements"); @@ -4139,7 +4161,7 @@ public class Quests extends JavaPlugin implements QuestsAPI { final ConfigurationSection sec = config.getConfigurationSection("conditions"); if (sec != null) { for (final String s : sec.getKeys(false)) { - Condition condition = null; + BukkitCondition condition = null; try { condition = loadCondition(s); } catch (final ConditionFormatException e) { @@ -4246,11 +4268,11 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @return Exact match or null if not found * @since 3.8.6 */ - public BukkitQuest getQuestById(final String id) { + public Quest getQuestById(final String id) { if (id == null) { return null; } - for (final BukkitQuest q : quests) { + for (final Quest q : quests) { if (q.getId().equals(id)) { return q; } @@ -4264,21 +4286,21 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @param name Name of the quest * @return Closest match or null if not found */ - public BukkitQuest getQuest(final String name) { + public Quest getQuest(final String name) { if (name == null) { return null; } - for (final BukkitQuest q : quests) { + for (final Quest q : quests) { if (q.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) { return q; } } - for (final BukkitQuest q : quests) { + for (final Quest q : quests) { if (q.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { return q; } } - for (final BukkitQuest q : quests) { + for (final Quest q : quests) { if (q.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { return q; } @@ -4320,21 +4342,21 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @param name Name of the condition * @return Closest match or null if not found */ - public Condition getCondition(final String name) { + public BukkitCondition getCondition(final String name) { if (name == null) { return null; } - for (final Condition c : conditions) { + for (final BukkitCondition c : conditions) { if (c.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) { return c; } } - for (final Condition c : conditions) { + for (final BukkitCondition c : conditions) { if (c.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { return c; } } - for (final Condition c : conditions) { + for (final BukkitCondition c : conditions) { if (c.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { return c; } @@ -4349,10 +4371,10 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @param quester The player to check * @return true if at least one available quest has not yet been completed */ - public boolean hasQuest(final NPC npc, final BukkitQuester quester) { - for (final BukkitQuest q : quests) { - if (q.npcStart != null && !quester.completedQuests.contains(q)) { - if (q.npcStart.getId() == npc.getId()) { + public boolean hasQuest(final NPC npc, final Quester quester) { + for (final Quest q : quests) { + if (q.getNpcStart() != null && !quester.getCompletedQuests().contains(q)) { + if (q.getNpcStart().getId() == npc.getId()) { final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); if (!ignoreLockedQuests || q.testRequirements(quester)) { return true; @@ -4371,10 +4393,10 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @param quester The player to check * @return true if at least one available quest has been completed */ - public boolean hasCompletedQuest(final NPC npc, final BukkitQuester quester) { - for (final BukkitQuest q : quests) { - if (q.npcStart != null && quester.completedQuests.contains(q)) { - if (q.npcStart.getId() == npc.getId()) { + public boolean hasCompletedQuest(final NPC npc, final Quester quester) { + for (final Quest q : quests) { + if (q.getNpcStart() != null && quester.getCompletedQuests().contains(q)) { + if (q.getNpcStart().getId() == npc.getId()) { final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); if (!ignoreLockedQuests || q.testRequirements(quester)) { return true; @@ -4392,10 +4414,11 @@ public class Quests extends JavaPlugin implements QuestsAPI { * @param quester The player to check * @return true if at least one available, redoable quest has been completed */ - public boolean hasCompletedRedoableQuest(final NPC npc, final BukkitQuester quester) { - for (final BukkitQuest q : quests) { - if (q.npcStart != null && quester.completedQuests.contains(q) && q.getPlanner().getCooldown() > -1) { - if (q.npcStart.getId() == npc.getId()) { + public boolean hasCompletedRedoableQuest(final NPC npc, final Quester quester) { + for (final Quest q : quests) { + if (q.getNpcStart() != null && quester.getCompletedQuests().contains(q) + && q.getPlanner().getCooldown() > -1) { + if (q.getNpcStart().getId() == npc.getId()) { final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); if (!ignoreLockedQuests || q.testRequirements(quester)) { return true; diff --git a/core/src/main/java/me/blackvein/quests/actions/BukkitAction.java b/core/src/main/java/me/blackvein/quests/actions/BukkitAction.java index 950f96700..0cf96bb87 100644 --- a/core/src/main/java/me/blackvein/quests/actions/BukkitAction.java +++ b/core/src/main/java/me/blackvein/quests/actions/BukkitAction.java @@ -11,10 +11,10 @@ */ package me.blackvein.quests.actions; -import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.QuestMob; -import me.blackvein.quests.player.BukkitQuester; +import me.blackvein.quests.Quest; +import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; +import me.blackvein.quests.entity.QuestMob; import me.blackvein.quests.tasks.ActionTimer; import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.InventoryUtil; @@ -31,7 +31,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.Map; -public class BukkitAction implements Comparable { +public class BukkitAction implements Action, Comparable { private final Quests plugin; private String name = ""; @@ -88,191 +88,237 @@ public class BukkitAction implements Comparable { return name.compareTo(action.getName()); } + @Override public String getName() { return name; } - + + @Override public void setName(final String name) { this.name = name; } + @Override public String getMessage() { return message; } + @Override public void setMessage(final String message) { this.message = message; } + @Override public boolean isClearInv() { return clearInv; } + @Override public void setClearInv(final boolean clearInv) { this.clearInv = clearInv; } + @Override public boolean isFailQuest() { return failQuest; } + @Override public void setFailQuest(final boolean failQuest) { this.failQuest = failQuest; } + @Override public LinkedList getExplosions() { return explosions; } + @Override public void setExplosions(final LinkedList explosions) { this.explosions = explosions; } + @Override public Map getEffects() { return effects; } + @Override public void setEffects(final Map effects) { this.effects = effects; } + @Override public LinkedList getItems() { return items; } + @Override public void setItems(final LinkedList items) { this.items = items; } + @Override public World getStormWorld() { return stormWorld; } + @Override public void setStormWorld(final World stormWorld) { this.stormWorld = stormWorld; } + @Override public int getStormDuration() { return stormDuration; } + @Override public void setStormDuration(final int stormDuration) { this.stormDuration = stormDuration; } + @Override public World getThunderWorld() { return thunderWorld; } + @Override public void setThunderWorld(final World thunderWorld) { this.thunderWorld = thunderWorld; } + @Override public int getThunderDuration() { return thunderDuration; } + @Override public void setThunderDuration(final int thunderDuration) { this.thunderDuration = thunderDuration; } + @Override public int getTimer() { return timer; } + @Override public void setTimer(final int timer) { this.timer = timer; } + @Override public boolean isCancelTimer() { return cancelTimer; } + @Override public void setCancelTimer(final boolean cancelTimer) { this.cancelTimer = cancelTimer; } + @Override public LinkedList getMobSpawns() { return mobSpawns; } + @Override public void setMobSpawns(final LinkedList mobSpawns) { this.mobSpawns = mobSpawns; } + @Override public LinkedList getLightningStrikes() { return lightningStrikes; } + @Override public void setLightningStrikes(final LinkedList lightningStrikes) { this.lightningStrikes = lightningStrikes; } + @Override public LinkedList getCommands() { return commands; } + @Override public void setCommands(final LinkedList commands) { this.commands = commands; } + @Override public LinkedList getPotionEffects() { return potionEffects; } + @Override public void setPotionEffects(final LinkedList potionEffects) { this.potionEffects = potionEffects; } + @Override public int getHunger() { return hunger; } + @Override public void setHunger(final int hunger) { this.hunger = hunger; } + @Override public int getSaturation() { return saturation; } + @Override public void setSaturation(final int saturation) { this.saturation = saturation; } + @Override public float getHealth() { return health; } + @Override public void setHealth(final float health) { this.health = health; } + @Override public Location getTeleport() { return teleport; } + @Override public void setTeleport(final Location teleport) { this.teleport = teleport; } + @Override public String getBook() { return book; } + @Override public void setBook(final String book) { this.book = book; } - + + @Override public String getDenizenScript() { return book; } + @Override public void setDenizenScript(final String scriptName) { this.denizenScript = scriptName; } - public void fire(final BukkitQuester quester, final BukkitQuest quest) { + public void fire(final Quester quester, final Quest quest) { final Player player = quester.getPlayer(); if (message != null) { player.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(message, quest, player)); @@ -406,7 +452,7 @@ public class BukkitAction implements Comparable { .runTaskLater(plugin, timer * 20L).getTaskId(), quest); } if (cancelTimer) { - for (final Map.Entry entry : quester.getTimers().entrySet()) { + for (final Map.Entry entry : quester.getTimers().entrySet()) { if (entry.getValue().getName().equals(quest.getName())) { plugin.getServer().getScheduler().cancelTask(entry.getKey()); quester.getTimers().remove(entry.getKey()); diff --git a/core/src/main/java/me/blackvein/quests/actions/ActionFactory.java b/core/src/main/java/me/blackvein/quests/actions/BukkitActionFactory.java similarity index 87% rename from core/src/main/java/me/blackvein/quests/actions/ActionFactory.java rename to core/src/main/java/me/blackvein/quests/actions/BukkitActionFactory.java index 21b5e3d49..b57373029 100644 --- a/core/src/main/java/me/blackvein/quests/actions/ActionFactory.java +++ b/core/src/main/java/me/blackvein/quests/actions/BukkitActionFactory.java @@ -12,12 +12,13 @@ package me.blackvein.quests.actions; -import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.QuestMob; -import me.blackvein.quests.player.BukkitQuester; +import me.blackvein.quests.Quest; +import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.convo.actions.main.ActionMainPrompt; import me.blackvein.quests.convo.actions.menu.ActionMenuPrompt; +import me.blackvein.quests.entity.BukkitQuestMob; +import me.blackvein.quests.entity.QuestMob; import me.blackvein.quests.interfaces.ReloadCallback; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.ConfigUtil; @@ -53,7 +54,7 @@ import java.util.Map.Entry; import java.util.Objects; import java.util.UUID; -public class ActionFactory implements ConversationAbandonedListener { +public class BukkitActionFactory implements ActionFactory, ConversationAbandonedListener { private final Quests plugin; private final ConversationFactory conversationFactory; @@ -64,7 +65,7 @@ public class ActionFactory implements ConversationAbandonedListener { private Map selectedTeleportLocations = new HashMap<>(); private List editingActionNames = new LinkedList<>(); - public ActionFactory(final Quests plugin) { + public BukkitActionFactory(final Quests plugin) { this.plugin = plugin; // Ensure to initialize factory last so that 'this' is fully initialized before it is passed this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false) @@ -151,68 +152,68 @@ public class ActionFactory implements ConversationAbandonedListener { return new ActionMainPrompt(context); } - public void loadData(final BukkitAction event, final ConversationContext context) { - if (event.message != null) { - context.setSessionData(CK.E_MESSAGE, event.message); + public void loadData(final Action event, final ConversationContext context) { + if (event.getMessage() != null) { + context.setSessionData(CK.E_MESSAGE, event.getMessage()); } - if (event.clearInv) { + if (event.isClearInv()) { context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord")); } else { context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord")); } - if (event.failQuest) { + if (event.isFailQuest()) { context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord")); } else { context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord")); } - if (event.items != null && !event.items.isEmpty()) { - final LinkedList items = new LinkedList<>(event.items); + if (event.getItems() != null && !event.getItems().isEmpty()) { + final LinkedList items = new LinkedList<>(event.getItems()); context.setSessionData(CK.E_ITEMS, items); } - if (event.explosions != null && !event.explosions.isEmpty()) { + if (event.getExplosions() != null && !event.getExplosions().isEmpty()) { final LinkedList locs = new LinkedList<>(); - for (final Location loc : event.explosions) { + for (final Location loc : event.getExplosions()) { locs.add(ConfigUtil.getLocationInfo(loc)); } context.setSessionData(CK.E_EXPLOSIONS, locs); } - if (event.effects != null && !event.effects.isEmpty()) { + if (event.getEffects() != null && !event.getEffects().isEmpty()) { final LinkedList locs = new LinkedList<>(); final LinkedList effs = new LinkedList<>(); - for (final Entry e : event.effects.entrySet()) { + for (final Entry e : event.getEffects().entrySet()) { locs.add(ConfigUtil.getLocationInfo(e.getKey())); effs.add(e.getValue().toString()); } context.setSessionData(CK.E_EFFECTS, effs); context.setSessionData(CK.E_EFFECTS_LOCATIONS, locs); } - if (event.stormWorld != null) { - context.setSessionData(CK.E_WORLD_STORM, event.stormWorld.getName()); - context.setSessionData(CK.E_WORLD_STORM_DURATION, event.stormDuration); + if (event.getStormWorld() != null) { + context.setSessionData(CK.E_WORLD_STORM, event.getStormWorld().getName()); + context.setSessionData(CK.E_WORLD_STORM_DURATION, event.getStormDuration()); } - if (event.thunderWorld != null) { - context.setSessionData(CK.E_WORLD_THUNDER, event.thunderWorld.getName()); - context.setSessionData(CK.E_WORLD_THUNDER_DURATION, event.thunderDuration); + if (event.getThunderWorld() != null) { + context.setSessionData(CK.E_WORLD_THUNDER, event.getThunderWorld().getName()); + context.setSessionData(CK.E_WORLD_THUNDER_DURATION, event.getThunderDuration()); } - if (event.mobSpawns != null && !event.mobSpawns.isEmpty()) { + if (event.getMobSpawns() != null && !event.getMobSpawns().isEmpty()) { final LinkedList questMobs = new LinkedList<>(); - for (final QuestMob questMob : event.mobSpawns) { + for (final QuestMob questMob : event.getMobSpawns()) { questMobs.add(questMob.serialize()); } context.setSessionData(CK.E_MOB_TYPES, questMobs); } - if (event.lightningStrikes != null && !event.lightningStrikes.isEmpty()) { + if (event.getLightningStrikes() != null && !event.getLightningStrikes().isEmpty()) { final LinkedList locs = new LinkedList<>(); - for (final Location loc : event.lightningStrikes) { + for (final Location loc : event.getLightningStrikes()) { locs.add(ConfigUtil.getLocationInfo(loc)); } context.setSessionData(CK.E_LIGHTNING, locs); } - if (event.potionEffects != null && !event.potionEffects.isEmpty()) { + if (event.getPotionEffects() != null && !event.getPotionEffects().isEmpty()) { final LinkedList types = new LinkedList<>(); final LinkedList durations = new LinkedList<>(); final LinkedList mags = new LinkedList<>(); - for (final PotionEffect pe : event.potionEffects) { + for (final PotionEffect pe : event.getPotionEffects()) { types.add(pe.getType().getName()); durations.add((long) pe.getDuration()); mags.add(pe.getAmplifier()); @@ -221,25 +222,25 @@ public class ActionFactory implements ConversationAbandonedListener { context.setSessionData(CK.E_POTION_DURATIONS, durations); context.setSessionData(CK.E_POTION_STRENGTH, mags); } - if (event.hunger > -1) { - context.setSessionData(CK.E_HUNGER, event.hunger); + if (event.getHunger() > -1) { + context.setSessionData(CK.E_HUNGER, event.getHunger()); } - if (event.saturation > -1) { - context.setSessionData(CK.E_SATURATION, event.saturation); + if (event.getSaturation() > -1) { + context.setSessionData(CK.E_SATURATION, event.getSaturation()); } - if (event.health > -1) { - context.setSessionData(CK.E_HEALTH, event.health); + if (event.getHealth() > -1) { + context.setSessionData(CK.E_HEALTH, event.getHealth()); } - if (event.teleport != null) { - context.setSessionData(CK.E_TELEPORT, ConfigUtil.getLocationInfo(event.teleport)); + if (event.getTeleport() != null) { + context.setSessionData(CK.E_TELEPORT, ConfigUtil.getLocationInfo(event.getTeleport())); } - if (event.commands != null) { - context.setSessionData(CK.E_COMMANDS, event.commands); + if (event.getCommands() != null) { + context.setSessionData(CK.E_COMMANDS, event.getCommands()); } - if (event.timer > 0) { - context.setSessionData(CK.E_TIMER, event.timer); + if (event.getTimer() > 0) { + context.setSessionData(CK.E_TIMER, event.getTimer()); } - if (event.cancelTimer) { + if (event.isCancelTimer()) { context.setSessionData(CK.E_CANCEL_TIMER, true); } } @@ -312,8 +313,8 @@ public class ActionFactory implements ConversationAbandonedListener { "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; plugin.getLogger().info(identifier + " deleted action " + action); } - for (final BukkitQuester q : plugin.getOfflineQuesters()) { - for (final BukkitQuest quest : q.getCurrentQuests().keySet()) { + for (final Quester q : plugin.getOfflineQuesters()) { + for (final Quest quest : q.getCurrentQuests().keySet()) { q.checkQuest(quest); } } @@ -387,7 +388,7 @@ public class ActionFactory implements ConversationAbandonedListener { if (ss == null) { ss = section.createSection("mob-spawns." + count); } - final QuestMob questMob = QuestMob.fromString(s); + final QuestMob questMob = BukkitQuestMob.fromString(s); if (questMob.getName() != null) { ss.set("name", questMob.getName()); } @@ -469,8 +470,8 @@ public class ActionFactory implements ConversationAbandonedListener { "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; plugin.getLogger().info(identifier + " saved action " + context.getSessionData(CK.E_NAME)); } - for (final BukkitQuester q : plugin.getOfflineQuesters()) { - for (final BukkitQuest quest : q.getCurrentQuests().keySet()) { + for (final Quester q : plugin.getOfflineQuesters()) { + for (final Quest quest : q.getCurrentQuests().keySet()) { q.checkQuest(quest); } } diff --git a/core/src/main/java/me/blackvein/quests/conditions/Condition.java b/core/src/main/java/me/blackvein/quests/conditions/BukkitCondition.java similarity index 93% rename from core/src/main/java/me/blackvein/quests/conditions/Condition.java rename to core/src/main/java/me/blackvein/quests/conditions/BukkitCondition.java index 1b62e3c1c..eff0f3bd9 100644 --- a/core/src/main/java/me/blackvein/quests/conditions/Condition.java +++ b/core/src/main/java/me/blackvein/quests/conditions/BukkitCondition.java @@ -12,8 +12,8 @@ package me.blackvein.quests.conditions; -import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.player.BukkitQuester; +import me.blackvein.quests.Quest; +import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.MiscUtil; @@ -24,7 +24,7 @@ import org.bukkit.inventory.ItemStack; import java.util.LinkedList; import java.util.Objects; -public class Condition implements Comparable { +public class BukkitCondition implements Condition, Comparable { private final Quests plugin; private String name = ""; @@ -39,105 +39,128 @@ public class Condition implements Comparable { private LinkedList placeholdersCheckIdentifier = new LinkedList<>(); private LinkedList placeholdersCheckValue = new LinkedList<>(); - public Condition(final Quests plugin) { + public BukkitCondition(final Quests plugin) { this.plugin = plugin; } @Override - public int compareTo(final Condition condition) { + public int compareTo(final BukkitCondition condition) { return name.compareTo(condition.getName()); } + @Override public String getName() { return name; } - + + @Override public void setName(final String name) { this.name = name; } - + + @Override public boolean isFailQuest() { return failQuest; } + @Override public void setFailQuest(final boolean failQuest) { this.failQuest = failQuest; } - + + @Override public LinkedList getEntitiesWhileRiding() { return entitiesWhileRiding; } - + + @Override public void setEntitiesWhileRiding(final LinkedList entitiesWhileRiding) { this.entitiesWhileRiding = entitiesWhileRiding; } - + + @Override public LinkedList getNpcsWhileRiding() { return npcsWhileRiding; } - + + @Override public void setNpcsWhileRiding(final LinkedList npcsWhileRiding) { this.npcsWhileRiding = npcsWhileRiding; } - + + @Override public LinkedList getPermissions() { return permissions; } - + + @Override public void setPermissions(final LinkedList permissions) { this.permissions = permissions; } + @Override public LinkedList getItemsWhileHoldingMainHand() { return itemsWhileHoldingMainHand; } + @Override public void setItemsWhileHoldingMainHand(final LinkedList itemsWhileHoldingMainHand) { this.itemsWhileHoldingMainHand = itemsWhileHoldingMainHand; } - + + @Override public LinkedList getWorldsWhileStayingWithin() { return worldsWhileStayingWithin; } - + + @Override public void setWorldsWhileStayingWithin(final LinkedList worldsWhileStayingWithin) { this.worldsWhileStayingWithin = worldsWhileStayingWithin; } - + + @Override public LinkedList getBiomesWhileStayingWithin() { return biomesWhileStayingWithin; } - + + @Override public void setBiomesWhileStayingWithin(final LinkedList biomesWhileStayingWithin) { this.biomesWhileStayingWithin = biomesWhileStayingWithin; } - + + @Override public LinkedList getRegionsWhileStayingWithin() { return regionsWhileStayingWithin; } - + + @Override public void setRegionsWhileStayingWithin(final LinkedList biomesWhileStayingWithin) { this.regionsWhileStayingWithin = biomesWhileStayingWithin; } - + + @Override public LinkedList getPlaceholdersCheckIdentifier() { return placeholdersCheckIdentifier; } - + + @Override public void setPlaceholdersCheckIdentifier(final LinkedList placeholdersCheckIdentifier) { this.placeholdersCheckIdentifier = placeholdersCheckIdentifier; } - + + @Override public LinkedList getPlaceholdersCheckValue() { return placeholdersCheckValue; } - + + @Override public void setPlaceholdersCheckValue(final LinkedList placeholdersCheckValue) { this.placeholdersCheckValue = placeholdersCheckValue; } @SuppressWarnings("deprecation") - public boolean check(final BukkitQuester quester, final BukkitQuest quest) { + @Override + public boolean check(final Quester quester, final Quest quest) { final Player player = quester.getPlayer(); if (!entitiesWhileRiding.isEmpty()) { for (final String e : entitiesWhileRiding) { diff --git a/core/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java b/core/src/main/java/me/blackvein/quests/conditions/BukkitConditionFactory.java similarity index 95% rename from core/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java rename to core/src/main/java/me/blackvein/quests/conditions/BukkitConditionFactory.java index d6a54e12d..2113d604e 100644 --- a/core/src/main/java/me/blackvein/quests/conditions/ConditionFactory.java +++ b/core/src/main/java/me/blackvein/quests/conditions/BukkitConditionFactory.java @@ -12,8 +12,8 @@ package me.blackvein.quests.conditions; -import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.player.BukkitQuester; +import me.blackvein.quests.Quest; +import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt; import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt; @@ -43,13 +43,13 @@ import java.util.LinkedList; import java.util.List; import java.util.Objects; -public class ConditionFactory implements ConversationAbandonedListener { +public class BukkitConditionFactory implements ConditionFactory, ConversationAbandonedListener { private final Quests plugin; private final ConversationFactory conversationFactory; private List editingConditionNames = new LinkedList<>(); - public ConditionFactory(final Quests plugin) { + public BukkitConditionFactory(final Quests plugin) { this.plugin = plugin; // Ensure to initialize factory last so that 'this' is fully initialized before it is passed this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false) @@ -85,7 +85,7 @@ public class ConditionFactory implements ConversationAbandonedListener { return new ConditionMainPrompt(context); } - public void loadData(final Condition condition, final ConversationContext context) { + public void loadData(final BukkitCondition condition, final ConversationContext context) { if (condition.isFailQuest()) { context.setSessionData(CK.C_FAIL_QUEST, Lang.get("yesWord")); } else { @@ -179,8 +179,8 @@ public class ConditionFactory implements ConversationAbandonedListener { "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; plugin.getLogger().info(identifier + " deleted condition " + condition); } - for (final BukkitQuester q : plugin.getOfflineQuesters()) { - for (final BukkitQuest quest : q.getCurrentQuests().keySet()) { + for (final Quester q : plugin.getOfflineQuesters()) { + for (final Quest quest : q.getCurrentQuests().keySet()) { q.checkQuest(quest); } } @@ -201,7 +201,7 @@ public class ConditionFactory implements ConversationAbandonedListener { if (context.getSessionData(CK.C_OLD_CONDITION) != null && !((String) Objects.requireNonNull(context.getSessionData(CK.C_OLD_CONDITION))).isEmpty()) { data.set("conditions." + context.getSessionData(CK.C_OLD_CONDITION), null); - final Collection temp = plugin.getLoadedConditions(); + final Collection temp = plugin.getLoadedConditions(); temp.remove(plugin.getCondition((String) context.getSessionData(CK.C_OLD_CONDITION))); plugin.setLoadedConditions(temp); } @@ -267,8 +267,8 @@ public class ConditionFactory implements ConversationAbandonedListener { "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; plugin.getLogger().info(identifier + " saved condition " + context.getSessionData(CK.C_NAME)); } - for (final BukkitQuester q : plugin.getOfflineQuesters()) { - for (final BukkitQuest quest : q.getCurrentQuests().keySet()) { + for (final Quester q : plugin.getOfflineQuesters()) { + for (final Quest quest : q.getCurrentQuests().keySet()) { q.checkQuest(quest); } } 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 8e2955999..c5158f757 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 @@ -12,11 +12,10 @@ package me.blackvein.quests.convo.actions.main; -import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.QuestMob; +import me.blackvein.quests.Quest; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.BukkitStage; -import me.blackvein.quests.actions.BukkitAction; +import me.blackvein.quests.Stage; +import me.blackvein.quests.actions.Action; import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; @@ -25,6 +24,7 @@ import me.blackvein.quests.convo.actions.tasks.PlayerPrompt; import me.blackvein.quests.convo.actions.tasks.TimerPrompt; import me.blackvein.quests.convo.actions.tasks.WeatherPrompt; import me.blackvein.quests.convo.generic.ItemStackPrompt; +import me.blackvein.quests.entity.BukkitQuestMob; import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenNumericPromptEvent; import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenStringPromptEvent; import me.blackvein.quests.util.CK; @@ -147,7 +147,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { final StringBuilder text = new StringBuilder(); if (types != null) { for (final String s : types) { - final QuestMob qm = QuestMob.fromString(s); + final BukkitQuestMob qm = BukkitQuestMob.fromString(s); text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA) .append(qm.getType().name()) .append((qm.getName() != null) ? " (" + qm.getName() + ")" : "").append(ChatColor.GRAY) @@ -181,7 +181,8 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { @Override public @NotNull String getBasicPromptText(final @NotNull ConversationContext context) { - final ActionsEditorPostOpenNumericPromptEvent event = new ActionsEditorPostOpenNumericPromptEvent(context, this); + final ActionsEditorPostOpenNumericPromptEvent event + = new ActionsEditorPostOpenNumericPromptEvent(context, this); plugin.getServer().getPluginManager().callEvent(event); final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": " @@ -271,7 +272,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { return null; } if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - for (final BukkitAction a : plugin.getLoadedActions()) { + for (final Action a : plugin.getLoadedActions()) { if (a.getName().equalsIgnoreCase(input)) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); return new ActionNamePrompt(context); @@ -352,7 +353,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { final StringBuilder text = new StringBuilder(); if (types != null) { for (final String type : types) { - final QuestMob qm = QuestMob.fromString(type); + final BukkitQuestMob qm = BukkitQuestMob.fromString(type); text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA) .append(qm.getType().name()) .append((qm.getName() != null) ? " (" + qm.getName() + ")" : "") @@ -404,11 +405,11 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { public class ActionMobPrompt extends ActionsEditorNumericPrompt { - private QuestMob questMob; + private BukkitQuestMob questMob; private Integer itemIndex = -1; private final Integer mobIndex; - public ActionMobPrompt(final ConversationContext context, final int mobIndex, final QuestMob questMob) { + public ActionMobPrompt(final ConversationContext context, final int mobIndex, final BukkitQuestMob questMob) { super(context); this.questMob = questMob; this.mobIndex = mobIndex; @@ -549,7 +550,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { @Override public @NotNull String getBasicPromptText(final @NotNull ConversationContext context) { if (questMob == null) { - questMob = new QuestMob(); + questMob = new BukkitQuestMob(); } // Check/add newly made item if (context.getSessionData("tempStack") != null) { @@ -656,10 +657,10 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { public class ActionMobNamePrompt extends ActionsEditorStringPrompt { - private final QuestMob questMob; + private final BukkitQuestMob questMob; private final Integer mobIndex; - public ActionMobNamePrompt(final ConversationContext context, final int mobIndex, final QuestMob questMob) { + public ActionMobNamePrompt(final ConversationContext context, final int mobIndex, final BukkitQuestMob questMob) { super(context); this.questMob = questMob; this.mobIndex = mobIndex; @@ -677,7 +678,8 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { @Override public @NotNull String getPromptText(final @NotNull ConversationContext context) { - final ActionsEditorPostOpenStringPromptEvent event = new ActionsEditorPostOpenStringPromptEvent(context, this); + final ActionsEditorPostOpenStringPromptEvent event + = new ActionsEditorPostOpenStringPromptEvent(context, this); if (context.getPlugin() != null) { context.getPlugin().getServer().getPluginManager().callEvent(event); } @@ -705,10 +707,10 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { public class ActionMobTypePrompt extends ActionsEditorStringPrompt { - private final QuestMob questMob; + private final BukkitQuestMob questMob; private final Integer mobIndex; - public ActionMobTypePrompt(final ConversationContext context, final int mobIndex, final QuestMob questMob) { + public ActionMobTypePrompt(final ConversationContext context, final int mobIndex, final BukkitQuestMob questMob) { super(context); this.questMob = questMob; this.mobIndex = mobIndex; @@ -768,10 +770,10 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { public class ActionMobAmountPrompt extends ActionsEditorStringPrompt { - private final QuestMob questMob; + private final BukkitQuestMob questMob; private final Integer mobIndex; - public ActionMobAmountPrompt(final ConversationContext context, final int mobIndex, final QuestMob questMob) { + public ActionMobAmountPrompt(final ConversationContext context, final int mobIndex, final BukkitQuestMob questMob) { super(context); this.questMob = questMob; this.mobIndex = mobIndex; @@ -825,10 +827,10 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { public class ActionMobLocationPrompt extends ActionsEditorStringPrompt { - private final QuestMob questMob; + private final BukkitQuestMob questMob; private final Integer mobIndex; - public ActionMobLocationPrompt(final ConversationContext context, final int mobIndex, final QuestMob questMob) { + public ActionMobLocationPrompt(final ConversationContext context, final int mobIndex, final BukkitQuestMob questMob) { super(context); this.questMob = questMob; this.mobIndex = mobIndex; @@ -887,11 +889,11 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { public class ActionMobDropPrompt extends ActionsEditorStringPrompt { - private final QuestMob questMob; + private final BukkitQuestMob questMob; private final Integer mobIndex; private final Integer invIndex; - public ActionMobDropPrompt(final ConversationContext context, final int invIndex, final int mobIndex, final QuestMob questMob) { + public ActionMobDropPrompt(final ConversationContext context, final int invIndex, final int mobIndex, final BukkitQuestMob questMob) { super(context); this.questMob = questMob; this.mobIndex = mobIndex; @@ -1013,8 +1015,8 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt { super(context); if (modifiedName != null) { modName = modifiedName; - for (final BukkitQuest q : plugin.getLoadedQuests()) { - for (final BukkitStage s : q.getStages()) { + for (final Quest q : plugin.getLoadedQuests()) { + for (final Stage 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 e753e6529..d0fc0fdfd 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 @@ -12,10 +12,10 @@ package me.blackvein.quests.convo.actions.menu; -import me.blackvein.quests.quests.BukkitQuest; +import me.blackvein.quests.Quest; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.BukkitStage; -import me.blackvein.quests.actions.BukkitAction; +import me.blackvein.quests.Stage; +import me.blackvein.quests.actions.Action; import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; @@ -186,7 +186,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt { } input = input.trim(); if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - for (final BukkitAction a : plugin.getLoadedActions()) { + for (final Action a : plugin.getLoadedActions()) { if (a.getName().equalsIgnoreCase(input)) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); return new ActionSelectCreatePrompt(context); @@ -236,7 +236,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt { final ActionsEditorPostOpenStringPromptEvent event = new ActionsEditorPostOpenStringPromptEvent(context, this); plugin.getServer().getPluginManager().callEvent(event); - final List names = plugin.getLoadedActions().stream().map(BukkitAction::getName).collect(Collectors.toList()); + final List names = plugin.getLoadedActions().stream().map(Action::getName).collect(Collectors.toList()); return sendClickableMenu(getTitle(context), names, getQueryText(context), context); } @@ -246,7 +246,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt { return null; } if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - final BukkitAction a = plugin.getAction(input); + final Action a = plugin.getAction(input); if (a != null) { context.setSessionData(CK.E_OLD_EVENT, a.getName()); context.setSessionData(CK.E_NAME, a.getName()); @@ -282,7 +282,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt { final ActionsEditorPostOpenStringPromptEvent event = new ActionsEditorPostOpenStringPromptEvent(context, this); plugin.getServer().getPluginManager().callEvent(event); - final List names = plugin.getLoadedActions().stream().map(BukkitAction::getName).collect(Collectors.toList()); + final List names = plugin.getLoadedActions().stream().map(Action::getName).collect(Collectors.toList()); return sendClickableMenu(getTitle(context), names, getQueryText(context), context); } @@ -293,10 +293,10 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt { } if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { final LinkedList used = new LinkedList(); - final BukkitAction a = plugin.getAction(input); + final Action a = plugin.getAction(input); if (a != null) { - for (final BukkitQuest quest : plugin.getLoadedQuests()) { - for (final BukkitStage stage : quest.getStages()) { + for (final Quest quest : plugin.getLoadedQuests()) { + for (final Stage 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 b38027060..826fa9abf 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 @@ -12,10 +12,10 @@ package me.blackvein.quests.convo.conditions.main; -import me.blackvein.quests.quests.BukkitQuest; +import me.blackvein.quests.Quest; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.BukkitStage; -import me.blackvein.quests.conditions.Condition; +import me.blackvein.quests.Stage; +import me.blackvein.quests.conditions.BukkitCondition; import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt; @@ -204,14 +204,14 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt { return null; } if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - for (final Condition c : plugin.getLoadedConditions()) { + for (final BukkitCondition c : plugin.getLoadedConditions()) { if (c.getName().equalsIgnoreCase(input)) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists")); return new ConditionNamePrompt(context); } } - final List actionNames = plugin.getConditionFactory().getNamesOfConditionsBeingEdited(); - if (actionNames.contains(input)) { + final List conditionNames = plugin.getConditionFactory().getNamesOfConditionsBeingEdited(); + if (conditionNames.contains(input)) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited")); return new ConditionNamePrompt(context); } @@ -219,10 +219,10 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName")); return new ConditionNamePrompt(context); } - actionNames.remove((String) context.getSessionData(CK.C_NAME)); + conditionNames.remove((String) context.getSessionData(CK.C_NAME)); context.setSessionData(CK.C_NAME, input); - actionNames.add(input); - plugin.getConditionFactory().setNamesOfConditionsBeingEdited(actionNames); + conditionNames.add(input); + plugin.getConditionFactory().setNamesOfConditionsBeingEdited(conditionNames); } return new ConditionMainPrompt(context); } @@ -482,8 +482,8 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt { super(context); if (modifiedName != null) { modName = modifiedName; - for (final BukkitQuest q : plugin.getLoadedQuests()) { - for (final BukkitStage s : q.getStages()) { + for (final Quest q : plugin.getLoadedQuests()) { + for (final Stage 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 6aa813bfb..0a260630b 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.quests.BukkitQuest; import me.blackvein.quests.Quests; import me.blackvein.quests.quests.BukkitStage; -import me.blackvein.quests.conditions.Condition; +import me.blackvein.quests.conditions.BukkitCondition; import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt; @@ -185,7 +185,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt { } input = input.trim(); if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - for (final Condition c : plugin.getLoadedConditions()) { + for (final BukkitCondition c : plugin.getLoadedConditions()) { if (c.getName().equalsIgnoreCase(input)) { context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists")); return new ConditionSelectCreatePrompt(context); @@ -235,7 +235,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt { final ConditionsEditorPostOpenStringPromptEvent event = new ConditionsEditorPostOpenStringPromptEvent(context, this); plugin.getServer().getPluginManager().callEvent(event); - final List names = plugin.getLoadedConditions().stream().map(Condition::getName).collect(Collectors.toList()); + final List names = plugin.getLoadedConditions().stream().map(BukkitCondition::getName).collect(Collectors.toList()); return sendClickableMenu(getTitle(context), names, getQueryText(context), context); } @@ -245,7 +245,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt { return null; } if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - final Condition c = plugin.getCondition(input); + final BukkitCondition c = plugin.getCondition(input); if (c != null) { context.setSessionData(CK.C_OLD_CONDITION, c.getName()); context.setSessionData(CK.C_NAME, c.getName()); @@ -281,7 +281,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt { final ConditionsEditorPostOpenStringPromptEvent event = new ConditionsEditorPostOpenStringPromptEvent(context, this); plugin.getServer().getPluginManager().callEvent(event); - final List names = plugin.getLoadedConditions().stream().map(Condition::getName).collect(Collectors.toList()); + final List names = plugin.getLoadedConditions().stream().map(BukkitCondition::getName).collect(Collectors.toList()); return sendClickableMenu(getTitle(context), names, getQueryText(context), context); } @@ -292,7 +292,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt { } if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { final LinkedList used = new LinkedList<>(); - final Condition c = plugin.getCondition(input); + final BukkitCondition c = plugin.getCondition(input); if (c != null) { for (final BukkitQuest quest : plugin.getLoadedQuests()) { for (final BukkitStage stage : quest.getStages()) { diff --git a/core/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorNumericPrompt.java b/core/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorNumericPrompt.java index 2397fa389..0c7f7cb54 100644 --- a/core/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorNumericPrompt.java +++ b/core/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorNumericPrompt.java @@ -15,13 +15,13 @@ package me.blackvein.quests.convo.quests; import org.bukkit.ChatColor; import org.bukkit.conversations.ConversationContext; -import me.blackvein.quests.QuestFactory; +import me.blackvein.quests.quests.BukkitQuestFactory; import me.blackvein.quests.Quests; import me.blackvein.quests.convo.QuestsNumericPrompt; public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt { private final ConversationContext context; - private QuestFactory factory; + private BukkitQuestFactory factory; public QuestsEditorNumericPrompt(final ConversationContext context) { this.context = context; @@ -31,7 +31,7 @@ public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt { } @Deprecated - public QuestsEditorNumericPrompt(final ConversationContext context, final QuestFactory factory) { + public QuestsEditorNumericPrompt(final ConversationContext context, final BukkitQuestFactory factory) { this.context = context; this.factory = factory; } @@ -45,7 +45,7 @@ public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt { return context; } - public QuestFactory getQuestFactory() { + public BukkitQuestFactory getQuestFactory() { return factory; } diff --git a/core/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorStringPrompt.java b/core/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorStringPrompt.java index 4205b4191..835ba826e 100644 --- a/core/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorStringPrompt.java +++ b/core/src/main/java/me/blackvein/quests/convo/quests/QuestsEditorStringPrompt.java @@ -14,13 +14,13 @@ package me.blackvein.quests.convo.quests; import org.bukkit.conversations.ConversationContext; -import me.blackvein.quests.QuestFactory; +import me.blackvein.quests.quests.BukkitQuestFactory; import me.blackvein.quests.Quests; import me.blackvein.quests.convo.QuestsStringPrompt; public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt { private final ConversationContext context; - private QuestFactory factory; + private BukkitQuestFactory factory; public QuestsEditorStringPrompt(final ConversationContext context) { this.context = context; @@ -30,7 +30,7 @@ public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt { } @Deprecated - public QuestsEditorStringPrompt(final ConversationContext context, final QuestFactory factory) { + public QuestsEditorStringPrompt(final ConversationContext context, final BukkitQuestFactory factory) { this.context = context; this.factory = factory; } @@ -44,7 +44,7 @@ public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt { return context; } - public QuestFactory getQuestFactory() { + public BukkitQuestFactory getQuestFactory() { return factory; } diff --git a/core/src/main/java/me/blackvein/quests/convo/quests/stages/StageMainPrompt.java b/core/src/main/java/me/blackvein/quests/convo/quests/stages/StageMainPrompt.java index cad5d2c0c..a64de3b97 100644 --- a/core/src/main/java/me/blackvein/quests/convo/quests/stages/StageMainPrompt.java +++ b/core/src/main/java/me/blackvein/quests/convo/quests/stages/StageMainPrompt.java @@ -15,7 +15,7 @@ package me.blackvein.quests.convo.quests.stages; import me.blackvein.quests.CustomObjective; import me.blackvein.quests.Quests; import me.blackvein.quests.actions.BukkitAction; -import me.blackvein.quests.conditions.Condition; +import me.blackvein.quests.conditions.BukkitCondition; import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.generic.OverridePrompt; import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt; @@ -2058,7 +2058,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { if (plugin.getLoadedConditions().isEmpty()) { text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n"); } else { - for (final Condition c : plugin.getLoadedConditions()) { + for (final BukkitCondition c : plugin.getLoadedConditions()) { text.append(ChatColor.GREEN).append("- ").append(c.getName()).append("\n"); } } @@ -2070,8 +2070,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt { final Player player = (Player) context.getForWhom(); if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) { - Condition found = null; - for (final Condition c : plugin.getLoadedConditions()) { + BukkitCondition found = null; + for (final BukkitCondition c : plugin.getLoadedConditions()) { if (c.getName().equalsIgnoreCase(input)) { found = c; break; diff --git a/core/src/main/java/me/blackvein/quests/QuestMob.java b/core/src/main/java/me/blackvein/quests/entity/BukkitQuestMob.java similarity index 96% rename from core/src/main/java/me/blackvein/quests/QuestMob.java rename to core/src/main/java/me/blackvein/quests/entity/BukkitQuestMob.java index c7c93a507..e9287ba81 100644 --- a/core/src/main/java/me/blackvein/quests/QuestMob.java +++ b/core/src/main/java/me/blackvein/quests/entity/BukkitQuestMob.java @@ -10,7 +10,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package me.blackvein.quests; +package me.blackvein.quests.entity; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -24,7 +24,7 @@ import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.MiscUtil; -public class QuestMob { +public class BukkitQuestMob implements QuestMob { private String name = null; private EntityType entityType = null; @@ -33,10 +33,10 @@ public class QuestMob { private ItemStack[] inventory = new ItemStack[5]; private Float[] dropChances = new Float[5]; - public QuestMob(){ + public BukkitQuestMob(){ } - public QuestMob(final EntityType entityType, final Location spawnLocation, final int spawnAmounts) { + public BukkitQuestMob(final EntityType entityType, final Location spawnLocation, final int spawnAmounts) { this.entityType = entityType; this.spawnLocation = spawnLocation; this.spawnAmounts = spawnAmounts; @@ -189,7 +189,7 @@ public class QuestMob { return string; } - public static QuestMob fromString(final String str) { + public static BukkitQuestMob fromString(final String str) { String name = null; EntityType entityType = null; Location loc = null; @@ -258,7 +258,7 @@ public class QuestMob { } } } - final QuestMob qm = new QuestMob(entityType, loc, amounts != null ? amounts : 1); + final BukkitQuestMob qm = new BukkitQuestMob(entityType, loc, amounts != null ? amounts : 1); qm.setName(name); qm.inventory = inventory; qm.dropChances = dropChances; diff --git a/core/src/main/java/me/blackvein/quests/exceptions/StageFormatException.java b/core/src/main/java/me/blackvein/quests/exceptions/StageFormatException.java index 77422e107..514c6d9a6 100644 --- a/core/src/main/java/me/blackvein/quests/exceptions/StageFormatException.java +++ b/core/src/main/java/me/blackvein/quests/exceptions/StageFormatException.java @@ -12,17 +12,17 @@ package me.blackvein.quests.exceptions; -import me.blackvein.quests.quests.BukkitQuest; +import me.blackvein.quests.Quest; public class StageFormatException extends Exception { private static final long serialVersionUID = -8217391053042612896L; private final String message; - private final BukkitQuest quest; + private final Quest quest; private final int stage; - public StageFormatException(final String message, final BukkitQuest quest, final int stage) { + public StageFormatException(final String message, final Quest quest, final int stage) { super(message + ", see quest " + quest.getName() + " stage " + stage); this.message = message + ", see quest " + quest.getName() + " stage " + stage; this.quest = quest; @@ -44,7 +44,7 @@ public class StageFormatException extends Exception { * * @return The quest that an invalid stage id was set within. */ - public BukkitQuest getQuest() { + public Quest getQuest() { return quest; } diff --git a/core/src/main/java/me/blackvein/quests/player/BukkitQuester.java b/core/src/main/java/me/blackvein/quests/player/BukkitQuester.java index de9d68364..d4bd99715 100644 --- a/core/src/main/java/me/blackvein/quests/player/BukkitQuester.java +++ b/core/src/main/java/me/blackvein/quests/player/BukkitQuester.java @@ -19,6 +19,8 @@ import com.gmail.nossr50.util.player.UserManager; import me.blackvein.quests.CustomObjective; import me.blackvein.quests.CustomRequirement; import me.blackvein.quests.Dependencies; +import me.blackvein.quests.Objective; +import me.blackvein.quests.Planner; import me.blackvein.quests.Quest; import me.blackvein.quests.QuestData; import me.blackvein.quests.Quester; @@ -35,10 +37,7 @@ import me.blackvein.quests.events.quester.QuesterPreStartQuestEvent; import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent; import me.blackvein.quests.item.QuestJournal; import me.blackvein.quests.quests.BukkitObjective; -import me.blackvein.quests.quests.BukkitPlanner; import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.quests.BukkitRequirements; -import me.blackvein.quests.quests.BukkitStage; import me.blackvein.quests.storage.Storage; import me.blackvein.quests.tasks.StageTimer; import me.blackvein.quests.util.ConfigUtil; @@ -91,7 +90,7 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Collectors; -public class BukkitQuester implements Quester, Comparable { +public class BukkitQuester implements Quester { private final Quests plugin; private UUID id; @@ -100,7 +99,7 @@ public class BukkitQuester implements Quester, Comparable { protected int questPoints = 0; private String compassTargetQuestId; private long lastNotifiedCondition = 0L; - protected ConcurrentHashMap timers = new ConcurrentHashMap<>(); + protected ConcurrentHashMap timers = new ConcurrentHashMap<>(); protected ConcurrentHashMap currentQuests = new ConcurrentHashMap() { private static final long serialVersionUID = 6361484975823846780L; @@ -169,13 +168,13 @@ public class BukkitQuester implements Quester, Comparable { return b; } }; - protected ConcurrentHashMap completedTimes = new ConcurrentHashMap<>(); - protected ConcurrentHashMap amountsCompleted = new ConcurrentHashMap() { + protected ConcurrentHashMap completedTimes = new ConcurrentHashMap<>(); + protected ConcurrentHashMap amountsCompleted = new ConcurrentHashMap() { private static final long serialVersionUID = 5475202358792520975L; @Override - public Integer put(final @NotNull BukkitQuest key, final @NotNull Integer val) { + public Integer put(final @NotNull Quest key, final @NotNull Integer val) { final Integer data = super.put(key, val); updateJournal(); return data; @@ -195,17 +194,17 @@ public class BukkitQuester implements Quester, Comparable { } @Override - public void putAll(final Map m) { + public void putAll(final Map m) { super.putAll(m); updateJournal(); } }; - protected ConcurrentHashMap questData = new ConcurrentHashMap() { + protected ConcurrentHashMap questData = new ConcurrentHashMap() { private static final long serialVersionUID = -4607112433003926066L; @Override - public QuestData put(final @NotNull BukkitQuest key, final @NotNull QuestData val) { + public QuestData put(final @NotNull Quest key, final @NotNull QuestData val) { final QuestData data = super.put(key, val); updateJournal(); return data; @@ -225,7 +224,7 @@ public class BukkitQuester implements Quester, Comparable { } @Override - public void putAll(final Map m) { + public void putAll(final Map m) { super.putAll(m); updateJournal(); } @@ -248,40 +247,48 @@ public class BukkitQuester implements Quester, Comparable { this.lastKnownName = getOfflinePlayer().getName(); } } - + @Override - public int compareTo(final BukkitQuester quester) { + public int compareTo(final Quester quester) { return id.compareTo(quester.getUUID()); } + @Override public UUID getUUID() { return id; } + @Override public void setUUID(final UUID id) { this.id = id; } + @Override public String getQuestIdToTake() { return questIdToTake; } + @Override public void setQuestIdToTake(final String questIdToTake) { this.questIdToTake = questIdToTake; } - + + @Override public String getLastKnownName() { return lastKnownName; } + @Override public void setLastKnownName(final String lastKnownName) { this.lastKnownName = lastKnownName; } - + + @Override public int getQuestPoints() { return questPoints; } + @Override public void setQuestPoints(final int questPoints) { this.questPoints = questPoints; } @@ -291,6 +298,7 @@ public class BukkitQuester implements Quester, Comparable { * * @return Quest or null */ + @Override public BukkitQuest getCompassTarget() { return compassTargetQuestId != null ? plugin.getQuestById(compassTargetQuestId) : null; } @@ -300,77 +308,95 @@ public class BukkitQuester implements Quester, Comparable { * * @param quest The target quest */ - public void setCompassTarget(final BukkitQuest quest) { + @Override + public void setCompassTarget(final Quest quest) { compassTargetQuestId = quest.getId(); } - public ConcurrentHashMap getTimers() { + @Override + public ConcurrentHashMap getTimers() { return timers; } - public void setTimers(final ConcurrentHashMap timers) { + @Override + public void setTimers(final ConcurrentHashMap timers) { this.timers = timers; } - + + @Override public void removeTimer(final Integer timerId) { this.timers.remove(timerId); } - public ConcurrentHashMap getCurrentQuests() { + @Override + public ConcurrentHashMap getCurrentQuests() { return currentQuests; } - public void setCurrentQuests(final ConcurrentHashMap currentQuests) { + @Override + public void setCurrentQuests(final ConcurrentHashMap currentQuests) { this.currentQuests = currentQuests; } - public ConcurrentSkipListSet getCompletedQuests() { + @Override + public ConcurrentSkipListSet getCompletedQuests() { return completedQuests; } - public void setCompletedQuests(final ConcurrentSkipListSet completedQuests) { + @Override + public void setCompletedQuests(final ConcurrentSkipListSet completedQuests) { this.completedQuests = completedQuests; } - public ConcurrentHashMap getCompletedTimes() { + @Override + public ConcurrentHashMap getCompletedTimes() { return completedTimes; } - public void setCompletedTimes(final ConcurrentHashMap completedTimes) { + @Override + public void setCompletedTimes(final ConcurrentHashMap completedTimes) { this.completedTimes = completedTimes; } - public ConcurrentHashMap getAmountsCompleted() { + @Override + public ConcurrentHashMap getAmountsCompleted() { return amountsCompleted; } - public void setAmountsCompleted(final ConcurrentHashMap amountsCompleted) { + @Override + public void setAmountsCompleted(final ConcurrentHashMap amountsCompleted) { this.amountsCompleted = amountsCompleted; } - public ConcurrentHashMap getQuestData() { + @Override + public ConcurrentHashMap getQuestData() { return questData; } - public void setQuestData(final ConcurrentHashMap questData) { + @Override + public void setQuestData(final ConcurrentHashMap questData) { this.questData = questData; } + @Override public Player getPlayer() { return plugin.getServer().getPlayer(id); } + @Override public OfflinePlayer getOfflinePlayer() { return plugin.getServer().getOfflinePlayer(id); } - + + @Override public void sendMessage(final String message) { if (getPlayer() == null || !getPlayer().isOnline() || message.trim().isEmpty()) { return; } getPlayer().sendMessage(message); } - + + @Override public Stage getCurrentStage(final Quest quest) { if (currentQuests.containsKey(quest)) { return quest.getStage(currentQuests.get(quest)); @@ -378,8 +404,9 @@ public class BukkitQuester implements Quester, Comparable { return null; } - public QuestData getQuestData(final BukkitQuest quest) { - for (final BukkitQuest q : questData.keySet()) { + @Override + public QuestData getQuestData(final Quest quest) { + for (final Quest q : questData.keySet()) { if (q.getId().equals(quest.getId())) { return questData.get(q); } @@ -389,11 +416,13 @@ public class BukkitQuester implements Quester, Comparable { } return new QuestData(this); } - + + @Override public boolean hasJournal() { return getJournal() != null; } - + + @Override public ItemStack getJournal() { if (getPlayer() == null || !getPlayer().isOnline()) { return null; @@ -405,7 +434,8 @@ public class BukkitQuester implements Quester, Comparable { } return null; } - + + @Override public int getJournalIndex() { if (getPlayer() == null || !getPlayer().isOnline()) { return -1; @@ -421,6 +451,7 @@ public class BukkitQuester implements Quester, Comparable { return -1; } + @Override public void updateJournal() { if (getPlayer() == null) { return; @@ -443,7 +474,7 @@ public class BukkitQuester implements Quester, Comparable { * @param ignoreRequirements Whether to ignore Requirements */ @SuppressWarnings("deprecation") - public void takeQuest(final BukkitQuest quest, final boolean ignoreRequirements) { + public void takeQuest(final Quest quest, final boolean ignoreRequirements) { if (quest == null) { return; } @@ -454,7 +485,7 @@ public class BukkitQuester implements Quester, Comparable { } final OfflinePlayer offlinePlayer = getOfflinePlayer(); if (offlinePlayer.isOnline()) { - final BukkitPlanner pln = quest.getPlanner(); + final Planner pln = quest.getPlanner(); final long currentTime = System.currentTimeMillis(); final long start = pln.getStartInMillis(); // Start time in milliseconds since UTC epoch final long end = pln.getEndInMillis(); // End time in milliseconds since UTC epoch @@ -688,7 +719,7 @@ public class BukkitQuester implements Quester, Comparable { * @param message Message to inform player, can be left null or empty * @since 3.8.6 */ - public void quitQuest(final BukkitQuest quest, final String message) { + public void quitQuest(final Quest quest, final String message) { quitQuest(quest, new String[] {message}); } @@ -699,7 +730,7 @@ public class BukkitQuester implements Quester, Comparable { * @param messages Messages to inform player, can be left null or empty * @since 3.8.6 */ - public void quitQuest(final BukkitQuest quest, final String[] messages) { + public void quitQuest(final Quest quest, final String[] messages) { if (quest == null) { return; } @@ -716,11 +747,11 @@ public class BukkitQuester implements Quester, Comparable { updateJournal(); } - public LinkedList getCurrentRequirements(final BukkitQuest quest, final boolean ignoreOverrides) { + public LinkedList getCurrentRequirements(final Quest quest, final boolean ignoreOverrides) { if (quest == null) { return new LinkedList<>(); } - final BukkitRequirements requirements = quest.getRequirements(); + final Requirements requirements = quest.getRequirements(); if (!ignoreOverrides) { if (requirements.getDetailsOverride() != null && !requirements.getDetailsOverride().isEmpty()) { final LinkedList current = new LinkedList<>(); @@ -757,7 +788,7 @@ public class BukkitQuester implements Quester, Comparable { finishedRequirements.add(ChatColor.GRAY + "" + requirements.getQuestPoints() + " " + Lang.get("questPoints")); } } - for (final BukkitQuest q : requirements.getNeededQuests()) { + for (final Quest q : requirements.getNeededQuests()) { if (q != null) { if (getCompletedQuests().contains(q)) { finishedRequirements.add(ChatColor.GREEN + q.getName()); @@ -766,7 +797,7 @@ public class BukkitQuester implements Quester, Comparable { } } } - for (final BukkitQuest q : requirements.getBlockQuests()) { + for (final Quest q : requirements.getBlockQuests()) { if (q != null) { if (completedQuests.contains(q) || currentQuests.containsKey(q)) { current.add(ChatColor.RED + quest.getName()); @@ -855,7 +886,7 @@ public class BukkitQuester implements Quester, Comparable { * @return List of detailed objectives */ @SuppressWarnings("deprecation") - public LinkedList getCurrentObjectives(final BukkitQuest quest, final boolean ignoreOverrides) { + public LinkedList getCurrentObjectives(final Quest quest, final boolean ignoreOverrides) { if (quest == null) { plugin.getLogger().severe("Quest was null when getting objectives for " + getLastKnownName()); return new LinkedList<>(); @@ -881,7 +912,7 @@ public class BukkitQuester implements Quester, Comparable { return objectives; } final QuestData data = getQuestData(quest); - final BukkitStage stage = getCurrentStage(quest); + final Stage stage = getCurrentStage(quest); final LinkedList objectives = new LinkedList<>(); for (final ItemStack e : stage.getBlocksToBreak()) { for (final ItemStack e2 : data.blocksBroken) { @@ -1322,13 +1353,13 @@ public class BukkitQuester implements Quester, Comparable { /** * Get current objectives for a quest, both finished and unfinished * - * @deprecated Use {@link #getCurrentObjectives(BukkitQuest, boolean)} + * @deprecated Use {@link #getCurrentObjectives(Quest, boolean)} * @param quest The quest to get objectives of * @param ignoreOverrides Whether to ignore objective-overrides * @return List of detailed objectives */ @Deprecated - public LinkedList getObjectives(final BukkitQuest quest, final boolean ignoreOverrides) { + public LinkedList getObjectives(final Quest quest, final boolean ignoreOverrides) { return getCurrentObjectives(quest, ignoreOverrides); } @@ -1340,13 +1371,13 @@ public class BukkitQuester implements Quester, Comparable { * milkCow, catchFish, killMob, deliverItem, killPlayer, talkToNPC, * killNPC, tameMob, shearSheep, password, reachLocation * - * @deprecated Use {@link BukkitStage#containsObjective(ObjectiveType)} + * @deprecated Use {@link Stage#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 */ @Deprecated - public boolean containsObjective(final BukkitQuest quest, final String name) { + public boolean containsObjective(final Quest quest, final String name) { if (quest == null || getCurrentStage(quest) == null) { return false; } @@ -1360,7 +1391,7 @@ public class BukkitQuester implements Quester, Comparable { * @param name The exact name of custom objective to check for * @return true if stage contains specified objective */ - public boolean hasCustomObjective(final BukkitQuest quest, final String name) { + public boolean hasCustomObjective(final Quest quest, final String name) { if (quest == null || getCurrentStage(quest) == null) { return false; } @@ -1379,7 +1410,7 @@ public class BukkitQuester implements Quester, Comparable { * @param itemStack The block being broken */ @SuppressWarnings("deprecation") - public void breakBlock(final BukkitQuest quest, final ItemStack itemStack) { + public void breakBlock(final Quest quest, final ItemStack itemStack) { itemStack.setAmount(0); ItemStack broken = itemStack; ItemStack toBreak = itemStack; @@ -1462,7 +1493,7 @@ public class BukkitQuester implements Quester, Comparable { // Multiplayer final ItemStack finalBroken = broken; final ItemStack finalToBreak = toBreak; - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).blocksBroken.set(getQuestData(quest).blocksBroken .indexOf(finalBroken), newBroken); q.finishObjective(quest, new BukkitObjective(type, itemStack, finalToBreak), null, null, null, null, null, @@ -1485,7 +1516,7 @@ public class BukkitQuester implements Quester, Comparable { * @param itemStack The block being damaged */ @SuppressWarnings("deprecation") - public void damageBlock(final BukkitQuest quest, final ItemStack itemStack) { + public void damageBlock(final Quest quest, final ItemStack itemStack) { itemStack.setAmount(0); ItemStack damaged = itemStack; ItemStack toDamage = itemStack; @@ -1549,7 +1580,7 @@ public class BukkitQuester implements Quester, Comparable { // Multiplayer final ItemStack finalDamaged = damaged; final ItemStack finalToDamage = toDamage; - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).blocksDamaged.set(getQuestData(quest).blocksDamaged .indexOf(finalDamaged), newDamaged); q.finishObjective(quest, new BukkitObjective(type, itemStack, finalToDamage), null, null, null, null, null, @@ -1572,7 +1603,7 @@ public class BukkitQuester implements Quester, Comparable { * @param itemStack The block being placed */ @SuppressWarnings("deprecation") - public void placeBlock(final BukkitQuest quest, final ItemStack itemStack) { + public void placeBlock(final Quest quest, final ItemStack itemStack) { itemStack.setAmount(0); ItemStack placed = itemStack; ItemStack toPlace = itemStack; @@ -1635,7 +1666,7 @@ public class BukkitQuester implements Quester, Comparable { // Multiplayer final ItemStack finalPlaced = placed; final ItemStack finalToPlace = toPlace; - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).blocksPlaced.set(getQuestData(quest).blocksPlaced .indexOf(finalPlaced), newPlaced); q.finishObjective(quest, new BukkitObjective(type, itemStack, finalToPlace), null, null, null, null, null, @@ -1658,7 +1689,7 @@ public class BukkitQuester implements Quester, Comparable { * @param itemStack The block being used */ @SuppressWarnings("deprecation") - public void useBlock(final BukkitQuest quest, final ItemStack itemStack) { + public void useBlock(final Quest quest, final ItemStack itemStack) { itemStack.setAmount(0); ItemStack used = itemStack; ItemStack toUse = itemStack; @@ -1721,7 +1752,7 @@ public class BukkitQuester implements Quester, Comparable { // Multiplayer final ItemStack finalUsed = used; final ItemStack finalToUse = toUse; - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).blocksUsed.set(getQuestData(quest).blocksUsed .indexOf(finalUsed), newUsed); q.finishObjective(quest, new BukkitObjective(type, itemStack, finalToUse), null, null, null, null, null, null, @@ -1744,7 +1775,7 @@ public class BukkitQuester implements Quester, Comparable { * @param itemStack The block being cut */ @SuppressWarnings("deprecation") - public void cutBlock(final BukkitQuest quest, final ItemStack itemStack) { + public void cutBlock(final Quest quest, final ItemStack itemStack) { itemStack.setAmount(0); ItemStack cut = itemStack; ItemStack toCut = itemStack; @@ -1807,7 +1838,7 @@ public class BukkitQuester implements Quester, Comparable { // Multiplayer final ItemStack finalCut = cut; final ItemStack finalToCut = toCut; - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).blocksCut.set(getQuestData(quest).blocksCut.indexOf(finalCut), newCut); q.finishObjective(quest, new BukkitObjective(type, itemStack, finalToCut), null, null, null, null, null, null, null); @@ -1828,7 +1859,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the item is being crafted * @param itemStack The item being crafted */ - public void craftItem(final BukkitQuest quest, final ItemStack itemStack) { + public void craftItem(final Quest quest, final ItemStack itemStack) { int currentIndex = -1; final LinkedList matches = new LinkedList<>(); for (final ItemStack is : getQuestData(quest).itemsCrafted) { @@ -1861,7 +1892,7 @@ public class BukkitQuester implements Quester, Comparable { null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).itemsCrafted.set(items.indexOf(found), found); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(m, 1), found), null, null, null, null, null, null, null); @@ -1886,7 +1917,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the item is being smelted * @param itemStack The item being smelted */ - public void smeltItem(final BukkitQuest quest, final ItemStack itemStack) { + public void smeltItem(final Quest quest, final ItemStack itemStack) { int currentIndex = -1; final LinkedList matches = new LinkedList<>(); for (final ItemStack is : getQuestData(quest).itemsSmelted) { @@ -1919,7 +1950,7 @@ public class BukkitQuester implements Quester, Comparable { null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).itemsSmelted.set(items.indexOf(found), found); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(m, 1), found), null, null, null, null, null, null, null); @@ -1944,7 +1975,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the item is being enchanted * @param itemStack The book being enchanted */ - public void enchantBook(final BukkitQuest quest, final ItemStack itemStack, + public void enchantBook(final Quest quest, final ItemStack itemStack, final Map enchantsToAdd) { int currentIndex = -1; final LinkedList matches = new LinkedList<>(); @@ -1980,7 +2011,7 @@ public class BukkitQuester implements Quester, Comparable { null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).itemsEnchanted.set(items.indexOf(found), found); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(m, 1), found), null, null, null, null, null, null, null); @@ -2005,7 +2036,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the item is being enchanted * @param itemStack The item being enchanted */ - public void enchantItem(final BukkitQuest quest, final ItemStack itemStack) { + public void enchantItem(final Quest quest, final ItemStack itemStack) { int currentIndex = -1; final LinkedList matches = new LinkedList<>(); if (!itemStack.getType().equals(Material.BOOK)) { @@ -2046,7 +2077,7 @@ public class BukkitQuester implements Quester, Comparable { null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).itemsEnchanted.set(items.indexOf(found), found); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(m, 1), found), null, null, null, null, null, null, null); @@ -2071,7 +2102,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the item is being brewed * @param itemStack The item being brewed */ - public void brewItem(final BukkitQuest quest, final ItemStack itemStack) { + public void brewItem(final Quest quest, final ItemStack itemStack) { int currentIndex = -1; final LinkedList matches = new LinkedList<>(); for (final ItemStack is : getQuestData(quest).itemsBrewed) { @@ -2104,7 +2135,7 @@ public class BukkitQuester implements Quester, Comparable { null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).itemsBrewed.set(items.indexOf(found), found); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(m, 1), found), null, null, null, null, null, null, null); @@ -2129,7 +2160,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the item is being consumed * @param itemStack The item being consumed */ - public void consumeItem(final BukkitQuest quest, final ItemStack itemStack) { + public void consumeItem(final Quest quest, final ItemStack itemStack) { int currentIndex = -1; final LinkedList matches = new LinkedList<>(); for (final ItemStack is : getQuestData(quest).itemsConsumed) { @@ -2162,7 +2193,7 @@ public class BukkitQuester implements Quester, Comparable { null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).itemsConsumed.set(items.indexOf(found), found); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(m, 1), found), null, null, null, null, null, null, null); @@ -2188,7 +2219,7 @@ public class BukkitQuester implements Quester, Comparable { * @param npc The NPC being delivered to * @param itemStack The item being delivered */ - public void deliverToNPC(final BukkitQuest quest, final NPC npc, final ItemStack itemStack) { + public void deliverToNPC(final Quest quest, final NPC npc, final ItemStack itemStack) { if (npc == null) { return; } @@ -2243,7 +2274,7 @@ public class BukkitQuester implements Quester, Comparable { null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).itemsDelivered.set(items.indexOf(found), found.clone()); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(m, 1), found), null, null, null, null, null, null, null); @@ -2274,7 +2305,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the NPC is being interacted with * @param npc The NPC being interacted with */ - public void interactWithNPC(final BukkitQuest quest, final NPC npc) { + public void interactWithNPC(final Quest quest, final NPC npc) { if (!getCurrentStage(quest).getCitizensToInteract().contains(npc.getId())) { return; } @@ -2293,7 +2324,7 @@ public class BukkitQuester implements Quester, Comparable { new ItemStack(Material.AIR, 1)), null, null, npc, null, null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).citizensInteracted.set(index, true); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1)), null, null, npc, null, null, null, null); @@ -2312,7 +2343,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the NPC is being killed * @param npc The NPC being killed */ - public void killNPC(final BukkitQuest quest, final NPC npc) { + public void killNPC(final Quest quest, final NPC npc) { if (!getCurrentStage(quest).getCitizensToKill().contains(npc.getId())) { return; } @@ -2334,7 +2365,7 @@ public class BukkitQuester implements Quester, Comparable { new ItemStack(Material.AIR, npcsToKill)), null, null, npc, null, null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).citizensNumKilled.set(index, getQuestData(quest).citizensNumKilled .get(index)); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1), @@ -2354,12 +2385,12 @@ public class BukkitQuester implements Quester, Comparable { * * @param quest The quest for which the fish is being caught */ - public void milkCow(final BukkitQuest quest) { + public void milkCow(final Quest quest) { final QuestData questData = getQuestData(quest); if (questData == null) { return; } - final BukkitStage currentStage = getCurrentStage(quest); + final Stage currentStage = getCurrentStage(quest); if (currentStage == null) { return; } @@ -2384,7 +2415,7 @@ public class BukkitQuester implements Quester, Comparable { new ItemStack(Material.AIR, cowsToMilk)), null, null, null, null, null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).setCowsMilked(cowsToMilk); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, cowsToMilk)), null, null, null, null, null, null, null); @@ -2403,12 +2434,12 @@ public class BukkitQuester implements Quester, Comparable { * * @param quest The quest for which the fish is being caught */ - public void catchFish(final BukkitQuest quest) { + public void catchFish(final Quest quest) { final QuestData questData = getQuestData(quest); if (questData == null) { return; } - final BukkitStage currentStage = getCurrentStage(quest); + final Stage currentStage = getCurrentStage(quest); if (currentStage == null) { return; } @@ -2433,7 +2464,7 @@ public class BukkitQuester implements Quester, Comparable { new ItemStack(Material.AIR, fishToCatch)), null, null, null, null, null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).setFishCaught(fishToCatch); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, fishToCatch)), null, null, null, null, null, null, null); @@ -2454,12 +2485,12 @@ public class BukkitQuester implements Quester, Comparable { * @param killedLocation The optional location to kill at * @param entityType The mob to be killed */ - public void killMob(final BukkitQuest quest, final Location killedLocation, final EntityType entityType) { + public void killMob(final Quest quest, final Location killedLocation, final EntityType entityType) { final QuestData questData = getQuestData(quest); if (entityType == null) { return; } - final BukkitStage currentStage = getCurrentStage(quest); + final Stage currentStage = getCurrentStage(quest); if (currentStage.getMobsToKill() == null) { return; } @@ -2504,7 +2535,7 @@ public class BukkitQuester implements Quester, Comparable { new ItemStack(Material.AIR, mobsToKill)), entityType, null, null, null, null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, currentStage, (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, currentStage, (final Quester q) -> { q.getQuestData(quest).mobNumKilled.set(index, newMobsKilled); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, mobsToKill)), entityType, null, null, null, null, null, null); @@ -2524,12 +2555,12 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the player is being killed * @param player The player to be killed */ - public void killPlayer(final BukkitQuest quest, final Player player) { + public void killPlayer(final Quest quest, final Player player) { final QuestData questData = getQuestData(quest); if (questData == null) { return; } - final BukkitStage currentStage = getCurrentStage(quest); + final Stage currentStage = getCurrentStage(quest); if (currentStage == null) { return; } @@ -2553,7 +2584,7 @@ public class BukkitQuester implements Quester, Comparable { new ItemStack(Material.AIR, playersToKill)), null, null, null, null, null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).setPlayersKilled(getQuestData(quest).getPlayersKilled()); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, playersToKill)), null, null, null, null, null, null, null); @@ -2573,7 +2604,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the location is being reached * @param location The location being reached */ - public void reachLocation(final BukkitQuest quest, final Location location) { + public void reachLocation(final Quest quest, final Location location) { if (getQuestData(quest) == null || getCurrentStage(quest) == null || getCurrentStage(quest).getLocationsToReach() == null || getQuestData(quest).locationsReached == null) { @@ -2616,7 +2647,7 @@ public class BukkitQuester implements Quester, Comparable { // Multiplayer final int finalIndex = index; - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).locationsReached.set(finalIndex, true); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1)), null, null, null, toReach, null, @@ -2652,12 +2683,12 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the mob is being tamed * @param entityType The type of mob being tamed */ - public void tameMob(final BukkitQuest quest, final EntityType entityType) { + public void tameMob(final Quest quest, final EntityType entityType) { final QuestData questData = getQuestData(quest); if (entityType == null) { return; } - final BukkitStage currentStage = getCurrentStage(quest); + final Stage currentStage = getCurrentStage(quest); if (currentStage.getMobsToTame() == null) { return; } @@ -2683,7 +2714,7 @@ public class BukkitQuester implements Quester, Comparable { new ItemStack(Material.AIR, mobsToTame)), entityType, null, null, null, null, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).mobsTamed.set(index, newMobsToTame); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, mobsToTame)), entityType, null, null, null, null, null, null); @@ -2703,12 +2734,12 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the sheep is being sheared * @param color The wool color of the sheep being sheared */ - public void shearSheep(final BukkitQuest quest, final DyeColor color) { + public void shearSheep(final Quest quest, final DyeColor color) { final QuestData questData = getQuestData(quest); if (color == null) { return; } - final BukkitStage currentStage = getCurrentStage(quest); + final Stage currentStage = getCurrentStage(quest); if (currentStage.getSheepToShear() == null) { return; } @@ -2734,7 +2765,7 @@ public class BukkitQuester implements Quester, Comparable { new ItemStack(Material.AIR, sheepToShear)), null, null, null, null, color, null, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).sheepSheared.set(index, newSheepSheared); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, sheepToShear)), null, null, null, null, color, null, null); @@ -2754,7 +2785,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest for which the password is being entered * @param evt The event during which the password was entered */ - public void sayPassword(final BukkitQuest quest, final AsyncPlayerChatEvent evt) { + public void sayPassword(final Quest quest, final AsyncPlayerChatEvent evt) { final ObjectiveType type = ObjectiveType.PASSWORD; plugin.getServer().getScheduler().runTask(plugin, () -> { final QuesterPreUpdateObjectiveEvent preEvent = new QuesterPreUpdateObjectiveEvent(this, quest, @@ -2773,7 +2804,7 @@ public class BukkitQuester implements Quester, Comparable { new ItemStack(Material.AIR, 1)), null, null, null, null, null, display, null); // Multiplayer - dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final BukkitQuester q) -> { + dispatchMultiplayerObjectives(quest, getCurrentStage(quest), (final Quester q) -> { q.getQuestData(quest).passwordsSaid.set(finalIndex, true); q.finishObjective(quest, new BukkitObjective(type, new ItemStack(Material.AIR, 1), new ItemStack(Material.AIR, 1)), null, null, null, null, null, display, null); @@ -2814,7 +2845,7 @@ public class BukkitQuester implements Quester, Comparable { * Custom objective, if any. See {@link CustomObjective} */ @SuppressWarnings("deprecation") - public void finishObjective(final BukkitQuest quest, final BukkitObjective objective, final EntityType mob, + public void finishObjective(final Quest quest, final Objective objective, final EntityType mob, final String extra, final NPC npc, final Location location, final DyeColor color, final String pass, final CustomObjective co) { if (objective == null) { @@ -3187,7 +3218,7 @@ public class BukkitQuester implements Quester, Comparable { /** * Complete quest objective * - * @deprecated Use {@link #finishObjective(BukkitQuest, BukkitObjective, EntityType, + * @deprecated Use {@link #finishObjective(Quest, Objective, EntityType, * String, NPC, Location, DyeColor, String, CustomObjective)} * * @param quest @@ -3216,7 +3247,7 @@ public class BukkitQuester implements Quester, Comparable { * See CustomObjective class */ @Deprecated - public void finishObjective(final BukkitQuest quest, final String objective, final ItemStack increment, + public void finishObjective(final Quest quest, final String objective, final ItemStack increment, final ItemStack goal, final Enchantment enchantment, final EntityType mob, final String extra, final NPC npc, final Location location, final DyeColor color, final String pass, final CustomObjective co) { @@ -3238,7 +3269,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest with the current stage being checked * @return true if all stage objectives are marked complete */ - public boolean testComplete(final BukkitQuest quest) { + public boolean testComplete(final Quest quest) { for (final String s : getCurrentObjectives(quest, true)) { if (s.startsWith(ChatColor.GREEN.toString())) { return false; @@ -3254,7 +3285,7 @@ public class BukkitQuester implements Quester, Comparable { * @param stage Where first stage is '0' */ @SuppressWarnings("deprecation") - public void addEmptiesFor(final BukkitQuest quest, final int stage) { + public void addEmptiesFor(final Quest quest, final int stage) { final QuestData data = new QuestData(this); data.setDoJournalUpdate(false); if (quest == null) { @@ -3432,7 +3463,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest to get the last completed time of * @return Difference between now and then in milliseconds */ - public long getCompletionDifference(final BukkitQuest quest) { + public long getCompletionDifference(final Quest quest) { final long currentTime = System.currentTimeMillis(); final long lastTime; if (!completedTimes.containsKey(quest)) { @@ -3444,25 +3475,13 @@ public class BukkitQuester implements Quester, Comparable { return currentTime - lastTime; } - /** - * Get the difference between player cooldown and time since last completion of a quest - * - * @deprecated Use {@link #getRemainingCooldown(BukkitQuest)} - * @param quest The quest to get the last completed time of - * @return Difference between now and then in milliseconds - */ - @Deprecated - public long getCooldownDifference(final BukkitQuest quest) { - return quest.getPlanner().getCooldown() - getCompletionDifference(quest); - } - /** * Get the amount of time left before Quester may take a completed quest again * * @param quest The quest to calculate the cooldown for * @return Length of time in milliseconds */ - public long getRemainingCooldown(final BukkitQuest quest) { + public long getRemainingCooldown(final Quest quest) { return quest.getPlanner().getCooldown() - getCompletionDifference(quest); } @@ -3471,7 +3490,7 @@ public class BukkitQuester implements Quester, Comparable { if (!currentQuests.isEmpty()) { final ArrayList questIds = new ArrayList<>(); final ArrayList questStages = new ArrayList<>(); - for (final BukkitQuest quest : currentQuests.keySet()) { + for (final Quest quest : currentQuests.keySet()) { questIds.add(quest.getId()); questStages.add(currentQuests.get(quest)); } @@ -3479,7 +3498,7 @@ public class BukkitQuester implements Quester, Comparable { data.set("currentStages", questStages); data.set("quest-points", questPoints); final ConfigurationSection dataSec = data.createSection("questData"); - for (final BukkitQuest quest : currentQuests.keySet()) { + for (final Quest quest : currentQuests.keySet()) { if (quest.getName() == null || quest.getName().isEmpty()) { plugin.getLogger().severe("Quest name was null or empty while loading data"); return null; @@ -3578,7 +3597,7 @@ public class BukkitQuester implements Quester, Comparable { if (!questData.mobsTamed.isEmpty()) { questSec.set("mob-tame-amounts", questData.mobsTamed); } - final BukkitStage stage = getCurrentStage(quest); + final Stage stage = getCurrentStage(quest); if (stage != null) { if (stage.getFishToCatch() != null) { questSec.set("fish-caught", questData.getFishCaught()); @@ -3623,7 +3642,7 @@ public class BukkitQuester implements Quester, Comparable { if (!completedTimes.isEmpty()) { final List questIds = new LinkedList<>(); final List questTimes = new LinkedList<>(); - for (final Entry entry : completedTimes.entrySet()) { + for (final Entry entry : completedTimes.entrySet()) { questIds.add(entry.getKey().getId()); questTimes.add(entry.getValue()); } @@ -3633,7 +3652,7 @@ public class BukkitQuester implements Quester, Comparable { if (!amountsCompleted.isEmpty()) { final List questIds = new LinkedList<>(); final List questAmounts = new LinkedList<>(); - for (final Entry entry : amountsCompleted.entrySet()) { + for (final Entry entry : amountsCompleted.entrySet()) { questIds.add(entry.getKey().getId()); questAmounts.add(entry.getValue()); } @@ -3682,7 +3701,7 @@ public class BukkitQuester implements Quester, Comparable { * Initiate the stage timer * @param quest The quest of which the timer is for */ - public void startStageTimer(final BukkitQuest quest) { + public void startStageTimer(final Quest quest) { if (getQuestData(quest).getDelayTimeLeft() > -1) { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(plugin, this, quest), (long) (getQuestData(quest).getDelayTimeLeft() * 0.02)); @@ -3704,7 +3723,7 @@ public class BukkitQuester implements Quester, Comparable { * Pause the stage timer. Useful when a player quits * @param quest The quest of which the timer is for */ - public void stopStageTimer(final BukkitQuest quest) { + public void stopStageTimer(final Quest quest) { if (getQuestData(quest).getDelayTimeLeft() > -1) { getQuestData(quest).setDelayTimeLeft(getQuestData(quest).getDelayTimeLeft() - (System.currentTimeMillis() - getQuestData(quest).getDelayStartTime())); @@ -3719,7 +3738,7 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest of which the timer is for * @return Remaining time in milliseconds */ - public long getStageTime(final BukkitQuest quest) { + public long getStageTime(final Quest quest) { if (getQuestData(quest).getDelayTimeLeft() > -1) { return getQuestData(quest).getDelayTimeLeft() - (System.currentTimeMillis() - getQuestData(quest).getDelayStartTime()); @@ -3734,12 +3753,12 @@ public class BukkitQuester implements Quester, Comparable { * * @param quest The quest to check */ - public void checkQuest(final BukkitQuest quest) { + public void checkQuest(final Quest quest) { if (quest != null) { boolean exists = false; - for (final BukkitQuest q : plugin.getLoadedQuests()) { + for (final Quest q : plugin.getLoadedQuests()) { if (q.getId().equalsIgnoreCase(quest.getId())) { - final BukkitStage stage = getCurrentStage(quest); + final Stage stage = getCurrentStage(quest); if (stage != null) { quest.updateCompass(this, stage); // TODO - decide whether or not to handle this @@ -3821,16 +3840,16 @@ public class BukkitQuester implements Quester, Comparable { /** * Force Quester to quit the specified quest (canceling any timers), then update Quest Journal

* - * Does not save changes to disk. Consider {@link #quitQuest(BukkitQuest, String)} or {@link #quitQuest(BukkitQuest, String[])} + * Does not save changes to disk. Consider {@link #quitQuest(Quest, String)} or {@link #quitQuest(Quest, String[])} * * @param quest The quest to quit */ - public void hardQuit(final BukkitQuest quest) { + public void hardQuit(final Quest quest) { try { currentQuests.remove(quest); questData.remove(quest); if (!timers.isEmpty()) { - for (final Map.Entry entry : timers.entrySet()) { + for (final Map.Entry entry : timers.entrySet()) { if (entry.getValue().getName().equals(quest.getName())) { plugin.getServer().getScheduler().cancelTask(entry.getKey()); timers.remove(entry.getKey()); @@ -3849,7 +3868,7 @@ public class BukkitQuester implements Quester, Comparable { * * @param quest The quest to remove */ - public void hardRemove(final BukkitQuest quest) { + public void hardRemove(final Quest quest) { try { completedQuests.remove(quest); } catch (final Exception ex) { @@ -3880,7 +3899,7 @@ public class BukkitQuester implements Quester, Comparable { * @param key The quest to set stage of * @param val The stage number to set */ - public void hardStagePut(final BukkitQuest key, final Integer val) { + public void hardStagePut(final Quest key, final Integer val) { try { currentQuests.put(key, val); } catch (final Exception ex) { @@ -3896,7 +3915,7 @@ public class BukkitQuester implements Quester, Comparable { * @param key The quest to set stage of * @param val The data to set */ - public void hardDataPut(final BukkitQuest key, final QuestData val) { + public void hardDataPut(final Quest key, final QuestData val) { try { questData.put(key, val); } catch (final Exception ex) { @@ -3942,8 +3961,8 @@ public class BukkitQuester implements Quester, Comparable { if (!canUseCompass()) { return; } - for (final BukkitQuest quest : currentQuests.keySet()) { - final BukkitStage stage = getCurrentStage(quest); + for (final Quest quest : currentQuests.keySet()) { + final Stage stage = getCurrentStage(quest); if (stage != null && quest.updateCompass(this, stage)) { break; } @@ -3961,7 +3980,7 @@ public class BukkitQuester implements Quester, Comparable { } Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { final LinkedList list = currentQuests.keySet().stream() - .sorted(Comparator.comparing(BukkitQuest::getName)).map(BukkitQuest::getId) + .sorted(Comparator.comparing(Quest::getName)).map(Quest::getId) .collect(Collectors.toCollection(LinkedList::new)); int index = 0; if (compassTargetQuestId != null) { @@ -3974,9 +3993,9 @@ public class BukkitQuester implements Quester, Comparable { } } if (list.size() > 0) { - final BukkitQuest quest = plugin.getQuestById(list.get(index)); + final Quest quest = plugin.getQuestById(list.get(index)); compassTargetQuestId = quest.getId(); - final BukkitStage stage = getCurrentStage(quest); + final Stage stage = getCurrentStage(quest); if (stage != null) { quest.updateCompass(BukkitQuester.this, stage); if (notify) { @@ -4010,42 +4029,23 @@ public class BukkitQuester implements Quester, Comparable { return playerAmount >= is.getAmount(); } - /** - * Dispatch player event to fellow questers

- * - * Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock, - * cutBlock, craftItem, smeltItem, enchantItem, brewItem, consumeItem, - * milkCow, catchFish, killMob, deliverItem, killPlayer, talkToNPC, - * killNPC, tameMob, shearSheep, password, reachLocation - * - * @deprecated Use {@link #dispatchMultiplayerEverything(BukkitQuest, ObjectiveType, BiFunction)} - * - * @param objectiveType The type of objective to progress - * @param fun The function to execute, the event call - */ - @Deprecated - public void dispatchMultiplayerEverything(final BukkitQuest quest, final String objectiveType, - final BiFunction fun) { - dispatchMultiplayerEverything(quest, ObjectiveType.fromName(objectiveType), fun); - } - /** * Dispatch player event to fellow questers

* * @param type The type of objective to progress * @param fun The function to execute, the event call */ - public Set dispatchMultiplayerEverything(final BukkitQuest quest, final ObjectiveType type, - final BiFunction fun) { + public Set dispatchMultiplayerEverything(final Quest quest, final ObjectiveType type, + final BiFunction fun) { final Set appliedQuestIDs = new HashSet<>(); if (quest != null) { try { if (quest.getOptions().getShareProgressLevel() == 1) { - final List mq = getMultiplayerQuesters(quest); + final List mq = getMultiplayerQuesters(quest); if (mq == null) { return appliedQuestIDs; } - for (final BukkitQuester q : mq) { + for (final Quester q : mq) { if (q == null) { continue; } @@ -4081,15 +4081,15 @@ public class BukkitQuester implements Quester, Comparable { * @param currentStage The current stage of the quest * @param fun The function to execute, the event call */ - public Set dispatchMultiplayerObjectives(final BukkitQuest quest, final BukkitStage currentStage, - final Function fun) { + public Set dispatchMultiplayerObjectives(final Quest quest, final Stage currentStage, + final Function fun) { final Set appliedQuestIDs = new HashSet<>(); if (quest.getOptions().getShareProgressLevel() == 2) { - final List mq = getMultiplayerQuesters(quest); + final List mq = getMultiplayerQuesters(quest); if (mq == null) { return appliedQuestIDs; } - for (final BukkitQuester q : mq) { + for (final Quester q : mq) { if (q == null) { continue; } @@ -4109,11 +4109,11 @@ public class BukkitQuester implements Quester, Comparable { * @param quest The quest which uses a linked plugin, i.e. Parties or DungeonsXL * @return Potentially empty list of Questers or null for invalid quest */ - public List getMultiplayerQuesters(final BukkitQuest quest) { + public List getMultiplayerQuesters(final Quest quest) { if (quest == null) { return null; } - final List mq = new LinkedList<>(); + final List mq = new LinkedList<>(); if (plugin.getDependencies().getPartyProvider() != null) { final PartyProvider partyProvider = plugin.getDependencies().getPartyProvider(); if (partyProvider != null) { @@ -4202,7 +4202,7 @@ public class BukkitQuester implements Quester, Comparable { * @param giveReason Whether to inform Quester of unavailability * @return true if successful */ - public boolean offerQuest(final BukkitQuest quest, final boolean giveReason) { + public boolean offerQuest(final Quest quest, final boolean giveReason) { if (quest == null) { return false; } @@ -4241,7 +4241,7 @@ public class BukkitQuester implements Quester, Comparable { * @param giveReason Whether to inform Quester of unavailability * @return true if available */ - public boolean canAcceptOffer(final BukkitQuest quest, final boolean giveReason) { + public boolean canAcceptOffer(final Quest quest, final boolean giveReason) { if (quest == null) { return false; } @@ -4309,8 +4309,8 @@ public class BukkitQuester implements Quester, Comparable { return true; } - public boolean meetsCondition(final BukkitQuest quest, final boolean giveReason) { - final BukkitStage stage = getCurrentStage(quest); + public boolean meetsCondition(final Quest quest, final boolean giveReason) { + final Stage 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/BukkitQuest.java b/core/src/main/java/me/blackvein/quests/quests/BukkitQuest.java index c9fbac049..cabd6cbe7 100644 --- a/core/src/main/java/me/blackvein/quests/quests/BukkitQuest.java +++ b/core/src/main/java/me/blackvein/quests/quests/BukkitQuest.java @@ -20,19 +20,18 @@ import com.codisimus.plugins.phatloots.loot.LootBundle; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.util.player.UserManager; import com.herocraftonline.heroes.characters.Hero; -import me.blackvein.quests.Quester; -import me.blackvein.quests.actions.Action; import me.blackvein.quests.CustomRequirement; import me.blackvein.quests.CustomReward; import me.blackvein.quests.Dependencies; import me.blackvein.quests.Options; import me.blackvein.quests.Planner; import me.blackvein.quests.Quest; +import me.blackvein.quests.Quester; +import me.blackvein.quests.Quests; import me.blackvein.quests.Requirements; import me.blackvein.quests.Rewards; import me.blackvein.quests.Stage; -import me.blackvein.quests.player.BukkitQuester; -import me.blackvein.quests.Quests; +import me.blackvein.quests.actions.Action; import me.blackvein.quests.actions.BukkitAction; import me.blackvein.quests.conditions.Condition; import me.blackvein.quests.events.quest.QuestUpdateCompassEvent; @@ -70,9 +69,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.UUID; import java.util.concurrent.CompletableFuture; -public class BukkitQuest implements Quest, Comparable { +public class BukkitQuest implements Quest { protected Quests plugin; protected String id; @@ -81,7 +81,7 @@ public class BukkitQuest implements Quest, Comparable { protected String finished; protected ItemStack guiDisplay = null; private final LinkedList orderedStages = new LinkedList<>(); - protected NPC npcStart; + protected UUID npcStart; protected Location blockStart; protected String regionStart = null; protected BukkitAction initialAction; @@ -91,15 +91,29 @@ public class BukkitQuest implements Quest, Comparable { private final BukkitOptions options = new BukkitOptions(); @Override - public int compareTo(final BukkitQuest quest) { + public int compareTo(final Quest quest) { return id.compareTo(quest.getId()); } + public Quests getPlugin() { + return plugin; + } + + public void setPlugin(Quests plugin) { + this.plugin = plugin; + } + @Override public String getId() { return id; } + public void setId(String id) { + if (plugin != null) { + this.id = id; + } + } + @Override public String getName() { return name; @@ -166,12 +180,15 @@ public class BukkitQuest implements Quest, Comparable { @Override public NPC getNpcStart() { - return npcStart; + if (CitizensAPI.getNPCRegistry().getByUniqueId(npcStart) != null) { + return CitizensAPI.getNPCRegistry().getByUniqueId(npcStart); + } + return null; } @Override public void setNpcStart(final NPC npcStart) { - this.npcStart = npcStart; + this.npcStart = npcStart.getUniqueId(); } @Override @@ -186,7 +203,7 @@ public class BukkitQuest implements Quest, Comparable { @Override public Action getInitialAction() { - return (Action) initialAction; + return initialAction; } @Override @@ -220,7 +237,7 @@ public class BukkitQuest implements Quest, Comparable { * @param quester Player to force * @param allowSharedProgress Whether to distribute progress to fellow questers */ - public void nextStage(final BukkitQuester quester, final boolean allowSharedProgress) { + public void nextStage(final Quester quester, final boolean allowSharedProgress) { final Stage currentStage = quester.getCurrentStage(this); if (currentStage == null) { plugin.getLogger().severe("Current stage was null for quester " + quester.getPlayer().getUniqueId()); @@ -256,8 +273,8 @@ public class BukkitQuest implements Quest, Comparable { // Multiplayer if (allowSharedProgress && options.getShareProgressLevel() == 3) { - final List mq = quester.getMultiplayerQuesters(this); - for (final BukkitQuester qq : mq) { + final List mq = quester.getMultiplayerQuesters(this); + for (final Quester qq : mq) { if (currentStage.equals(qq.getCurrentStage(this))) { nextStage(qq, true); } @@ -276,7 +293,7 @@ public class BukkitQuest implements Quest, Comparable { * @param stage Stage number to specify * @throws IndexOutOfBoundsException if stage does not exist */ - public void setStage(final BukkitQuester quester, final int stage) throws IndexOutOfBoundsException { + public void setStage(final Quester quester, final int stage) throws IndexOutOfBoundsException { final OfflinePlayer player = quester.getOfflinePlayer(); if (orderedStages.size() - 1 < stage) { final String msg = "Tried to set invalid stage number of " + stage + " for quest " + getName() + " on " @@ -412,15 +429,15 @@ public class BukkitQuest implements Quest, Comparable { Location targetLocation = null; if (stage.getCitizensToInteract() != null && stage.getCitizensToInteract().size() > 0) { targetLocation = plugin.getDependencies().getNPCLocation(stage.getCitizensToInteract().getFirst()); - } else if (stage.citizensToKill != null && stage.citizensToKill.size() > 0) { - targetLocation = plugin.getDependencies().getNPCLocation(stage.citizensToKill.getFirst()); - } else if (stage.locationsToReach != null && stage.locationsToReach.size() > 0) { - targetLocation = stage.locationsToReach.getFirst(); - } else if (stage.itemDeliveryTargets != null && stage.itemDeliveryTargets.size() > 0) { - final NPC npc = plugin.getDependencies().getCitizens().getNPCRegistry().getById(stage.itemDeliveryTargets - .getFirst()); + } else if (stage.getCitizensToKill() != null && stage.getCitizensToKill().size() > 0) { + targetLocation = plugin.getDependencies().getNPCLocation(stage.getCitizensToKill().getFirst()); + } else if (stage.getLocationsToReach() != null && stage.getLocationsToReach().size() > 0) { + targetLocation = stage.getLocationsToReach().getFirst(); + } else if (stage.getItemDeliveryTargets() != null && stage.getItemDeliveryTargets().size() > 0) { + final NPC npc = plugin.getDependencies().getCitizens().getNPCRegistry().getById(stage + .getItemDeliveryTargets().getFirst()); targetLocation = npc.getStoredLocation(); - } else if (stage.playersToKill != null && stage.playersToKill > 0) { + } else if (stage.getPlayersToKill() != null && stage.getPlayersToKill() > 0) { final Location source = quester.getPlayer().getLocation(); Location nearest = null; double old_distance = 30000000; @@ -440,11 +457,11 @@ public class BukkitQuest implements Quest, Comparable { if (nearest != null) { targetLocation = nearest; } - } else if (stage.mobsToKill != null && stage.mobsToKill.size() > 0) { + } else if (stage.getMobsToKill() != null && stage.getMobsToKill().size() > 0) { final Location source = quester.getPlayer().getLocation(); Location nearest = null; double old_distance = 30000000; - final EntityType et = stage.mobsToKill.getFirst(); + final EntityType et = stage.getMobsToKill().getFirst(); if (source.getWorld() == null) { return; } @@ -461,11 +478,11 @@ public class BukkitQuest implements Quest, Comparable { if (nearest != null) { targetLocation = nearest; } - } else if (stage.mobsToTame != null && stage.mobsToTame.size() > 0) { + } else if (stage.getMobsToTame() != null && stage.getMobsToTame().size() > 0) { final Location source = quester.getPlayer().getLocation(); Location nearest = null; double old_distance = 30000000; - final EntityType et = stage.mobsToTame.getFirst(); + final EntityType et = stage.getMobsToTame().getFirst(); if (source.getWorld() == null) { return; } @@ -482,11 +499,11 @@ public class BukkitQuest implements Quest, Comparable { if (nearest != null) { targetLocation = nearest; } - } else if (stage.sheepToShear != null && stage.sheepToShear.size() > 0) { + } else if (stage.getSheepToShear() != null && stage.getSheepToShear().size() > 0) { final Location source = quester.getPlayer().getLocation(); Location nearest = null; double old_distance = 30000000; - final DyeColor dc = stage.sheepToShear.getFirst(); + final DyeColor dc = stage.getSheepToShear().getFirst(); if (source.getWorld() == null) { return; } @@ -532,7 +549,7 @@ public class BukkitQuest implements Quest, Comparable { * @param quester The quester to check * @return true if all Requirements have been met */ - public boolean testRequirements(final BukkitQuester quester) { + public boolean testRequirements(final Quester quester) { return testRequirements(quester.getOfflinePlayer()); } @@ -544,8 +561,8 @@ public class BukkitQuest implements Quest, Comparable { * @param player The player to check * @return true if all Requirements have been met */ - protected boolean testRequirements(final OfflinePlayer player) { - final BukkitQuester quester = plugin.getQuester(player.getUniqueId()); + public boolean testRequirements(final OfflinePlayer player) { + final Quester quester = plugin.getQuester(player.getUniqueId()); if (requirements.getMoney() != 0 && plugin.getDependencies().getVaultEconomy() != null) { if (plugin.getDependencies().getVaultEconomy().getBalance(player) < requirements.getMoney()) { return false; @@ -622,7 +639,7 @@ public class BukkitQuest implements Quest, Comparable { * * @param quester The quester finishing this quest */ - public void completeQuest(final BukkitQuester quester) { + public void completeQuest(final Quester quester) { completeQuest(quester, true); } @@ -633,7 +650,7 @@ public class BukkitQuest implements Quest, Comparable { * @param allowMultiplayer Allow multiplayer sharing */ @SuppressWarnings("deprecation") - public void completeQuest(final BukkitQuester quester, final boolean allowMultiplayer) { + public void completeQuest(final Quester quester, final boolean allowMultiplayer) { final OfflinePlayer player = quester.getOfflinePlayer(); boolean cancelled = false; if (player.isOnline()) { @@ -664,7 +681,7 @@ public class BukkitQuest implements Quest, Comparable { } quester.hardQuit(this); quester.getCompletedQuests().add(this); - for (final Map.Entry entry : quester.getTimers().entrySet()) { + for (final Map.Entry entry : quester.getTimers().entrySet()) { if (entry.getValue().getName().equals(getName())) { plugin.getServer().getScheduler().cancelTask(entry.getKey()); quester.getTimers().remove(entry.getKey()); @@ -1079,8 +1096,8 @@ public class BukkitQuest implements Quest, Comparable { // Multiplayer if (allowMultiplayer && options.getShareProgressLevel() == 4) { - final List mq = quester.getMultiplayerQuesters(this); - for (final BukkitQuester qq : mq) { + final List mq = quester.getMultiplayerQuesters(this); + for (final Quester qq : mq) { if (qq.getQuestData(this) != null) { completeQuest(qq, false); } @@ -1093,7 +1110,7 @@ public class BukkitQuest implements Quest, Comparable { * * @param quester The quester to be ejected */ - public void failQuest(final BukkitQuester quester) { + public void failQuest(final Quester quester) { failQuest(quester, false); } @@ -1103,8 +1120,7 @@ public class BukkitQuest implements Quest, Comparable { * @param quester The quester to be ejected * @param ignoreFailAction Whether to ignore quest fail Action */ - @SuppressWarnings("deprecation") - public void failQuest(final BukkitQuester quester, final boolean ignoreFailAction) { + public void failQuest(final Quester quester, final boolean ignoreFailAction) { final QuesterPreFailQuestEvent preEvent = new QuesterPreFailQuestEvent(quester, this); plugin.getServer().getPluginManager().callEvent(preEvent); if (preEvent.isCancelled()) { @@ -1132,12 +1148,12 @@ public class BukkitQuest implements Quest, Comparable { /** * Checks if quester is in WorldGuard region start * - * @deprecated Use {@link #isInRegionStart(BukkitQuester)} + * @deprecated Use {@link #isInRegionStart(Quester)} * @param quester The quester to check * @return true if quester is in region */ @Deprecated - public boolean isInRegion(final BukkitQuester quester) { + public boolean isInRegion(final Quester quester) { return isInRegionStart(quester); } @@ -1160,7 +1176,7 @@ public class BukkitQuest implements Quest, Comparable { * @param quester The quester to check * @return true if quester is in region */ - public boolean isInRegionStart(final BukkitQuester quester) { + public boolean isInRegionStart(final Quester quester) { return isInRegionStart(quester.getPlayer()); } diff --git a/core/src/main/java/me/blackvein/quests/QuestFactory.java b/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java similarity index 98% rename from core/src/main/java/me/blackvein/quests/QuestFactory.java rename to core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java index 903214c07..6be1b908f 100644 --- a/core/src/main/java/me/blackvein/quests/QuestFactory.java +++ b/core/src/main/java/me/blackvein/quests/quests/BukkitQuestFactory.java @@ -10,18 +10,21 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package me.blackvein.quests; +package me.blackvein.quests.quests; +import me.blackvein.quests.CustomObjective; +import me.blackvein.quests.Options; +import me.blackvein.quests.Planner; +import me.blackvein.quests.Quest; +import me.blackvein.quests.QuestFactory; +import me.blackvein.quests.Quests; +import me.blackvein.quests.Requirements; +import me.blackvein.quests.Rewards; +import me.blackvein.quests.Stage; import me.blackvein.quests.convo.quests.main.QuestMainPrompt; import me.blackvein.quests.convo.quests.menu.QuestMenuPrompt; import me.blackvein.quests.convo.quests.stages.StageMenuPrompt; import me.blackvein.quests.interfaces.ReloadCallback; -import me.blackvein.quests.quests.BukkitOptions; -import me.blackvein.quests.quests.BukkitPlanner; -import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.quests.BukkitRequirements; -import me.blackvein.quests.quests.BukkitRewards; -import me.blackvein.quests.quests.BukkitStage; import me.blackvein.quests.util.CK; import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.FakeConversable; @@ -59,7 +62,7 @@ import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; -public class QuestFactory implements ConversationAbandonedListener { +public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedListener { private final Quests plugin; private final ConversationFactory conversationFactory; @@ -69,7 +72,7 @@ public class QuestFactory implements ConversationAbandonedListener { private Set selectingNpcs = new HashSet<>(); private List editingQuestNames = new LinkedList<>(); - public QuestFactory(final Quests plugin) { + public BukkitQuestFactory(final Quests plugin) { this.plugin = plugin; // Ensure to initialize factory last so that 'this' is fully initialized before it is passed this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false) @@ -182,7 +185,7 @@ public class QuestFactory implements ConversationAbandonedListener { if (q.getGUIDisplay() != null) { context.setSessionData(CK.Q_GUIDISPLAY, q.getGUIDisplay()); } - final BukkitRequirements requirements = q.getRequirements(); + final Requirements requirements = q.getRequirements(); if (requirements.getMoney() != 0) { context.setSessionData(CK.REQ_MONEY, requirements.getMoney()); } @@ -194,11 +197,11 @@ public class QuestFactory implements ConversationAbandonedListener { context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems()); } if (!requirements.getNeededQuests().isEmpty()) { - final List ids = requirements.getNeededQuests().stream().map(BukkitQuest::getId).collect(Collectors.toList()); + final List ids = requirements.getNeededQuests().stream().map(Quest::getId).collect(Collectors.toList()); context.setSessionData(CK.REQ_QUEST, ids); } if (!requirements.getBlockQuests().isEmpty()) { - final List ids = requirements.getBlockQuests().stream().map(BukkitQuest::getId).collect(Collectors.toList()); + final List ids = requirements.getBlockQuests().stream().map(Quest::getId).collect(Collectors.toList()); context.setSessionData(CK.REQ_QUEST_BLOCK, ids); } if (!requirements.getMcmmoSkills().isEmpty()) { @@ -227,7 +230,7 @@ public class QuestFactory implements ConversationAbandonedListener { if (!requirements.getDetailsOverride().isEmpty()) { context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride()); } - final BukkitRewards rewards = q.getRewards(); + final Rewards rewards = q.getRewards(); if (rewards.getMoney() != 0) { context.setSessionData(CK.REW_MONEY, rewards.getMoney()); } @@ -273,7 +276,7 @@ public class QuestFactory implements ConversationAbandonedListener { if (!rewards.getDetailsOverride().isEmpty()) { context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride()); } - final BukkitPlanner pln = q.getPlanner(); + final Planner pln = q.getPlanner(); if (pln.getStart() != null) { context.setSessionData(CK.PLN_START_DATE, pln.getStart()); } @@ -287,7 +290,7 @@ public class QuestFactory implements ConversationAbandonedListener { context.setSessionData(CK.PLN_COOLDOWN, pln.getCooldown()); } context.setSessionData(CK.PLN_OVERRIDE, pln.getOverride()); - final BukkitOptions opt = q.getOptions(); + final Options opt = q.getOptions(); context.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.canAllowCommands()); context.setSessionData(CK.OPT_ALLOW_QUITTING, opt.canAllowQuitting()); context.setSessionData(CK.OPT_IGNORE_SILK_TOUCH, opt.canIgnoreSilkTouch()); @@ -299,7 +302,7 @@ public class QuestFactory implements ConversationAbandonedListener { context.setSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS, opt.canHandleOfflinePlayers()); // Stages (Objectives) int index = 1; - for (final BukkitStage stage : q.getStages()) { + for (final Stage stage : q.getStages()) { final String pref = "stage" + index; index++; context.setSessionData(pref, Boolean.TRUE); @@ -454,7 +457,7 @@ public class QuestFactory implements ConversationAbandonedListener { colors.add(MiscUtil.getPrettyDyeColorName(d)); } - final LinkedList amounts = new LinkedList<>(stage.sheepNumToShear); + final LinkedList amounts = new LinkedList<>(stage.getSheepNumToShear()); context.setSessionData(pref + CK.S_SHEAR_COLORS, colors); context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amounts); } diff --git a/core/src/main/java/me/blackvein/quests/quests/BukkitStage.java b/core/src/main/java/me/blackvein/quests/quests/BukkitStage.java index 443e3555b..b39ae1ab3 100644 --- a/core/src/main/java/me/blackvein/quests/quests/BukkitStage.java +++ b/core/src/main/java/me/blackvein/quests/quests/BukkitStage.java @@ -15,7 +15,6 @@ package me.blackvein.quests.quests; import me.blackvein.quests.CustomObjective; import me.blackvein.quests.Stage; import me.blackvein.quests.actions.Action; -import me.blackvein.quests.actions.Action; import me.blackvein.quests.conditions.Condition; import me.blackvein.quests.enums.ObjectiveType; import org.bukkit.DyeColor; @@ -145,6 +144,11 @@ public class BukkitStage implements Stage { return blocksToBreak; } + @Override + public boolean addBlockToBreak(ItemStack blockToBreak) { + return blocksToBreak.add(blockToBreak); + } + public void setBlocksToBreak(final LinkedList blocksToBreak) { this.blocksToBreak = blocksToBreak; } @@ -153,6 +157,11 @@ public class BukkitStage implements Stage { return blocksToDamage; } + @Override + public boolean addBlockToDamage(ItemStack blockToDamage) { + return blocksToDamage.add(blockToDamage); + } + public void setBlocksToDamage(final LinkedList blocksToDamage) { this.blocksToDamage = blocksToDamage; } @@ -161,6 +170,11 @@ public class BukkitStage implements Stage { return blocksToPlace; } + @Override + public boolean addBlockToPlace(ItemStack blockToPlace) { + return blocksToPlace.add(blockToPlace); + } + public void setBlocksToPlace(final LinkedList blocksToPlace) { this.blocksToPlace = blocksToPlace; } @@ -169,6 +183,11 @@ public class BukkitStage implements Stage { return blocksToUse; } + @Override + public boolean addBlockToUse(ItemStack blockToUse) { + return blocksToUse.add(blockToUse); + } + public void setBlocksToUse(final LinkedList blocksToUse) { this.blocksToUse = blocksToUse; } @@ -177,6 +196,11 @@ public class BukkitStage implements Stage { return blocksToCut; } + @Override + public boolean addBlockToCut(ItemStack blockToCut) { + return blocksToCut.add(blockToCut); + } + public void setBlocksToCut(final LinkedList blocksToCut) { this.blocksToCut = blocksToCut; } @@ -185,6 +209,11 @@ public class BukkitStage implements Stage { return itemsToCraft; } + @Override + public boolean addItemToCraft(ItemStack itemToCraft) { + return itemsToCraft.add(itemToCraft); + } + public void setItemsToCraft(final LinkedList itemsToCraft) { this.itemsToCraft = itemsToCraft; } @@ -193,6 +222,11 @@ public class BukkitStage implements Stage { return itemsToSmelt; } + @Override + public boolean addItemToSmelt(ItemStack itemToSmelt) { + return itemsToSmelt.add(itemToSmelt); + } + public void setItemsToSmelt(final LinkedList itemsToSmelt) { this.itemsToSmelt = itemsToSmelt; } @@ -201,6 +235,11 @@ public class BukkitStage implements Stage { return itemsToEnchant; } + @Override + public boolean addItemToEnchant(ItemStack itemToEnchant) { + return itemsToEnchant.add(itemToEnchant); + } + public void setItemsToEnchant(final LinkedList itemsToEnchant) { this.itemsToEnchant = itemsToEnchant; } @@ -209,6 +248,11 @@ public class BukkitStage implements Stage { return itemsToBrew; } + @Override + public boolean addItemsToBrew(ItemStack itemToBrew) { + return itemsToBrew.add(itemToBrew); + } + public void setItemsToBrew(final LinkedList itemsToBrew) { this.itemsToBrew = itemsToBrew; } @@ -217,6 +261,11 @@ public class BukkitStage implements Stage { return itemsToConsume; } + @Override + public boolean addItemToConsume(ItemStack itemToConsume) { + return itemsToConsume.add(itemToConsume); + } + public void setItemsToConsume(final LinkedList itemsToConsume) { this.itemsToBrew = itemsToConsume; } @@ -225,6 +274,11 @@ public class BukkitStage implements Stage { return itemsToDeliver; } + @Override + public boolean addItemToDeliver(ItemStack itemToDeliver) { + return itemsToDeliver.add(itemToDeliver); + } + public void setItemsToDeliver(final LinkedList itemsToDeliver) { this.itemsToDeliver = itemsToDeliver; } @@ -233,6 +287,11 @@ public class BukkitStage implements Stage { return itemDeliveryTargets; } + @Override + public boolean addItemDeliveryTarget(Integer itemDeliveryTarget) { + return itemDeliveryTargets.add(itemDeliveryTarget); + } + public void setItemDeliveryTargets(final LinkedList itemDeliveryTargets) { this.itemDeliveryTargets = itemDeliveryTargets; } @@ -241,6 +300,11 @@ public class BukkitStage implements Stage { return deliverMessages; } + @Override + public boolean addDeliverMessage(String deliverMessage) { + return deliverMessages.add(deliverMessage); + } + public void setDeliverMessages(final LinkedList deliverMessages) { this.deliverMessages = deliverMessages; } @@ -249,6 +313,11 @@ public class BukkitStage implements Stage { return citizensToInteract; } + @Override + public boolean addCitizenToInteract(Integer citizenToInteract) { + return citizensToInteract.add(citizenToInteract); + } + public void setCitizensToInteract(final LinkedList citizensToInteract) { this.citizensToInteract = citizensToInteract; } @@ -257,6 +326,11 @@ public class BukkitStage implements Stage { return citizensToKill; } + @Override + public boolean addCitizenToKill(Integer citizenToKill) { + return citizensToKill.add(citizenToKill); + } + public void setCitizensToKill(final LinkedList citizensToKill) { this.citizensToKill = citizensToKill; } @@ -265,6 +339,11 @@ public class BukkitStage implements Stage { return citizenNumToKill; } + @Override + public boolean addCitizenNumToKill(Integer citizenNumToKill) { + return this.citizenNumToKill.add(citizenNumToKill); + } + public void setCitizenNumToKill(final LinkedList citizenNumToKill) { this.citizenNumToKill = citizenNumToKill; } @@ -273,6 +352,11 @@ public class BukkitStage implements Stage { return mobsToKill; } + @Override + public boolean addMobToKill(EntityType mobToKill) { + return mobsToKill.add(mobToKill); + } + public void setMobsToKill(final LinkedList mobsToKill) { this.mobsToKill = mobsToKill; } @@ -281,6 +365,11 @@ public class BukkitStage implements Stage { return mobNumToKill; } + @Override + public boolean addMobNumToKill(Integer mobNumToKill) { + return this.mobNumToKill.add(mobNumToKill); + } + public void setMobNumToKill(final LinkedList mobNumToKill) { this.mobNumToKill = mobNumToKill; } @@ -289,6 +378,11 @@ public class BukkitStage implements Stage { return locationsToKillWithin; } + @Override + public boolean addLocationToKillWithin(Location locationToKillWithin) { + return locationsToKillWithin.add(locationToKillWithin); + } + public void setLocationsToKillWithin(final LinkedList locationsToKillWithin) { this.locationsToKillWithin = locationsToKillWithin; } @@ -297,6 +391,11 @@ public class BukkitStage implements Stage { return radiiToKillWithin; } + @Override + public boolean addRadiusToKillWithin(Integer radiusToKillWithin) { + return radiiToKillWithin.add(radiusToKillWithin); + } + public void setRadiiToKillWithin(final LinkedList radiiToKillWithin) { this.radiiToKillWithin = radiiToKillWithin; } @@ -305,6 +404,11 @@ public class BukkitStage implements Stage { return killNames; } + @Override + public boolean addKillName(String killName) { + return killNames.add(killName); + } + public void setKillNames(final LinkedList killNames) { this.killNames = killNames; } @@ -313,6 +417,11 @@ public class BukkitStage implements Stage { return locationsToReach; } + @Override + public boolean addLocationToReach(Location locationToReach) { + return locationsToReach.add(locationToReach); + } + public void setLocationsToReach(final LinkedList locationsToReach) { this.locationsToReach = locationsToReach; } @@ -321,6 +430,11 @@ public class BukkitStage implements Stage { return radiiToReachWithin; } + @Override + public boolean addRadiusToReachWithin(Integer radiusToReachWithin) { + return radiiToReachWithin.add(radiusToReachWithin); + } + public void setRadiiToReachWithin(final LinkedList radiiToReachWithin) { this.radiiToReachWithin = radiiToReachWithin; } @@ -329,6 +443,11 @@ public class BukkitStage implements Stage { return worldsToReachWithin; } + @Override + public boolean addWorldToReachWithin(World worldToReachWithin) { + return worldsToReachWithin.add(worldToReachWithin); + } + public void setWorldsToReachWithin(final LinkedList worldsToReachWithin) { this.worldsToReachWithin = worldsToReachWithin; } @@ -337,6 +456,11 @@ public class BukkitStage implements Stage { return locationNames; } + @Override + public boolean addLocationName(String locationName) { + return locationNames.add(locationName); + } + public void setLocationNames(final LinkedList locationNames) { this.locationNames = locationNames; } @@ -345,6 +469,11 @@ public class BukkitStage implements Stage { return mobsToTame; } + @Override + public boolean addMobToTame(EntityType mobToTame) { + return mobsToTame.add(mobToTame); + } + public void setMobsToTame(final LinkedList mobsToTame) { this.mobsToTame = mobsToTame; } @@ -353,6 +482,11 @@ public class BukkitStage implements Stage { return mobNumToTame; } + @Override + public boolean addMobNumToTame(Integer mobNumToTame) { + return this.mobNumToTame.add(mobNumToTame); + } + public void setMobNumToTame(final LinkedList mobNumToTame) { this.mobNumToTame = mobNumToTame; } @@ -385,6 +519,11 @@ public class BukkitStage implements Stage { return sheepToShear; } + @Override + public boolean addSheepToShear(DyeColor sheepToShear) { + return this.sheepToShear.add(sheepToShear); + } + public void setSheepToShear(final LinkedList sheepToShear) { this.sheepToShear = sheepToShear; } @@ -393,6 +532,11 @@ public class BukkitStage implements Stage { return sheepNumToShear; } + @Override + public boolean addSheepNumToShear(Integer sheepNumToShear) { + return this.sheepNumToShear.add(sheepNumToShear); + } + public void setSheepNumToShear(final LinkedList sheepNumToShear) { this.sheepNumToShear = sheepNumToShear; } @@ -401,6 +545,11 @@ public class BukkitStage implements Stage { return passwordDisplays; } + @Override + public boolean addPasswordDisplay(String passwordDisplay) { + return passwordDisplays.add(passwordDisplay); + } + public void setPasswordDisplays(final LinkedList passwordDisplays) { this.passwordDisplays = passwordDisplays; } @@ -409,6 +558,11 @@ public class BukkitStage implements Stage { return passwordPhrases; } + @Override + public boolean addPasswordPhrase(String passwordPhrase) { + return passwordPhrases.add(passwordPhrase); + } + public void setPasswordPhrases(final LinkedList passwordPhrases) { this.passwordPhrases = passwordPhrases; } @@ -457,6 +611,11 @@ public class BukkitStage implements Stage { return chatActions; } + @Override + public void addChatAction(Entry chatAction) { + chatActions.put(chatAction.getKey(), chatAction.getValue()); + } + public void setChatActions(final Map chatActions) { this.chatActions = chatActions; } @@ -465,6 +624,11 @@ public class BukkitStage implements Stage { return commandActions; } + @Override + public void addCommandAction(Entry commandAction) { + commandActions.put(commandAction.getKey(), commandAction.getValue()); + } + public void setCommandActions(final Map commandActions) { this.commandActions = commandActions; } @@ -521,6 +685,11 @@ public class BukkitStage implements Stage { return objectiveOverrides; } + @Override + public boolean addObjectiveOverride(String objectiveOverride) { + return objectiveOverrides.add(objectiveOverride); + } + public void setObjectiveOverrides(final LinkedList objectiveOverrides) { this.objectiveOverrides = objectiveOverrides; } @@ -529,18 +698,34 @@ public class BukkitStage implements Stage { return customObjectives; } + public void clearCustomObjectives() { + customObjectives.clear(); + } + public LinkedList getCustomObjectiveCounts() { return customObjectiveCounts; } + public void clearCustomObjectiveCounts() { + customObjectiveCounts.clear(); + } + public LinkedList getCustomObjectiveDisplays() { return customObjectiveDisplays; } + public void clearCustomObjectiveDisplays() { + customObjectiveDisplays.clear(); + } + public LinkedList> getCustomObjectiveData() { return customObjectiveData; } + public void clearCustomObjectiveData() { + customObjectiveData.clear(); + } + /** * Check if stage has at least one objective

* diff --git a/core/src/main/java/me/blackvein/quests/storage/Storage.java b/core/src/main/java/me/blackvein/quests/storage/Storage.java index b5b051555..afba415ed 100644 --- a/core/src/main/java/me/blackvein/quests/storage/Storage.java +++ b/core/src/main/java/me/blackvein/quests/storage/Storage.java @@ -12,7 +12,7 @@ package me.blackvein.quests.storage; -import me.blackvein.quests.player.BukkitQuester; +import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.storage.implementation.StorageImplementation; @@ -85,11 +85,11 @@ public class Storage { } } - public CompletableFuture loadQuester(final UUID uniqueId) { + public CompletableFuture loadQuester(final UUID uniqueId) { return makeFuture(() -> implementation.loadQuester(uniqueId)); } - public CompletableFuture saveQuester(final BukkitQuester quester) { + public CompletableFuture saveQuester(final Quester quester) { return makeFuture(() -> { try { implementation.saveQuester(quester); @@ -102,7 +102,7 @@ public class Storage { public CompletableFuture saveOfflineQuesters() { return makeFuture(() -> { try { - for (BukkitQuester quester : plugin.getOfflineQuesters()) { + for (Quester quester : plugin.getOfflineQuesters()) { implementation.saveQuester(quester); } } catch (final Exception e) { diff --git a/core/src/main/java/me/blackvein/quests/storage/implementation/StorageImplementation.java b/core/src/main/java/me/blackvein/quests/storage/implementation/StorageImplementation.java index 01ae514d6..46f3e12d4 100644 --- a/core/src/main/java/me/blackvein/quests/storage/implementation/StorageImplementation.java +++ b/core/src/main/java/me/blackvein/quests/storage/implementation/StorageImplementation.java @@ -12,7 +12,7 @@ package me.blackvein.quests.storage.implementation; -import me.blackvein.quests.player.BukkitQuester; +import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import java.util.Collection; @@ -27,9 +27,9 @@ public interface StorageImplementation { void close(); - BukkitQuester loadQuester(UUID uniqueId) throws Exception; + Quester loadQuester(UUID uniqueId) throws Exception; - void saveQuester(BukkitQuester quester) throws Exception; + void saveQuester(Quester quester) throws Exception; void deleteQuester(UUID uniqueId) throws Exception; 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 a56ee2116..d823eddb6 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 @@ -12,10 +12,11 @@ package me.blackvein.quests.storage.implementation.file; -import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.player.BukkitQuester; +import me.blackvein.quests.Quest; +import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; -import me.blackvein.quests.quests.BukkitStage; +import me.blackvein.quests.Stage; +import me.blackvein.quests.player.BukkitQuester; import me.blackvein.quests.storage.implementation.StorageImplementation; import org.bukkit.OfflinePlayer; import org.bukkit.configuration.ConfigurationSection; @@ -65,9 +66,9 @@ public class SeparatedYamlStorage implements StorageImplementation { @SuppressWarnings("deprecation") @Override - public BukkitQuester loadQuester(final UUID uniqueId) throws Exception { + public Quester loadQuester(final UUID uniqueId) throws Exception { final FileConfiguration data = new YamlConfiguration(); - BukkitQuester quester = plugin.getQuester(uniqueId); + Quester quester = plugin.getQuester(uniqueId); if (quester != null) { quester.hardClear(); } else { @@ -87,7 +88,7 @@ public class SeparatedYamlStorage implements StorageImplementation { if (data.contains("completedRedoableQuests")) { final List questIds = data.getStringList("completedRedoableQuests"); final List questTimes = data.getLongList("completedQuestTimes"); - final ConcurrentHashMap completedTimes = quester.getCompletedTimes(); + final ConcurrentHashMap completedTimes = quester.getCompletedTimes(); for (int i = 0; i < questIds.size(); i++) { if (plugin.getQuestById(questIds.get(i)) != null) { completedTimes.put(plugin.getQuestById(questIds.get(i)), questTimes.get(i)); @@ -101,7 +102,7 @@ public class SeparatedYamlStorage implements StorageImplementation { if (data.contains("amountsCompletedQuests")) { final List questIds = data.getStringList("amountsCompletedQuests"); final List questAmounts = data.getIntegerList("amountsCompleted"); - final ConcurrentHashMap amountsCompleted = quester.getAmountsCompleted(); + final ConcurrentHashMap amountsCompleted = quester.getAmountsCompleted(); for (int i = 0; i < questIds.size(); i++) { if (plugin.getQuestById(questIds.get(i)) != null) { amountsCompleted.put(plugin.getQuestById(questIds.get(i)), questAmounts.get(i)); @@ -114,10 +115,10 @@ public class SeparatedYamlStorage implements StorageImplementation { } quester.setLastKnownName(data.getString("lastKnownName")); quester.setQuestPoints(data.getInt("quest-points")); - final ConcurrentSkipListSet completedQuests = quester.getCompletedQuests(); + final ConcurrentSkipListSet completedQuests = quester.getCompletedQuests(); if (data.isList("completed-Quests")) { for (final String s : data.getStringList("completed-Quests")) { - for (final BukkitQuest q : plugin.getLoadedQuests()) { + for (final Quest q : plugin.getLoadedQuests()) { if (q.getId().equals(s)) { if (!quester.getCompletedQuests().contains(q)) { completedQuests.add(q); @@ -138,7 +139,7 @@ public class SeparatedYamlStorage implements StorageImplementation { final List questIds = data.getStringList("currentQuests"); final List questStages = data.getIntegerList("currentStages"); final int maxSize = Math.min(questIds.size(), questStages.size()); - final ConcurrentHashMap currentQuests = quester.getCurrentQuests(); + final ConcurrentHashMap currentQuests = quester.getCurrentQuests(); for (int i = 0; i < maxSize; i++) { if (plugin.getQuestById(questIds.get(i)) != null) { currentQuests.put(plugin.getQuestById(questIds.get(i)), questStages.get(i)); @@ -154,11 +155,11 @@ public class SeparatedYamlStorage implements StorageImplementation { } for (final String key : dataSec.getKeys(false)) { final ConfigurationSection questSec = dataSec.getConfigurationSection(key); - final BukkitQuest quest = plugin.getQuestById(key) != null ? plugin.getQuestById(key) : plugin.getQuest(key); + final Quest quest = plugin.getQuestById(key) != null ? plugin.getQuestById(key) : plugin.getQuest(key); if (quest == null || !quester.getCurrentQuests().containsKey(quest)) { continue; } - final BukkitStage stage = quester.getCurrentStage(quest); + final Stage stage = quester.getCurrentStage(quest); if (stage == null) { quest.completeQuest(quester); plugin.getLogger().severe("[Quests] Invalid stage number for player: \"" + uniqueId + "\" on Quest \"" @@ -376,7 +377,7 @@ public class SeparatedYamlStorage implements StorageImplementation { } @Override - public void saveQuester(final BukkitQuester quester) throws Exception { + public void saveQuester(final Quester quester) throws Exception { final FileConfiguration data = quester.getBaseData(); try { data.save(new File(directoryPath + File.separator + quester.getUUID() + ".yml")); @@ -434,7 +435,7 @@ public class SeparatedYamlStorage implements StorageImplementation { * * @return file if exists, otherwise null */ - public File getDataFile(final BukkitQuester quester) { + public File getDataFile(final Quester quester) { File dataFile = new File(plugin.getDataFolder(), "data" + File.separator + quester.getUUID().toString() + ".yml"); if (!dataFile.exists()) { final OfflinePlayer p = quester.getOfflinePlayer(); diff --git a/core/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java b/core/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java index 8a0db535b..ebc87ac56 100644 --- a/core/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java +++ b/core/src/main/java/me/blackvein/quests/storage/implementation/sql/SqlStorage.java @@ -12,9 +12,9 @@ package me.blackvein.quests.storage.implementation.sql; -import me.blackvein.quests.quests.BukkitQuest; +import me.blackvein.quests.Quest; import me.blackvein.quests.QuestData; -import me.blackvein.quests.player.BukkitQuester; +import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; import me.blackvein.quests.storage.implementation.StorageImplementation; import me.blackvein.quests.storage.implementation.sql.connection.ConnectionFactory; @@ -221,8 +221,8 @@ public class SqlStorage implements StorageImplementation { } @Override - public BukkitQuester loadQuester(final UUID uniqueId) throws Exception { - final BukkitQuester quester = plugin.getQuester(uniqueId); + public Quester loadQuester(final UUID uniqueId) throws Exception { + final Quester quester = plugin.getQuester(uniqueId); if (quester == null) { return null; } @@ -248,21 +248,21 @@ public class SqlStorage implements StorageImplementation { } @Override - public void saveQuester(final BukkitQuester quester) throws Exception { + public void saveQuester(final Quester quester) throws Exception { final UUID uniqueId = quester.getUUID(); final String lastKnownName = quester.getLastKnownName(); final String oldLastKnownName = getQuesterLastKnownName(uniqueId); - final Set currentQuests = quester.getCurrentQuests().keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); - final Set oldCurrentQuests = getQuesterCurrentQuests(uniqueId).keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); + final Set currentQuests = quester.getCurrentQuests().keySet().stream().map(Quest::getId).collect(Collectors.toSet()); + final Set oldCurrentQuests = getQuesterCurrentQuests(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet()); oldCurrentQuests.removeAll(currentQuests); - final Set completedQuests = quester.getCompletedQuests().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); - final Set oldCompletedQuests = getQuesterCompletedQuests(uniqueId).stream().map(BukkitQuest::getId).collect(Collectors.toSet()); + final Set completedQuests = quester.getCompletedQuests().stream().map(Quest::getId).collect(Collectors.toSet()); + final Set oldCompletedQuests = getQuesterCompletedQuests(uniqueId).stream().map(Quest::getId).collect(Collectors.toSet()); oldCompletedQuests.removeAll(completedQuests); - final Set redoableQuests = quester.getCompletedTimes().keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); - final Set oldRedoableQuests = getQuesterCompletedTimes(uniqueId).keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); + final Set redoableQuests = quester.getCompletedTimes().keySet().stream().map(Quest::getId).collect(Collectors.toSet()); + final Set oldRedoableQuests = getQuesterCompletedTimes(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet()); oldRedoableQuests.removeAll(redoableQuests); - final Set questData = quester.getQuestData().keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); - final Set oldQuestData = getQuesterQuestData(uniqueId).keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); + final Set questData = quester.getQuestData().keySet().stream().map(Quest::getId).collect(Collectors.toSet()); + final Set oldQuestData = getQuesterQuestData(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet()); oldQuestData.removeAll(questData); try (final Connection c = connectionFactory.getConnection()) { @@ -290,7 +290,7 @@ public class SqlStorage implements StorageImplementation { } } } else { - for (final Entry entry : quester.getCurrentQuests().entrySet()) { + for (final Entry entry : quester.getCurrentQuests().entrySet()) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_CURRENT_QUESTS_INSERT))) { ps.setString(1, uniqueId.toString()); ps.setString(2, entry.getKey().getId()); @@ -309,7 +309,7 @@ public class SqlStorage implements StorageImplementation { } } } else { - for (final BukkitQuest quest : quester.getCompletedQuests()) { + for (final Quest quest : quester.getCompletedQuests()) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_INSERT))) { ps.setString(1, uniqueId.toString()); ps.setString(2, quest.getId()); @@ -327,7 +327,7 @@ public class SqlStorage implements StorageImplementation { } } } else { - for (final Entry entry : quester.getCompletedTimes().entrySet()) { + for (final Entry entry : quester.getCompletedTimes().entrySet()) { final int amount = quester.getAmountsCompleted().get(entry.getKey()); try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_INSERT))) { ps.setString(1, uniqueId.toString()); @@ -348,7 +348,7 @@ public class SqlStorage implements StorageImplementation { } } } else { - for (final Entry entry : quester.getQuestData().entrySet()) { + for (final Entry entry : quester.getQuestData().entrySet()) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_QUEST_DATA_INSERT))) { ps.setString(1, uniqueId.toString()); ps.setString(2, entry.getKey().getId()); @@ -424,14 +424,14 @@ public class SqlStorage implements StorageImplementation { return null; } - public ConcurrentHashMap getQuesterCurrentQuests(final UUID uniqueId) throws Exception { - final ConcurrentHashMap currentQuests = new ConcurrentHashMap<>(); + public ConcurrentHashMap getQuesterCurrentQuests(final UUID uniqueId) throws Exception { + final ConcurrentHashMap currentQuests = new ConcurrentHashMap<>(); try (final Connection c = connectionFactory.getConnection()) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_CURRENT_QUESTS_SELECT_BY_UUID))) { ps.setString(1, uniqueId.toString()); try (final ResultSet rs = ps.executeQuery()) { while (rs.next()) { - final BukkitQuest quest = plugin.getQuestById(rs.getString("questid")); + final Quest quest = plugin.getQuestById(rs.getString("questid")); if (quest != null) { currentQuests.put(quest, rs.getInt("stageNum")); } @@ -442,15 +442,15 @@ public class SqlStorage implements StorageImplementation { return currentQuests; } - public ConcurrentHashMap getQuesterQuestData(final UUID uniqueId) throws Exception { - final BukkitQuester quester = plugin.getQuester(uniqueId); - final ConcurrentHashMap questData = new ConcurrentHashMap<>(); + public ConcurrentHashMap getQuesterQuestData(final UUID uniqueId) throws Exception { + final Quester quester = plugin.getQuester(uniqueId); + final ConcurrentHashMap questData = new ConcurrentHashMap<>(); try (final Connection c = connectionFactory.getConnection()) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_QUEST_DATA_SELECT_BY_UUID))) { ps.setString(1, uniqueId.toString()); try (final ResultSet rs = ps.executeQuery()) { while (rs.next()) { - final BukkitQuest quest = plugin.getQuestById(rs.getString("quest_id")); + final Quest quest = plugin.getQuestById(rs.getString("quest_id")); final QuestData data = new QuestData(quester); if (quest != null && quester.getCurrentStage(quest) != null) { data.blocksBroken.addAll(deserializeItemStackProgress(rs.getString("blocks_broken"), @@ -497,14 +497,14 @@ public class SqlStorage implements StorageImplementation { return questData; } - public ConcurrentSkipListSet getQuesterCompletedQuests(final UUID uniqueId) throws Exception { - final ConcurrentSkipListSet completedQuests = new ConcurrentSkipListSet<>(); + public ConcurrentSkipListSet getQuesterCompletedQuests(final UUID uniqueId) throws Exception { + final ConcurrentSkipListSet completedQuests = new ConcurrentSkipListSet<>(); try (final Connection c = connectionFactory.getConnection()) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_SELECT_BY_UUID))) { ps.setString(1, uniqueId.toString()); try (final ResultSet rs = ps.executeQuery()) { while (rs.next()) { - final BukkitQuest quest = plugin.getQuestById(rs.getString("questid")); + final Quest quest = plugin.getQuestById(rs.getString("questid")); if (quest != null) { completedQuests.add(quest); } @@ -515,14 +515,14 @@ public class SqlStorage implements StorageImplementation { return completedQuests; } - public ConcurrentHashMap getQuesterCompletedTimes(final UUID uniqueId) throws Exception { - final ConcurrentHashMap completedTimes = new ConcurrentHashMap<>(); + public ConcurrentHashMap getQuesterCompletedTimes(final UUID uniqueId) throws Exception { + final ConcurrentHashMap completedTimes = new ConcurrentHashMap<>(); try (final Connection c = connectionFactory.getConnection()) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID))) { ps.setString(1, uniqueId.toString()); try (final ResultSet rs = ps.executeQuery()) { while (rs.next()) { - final BukkitQuest quest = plugin.getQuestById(rs.getString("questid")); + final Quest quest = plugin.getQuestById(rs.getString("questid")); if (quest != null) { completedTimes.put(quest, rs.getLong("lasttime")); } @@ -533,14 +533,14 @@ public class SqlStorage implements StorageImplementation { return completedTimes; } - public ConcurrentHashMap getQuesterAmountsCompleted(final UUID uniqueId) throws Exception { - final ConcurrentHashMap amountsCompleted = new ConcurrentHashMap<>(); + public ConcurrentHashMap getQuesterAmountsCompleted(final UUID uniqueId) throws Exception { + final ConcurrentHashMap amountsCompleted = new ConcurrentHashMap<>(); try (final Connection c = connectionFactory.getConnection()) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID))) { ps.setString(1, uniqueId.toString()); try (final ResultSet rs = ps.executeQuery()) { while (rs.next()) { - final BukkitQuest quest = plugin.getQuestById(rs.getString("questid")); + final Quest quest = plugin.getQuestById(rs.getString("questid")); if (quest != null) { amountsCompleted.put(quest, rs.getInt("amount")); } diff --git a/core/src/main/java/me/blackvein/quests/tasks/ActionTimer.java b/core/src/main/java/me/blackvein/quests/tasks/ActionTimer.java index d04a16a96..5595c1344 100644 --- a/core/src/main/java/me/blackvein/quests/tasks/ActionTimer.java +++ b/core/src/main/java/me/blackvein/quests/tasks/ActionTimer.java @@ -12,21 +12,20 @@ package me.blackvein.quests.tasks; +import me.blackvein.quests.Quest; +import me.blackvein.quests.Quester; +import me.blackvein.quests.util.Lang; import org.bukkit.ChatColor; import org.bukkit.scheduler.BukkitRunnable; -import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.player.BukkitQuester; -import me.blackvein.quests.util.Lang; - public class ActionTimer extends BukkitRunnable { - private final BukkitQuester quester; - private final BukkitQuest quest; + private final Quester quester; + private final Quest quest; private final int time; private final boolean last; - public ActionTimer(final BukkitQuester quester, final BukkitQuest quest, final int time, final boolean last) { + public ActionTimer(final Quester quester, final Quest quest, final int time, final boolean last) { this.quester = quester; this.quest = quest; this.time = time; diff --git a/core/src/main/java/me/blackvein/quests/tasks/StageTimer.java b/core/src/main/java/me/blackvein/quests/tasks/StageTimer.java index 3295f99ab..391049c8e 100644 --- a/core/src/main/java/me/blackvein/quests/tasks/StageTimer.java +++ b/core/src/main/java/me/blackvein/quests/tasks/StageTimer.java @@ -12,17 +12,17 @@ package me.blackvein.quests.tasks; -import me.blackvein.quests.quests.BukkitQuest; -import me.blackvein.quests.player.BukkitQuester; +import me.blackvein.quests.Quest; +import me.blackvein.quests.Quester; import me.blackvein.quests.Quests; public class StageTimer implements Runnable { - private final BukkitQuester quester; + private final Quester quester; private final Quests plugin; - private final BukkitQuest quest; + private final Quest quest; - public StageTimer(final Quests plugin, final BukkitQuester quester, final BukkitQuest quest) { + public StageTimer(final Quests plugin, final Quester quester, final Quest quest) { this.quester = quester; this.quest = quest; this.plugin = plugin; diff --git a/core/src/main/java/me/blackvein/quests/util/ConfigUtil.java b/core/src/main/java/me/blackvein/quests/util/ConfigUtil.java index f27e8905a..1326327e2 100644 --- a/core/src/main/java/me/blackvein/quests/util/ConfigUtil.java +++ b/core/src/main/java/me/blackvein/quests/util/ConfigUtil.java @@ -13,7 +13,7 @@ package me.blackvein.quests.util; import me.blackvein.quests.Dependencies; -import me.blackvein.quests.quests.BukkitQuest; +import me.blackvein.quests.Quest; import me.clip.placeholderapi.PlaceholderAPI; import net.citizensnpcs.api.npc.NPC; import org.bukkit.Bukkit; @@ -100,7 +100,7 @@ public class ConfigUtil { + loc.getZ(); } - public static String[] parseStringWithPossibleLineBreaks(final String s, final BukkitQuest quest, final Player player) { + public static String[] parseStringWithPossibleLineBreaks(final String s, final Quest quest, final Player player) { String parsed = parseString(s); if (parsed.contains("")) { if (quest.getNpcStart() != null) { @@ -115,7 +115,7 @@ public class ConfigUtil { return parsed.split("\n"); } - public static String[] parseStringWithPossibleLineBreaks(final String s, final BukkitQuest quest) { + public static String[] parseStringWithPossibleLineBreaks(final String s, final Quest quest) { String parsed = parseString(s); if (parsed.contains("")) { if (quest.getNpcStart() != null) { @@ -135,7 +135,7 @@ public class ConfigUtil { return parsed.split("\n"); } - public static String parseString(final String s, final BukkitQuest quest) { + public static String parseString(final String s, final Quest quest) { String parsed = parseString(s); if (parsed.contains("")) { if (quest.getNpcStart() != null) { @@ -147,7 +147,7 @@ public class ConfigUtil { return parsed; } - public static String parseString(final String s, final BukkitQuest quest, final Player player) { + public static String parseString(final String s, final Quest quest, final Player player) { String parsed = parseString(s, quest); if (Dependencies.placeholder != null && player != null) { parsed = PlaceholderAPI.setPlaceholders(player, parsed);