Refactor to core module, part 2

This commit is contained in:
PikaMug 2022-01-12 15:10:01 -05:00
parent 7656f6ace6
commit b45ca9b8d3
47 changed files with 1569 additions and 767 deletions

View File

@ -1,4 +1,16 @@
package me.blackvein.quests; package me.blackvein.quests;
import me.blackvein.quests.enums.ObjectiveType;
import org.bukkit.inventory.ItemStack;
public interface Objective { public interface Objective {
ObjectiveType getType();
int getProgress();
int getGoal();
ItemStack getItemProgress();
ItemStack getItemGoal();
} }

View File

@ -1,4 +1,39 @@
package me.blackvein.quests; package me.blackvein.quests;
public interface Options { 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);
} }

View File

@ -1,4 +1,20 @@
package me.blackvein.quests; package me.blackvein.quests;
public interface Planner { 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);
} }

View File

@ -3,54 +3,77 @@ package me.blackvein.quests;
import me.blackvein.quests.actions.Action; import me.blackvein.quests.actions.Action;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.LinkedList; import java.util.LinkedList;
public interface Quest { public interface Quest extends Comparable<Quest> {
public String getId(); 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<Stage> getStages(); LinkedList<Stage> 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);
} }

View File

@ -12,7 +12,6 @@
package me.blackvein.quests; package me.blackvein.quests;
import me.blackvein.quests.player.BukkitQuester;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Collection; import java.util.Collection;
@ -23,9 +22,9 @@ import java.util.LinkedList;
*/ */
public class QuestData { public class QuestData {
private final BukkitQuester quester; private final Quester quester;
public QuestData(final BukkitQuester quester) { public QuestData(final Quester quester) {
this.quester = quester; this.quester = quester;
} }

View File

@ -0,0 +1,4 @@
package me.blackvein.quests;
public interface QuestFactory {
}

View File

@ -1,63 +1,228 @@
package me.blackvein.quests; 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.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet; import java.util.concurrent.ConcurrentSkipListSet;
import java.util.function.BiFunction;
import java.util.function.Function;
public interface Quester { public interface Quester extends Comparable<Quester> {
public UUID getUUID(); 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 * Get compass target quest. Returns null if not set
* *
* @return Quest or null * @return Quest or null
*/ */
public Quest getCompassTarget(); Quest getCompassTarget();
/** /**
* Set compass target quest. Does not update in-game * Set compass target quest. Does not update in-game
* *
* @param quest The target quest * @param quest The target quest
*/ */
public void setCompassTarget(final Quest quest); void setCompassTarget(final Quest quest);
public ConcurrentHashMap<Integer, Quest> getTimers(); ConcurrentHashMap<Integer, Quest> getTimers();
public void setTimers(final ConcurrentHashMap<Integer, Quest> timers); void setTimers(final ConcurrentHashMap<Integer, Quest> timers);
public void removeTimer(final Integer timerId); void removeTimer(final Integer timerId);
public ConcurrentHashMap<Quest, Integer> getCurrentQuests(); ConcurrentHashMap<Quest, Integer> getCurrentQuests();
public void setCurrentQuests(final ConcurrentHashMap<Quest, Integer> currentQuests); void setCurrentQuests(final ConcurrentHashMap<Quest, Integer> currentQuests);
public ConcurrentSkipListSet<Quest> getCompletedQuests(); ConcurrentSkipListSet<Quest> getCompletedQuests();
public void setCompletedQuests(final ConcurrentSkipListSet<Quest> completedQuests); void setCompletedQuests(final ConcurrentSkipListSet<Quest> completedQuests);
public ConcurrentHashMap<Quest, Long> getCompletedTimes(); ConcurrentHashMap<Quest, Long> getCompletedTimes();
public void setCompletedTimes(final ConcurrentHashMap<Quest, Long> completedTimes); void setCompletedTimes(final ConcurrentHashMap<Quest, Long> completedTimes);
public ConcurrentHashMap<Quest, Integer> getAmountsCompleted(); ConcurrentHashMap<Quest, Integer> getAmountsCompleted();
public void setAmountsCompleted(final ConcurrentHashMap<Quest, Integer> amountsCompleted); void setAmountsCompleted(final ConcurrentHashMap<Quest, Integer> amountsCompleted);
public ConcurrentHashMap<Quest, QuestData> getQuestData(); ConcurrentHashMap<Quest, QuestData> getQuestData();
public void setQuestData(final ConcurrentHashMap<Quest, QuestData> questData); void setQuestData(final ConcurrentHashMap<Quest, QuestData> 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<String> getCurrentRequirements(final Quest quest, final boolean ignoreOverrides);
LinkedList<String> getCurrentObjectives(final Quest quest, final boolean ignoreOverrides);
LinkedList<String> 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<Enchantment, Integer> 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<Quest> 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<String> dispatchMultiplayerEverything(final Quest quest, final ObjectiveType type,
final BiFunction<Quester, Quest, Void> fun);
Set<String> dispatchMultiplayerObjectives(final Quest quest, final Stage currentStage,
final Function<Quester, Void> fun);
List<Quester> 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);
} }

View File

@ -1,6 +1,8 @@
package me.blackvein.quests; package me.blackvein.quests;
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; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -13,110 +15,164 @@ import java.util.Map;
public interface Stage { public interface Stage {
LinkedList<ItemStack> getBlocksToBreak(); LinkedList<ItemStack> getBlocksToBreak();
boolean addBlockToBreak(ItemStack blockToBreak);
void setBlocksToBreak(final LinkedList<ItemStack> blocksToBreak); void setBlocksToBreak(final LinkedList<ItemStack> blocksToBreak);
LinkedList<ItemStack> getBlocksToDamage(); LinkedList<ItemStack> getBlocksToDamage();
boolean addBlockToDamage(ItemStack blockToDamage);
void setBlocksToDamage(final LinkedList<ItemStack> blocksToDamage); void setBlocksToDamage(final LinkedList<ItemStack> blocksToDamage);
LinkedList<ItemStack> getBlocksToPlace(); LinkedList<ItemStack> getBlocksToPlace();
boolean addBlockToPlace(ItemStack blockToPlace);
void setBlocksToPlace(final LinkedList<ItemStack> blocksToPlace); void setBlocksToPlace(final LinkedList<ItemStack> blocksToPlace);
LinkedList<ItemStack> getBlocksToUse(); LinkedList<ItemStack> getBlocksToUse();
boolean addBlockToUse(ItemStack blockToUse);
void setBlocksToUse(final LinkedList<ItemStack> blocksToUse); void setBlocksToUse(final LinkedList<ItemStack> blocksToUse);
LinkedList<ItemStack> getBlocksToCut(); LinkedList<ItemStack> getBlocksToCut();
boolean addBlockToCut(ItemStack blockToCut);
void setBlocksToCut(final LinkedList<ItemStack> blocksToCut); void setBlocksToCut(final LinkedList<ItemStack> blocksToCut);
LinkedList<ItemStack> getItemsToCraft(); LinkedList<ItemStack> getItemsToCraft();
boolean addItemToCraft(ItemStack itemToCraft);
void setItemsToCraft(final LinkedList<ItemStack> itemsToCraft); void setItemsToCraft(final LinkedList<ItemStack> itemsToCraft);
LinkedList<ItemStack> getItemsToSmelt(); LinkedList<ItemStack> getItemsToSmelt();
boolean addItemToSmelt(ItemStack itemToSmelt);
void setItemsToSmelt(final LinkedList<ItemStack> itemsToSmelt); void setItemsToSmelt(final LinkedList<ItemStack> itemsToSmelt);
LinkedList<ItemStack> getItemsToEnchant(); LinkedList<ItemStack> getItemsToEnchant();
boolean addItemToEnchant(ItemStack itemToEnchant);
void setItemsToEnchant(final LinkedList<ItemStack> itemsToEnchant); void setItemsToEnchant(final LinkedList<ItemStack> itemsToEnchant);
LinkedList<ItemStack> getItemsToBrew(); LinkedList<ItemStack> getItemsToBrew();
boolean addItemsToBrew(ItemStack itemToBrew);
void setItemsToBrew(final LinkedList<ItemStack> itemsToBrew); void setItemsToBrew(final LinkedList<ItemStack> itemsToBrew);
LinkedList<ItemStack> getItemsToConsume(); LinkedList<ItemStack> getItemsToConsume();
boolean addItemToConsume(ItemStack itemToConsume);
void setItemsToConsume(final LinkedList<ItemStack> itemsToConsume); void setItemsToConsume(final LinkedList<ItemStack> itemsToConsume);
LinkedList<ItemStack> getItemsToDeliver(); LinkedList<ItemStack> getItemsToDeliver();
boolean addItemToDeliver(ItemStack itemToDeliver);
void setItemsToDeliver(final LinkedList<ItemStack> itemsToDeliver); void setItemsToDeliver(final LinkedList<ItemStack> itemsToDeliver);
LinkedList<Integer> getItemDeliveryTargets(); LinkedList<Integer> getItemDeliveryTargets();
boolean addItemDeliveryTarget(Integer itemDeliveryTarget);
void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets); void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets);
LinkedList<String> getDeliverMessages(); LinkedList<String> getDeliverMessages();
boolean addDeliverMessage(String deliverMessage);
void setDeliverMessages(final LinkedList<String> deliverMessages); void setDeliverMessages(final LinkedList<String> deliverMessages);
LinkedList<Integer> getCitizensToInteract(); LinkedList<Integer> getCitizensToInteract();
boolean addCitizenToInteract(Integer citizenToInteract);
void setCitizensToInteract(final LinkedList<Integer> citizensToInteract); void setCitizensToInteract(final LinkedList<Integer> citizensToInteract);
LinkedList<Integer> getCitizensToKill(); LinkedList<Integer> getCitizensToKill();
boolean addCitizenToKill(Integer citizenToKill);
void setCitizensToKill(final LinkedList<Integer> citizensToKill); void setCitizensToKill(final LinkedList<Integer> citizensToKill);
LinkedList<Integer> getCitizenNumToKill(); LinkedList<Integer> getCitizenNumToKill();
boolean addCitizenNumToKill(Integer citizenNumToKill);
void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill); void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill);
LinkedList<EntityType> getMobsToKill(); LinkedList<EntityType> getMobsToKill();
boolean addMobToKill(EntityType mobToKill);
void setMobsToKill(final LinkedList<EntityType> mobsToKill); void setMobsToKill(final LinkedList<EntityType> mobsToKill);
LinkedList<Integer> getMobNumToKill(); LinkedList<Integer> getMobNumToKill();
boolean addMobNumToKill(Integer mobNumToKill);
void setMobNumToKill(final LinkedList<Integer> mobNumToKill); void setMobNumToKill(final LinkedList<Integer> mobNumToKill);
LinkedList<Location> getLocationsToKillWithin(); LinkedList<Location> getLocationsToKillWithin();
boolean addLocationToKillWithin(Location locationToKillWithin);
void setLocationsToKillWithin(final LinkedList<Location> locationsToKillWithin); void setLocationsToKillWithin(final LinkedList<Location> locationsToKillWithin);
LinkedList<Integer> getRadiiToKillWithin(); LinkedList<Integer> getRadiiToKillWithin();
boolean addRadiusToKillWithin(Integer radiusToKillWithin);
void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin); void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin);
LinkedList<String> getKillNames(); LinkedList<String> getKillNames();
boolean addKillName(String killName);
void setKillNames(final LinkedList<String> killNames); void setKillNames(final LinkedList<String> killNames);
LinkedList<Location> getLocationsToReach(); LinkedList<Location> getLocationsToReach();
boolean addLocationToReach(Location locationToReach);
void setLocationsToReach(final LinkedList<Location> locationsToReach); void setLocationsToReach(final LinkedList<Location> locationsToReach);
LinkedList<Integer> getRadiiToReachWithin(); LinkedList<Integer> getRadiiToReachWithin();
boolean addRadiusToReachWithin(Integer radiusToReachWithin);
void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin); void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin);
LinkedList<World> getWorldsToReachWithin(); LinkedList<World> getWorldsToReachWithin();
boolean addWorldToReachWithin(World worldToReachWithin);
void setWorldsToReachWithin(final LinkedList<World> worldsToReachWithin); void setWorldsToReachWithin(final LinkedList<World> worldsToReachWithin);
LinkedList<String> getLocationNames(); LinkedList<String> getLocationNames();
boolean addLocationName(String locationName);
void setLocationNames(final LinkedList<String> locationNames); void setLocationNames(final LinkedList<String> locationNames);
LinkedList<EntityType> getMobsToTame(); LinkedList<EntityType> getMobsToTame();
boolean addMobToTame(EntityType mobToTame);
void setMobsToTame(final LinkedList<EntityType> mobsToTame); void setMobsToTame(final LinkedList<EntityType> mobsToTame);
LinkedList<Integer> getMobNumToTame(); LinkedList<Integer> getMobNumToTame();
boolean addMobNumToTame(Integer mobNumToTame);
void setMobNumToTame(final LinkedList<Integer> mobNumToTame); void setMobNumToTame(final LinkedList<Integer> mobNumToTame);
Integer getFishToCatch(); Integer getFishToCatch();
@ -133,18 +189,26 @@ public interface Stage {
LinkedList<DyeColor> getSheepToShear(); LinkedList<DyeColor> getSheepToShear();
boolean addSheepToShear(DyeColor sheepToShear);
void setSheepToShear(final LinkedList<DyeColor> sheepToShear); void setSheepToShear(final LinkedList<DyeColor> sheepToShear);
LinkedList<Integer> getSheepNumToShear(); LinkedList<Integer> getSheepNumToShear();
boolean addSheepNumToShear(Integer sheepNumToShear);
void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear); void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear);
LinkedList<String> getPasswordDisplays(); LinkedList<String> getPasswordDisplays();
boolean addPasswordDisplay(String passwordDisplay);
void setPasswordDisplays(final LinkedList<String> passwordDisplays); void setPasswordDisplays(final LinkedList<String> passwordDisplays);
LinkedList<String> getPasswordPhrases(); LinkedList<String> getPasswordPhrases();
boolean addPasswordPhrase(String passwordPhrase);
void setPasswordPhrases(final LinkedList<String> passwordPhrases); void setPasswordPhrases(final LinkedList<String> passwordPhrases);
String getScript(); String getScript();
@ -169,10 +233,14 @@ public interface Stage {
Map<String, Action> getChatActions(); Map<String, Action> getChatActions();
void addChatAction(Map.Entry<String, Action> chatAction);
void setChatActions(final Map<String, Action> chatActions); void setChatActions(final Map<String, Action> chatActions);
Map<String, Action> getCommandActions(); Map<String, Action> getCommandActions();
void addCommandAction(Map.Entry<String, Action> commandAction);
void setCommandActions(final Map<String, Action> commandActions); void setCommandActions(final Map<String, Action> commandActions);
Action getDisconnectAction(); Action getDisconnectAction();
@ -201,16 +269,26 @@ public interface Stage {
LinkedList<String> getObjectiveOverrides(); LinkedList<String> getObjectiveOverrides();
boolean addObjectiveOverride(String objectiveOverride);
void setObjectiveOverrides(final LinkedList<String> objectiveOverrides); void setObjectiveOverrides(final LinkedList<String> objectiveOverrides);
LinkedList<CustomObjective> getCustomObjectives(); LinkedList<CustomObjective> getCustomObjectives();
void clearCustomObjectives();
LinkedList<Integer> getCustomObjectiveCounts(); LinkedList<Integer> getCustomObjectiveCounts();
void clearCustomObjectiveCounts();
LinkedList<String> getCustomObjectiveDisplays(); LinkedList<String> getCustomObjectiveDisplays();
void clearCustomObjectiveDisplays();
LinkedList<Map.Entry<String, Object>> getCustomObjectiveData(); LinkedList<Map.Entry<String, Object>> getCustomObjectiveData();
void clearCustomObjectiveData();
/** /**
* Check if stage has at least one objective<p> * Check if stage has at least one objective<p>
* *

View File

@ -2,6 +2,7 @@ package me.blackvein.quests.actions;
import me.blackvein.quests.Quest; import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester; import me.blackvein.quests.Quester;
import me.blackvein.quests.entity.QuestMob;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;

View File

@ -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<UUID, Block> getSelectedExplosionLocations();
void setSelectedExplosionLocations(final Map<UUID, Block> selectedExplosionLocations);
Map<UUID, Block> getSelectedEffectLocations();
void setSelectedEffectLocations(final Map<UUID, Block> selectedEffectLocations);
Map<UUID, Block> getSelectedMobLocations();
void setSelectedMobLocations(final Map<UUID, Block> selectedMobLocations);
Map<UUID, Block> getSelectedLightningLocations();
void setSelectedLightningLocations(final Map<UUID, Block> selectedLightningLocations);
Map<UUID, Block> getSelectedTeleportLocations();
void setSelectedTeleportLocations(final Map<UUID, Block> selectedTeleportLocations);
ConversationFactory getConversationFactory();
List<String> getNamesOfActionsBeingEdited();
void setNamesOfActionsBeingEdited(final List<String> 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);
}

View File

@ -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<String> getEntitiesWhileRiding();
void setEntitiesWhileRiding(final LinkedList<String> entitiesWhileRiding);
LinkedList<Integer> getNpcsWhileRiding();
void setNpcsWhileRiding(final LinkedList<Integer> npcsWhileRiding);
LinkedList<String> getPermissions();
void setPermissions(final LinkedList<String> permissions);
LinkedList<ItemStack> getItemsWhileHoldingMainHand();
void setItemsWhileHoldingMainHand(final LinkedList<ItemStack> itemsWhileHoldingMainHand);
LinkedList<String> getWorldsWhileStayingWithin();
void setWorldsWhileStayingWithin(final LinkedList<String> worldsWhileStayingWithin);
LinkedList<String> getBiomesWhileStayingWithin();
void setBiomesWhileStayingWithin(final LinkedList<String> biomesWhileStayingWithin);
LinkedList<String> getRegionsWhileStayingWithin();
void setRegionsWhileStayingWithin(final LinkedList<String> biomesWhileStayingWithin);
LinkedList<String> getPlaceholdersCheckIdentifier();
void setPlaceholdersCheckIdentifier(final LinkedList<String> placeholdersCheckIdentifier);
LinkedList<String> getPlaceholdersCheckValue();
void setPlaceholdersCheckValue(final LinkedList<String> placeholdersCheckValue);
boolean check(final Quester quester, final Quest quest);
}

View File

@ -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<String> getNamesOfConditionsBeingEdited();
void setNamesOfConditionsBeingEdited(final List<String> 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);
}

View File

@ -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();
}

View File

@ -12,10 +12,9 @@
package me.blackvein.quests.events.editor.actions; package me.blackvein.quests.events.editor.actions;
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class ActionsEditorPostOpenStringPromptEvent extends ActionsEditorEvent { public class ActionsEditorPostOpenStringPromptEvent extends ActionsEditorEvent {

View File

@ -12,15 +12,13 @@
package me.blackvein.quests; package me.blackvein.quests;
import me.blackvein.quests.player.BukkitQuester;
public class DenizenTrigger { public class DenizenTrigger {
private final Quests plugin; private final Quests plugin;
public DenizenTrigger(final Quests plugin) { public DenizenTrigger(final Quests plugin) {
this.plugin = 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) { if (scriptName == null) {
return false; return false;
} }

File diff suppressed because it is too large Load Diff

View File

@ -11,10 +11,10 @@
*/ */
package me.blackvein.quests.actions; package me.blackvein.quests.actions;
import me.blackvein.quests.quests.BukkitQuest; import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestMob; import me.blackvein.quests.Quester;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.entity.QuestMob;
import me.blackvein.quests.tasks.ActionTimer; import me.blackvein.quests.tasks.ActionTimer;
import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.InventoryUtil; import me.blackvein.quests.util.InventoryUtil;
@ -31,7 +31,7 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
public class BukkitAction implements Comparable<BukkitAction> { public class BukkitAction implements Action, Comparable<BukkitAction> {
private final Quests plugin; private final Quests plugin;
private String name = ""; private String name = "";
@ -88,191 +88,237 @@ public class BukkitAction implements Comparable<BukkitAction> {
return name.compareTo(action.getName()); return name.compareTo(action.getName());
} }
@Override
public String getName() { public String getName() {
return name; return name;
} }
@Override
public void setName(final String name) { public void setName(final String name) {
this.name = name; this.name = name;
} }
@Override
public String getMessage() { public String getMessage() {
return message; return message;
} }
@Override
public void setMessage(final String message) { public void setMessage(final String message) {
this.message = message; this.message = message;
} }
@Override
public boolean isClearInv() { public boolean isClearInv() {
return clearInv; return clearInv;
} }
@Override
public void setClearInv(final boolean clearInv) { public void setClearInv(final boolean clearInv) {
this.clearInv = clearInv; this.clearInv = clearInv;
} }
@Override
public boolean isFailQuest() { public boolean isFailQuest() {
return failQuest; return failQuest;
} }
@Override
public void setFailQuest(final boolean failQuest) { public void setFailQuest(final boolean failQuest) {
this.failQuest = failQuest; this.failQuest = failQuest;
} }
@Override
public LinkedList<Location> getExplosions() { public LinkedList<Location> getExplosions() {
return explosions; return explosions;
} }
@Override
public void setExplosions(final LinkedList<Location> explosions) { public void setExplosions(final LinkedList<Location> explosions) {
this.explosions = explosions; this.explosions = explosions;
} }
@Override
public Map<Location, Effect> getEffects() { public Map<Location, Effect> getEffects() {
return effects; return effects;
} }
@Override
public void setEffects(final Map<Location, Effect> effects) { public void setEffects(final Map<Location, Effect> effects) {
this.effects = effects; this.effects = effects;
} }
@Override
public LinkedList<ItemStack> getItems() { public LinkedList<ItemStack> getItems() {
return items; return items;
} }
@Override
public void setItems(final LinkedList<ItemStack> items) { public void setItems(final LinkedList<ItemStack> items) {
this.items = items; this.items = items;
} }
@Override
public World getStormWorld() { public World getStormWorld() {
return stormWorld; return stormWorld;
} }
@Override
public void setStormWorld(final World stormWorld) { public void setStormWorld(final World stormWorld) {
this.stormWorld = stormWorld; this.stormWorld = stormWorld;
} }
@Override
public int getStormDuration() { public int getStormDuration() {
return stormDuration; return stormDuration;
} }
@Override
public void setStormDuration(final int stormDuration) { public void setStormDuration(final int stormDuration) {
this.stormDuration = stormDuration; this.stormDuration = stormDuration;
} }
@Override
public World getThunderWorld() { public World getThunderWorld() {
return thunderWorld; return thunderWorld;
} }
@Override
public void setThunderWorld(final World thunderWorld) { public void setThunderWorld(final World thunderWorld) {
this.thunderWorld = thunderWorld; this.thunderWorld = thunderWorld;
} }
@Override
public int getThunderDuration() { public int getThunderDuration() {
return thunderDuration; return thunderDuration;
} }
@Override
public void setThunderDuration(final int thunderDuration) { public void setThunderDuration(final int thunderDuration) {
this.thunderDuration = thunderDuration; this.thunderDuration = thunderDuration;
} }
@Override
public int getTimer() { public int getTimer() {
return timer; return timer;
} }
@Override
public void setTimer(final int timer) { public void setTimer(final int timer) {
this.timer = timer; this.timer = timer;
} }
@Override
public boolean isCancelTimer() { public boolean isCancelTimer() {
return cancelTimer; return cancelTimer;
} }
@Override
public void setCancelTimer(final boolean cancelTimer) { public void setCancelTimer(final boolean cancelTimer) {
this.cancelTimer = cancelTimer; this.cancelTimer = cancelTimer;
} }
@Override
public LinkedList<QuestMob> getMobSpawns() { public LinkedList<QuestMob> getMobSpawns() {
return mobSpawns; return mobSpawns;
} }
@Override
public void setMobSpawns(final LinkedList<QuestMob> mobSpawns) { public void setMobSpawns(final LinkedList<QuestMob> mobSpawns) {
this.mobSpawns = mobSpawns; this.mobSpawns = mobSpawns;
} }
@Override
public LinkedList<Location> getLightningStrikes() { public LinkedList<Location> getLightningStrikes() {
return lightningStrikes; return lightningStrikes;
} }
@Override
public void setLightningStrikes(final LinkedList<Location> lightningStrikes) { public void setLightningStrikes(final LinkedList<Location> lightningStrikes) {
this.lightningStrikes = lightningStrikes; this.lightningStrikes = lightningStrikes;
} }
@Override
public LinkedList<String> getCommands() { public LinkedList<String> getCommands() {
return commands; return commands;
} }
@Override
public void setCommands(final LinkedList<String> commands) { public void setCommands(final LinkedList<String> commands) {
this.commands = commands; this.commands = commands;
} }
@Override
public LinkedList<PotionEffect> getPotionEffects() { public LinkedList<PotionEffect> getPotionEffects() {
return potionEffects; return potionEffects;
} }
@Override
public void setPotionEffects(final LinkedList<PotionEffect> potionEffects) { public void setPotionEffects(final LinkedList<PotionEffect> potionEffects) {
this.potionEffects = potionEffects; this.potionEffects = potionEffects;
} }
@Override
public int getHunger() { public int getHunger() {
return hunger; return hunger;
} }
@Override
public void setHunger(final int hunger) { public void setHunger(final int hunger) {
this.hunger = hunger; this.hunger = hunger;
} }
@Override
public int getSaturation() { public int getSaturation() {
return saturation; return saturation;
} }
@Override
public void setSaturation(final int saturation) { public void setSaturation(final int saturation) {
this.saturation = saturation; this.saturation = saturation;
} }
@Override
public float getHealth() { public float getHealth() {
return health; return health;
} }
@Override
public void setHealth(final float health) { public void setHealth(final float health) {
this.health = health; this.health = health;
} }
@Override
public Location getTeleport() { public Location getTeleport() {
return teleport; return teleport;
} }
@Override
public void setTeleport(final Location teleport) { public void setTeleport(final Location teleport) {
this.teleport = teleport; this.teleport = teleport;
} }
@Override
public String getBook() { public String getBook() {
return book; return book;
} }
@Override
public void setBook(final String book) { public void setBook(final String book) {
this.book = book; this.book = book;
} }
@Override
public String getDenizenScript() { public String getDenizenScript() {
return book; return book;
} }
@Override
public void setDenizenScript(final String scriptName) { public void setDenizenScript(final String scriptName) {
this.denizenScript = 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(); final Player player = quester.getPlayer();
if (message != null) { if (message != null) {
player.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(message, quest, player)); player.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(message, quest, player));
@ -406,7 +452,7 @@ public class BukkitAction implements Comparable<BukkitAction> {
.runTaskLater(plugin, timer * 20L).getTaskId(), quest); .runTaskLater(plugin, timer * 20L).getTaskId(), quest);
} }
if (cancelTimer) { if (cancelTimer) {
for (final Map.Entry<Integer, BukkitQuest> entry : quester.getTimers().entrySet()) { for (final Map.Entry<Integer, Quest> entry : quester.getTimers().entrySet()) {
if (entry.getValue().getName().equals(quest.getName())) { if (entry.getValue().getName().equals(quest.getName())) {
plugin.getServer().getScheduler().cancelTask(entry.getKey()); plugin.getServer().getScheduler().cancelTask(entry.getKey());
quester.getTimers().remove(entry.getKey()); quester.getTimers().remove(entry.getKey());

View File

@ -12,12 +12,13 @@
package me.blackvein.quests.actions; package me.blackvein.quests.actions;
import me.blackvein.quests.quests.BukkitQuest; import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestMob; import me.blackvein.quests.Quester;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.actions.main.ActionMainPrompt; import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
import me.blackvein.quests.convo.actions.menu.ActionMenuPrompt; 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.interfaces.ReloadCallback;
import me.blackvein.quests.util.CK; import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.ConfigUtil;
@ -53,7 +54,7 @@ import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
public class ActionFactory implements ConversationAbandonedListener { public class BukkitActionFactory implements ActionFactory, ConversationAbandonedListener {
private final Quests plugin; private final Quests plugin;
private final ConversationFactory conversationFactory; private final ConversationFactory conversationFactory;
@ -64,7 +65,7 @@ public class ActionFactory implements ConversationAbandonedListener {
private Map<UUID, Block> selectedTeleportLocations = new HashMap<>(); private Map<UUID, Block> selectedTeleportLocations = new HashMap<>();
private List<String> editingActionNames = new LinkedList<>(); private List<String> editingActionNames = new LinkedList<>();
public ActionFactory(final Quests plugin) { public BukkitActionFactory(final Quests plugin) {
this.plugin = plugin; this.plugin = plugin;
// Ensure to initialize factory last so that 'this' is fully initialized before it is passed // Ensure to initialize factory last so that 'this' is fully initialized before it is passed
this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false) this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
@ -151,68 +152,68 @@ public class ActionFactory implements ConversationAbandonedListener {
return new ActionMainPrompt(context); return new ActionMainPrompt(context);
} }
public void loadData(final BukkitAction event, final ConversationContext context) { public void loadData(final Action event, final ConversationContext context) {
if (event.message != null) { if (event.getMessage() != null) {
context.setSessionData(CK.E_MESSAGE, event.message); context.setSessionData(CK.E_MESSAGE, event.getMessage());
} }
if (event.clearInv) { if (event.isClearInv()) {
context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord")); context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord"));
} else { } else {
context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord")); context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord"));
} }
if (event.failQuest) { if (event.isFailQuest()) {
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord")); context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord"));
} else { } else {
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord")); context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord"));
} }
if (event.items != null && !event.items.isEmpty()) { if (event.getItems() != null && !event.getItems().isEmpty()) {
final LinkedList<ItemStack> items = new LinkedList<>(event.items); final LinkedList<ItemStack> items = new LinkedList<>(event.getItems());
context.setSessionData(CK.E_ITEMS, items); context.setSessionData(CK.E_ITEMS, items);
} }
if (event.explosions != null && !event.explosions.isEmpty()) { if (event.getExplosions() != null && !event.getExplosions().isEmpty()) {
final LinkedList<String> locs = new LinkedList<>(); final LinkedList<String> locs = new LinkedList<>();
for (final Location loc : event.explosions) { for (final Location loc : event.getExplosions()) {
locs.add(ConfigUtil.getLocationInfo(loc)); locs.add(ConfigUtil.getLocationInfo(loc));
} }
context.setSessionData(CK.E_EXPLOSIONS, locs); context.setSessionData(CK.E_EXPLOSIONS, locs);
} }
if (event.effects != null && !event.effects.isEmpty()) { if (event.getEffects() != null && !event.getEffects().isEmpty()) {
final LinkedList<String> locs = new LinkedList<>(); final LinkedList<String> locs = new LinkedList<>();
final LinkedList<String> effs = new LinkedList<>(); final LinkedList<String> effs = new LinkedList<>();
for (final Entry<Location, Effect> e : event.effects.entrySet()) { for (final Entry<Location, Effect> e : event.getEffects().entrySet()) {
locs.add(ConfigUtil.getLocationInfo(e.getKey())); locs.add(ConfigUtil.getLocationInfo(e.getKey()));
effs.add(e.getValue().toString()); effs.add(e.getValue().toString());
} }
context.setSessionData(CK.E_EFFECTS, effs); context.setSessionData(CK.E_EFFECTS, effs);
context.setSessionData(CK.E_EFFECTS_LOCATIONS, locs); context.setSessionData(CK.E_EFFECTS_LOCATIONS, locs);
} }
if (event.stormWorld != null) { if (event.getStormWorld() != null) {
context.setSessionData(CK.E_WORLD_STORM, event.stormWorld.getName()); context.setSessionData(CK.E_WORLD_STORM, event.getStormWorld().getName());
context.setSessionData(CK.E_WORLD_STORM_DURATION, event.stormDuration); context.setSessionData(CK.E_WORLD_STORM_DURATION, event.getStormDuration());
} }
if (event.thunderWorld != null) { if (event.getThunderWorld() != null) {
context.setSessionData(CK.E_WORLD_THUNDER, event.thunderWorld.getName()); context.setSessionData(CK.E_WORLD_THUNDER, event.getThunderWorld().getName());
context.setSessionData(CK.E_WORLD_THUNDER_DURATION, event.thunderDuration); 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<String> questMobs = new LinkedList<>(); final LinkedList<String> questMobs = new LinkedList<>();
for (final QuestMob questMob : event.mobSpawns) { for (final QuestMob questMob : event.getMobSpawns()) {
questMobs.add(questMob.serialize()); questMobs.add(questMob.serialize());
} }
context.setSessionData(CK.E_MOB_TYPES, questMobs); context.setSessionData(CK.E_MOB_TYPES, questMobs);
} }
if (event.lightningStrikes != null && !event.lightningStrikes.isEmpty()) { if (event.getLightningStrikes() != null && !event.getLightningStrikes().isEmpty()) {
final LinkedList<String> locs = new LinkedList<>(); final LinkedList<String> locs = new LinkedList<>();
for (final Location loc : event.lightningStrikes) { for (final Location loc : event.getLightningStrikes()) {
locs.add(ConfigUtil.getLocationInfo(loc)); locs.add(ConfigUtil.getLocationInfo(loc));
} }
context.setSessionData(CK.E_LIGHTNING, locs); context.setSessionData(CK.E_LIGHTNING, locs);
} }
if (event.potionEffects != null && !event.potionEffects.isEmpty()) { if (event.getPotionEffects() != null && !event.getPotionEffects().isEmpty()) {
final LinkedList<String> types = new LinkedList<>(); final LinkedList<String> types = new LinkedList<>();
final LinkedList<Long> durations = new LinkedList<>(); final LinkedList<Long> durations = new LinkedList<>();
final LinkedList<Integer> mags = new LinkedList<>(); final LinkedList<Integer> mags = new LinkedList<>();
for (final PotionEffect pe : event.potionEffects) { for (final PotionEffect pe : event.getPotionEffects()) {
types.add(pe.getType().getName()); types.add(pe.getType().getName());
durations.add((long) pe.getDuration()); durations.add((long) pe.getDuration());
mags.add(pe.getAmplifier()); 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_DURATIONS, durations);
context.setSessionData(CK.E_POTION_STRENGTH, mags); context.setSessionData(CK.E_POTION_STRENGTH, mags);
} }
if (event.hunger > -1) { if (event.getHunger() > -1) {
context.setSessionData(CK.E_HUNGER, event.hunger); context.setSessionData(CK.E_HUNGER, event.getHunger());
} }
if (event.saturation > -1) { if (event.getSaturation() > -1) {
context.setSessionData(CK.E_SATURATION, event.saturation); context.setSessionData(CK.E_SATURATION, event.getSaturation());
} }
if (event.health > -1) { if (event.getHealth() > -1) {
context.setSessionData(CK.E_HEALTH, event.health); context.setSessionData(CK.E_HEALTH, event.getHealth());
} }
if (event.teleport != null) { if (event.getTeleport() != null) {
context.setSessionData(CK.E_TELEPORT, ConfigUtil.getLocationInfo(event.teleport)); context.setSessionData(CK.E_TELEPORT, ConfigUtil.getLocationInfo(event.getTeleport()));
} }
if (event.commands != null) { if (event.getCommands() != null) {
context.setSessionData(CK.E_COMMANDS, event.commands); context.setSessionData(CK.E_COMMANDS, event.getCommands());
} }
if (event.timer > 0) { if (event.getTimer() > 0) {
context.setSessionData(CK.E_TIMER, event.timer); context.setSessionData(CK.E_TIMER, event.getTimer());
} }
if (event.cancelTimer) { if (event.isCancelTimer()) {
context.setSessionData(CK.E_CANCEL_TIMER, true); context.setSessionData(CK.E_CANCEL_TIMER, true);
} }
} }
@ -312,8 +313,8 @@ public class ActionFactory implements ConversationAbandonedListener {
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
plugin.getLogger().info(identifier + " deleted action " + action); plugin.getLogger().info(identifier + " deleted action " + action);
} }
for (final BukkitQuester q : plugin.getOfflineQuesters()) { for (final Quester q : plugin.getOfflineQuesters()) {
for (final BukkitQuest quest : q.getCurrentQuests().keySet()) { for (final Quest quest : q.getCurrentQuests().keySet()) {
q.checkQuest(quest); q.checkQuest(quest);
} }
} }
@ -387,7 +388,7 @@ public class ActionFactory implements ConversationAbandonedListener {
if (ss == null) { if (ss == null) {
ss = section.createSection("mob-spawns." + count); ss = section.createSection("mob-spawns." + count);
} }
final QuestMob questMob = QuestMob.fromString(s); final QuestMob questMob = BukkitQuestMob.fromString(s);
if (questMob.getName() != null) { if (questMob.getName() != null) {
ss.set("name", questMob.getName()); ss.set("name", questMob.getName());
} }
@ -469,8 +470,8 @@ public class ActionFactory implements ConversationAbandonedListener {
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
plugin.getLogger().info(identifier + " saved action " + context.getSessionData(CK.E_NAME)); plugin.getLogger().info(identifier + " saved action " + context.getSessionData(CK.E_NAME));
} }
for (final BukkitQuester q : plugin.getOfflineQuesters()) { for (final Quester q : plugin.getOfflineQuesters()) {
for (final BukkitQuest quest : q.getCurrentQuests().keySet()) { for (final Quest quest : q.getCurrentQuests().keySet()) {
q.checkQuest(quest); q.checkQuest(quest);
} }
} }

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.conditions; package me.blackvein.quests.conditions;
import me.blackvein.quests.quests.BukkitQuest; import me.blackvein.quests.Quest;
import me.blackvein.quests.player.BukkitQuester; import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.MiscUtil; import me.blackvein.quests.util.MiscUtil;
@ -24,7 +24,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Objects; import java.util.Objects;
public class Condition implements Comparable<Condition> { public class BukkitCondition implements Condition, Comparable<BukkitCondition> {
private final Quests plugin; private final Quests plugin;
private String name = ""; private String name = "";
@ -39,105 +39,128 @@ public class Condition implements Comparable<Condition> {
private LinkedList<String> placeholdersCheckIdentifier = new LinkedList<>(); private LinkedList<String> placeholdersCheckIdentifier = new LinkedList<>();
private LinkedList<String> placeholdersCheckValue = new LinkedList<>(); private LinkedList<String> placeholdersCheckValue = new LinkedList<>();
public Condition(final Quests plugin) { public BukkitCondition(final Quests plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public int compareTo(final Condition condition) { public int compareTo(final BukkitCondition condition) {
return name.compareTo(condition.getName()); return name.compareTo(condition.getName());
} }
@Override
public String getName() { public String getName() {
return name; return name;
} }
@Override
public void setName(final String name) { public void setName(final String name) {
this.name = name; this.name = name;
} }
@Override
public boolean isFailQuest() { public boolean isFailQuest() {
return failQuest; return failQuest;
} }
@Override
public void setFailQuest(final boolean failQuest) { public void setFailQuest(final boolean failQuest) {
this.failQuest = failQuest; this.failQuest = failQuest;
} }
@Override
public LinkedList<String> getEntitiesWhileRiding() { public LinkedList<String> getEntitiesWhileRiding() {
return entitiesWhileRiding; return entitiesWhileRiding;
} }
@Override
public void setEntitiesWhileRiding(final LinkedList<String> entitiesWhileRiding) { public void setEntitiesWhileRiding(final LinkedList<String> entitiesWhileRiding) {
this.entitiesWhileRiding = entitiesWhileRiding; this.entitiesWhileRiding = entitiesWhileRiding;
} }
@Override
public LinkedList<Integer> getNpcsWhileRiding() { public LinkedList<Integer> getNpcsWhileRiding() {
return npcsWhileRiding; return npcsWhileRiding;
} }
@Override
public void setNpcsWhileRiding(final LinkedList<Integer> npcsWhileRiding) { public void setNpcsWhileRiding(final LinkedList<Integer> npcsWhileRiding) {
this.npcsWhileRiding = npcsWhileRiding; this.npcsWhileRiding = npcsWhileRiding;
} }
@Override
public LinkedList<String> getPermissions() { public LinkedList<String> getPermissions() {
return permissions; return permissions;
} }
@Override
public void setPermissions(final LinkedList<String> permissions) { public void setPermissions(final LinkedList<String> permissions) {
this.permissions = permissions; this.permissions = permissions;
} }
@Override
public LinkedList<ItemStack> getItemsWhileHoldingMainHand() { public LinkedList<ItemStack> getItemsWhileHoldingMainHand() {
return itemsWhileHoldingMainHand; return itemsWhileHoldingMainHand;
} }
@Override
public void setItemsWhileHoldingMainHand(final LinkedList<ItemStack> itemsWhileHoldingMainHand) { public void setItemsWhileHoldingMainHand(final LinkedList<ItemStack> itemsWhileHoldingMainHand) {
this.itemsWhileHoldingMainHand = itemsWhileHoldingMainHand; this.itemsWhileHoldingMainHand = itemsWhileHoldingMainHand;
} }
@Override
public LinkedList<String> getWorldsWhileStayingWithin() { public LinkedList<String> getWorldsWhileStayingWithin() {
return worldsWhileStayingWithin; return worldsWhileStayingWithin;
} }
@Override
public void setWorldsWhileStayingWithin(final LinkedList<String> worldsWhileStayingWithin) { public void setWorldsWhileStayingWithin(final LinkedList<String> worldsWhileStayingWithin) {
this.worldsWhileStayingWithin = worldsWhileStayingWithin; this.worldsWhileStayingWithin = worldsWhileStayingWithin;
} }
@Override
public LinkedList<String> getBiomesWhileStayingWithin() { public LinkedList<String> getBiomesWhileStayingWithin() {
return biomesWhileStayingWithin; return biomesWhileStayingWithin;
} }
@Override
public void setBiomesWhileStayingWithin(final LinkedList<String> biomesWhileStayingWithin) { public void setBiomesWhileStayingWithin(final LinkedList<String> biomesWhileStayingWithin) {
this.biomesWhileStayingWithin = biomesWhileStayingWithin; this.biomesWhileStayingWithin = biomesWhileStayingWithin;
} }
@Override
public LinkedList<String> getRegionsWhileStayingWithin() { public LinkedList<String> getRegionsWhileStayingWithin() {
return regionsWhileStayingWithin; return regionsWhileStayingWithin;
} }
@Override
public void setRegionsWhileStayingWithin(final LinkedList<String> biomesWhileStayingWithin) { public void setRegionsWhileStayingWithin(final LinkedList<String> biomesWhileStayingWithin) {
this.regionsWhileStayingWithin = biomesWhileStayingWithin; this.regionsWhileStayingWithin = biomesWhileStayingWithin;
} }
@Override
public LinkedList<String> getPlaceholdersCheckIdentifier() { public LinkedList<String> getPlaceholdersCheckIdentifier() {
return placeholdersCheckIdentifier; return placeholdersCheckIdentifier;
} }
@Override
public void setPlaceholdersCheckIdentifier(final LinkedList<String> placeholdersCheckIdentifier) { public void setPlaceholdersCheckIdentifier(final LinkedList<String> placeholdersCheckIdentifier) {
this.placeholdersCheckIdentifier = placeholdersCheckIdentifier; this.placeholdersCheckIdentifier = placeholdersCheckIdentifier;
} }
@Override
public LinkedList<String> getPlaceholdersCheckValue() { public LinkedList<String> getPlaceholdersCheckValue() {
return placeholdersCheckValue; return placeholdersCheckValue;
} }
@Override
public void setPlaceholdersCheckValue(final LinkedList<String> placeholdersCheckValue) { public void setPlaceholdersCheckValue(final LinkedList<String> placeholdersCheckValue) {
this.placeholdersCheckValue = placeholdersCheckValue; this.placeholdersCheckValue = placeholdersCheckValue;
} }
@SuppressWarnings("deprecation") @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(); final Player player = quester.getPlayer();
if (!entitiesWhileRiding.isEmpty()) { if (!entitiesWhileRiding.isEmpty()) {
for (final String e : entitiesWhileRiding) { for (final String e : entitiesWhileRiding) {

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.conditions; package me.blackvein.quests.conditions;
import me.blackvein.quests.quests.BukkitQuest; import me.blackvein.quests.Quest;
import me.blackvein.quests.player.BukkitQuester; import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt; import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt;
import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt; import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt;
@ -43,13 +43,13 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
public class ConditionFactory implements ConversationAbandonedListener { public class BukkitConditionFactory implements ConditionFactory, ConversationAbandonedListener {
private final Quests plugin; private final Quests plugin;
private final ConversationFactory conversationFactory; private final ConversationFactory conversationFactory;
private List<String> editingConditionNames = new LinkedList<>(); private List<String> editingConditionNames = new LinkedList<>();
public ConditionFactory(final Quests plugin) { public BukkitConditionFactory(final Quests plugin) {
this.plugin = plugin; this.plugin = plugin;
// Ensure to initialize factory last so that 'this' is fully initialized before it is passed // Ensure to initialize factory last so that 'this' is fully initialized before it is passed
this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false) this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
@ -85,7 +85,7 @@ public class ConditionFactory implements ConversationAbandonedListener {
return new ConditionMainPrompt(context); 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()) { if (condition.isFailQuest()) {
context.setSessionData(CK.C_FAIL_QUEST, Lang.get("yesWord")); context.setSessionData(CK.C_FAIL_QUEST, Lang.get("yesWord"));
} else { } else {
@ -179,8 +179,8 @@ public class ConditionFactory implements ConversationAbandonedListener {
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
plugin.getLogger().info(identifier + " deleted condition " + condition); plugin.getLogger().info(identifier + " deleted condition " + condition);
} }
for (final BukkitQuester q : plugin.getOfflineQuesters()) { for (final Quester q : plugin.getOfflineQuesters()) {
for (final BukkitQuest quest : q.getCurrentQuests().keySet()) { for (final Quest quest : q.getCurrentQuests().keySet()) {
q.checkQuest(quest); q.checkQuest(quest);
} }
} }
@ -201,7 +201,7 @@ public class ConditionFactory implements ConversationAbandonedListener {
if (context.getSessionData(CK.C_OLD_CONDITION) != null if (context.getSessionData(CK.C_OLD_CONDITION) != null
&& !((String) Objects.requireNonNull(context.getSessionData(CK.C_OLD_CONDITION))).isEmpty()) { && !((String) Objects.requireNonNull(context.getSessionData(CK.C_OLD_CONDITION))).isEmpty()) {
data.set("conditions." + context.getSessionData(CK.C_OLD_CONDITION), null); data.set("conditions." + context.getSessionData(CK.C_OLD_CONDITION), null);
final Collection<Condition> temp = plugin.getLoadedConditions(); final Collection<BukkitCondition> temp = plugin.getLoadedConditions();
temp.remove(plugin.getCondition((String) context.getSessionData(CK.C_OLD_CONDITION))); temp.remove(plugin.getCondition((String) context.getSessionData(CK.C_OLD_CONDITION)));
plugin.setLoadedConditions(temp); plugin.setLoadedConditions(temp);
} }
@ -267,8 +267,8 @@ public class ConditionFactory implements ConversationAbandonedListener {
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
plugin.getLogger().info(identifier + " saved condition " + context.getSessionData(CK.C_NAME)); plugin.getLogger().info(identifier + " saved condition " + context.getSessionData(CK.C_NAME));
} }
for (final BukkitQuester q : plugin.getOfflineQuesters()) { for (final Quester q : plugin.getOfflineQuesters()) {
for (final BukkitQuest quest : q.getCurrentQuests().keySet()) { for (final Quest quest : q.getCurrentQuests().keySet()) {
q.checkQuest(quest); q.checkQuest(quest);
} }
} }

View File

@ -12,11 +12,10 @@
package me.blackvein.quests.convo.actions.main; package me.blackvein.quests.convo.actions.main;
import me.blackvein.quests.quests.BukkitQuest; import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestMob;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.quests.BukkitStage; import me.blackvein.quests.Stage;
import me.blackvein.quests.actions.BukkitAction; import me.blackvein.quests.actions.Action;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; 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.TimerPrompt;
import me.blackvein.quests.convo.actions.tasks.WeatherPrompt; import me.blackvein.quests.convo.actions.tasks.WeatherPrompt;
import me.blackvein.quests.convo.generic.ItemStackPrompt; 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.ActionsEditorPostOpenNumericPromptEvent;
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenStringPromptEvent; import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenStringPromptEvent;
import me.blackvein.quests.util.CK; import me.blackvein.quests.util.CK;
@ -147,7 +147,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
final StringBuilder text = new StringBuilder(); final StringBuilder text = new StringBuilder();
if (types != null) { if (types != null) {
for (final String s : types) { 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) text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA)
.append(qm.getType().name()) .append(qm.getType().name())
.append((qm.getName() != null) ? " (" + qm.getName() + ")" : "").append(ChatColor.GRAY) .append((qm.getName() != null) ? " (" + qm.getName() + ")" : "").append(ChatColor.GRAY)
@ -181,7 +181,8 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
@Override @Override
public @NotNull String getBasicPromptText(final @NotNull ConversationContext context) { 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); plugin.getServer().getPluginManager().callEvent(event);
final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": " final StringBuilder text = new StringBuilder(ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": "
@ -271,7 +272,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
return null; return null;
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final BukkitAction a : plugin.getLoadedActions()) { for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
return new ActionNamePrompt(context); return new ActionNamePrompt(context);
@ -352,7 +353,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
final StringBuilder text = new StringBuilder(); final StringBuilder text = new StringBuilder();
if (types != null) { if (types != null) {
for (final String type : types) { 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) text.append("\n").append(ChatColor.GRAY).append(" - ").append(ChatColor.AQUA)
.append(qm.getType().name()) .append(qm.getType().name())
.append((qm.getName() != null) ? " (" + qm.getName() + ")" : "") .append((qm.getName() != null) ? " (" + qm.getName() + ")" : "")
@ -404,11 +405,11 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
public class ActionMobPrompt extends ActionsEditorNumericPrompt { public class ActionMobPrompt extends ActionsEditorNumericPrompt {
private QuestMob questMob; private BukkitQuestMob questMob;
private Integer itemIndex = -1; private Integer itemIndex = -1;
private final Integer mobIndex; 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); super(context);
this.questMob = questMob; this.questMob = questMob;
this.mobIndex = mobIndex; this.mobIndex = mobIndex;
@ -549,7 +550,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
@Override @Override
public @NotNull String getBasicPromptText(final @NotNull ConversationContext context) { public @NotNull String getBasicPromptText(final @NotNull ConversationContext context) {
if (questMob == null) { if (questMob == null) {
questMob = new QuestMob(); questMob = new BukkitQuestMob();
} }
// Check/add newly made item // Check/add newly made item
if (context.getSessionData("tempStack") != null) { if (context.getSessionData("tempStack") != null) {
@ -656,10 +657,10 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
public class ActionMobNamePrompt extends ActionsEditorStringPrompt { public class ActionMobNamePrompt extends ActionsEditorStringPrompt {
private final QuestMob questMob; private final BukkitQuestMob questMob;
private final Integer mobIndex; 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); super(context);
this.questMob = questMob; this.questMob = questMob;
this.mobIndex = mobIndex; this.mobIndex = mobIndex;
@ -677,7 +678,8 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
@Override @Override
public @NotNull String getPromptText(final @NotNull ConversationContext context) { 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) { if (context.getPlugin() != null) {
context.getPlugin().getServer().getPluginManager().callEvent(event); context.getPlugin().getServer().getPluginManager().callEvent(event);
} }
@ -705,10 +707,10 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
public class ActionMobTypePrompt extends ActionsEditorStringPrompt { public class ActionMobTypePrompt extends ActionsEditorStringPrompt {
private final QuestMob questMob; private final BukkitQuestMob questMob;
private final Integer mobIndex; 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); super(context);
this.questMob = questMob; this.questMob = questMob;
this.mobIndex = mobIndex; this.mobIndex = mobIndex;
@ -768,10 +770,10 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
public class ActionMobAmountPrompt extends ActionsEditorStringPrompt { public class ActionMobAmountPrompt extends ActionsEditorStringPrompt {
private final QuestMob questMob; private final BukkitQuestMob questMob;
private final Integer mobIndex; 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); super(context);
this.questMob = questMob; this.questMob = questMob;
this.mobIndex = mobIndex; this.mobIndex = mobIndex;
@ -825,10 +827,10 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
public class ActionMobLocationPrompt extends ActionsEditorStringPrompt { public class ActionMobLocationPrompt extends ActionsEditorStringPrompt {
private final QuestMob questMob; private final BukkitQuestMob questMob;
private final Integer mobIndex; 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); super(context);
this.questMob = questMob; this.questMob = questMob;
this.mobIndex = mobIndex; this.mobIndex = mobIndex;
@ -887,11 +889,11 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
public class ActionMobDropPrompt extends ActionsEditorStringPrompt { public class ActionMobDropPrompt extends ActionsEditorStringPrompt {
private final QuestMob questMob; private final BukkitQuestMob questMob;
private final Integer mobIndex; private final Integer mobIndex;
private final Integer invIndex; 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); super(context);
this.questMob = questMob; this.questMob = questMob;
this.mobIndex = mobIndex; this.mobIndex = mobIndex;
@ -1013,8 +1015,8 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
super(context); super(context);
if (modifiedName != null) { if (modifiedName != null) {
modName = modifiedName; modName = modifiedName;
for (final BukkitQuest q : plugin.getLoadedQuests()) { for (final Quest q : plugin.getLoadedQuests()) {
for (final BukkitStage s : q.getStages()) { for (final Stage s : q.getStages()) {
if (s.getFinishAction() != null && s.getFinishAction().getName() != null) { if (s.getFinishAction() != null && s.getFinishAction().getName() != null) {
if (s.getFinishAction().getName().equalsIgnoreCase(modifiedName)) { if (s.getFinishAction().getName().equalsIgnoreCase(modifiedName)) {
modified.add(q.getName()); modified.add(q.getName());

View File

@ -12,10 +12,10 @@
package me.blackvein.quests.convo.actions.menu; 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;
import me.blackvein.quests.quests.BukkitStage; import me.blackvein.quests.Stage;
import me.blackvein.quests.actions.BukkitAction; import me.blackvein.quests.actions.Action;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
@ -186,7 +186,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
} }
input = input.trim(); input = input.trim();
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final BukkitAction a : plugin.getLoadedActions()) { for (final Action a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
return new ActionSelectCreatePrompt(context); return new ActionSelectCreatePrompt(context);
@ -236,7 +236,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
final ActionsEditorPostOpenStringPromptEvent event final ActionsEditorPostOpenStringPromptEvent event
= new ActionsEditorPostOpenStringPromptEvent(context, this); = new ActionsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedActions().stream().map(BukkitAction::getName).collect(Collectors.toList()); final List<String> names = plugin.getLoadedActions().stream().map(Action::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context); return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
} }
@ -246,7 +246,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
return null; return null;
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final BukkitAction a = plugin.getAction(input); final Action a = plugin.getAction(input);
if (a != null) { if (a != null) {
context.setSessionData(CK.E_OLD_EVENT, a.getName()); context.setSessionData(CK.E_OLD_EVENT, a.getName());
context.setSessionData(CK.E_NAME, a.getName()); context.setSessionData(CK.E_NAME, a.getName());
@ -282,7 +282,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
final ActionsEditorPostOpenStringPromptEvent event final ActionsEditorPostOpenStringPromptEvent event
= new ActionsEditorPostOpenStringPromptEvent(context, this); = new ActionsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedActions().stream().map(BukkitAction::getName).collect(Collectors.toList()); final List<String> names = plugin.getLoadedActions().stream().map(Action::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context); return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
} }
@ -293,10 +293,10 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final LinkedList<String> used = new LinkedList<String>(); final LinkedList<String> used = new LinkedList<String>();
final BukkitAction a = plugin.getAction(input); final Action a = plugin.getAction(input);
if (a != null) { if (a != null) {
for (final BukkitQuest quest : plugin.getLoadedQuests()) { for (final Quest quest : plugin.getLoadedQuests()) {
for (final BukkitStage stage : quest.getStages()) { for (final Stage stage : quest.getStages()) {
if (stage.getFinishAction() != null if (stage.getFinishAction() != null
&& stage.getFinishAction().getName().equalsIgnoreCase(a.getName())) { && stage.getFinishAction().getName().equalsIgnoreCase(a.getName())) {
used.add(quest.getName()); used.add(quest.getName());

View File

@ -12,10 +12,10 @@
package me.blackvein.quests.convo.conditions.main; 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;
import me.blackvein.quests.quests.BukkitStage; import me.blackvein.quests.Stage;
import me.blackvein.quests.conditions.Condition; import me.blackvein.quests.conditions.BukkitCondition;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt;
@ -204,14 +204,14 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
return null; return null;
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final Condition c : plugin.getLoadedConditions()) { for (final BukkitCondition c : plugin.getLoadedConditions()) {
if (c.getName().equalsIgnoreCase(input)) { if (c.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists"));
return new ConditionNamePrompt(context); return new ConditionNamePrompt(context);
} }
} }
final List<String> actionNames = plugin.getConditionFactory().getNamesOfConditionsBeingEdited(); final List<String> conditionNames = plugin.getConditionFactory().getNamesOfConditionsBeingEdited();
if (actionNames.contains(input)) { if (conditionNames.contains(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited"));
return new ConditionNamePrompt(context); return new ConditionNamePrompt(context);
} }
@ -219,10 +219,10 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
return new ConditionNamePrompt(context); 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); context.setSessionData(CK.C_NAME, input);
actionNames.add(input); conditionNames.add(input);
plugin.getConditionFactory().setNamesOfConditionsBeingEdited(actionNames); plugin.getConditionFactory().setNamesOfConditionsBeingEdited(conditionNames);
} }
return new ConditionMainPrompt(context); return new ConditionMainPrompt(context);
} }
@ -482,8 +482,8 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
super(context); super(context);
if (modifiedName != null) { if (modifiedName != null) {
modName = modifiedName; modName = modifiedName;
for (final BukkitQuest q : plugin.getLoadedQuests()) { for (final Quest q : plugin.getLoadedQuests()) {
for (final BukkitStage s : q.getStages()) { for (final Stage s : q.getStages()) {
if (s.getCondition() != null && s.getCondition().getName() != null) { if (s.getCondition() != null && s.getCondition().getName() != null) {
if (s.getCondition().getName().equalsIgnoreCase(modifiedName)) { if (s.getCondition().getName().equalsIgnoreCase(modifiedName)) {
modified.add(q.getName()); modified.add(q.getName());

View File

@ -15,7 +15,7 @@ package me.blackvein.quests.convo.conditions.menu;
import me.blackvein.quests.quests.BukkitQuest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.quests.BukkitStage; 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.QuestsNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorStringPrompt;
@ -185,7 +185,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
} }
input = input.trim(); input = input.trim();
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final Condition c : plugin.getLoadedConditions()) { for (final BukkitCondition c : plugin.getLoadedConditions()) {
if (c.getName().equalsIgnoreCase(input)) { if (c.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("conditionEditorExists"));
return new ConditionSelectCreatePrompt(context); return new ConditionSelectCreatePrompt(context);
@ -235,7 +235,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
final ConditionsEditorPostOpenStringPromptEvent event final ConditionsEditorPostOpenStringPromptEvent event
= new ConditionsEditorPostOpenStringPromptEvent(context, this); = new ConditionsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedConditions().stream().map(Condition::getName).collect(Collectors.toList()); final List<String> names = plugin.getLoadedConditions().stream().map(BukkitCondition::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context); return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
} }
@ -245,7 +245,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
return null; return null;
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final Condition c = plugin.getCondition(input); final BukkitCondition c = plugin.getCondition(input);
if (c != null) { if (c != null) {
context.setSessionData(CK.C_OLD_CONDITION, c.getName()); context.setSessionData(CK.C_OLD_CONDITION, c.getName());
context.setSessionData(CK.C_NAME, c.getName()); context.setSessionData(CK.C_NAME, c.getName());
@ -281,7 +281,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
final ConditionsEditorPostOpenStringPromptEvent event final ConditionsEditorPostOpenStringPromptEvent event
= new ConditionsEditorPostOpenStringPromptEvent(context, this); = new ConditionsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedConditions().stream().map(Condition::getName).collect(Collectors.toList()); final List<String> names = plugin.getLoadedConditions().stream().map(BukkitCondition::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context); return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
} }
@ -292,7 +292,7 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final LinkedList<String> used = new LinkedList<>(); final LinkedList<String> used = new LinkedList<>();
final Condition c = plugin.getCondition(input); final BukkitCondition c = plugin.getCondition(input);
if (c != null) { if (c != null) {
for (final BukkitQuest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final BukkitStage stage : quest.getStages()) { for (final BukkitStage stage : quest.getStages()) {

View File

@ -15,13 +15,13 @@ package me.blackvein.quests.convo.quests;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext; 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.Quests;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt { public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt {
private final ConversationContext context; private final ConversationContext context;
private QuestFactory factory; private BukkitQuestFactory factory;
public QuestsEditorNumericPrompt(final ConversationContext context) { public QuestsEditorNumericPrompt(final ConversationContext context) {
this.context = context; this.context = context;
@ -31,7 +31,7 @@ public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt {
} }
@Deprecated @Deprecated
public QuestsEditorNumericPrompt(final ConversationContext context, final QuestFactory factory) { public QuestsEditorNumericPrompt(final ConversationContext context, final BukkitQuestFactory factory) {
this.context = context; this.context = context;
this.factory = factory; this.factory = factory;
} }
@ -45,7 +45,7 @@ public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt {
return context; return context;
} }
public QuestFactory getQuestFactory() { public BukkitQuestFactory getQuestFactory() {
return factory; return factory;
} }

View File

@ -14,13 +14,13 @@ package me.blackvein.quests.convo.quests;
import org.bukkit.conversations.ConversationContext; 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.Quests;
import me.blackvein.quests.convo.QuestsStringPrompt; import me.blackvein.quests.convo.QuestsStringPrompt;
public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt { public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt {
private final ConversationContext context; private final ConversationContext context;
private QuestFactory factory; private BukkitQuestFactory factory;
public QuestsEditorStringPrompt(final ConversationContext context) { public QuestsEditorStringPrompt(final ConversationContext context) {
this.context = context; this.context = context;
@ -30,7 +30,7 @@ public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt {
} }
@Deprecated @Deprecated
public QuestsEditorStringPrompt(final ConversationContext context, final QuestFactory factory) { public QuestsEditorStringPrompt(final ConversationContext context, final BukkitQuestFactory factory) {
this.context = context; this.context = context;
this.factory = factory; this.factory = factory;
} }
@ -44,7 +44,7 @@ public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt {
return context; return context;
} }
public QuestFactory getQuestFactory() { public BukkitQuestFactory getQuestFactory() {
return factory; return factory;
} }

View File

@ -15,7 +15,7 @@ package me.blackvein.quests.convo.quests.stages;
import me.blackvein.quests.CustomObjective; import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.BukkitAction; 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.QuestsNumericPrompt;
import me.blackvein.quests.convo.generic.OverridePrompt; import me.blackvein.quests.convo.generic.OverridePrompt;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt; import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
@ -2058,7 +2058,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedConditions().isEmpty()) { if (plugin.getLoadedConditions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n"); text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n");
} else { } else {
for (final Condition c : plugin.getLoadedConditions()) { for (final BukkitCondition c : plugin.getLoadedConditions()) {
text.append(ChatColor.GREEN).append("- ").append(c.getName()).append("\n"); 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(); final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel")) if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) { && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Condition found = null; BukkitCondition found = null;
for (final Condition c : plugin.getLoadedConditions()) { for (final BukkitCondition c : plugin.getLoadedConditions()) {
if (c.getName().equalsIgnoreCase(input)) { if (c.getName().equalsIgnoreCase(input)) {
found = c; found = c;
break; break;

View File

@ -10,7 +10,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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.Bukkit;
import org.bukkit.Location; 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.ItemUtil;
import me.blackvein.quests.util.MiscUtil; import me.blackvein.quests.util.MiscUtil;
public class QuestMob { public class BukkitQuestMob implements QuestMob {
private String name = null; private String name = null;
private EntityType entityType = null; private EntityType entityType = null;
@ -33,10 +33,10 @@ public class QuestMob {
private ItemStack[] inventory = new ItemStack[5]; private ItemStack[] inventory = new ItemStack[5];
private Float[] dropChances = new Float[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.entityType = entityType;
this.spawnLocation = spawnLocation; this.spawnLocation = spawnLocation;
this.spawnAmounts = spawnAmounts; this.spawnAmounts = spawnAmounts;
@ -189,7 +189,7 @@ public class QuestMob {
return string; return string;
} }
public static QuestMob fromString(final String str) { public static BukkitQuestMob fromString(final String str) {
String name = null; String name = null;
EntityType entityType = null; EntityType entityType = null;
Location loc = 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.setName(name);
qm.inventory = inventory; qm.inventory = inventory;
qm.dropChances = dropChances; qm.dropChances = dropChances;

View File

@ -12,17 +12,17 @@
package me.blackvein.quests.exceptions; package me.blackvein.quests.exceptions;
import me.blackvein.quests.quests.BukkitQuest; import me.blackvein.quests.Quest;
public class StageFormatException extends Exception { public class StageFormatException extends Exception {
private static final long serialVersionUID = -8217391053042612896L; private static final long serialVersionUID = -8217391053042612896L;
private final String message; private final String message;
private final BukkitQuest quest; private final Quest quest;
private final int stage; 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); super(message + ", see quest " + quest.getName() + " stage " + stage);
this.message = message + ", see quest " + quest.getName() + " stage " + stage; this.message = message + ", see quest " + quest.getName() + " stage " + stage;
this.quest = quest; this.quest = quest;
@ -44,7 +44,7 @@ public class StageFormatException extends Exception {
* *
* @return The quest that an invalid stage id was set within. * @return The quest that an invalid stage id was set within.
*/ */
public BukkitQuest getQuest() { public Quest getQuest() {
return quest; return quest;
} }

View File

@ -20,19 +20,18 @@ import com.codisimus.plugins.phatloots.loot.LootBundle;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.characters.Hero; 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.CustomRequirement;
import me.blackvein.quests.CustomReward; import me.blackvein.quests.CustomReward;
import me.blackvein.quests.Dependencies; import me.blackvein.quests.Dependencies;
import me.blackvein.quests.Options; import me.blackvein.quests.Options;
import me.blackvein.quests.Planner; import me.blackvein.quests.Planner;
import me.blackvein.quests.Quest; import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.Requirements; import me.blackvein.quests.Requirements;
import me.blackvein.quests.Rewards; import me.blackvein.quests.Rewards;
import me.blackvein.quests.Stage; import me.blackvein.quests.Stage;
import me.blackvein.quests.player.BukkitQuester; import me.blackvein.quests.actions.Action;
import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.BukkitAction; import me.blackvein.quests.actions.BukkitAction;
import me.blackvein.quests.conditions.Condition; import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.events.quest.QuestUpdateCompassEvent; import me.blackvein.quests.events.quest.QuestUpdateCompassEvent;
@ -70,9 +69,10 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class BukkitQuest implements Quest, Comparable<BukkitQuest> { public class BukkitQuest implements Quest {
protected Quests plugin; protected Quests plugin;
protected String id; protected String id;
@ -81,7 +81,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
protected String finished; protected String finished;
protected ItemStack guiDisplay = null; protected ItemStack guiDisplay = null;
private final LinkedList<Stage> orderedStages = new LinkedList<>(); private final LinkedList<Stage> orderedStages = new LinkedList<>();
protected NPC npcStart; protected UUID npcStart;
protected Location blockStart; protected Location blockStart;
protected String regionStart = null; protected String regionStart = null;
protected BukkitAction initialAction; protected BukkitAction initialAction;
@ -91,15 +91,29 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
private final BukkitOptions options = new BukkitOptions(); private final BukkitOptions options = new BukkitOptions();
@Override @Override
public int compareTo(final BukkitQuest quest) { public int compareTo(final Quest quest) {
return id.compareTo(quest.getId()); return id.compareTo(quest.getId());
} }
public Quests getPlugin() {
return plugin;
}
public void setPlugin(Quests plugin) {
this.plugin = plugin;
}
@Override @Override
public String getId() { public String getId() {
return id; return id;
} }
public void setId(String id) {
if (plugin != null) {
this.id = id;
}
}
@Override @Override
public String getName() { public String getName() {
return name; return name;
@ -166,12 +180,15 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
@Override @Override
public NPC getNpcStart() { public NPC getNpcStart() {
return npcStart; if (CitizensAPI.getNPCRegistry().getByUniqueId(npcStart) != null) {
return CitizensAPI.getNPCRegistry().getByUniqueId(npcStart);
}
return null;
} }
@Override @Override
public void setNpcStart(final NPC npcStart) { public void setNpcStart(final NPC npcStart) {
this.npcStart = npcStart; this.npcStart = npcStart.getUniqueId();
} }
@Override @Override
@ -186,7 +203,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
@Override @Override
public Action getInitialAction() { public Action getInitialAction() {
return (Action) initialAction; return initialAction;
} }
@Override @Override
@ -220,7 +237,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
* @param quester Player to force * @param quester Player to force
* @param allowSharedProgress Whether to distribute progress to fellow questers * @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); final Stage currentStage = quester.getCurrentStage(this);
if (currentStage == null) { if (currentStage == null) {
plugin.getLogger().severe("Current stage was null for quester " + quester.getPlayer().getUniqueId()); plugin.getLogger().severe("Current stage was null for quester " + quester.getPlayer().getUniqueId());
@ -256,8 +273,8 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
// Multiplayer // Multiplayer
if (allowSharedProgress && options.getShareProgressLevel() == 3) { if (allowSharedProgress && options.getShareProgressLevel() == 3) {
final List<BukkitQuester> mq = quester.getMultiplayerQuesters(this); final List<Quester> mq = quester.getMultiplayerQuesters(this);
for (final BukkitQuester qq : mq) { for (final Quester qq : mq) {
if (currentStage.equals(qq.getCurrentStage(this))) { if (currentStage.equals(qq.getCurrentStage(this))) {
nextStage(qq, true); nextStage(qq, true);
} }
@ -276,7 +293,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
* @param stage Stage number to specify * @param stage Stage number to specify
* @throws IndexOutOfBoundsException if stage does not exist * @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(); final OfflinePlayer player = quester.getOfflinePlayer();
if (orderedStages.size() - 1 < stage) { if (orderedStages.size() - 1 < stage) {
final String msg = "Tried to set invalid stage number of " + stage + " for quest " + getName() + " on " 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<BukkitQuest> {
Location targetLocation = null; Location targetLocation = null;
if (stage.getCitizensToInteract() != null && stage.getCitizensToInteract().size() > 0) { if (stage.getCitizensToInteract() != null && stage.getCitizensToInteract().size() > 0) {
targetLocation = plugin.getDependencies().getNPCLocation(stage.getCitizensToInteract().getFirst()); targetLocation = plugin.getDependencies().getNPCLocation(stage.getCitizensToInteract().getFirst());
} else if (stage.citizensToKill != null && stage.citizensToKill.size() > 0) { } else if (stage.getCitizensToKill() != null && stage.getCitizensToKill().size() > 0) {
targetLocation = plugin.getDependencies().getNPCLocation(stage.citizensToKill.getFirst()); targetLocation = plugin.getDependencies().getNPCLocation(stage.getCitizensToKill().getFirst());
} else if (stage.locationsToReach != null && stage.locationsToReach.size() > 0) { } else if (stage.getLocationsToReach() != null && stage.getLocationsToReach().size() > 0) {
targetLocation = stage.locationsToReach.getFirst(); targetLocation = stage.getLocationsToReach().getFirst();
} else if (stage.itemDeliveryTargets != null && stage.itemDeliveryTargets.size() > 0) { } else if (stage.getItemDeliveryTargets() != null && stage.getItemDeliveryTargets().size() > 0) {
final NPC npc = plugin.getDependencies().getCitizens().getNPCRegistry().getById(stage.itemDeliveryTargets final NPC npc = plugin.getDependencies().getCitizens().getNPCRegistry().getById(stage
.getFirst()); .getItemDeliveryTargets().getFirst());
targetLocation = npc.getStoredLocation(); 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(); final Location source = quester.getPlayer().getLocation();
Location nearest = null; Location nearest = null;
double old_distance = 30000000; double old_distance = 30000000;
@ -440,11 +457,11 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
if (nearest != null) { if (nearest != null) {
targetLocation = nearest; 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(); final Location source = quester.getPlayer().getLocation();
Location nearest = null; Location nearest = null;
double old_distance = 30000000; double old_distance = 30000000;
final EntityType et = stage.mobsToKill.getFirst(); final EntityType et = stage.getMobsToKill().getFirst();
if (source.getWorld() == null) { if (source.getWorld() == null) {
return; return;
} }
@ -461,11 +478,11 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
if (nearest != null) { if (nearest != null) {
targetLocation = nearest; 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(); final Location source = quester.getPlayer().getLocation();
Location nearest = null; Location nearest = null;
double old_distance = 30000000; double old_distance = 30000000;
final EntityType et = stage.mobsToTame.getFirst(); final EntityType et = stage.getMobsToTame().getFirst();
if (source.getWorld() == null) { if (source.getWorld() == null) {
return; return;
} }
@ -482,11 +499,11 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
if (nearest != null) { if (nearest != null) {
targetLocation = nearest; 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(); final Location source = quester.getPlayer().getLocation();
Location nearest = null; Location nearest = null;
double old_distance = 30000000; double old_distance = 30000000;
final DyeColor dc = stage.sheepToShear.getFirst(); final DyeColor dc = stage.getSheepToShear().getFirst();
if (source.getWorld() == null) { if (source.getWorld() == null) {
return; return;
} }
@ -532,7 +549,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
* @param quester The quester to check * @param quester The quester to check
* @return true if all Requirements have been met * @return true if all Requirements have been met
*/ */
public boolean testRequirements(final BukkitQuester quester) { public boolean testRequirements(final Quester quester) {
return testRequirements(quester.getOfflinePlayer()); return testRequirements(quester.getOfflinePlayer());
} }
@ -544,8 +561,8 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
* @param player The player to check * @param player The player to check
* @return true if all Requirements have been met * @return true if all Requirements have been met
*/ */
protected boolean testRequirements(final OfflinePlayer player) { public boolean testRequirements(final OfflinePlayer player) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId()); final Quester quester = plugin.getQuester(player.getUniqueId());
if (requirements.getMoney() != 0 && plugin.getDependencies().getVaultEconomy() != null) { if (requirements.getMoney() != 0 && plugin.getDependencies().getVaultEconomy() != null) {
if (plugin.getDependencies().getVaultEconomy().getBalance(player) < requirements.getMoney()) { if (plugin.getDependencies().getVaultEconomy().getBalance(player) < requirements.getMoney()) {
return false; return false;
@ -622,7 +639,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
* *
* @param quester The quester finishing this quest * @param quester The quester finishing this quest
*/ */
public void completeQuest(final BukkitQuester quester) { public void completeQuest(final Quester quester) {
completeQuest(quester, true); completeQuest(quester, true);
} }
@ -633,7 +650,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
* @param allowMultiplayer Allow multiplayer sharing * @param allowMultiplayer Allow multiplayer sharing
*/ */
@SuppressWarnings("deprecation") @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(); final OfflinePlayer player = quester.getOfflinePlayer();
boolean cancelled = false; boolean cancelled = false;
if (player.isOnline()) { if (player.isOnline()) {
@ -664,7 +681,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
} }
quester.hardQuit(this); quester.hardQuit(this);
quester.getCompletedQuests().add(this); quester.getCompletedQuests().add(this);
for (final Map.Entry<Integer, BukkitQuest> entry : quester.getTimers().entrySet()) { for (final Map.Entry<Integer, Quest> entry : quester.getTimers().entrySet()) {
if (entry.getValue().getName().equals(getName())) { if (entry.getValue().getName().equals(getName())) {
plugin.getServer().getScheduler().cancelTask(entry.getKey()); plugin.getServer().getScheduler().cancelTask(entry.getKey());
quester.getTimers().remove(entry.getKey()); quester.getTimers().remove(entry.getKey());
@ -1079,8 +1096,8 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
// Multiplayer // Multiplayer
if (allowMultiplayer && options.getShareProgressLevel() == 4) { if (allowMultiplayer && options.getShareProgressLevel() == 4) {
final List<BukkitQuester> mq = quester.getMultiplayerQuesters(this); final List<Quester> mq = quester.getMultiplayerQuesters(this);
for (final BukkitQuester qq : mq) { for (final Quester qq : mq) {
if (qq.getQuestData(this) != null) { if (qq.getQuestData(this) != null) {
completeQuest(qq, false); completeQuest(qq, false);
} }
@ -1093,7 +1110,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
* *
* @param quester The quester to be ejected * @param quester The quester to be ejected
*/ */
public void failQuest(final BukkitQuester quester) { public void failQuest(final Quester quester) {
failQuest(quester, false); failQuest(quester, false);
} }
@ -1103,8 +1120,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
* @param quester The quester to be ejected * @param quester The quester to be ejected
* @param ignoreFailAction Whether to ignore quest fail Action * @param ignoreFailAction Whether to ignore quest fail Action
*/ */
@SuppressWarnings("deprecation") public void failQuest(final Quester quester, final boolean ignoreFailAction) {
public void failQuest(final BukkitQuester quester, final boolean ignoreFailAction) {
final QuesterPreFailQuestEvent preEvent = new QuesterPreFailQuestEvent(quester, this); final QuesterPreFailQuestEvent preEvent = new QuesterPreFailQuestEvent(quester, this);
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) { if (preEvent.isCancelled()) {
@ -1132,12 +1148,12 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
/** /**
* Checks if quester is in WorldGuard region start * Checks if quester is in WorldGuard region start
* *
* @deprecated Use {@link #isInRegionStart(BukkitQuester)} * @deprecated Use {@link #isInRegionStart(Quester)}
* @param quester The quester to check * @param quester The quester to check
* @return true if quester is in region * @return true if quester is in region
*/ */
@Deprecated @Deprecated
public boolean isInRegion(final BukkitQuester quester) { public boolean isInRegion(final Quester quester) {
return isInRegionStart(quester); return isInRegionStart(quester);
} }
@ -1160,7 +1176,7 @@ public class BukkitQuest implements Quest, Comparable<BukkitQuest> {
* @param quester The quester to check * @param quester The quester to check
* @return true if quester is in region * @return true if quester is in region
*/ */
public boolean isInRegionStart(final BukkitQuester quester) { public boolean isInRegionStart(final Quester quester) {
return isInRegionStart(quester.getPlayer()); return isInRegionStart(quester.getPlayer());
} }

View File

@ -10,18 +10,21 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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.main.QuestMainPrompt;
import me.blackvein.quests.convo.quests.menu.QuestMenuPrompt; import me.blackvein.quests.convo.quests.menu.QuestMenuPrompt;
import me.blackvein.quests.convo.quests.stages.StageMenuPrompt; import me.blackvein.quests.convo.quests.stages.StageMenuPrompt;
import me.blackvein.quests.interfaces.ReloadCallback; 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.CK;
import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.FakeConversable; import me.blackvein.quests.util.FakeConversable;
@ -59,7 +62,7 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class QuestFactory implements ConversationAbandonedListener { public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedListener {
private final Quests plugin; private final Quests plugin;
private final ConversationFactory conversationFactory; private final ConversationFactory conversationFactory;
@ -69,7 +72,7 @@ public class QuestFactory implements ConversationAbandonedListener {
private Set<UUID> selectingNpcs = new HashSet<>(); private Set<UUID> selectingNpcs = new HashSet<>();
private List<String> editingQuestNames = new LinkedList<>(); private List<String> editingQuestNames = new LinkedList<>();
public QuestFactory(final Quests plugin) { public BukkitQuestFactory(final Quests plugin) {
this.plugin = plugin; this.plugin = plugin;
// Ensure to initialize factory last so that 'this' is fully initialized before it is passed // Ensure to initialize factory last so that 'this' is fully initialized before it is passed
this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false) this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
@ -182,7 +185,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (q.getGUIDisplay() != null) { if (q.getGUIDisplay() != null) {
context.setSessionData(CK.Q_GUIDISPLAY, q.getGUIDisplay()); context.setSessionData(CK.Q_GUIDISPLAY, q.getGUIDisplay());
} }
final BukkitRequirements requirements = q.getRequirements(); final Requirements requirements = q.getRequirements();
if (requirements.getMoney() != 0) { if (requirements.getMoney() != 0) {
context.setSessionData(CK.REQ_MONEY, requirements.getMoney()); context.setSessionData(CK.REQ_MONEY, requirements.getMoney());
} }
@ -194,11 +197,11 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems()); context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems());
} }
if (!requirements.getNeededQuests().isEmpty()) { if (!requirements.getNeededQuests().isEmpty()) {
final List<String> ids = requirements.getNeededQuests().stream().map(BukkitQuest::getId).collect(Collectors.toList()); final List<String> ids = requirements.getNeededQuests().stream().map(Quest::getId).collect(Collectors.toList());
context.setSessionData(CK.REQ_QUEST, ids); context.setSessionData(CK.REQ_QUEST, ids);
} }
if (!requirements.getBlockQuests().isEmpty()) { if (!requirements.getBlockQuests().isEmpty()) {
final List<String> ids = requirements.getBlockQuests().stream().map(BukkitQuest::getId).collect(Collectors.toList()); final List<String> ids = requirements.getBlockQuests().stream().map(Quest::getId).collect(Collectors.toList());
context.setSessionData(CK.REQ_QUEST_BLOCK, ids); context.setSessionData(CK.REQ_QUEST_BLOCK, ids);
} }
if (!requirements.getMcmmoSkills().isEmpty()) { if (!requirements.getMcmmoSkills().isEmpty()) {
@ -227,7 +230,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (!requirements.getDetailsOverride().isEmpty()) { if (!requirements.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride()); context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride());
} }
final BukkitRewards rewards = q.getRewards(); final Rewards rewards = q.getRewards();
if (rewards.getMoney() != 0) { if (rewards.getMoney() != 0) {
context.setSessionData(CK.REW_MONEY, rewards.getMoney()); context.setSessionData(CK.REW_MONEY, rewards.getMoney());
} }
@ -273,7 +276,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (!rewards.getDetailsOverride().isEmpty()) { if (!rewards.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride()); context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride());
} }
final BukkitPlanner pln = q.getPlanner(); final Planner pln = q.getPlanner();
if (pln.getStart() != null) { if (pln.getStart() != null) {
context.setSessionData(CK.PLN_START_DATE, pln.getStart()); 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_COOLDOWN, pln.getCooldown());
} }
context.setSessionData(CK.PLN_OVERRIDE, pln.getOverride()); 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_COMMANDS, opt.canAllowCommands());
context.setSessionData(CK.OPT_ALLOW_QUITTING, opt.canAllowQuitting()); context.setSessionData(CK.OPT_ALLOW_QUITTING, opt.canAllowQuitting());
context.setSessionData(CK.OPT_IGNORE_SILK_TOUCH, opt.canIgnoreSilkTouch()); 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()); context.setSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS, opt.canHandleOfflinePlayers());
// Stages (Objectives) // Stages (Objectives)
int index = 1; int index = 1;
for (final BukkitStage stage : q.getStages()) { for (final Stage stage : q.getStages()) {
final String pref = "stage" + index; final String pref = "stage" + index;
index++; index++;
context.setSessionData(pref, Boolean.TRUE); context.setSessionData(pref, Boolean.TRUE);
@ -454,7 +457,7 @@ public class QuestFactory implements ConversationAbandonedListener {
colors.add(MiscUtil.getPrettyDyeColorName(d)); colors.add(MiscUtil.getPrettyDyeColorName(d));
} }
final LinkedList<Integer> amounts = new LinkedList<>(stage.sheepNumToShear); final LinkedList<Integer> amounts = new LinkedList<>(stage.getSheepNumToShear());
context.setSessionData(pref + CK.S_SHEAR_COLORS, colors); context.setSessionData(pref + CK.S_SHEAR_COLORS, colors);
context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amounts); context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amounts);
} }

View File

@ -15,7 +15,6 @@ package me.blackvein.quests.quests;
import me.blackvein.quests.CustomObjective; import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.Stage; import me.blackvein.quests.Stage;
import me.blackvein.quests.actions.Action; import me.blackvein.quests.actions.Action;
import me.blackvein.quests.actions.Action;
import me.blackvein.quests.conditions.Condition; import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.enums.ObjectiveType; import me.blackvein.quests.enums.ObjectiveType;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
@ -145,6 +144,11 @@ public class BukkitStage implements Stage {
return blocksToBreak; return blocksToBreak;
} }
@Override
public boolean addBlockToBreak(ItemStack blockToBreak) {
return blocksToBreak.add(blockToBreak);
}
public void setBlocksToBreak(final LinkedList<ItemStack> blocksToBreak) { public void setBlocksToBreak(final LinkedList<ItemStack> blocksToBreak) {
this.blocksToBreak = blocksToBreak; this.blocksToBreak = blocksToBreak;
} }
@ -153,6 +157,11 @@ public class BukkitStage implements Stage {
return blocksToDamage; return blocksToDamage;
} }
@Override
public boolean addBlockToDamage(ItemStack blockToDamage) {
return blocksToDamage.add(blockToDamage);
}
public void setBlocksToDamage(final LinkedList<ItemStack> blocksToDamage) { public void setBlocksToDamage(final LinkedList<ItemStack> blocksToDamage) {
this.blocksToDamage = blocksToDamage; this.blocksToDamage = blocksToDamage;
} }
@ -161,6 +170,11 @@ public class BukkitStage implements Stage {
return blocksToPlace; return blocksToPlace;
} }
@Override
public boolean addBlockToPlace(ItemStack blockToPlace) {
return blocksToPlace.add(blockToPlace);
}
public void setBlocksToPlace(final LinkedList<ItemStack> blocksToPlace) { public void setBlocksToPlace(final LinkedList<ItemStack> blocksToPlace) {
this.blocksToPlace = blocksToPlace; this.blocksToPlace = blocksToPlace;
} }
@ -169,6 +183,11 @@ public class BukkitStage implements Stage {
return blocksToUse; return blocksToUse;
} }
@Override
public boolean addBlockToUse(ItemStack blockToUse) {
return blocksToUse.add(blockToUse);
}
public void setBlocksToUse(final LinkedList<ItemStack> blocksToUse) { public void setBlocksToUse(final LinkedList<ItemStack> blocksToUse) {
this.blocksToUse = blocksToUse; this.blocksToUse = blocksToUse;
} }
@ -177,6 +196,11 @@ public class BukkitStage implements Stage {
return blocksToCut; return blocksToCut;
} }
@Override
public boolean addBlockToCut(ItemStack blockToCut) {
return blocksToCut.add(blockToCut);
}
public void setBlocksToCut(final LinkedList<ItemStack> blocksToCut) { public void setBlocksToCut(final LinkedList<ItemStack> blocksToCut) {
this.blocksToCut = blocksToCut; this.blocksToCut = blocksToCut;
} }
@ -185,6 +209,11 @@ public class BukkitStage implements Stage {
return itemsToCraft; return itemsToCraft;
} }
@Override
public boolean addItemToCraft(ItemStack itemToCraft) {
return itemsToCraft.add(itemToCraft);
}
public void setItemsToCraft(final LinkedList<ItemStack> itemsToCraft) { public void setItemsToCraft(final LinkedList<ItemStack> itemsToCraft) {
this.itemsToCraft = itemsToCraft; this.itemsToCraft = itemsToCraft;
} }
@ -193,6 +222,11 @@ public class BukkitStage implements Stage {
return itemsToSmelt; return itemsToSmelt;
} }
@Override
public boolean addItemToSmelt(ItemStack itemToSmelt) {
return itemsToSmelt.add(itemToSmelt);
}
public void setItemsToSmelt(final LinkedList<ItemStack> itemsToSmelt) { public void setItemsToSmelt(final LinkedList<ItemStack> itemsToSmelt) {
this.itemsToSmelt = itemsToSmelt; this.itemsToSmelt = itemsToSmelt;
} }
@ -201,6 +235,11 @@ public class BukkitStage implements Stage {
return itemsToEnchant; return itemsToEnchant;
} }
@Override
public boolean addItemToEnchant(ItemStack itemToEnchant) {
return itemsToEnchant.add(itemToEnchant);
}
public void setItemsToEnchant(final LinkedList<ItemStack> itemsToEnchant) { public void setItemsToEnchant(final LinkedList<ItemStack> itemsToEnchant) {
this.itemsToEnchant = itemsToEnchant; this.itemsToEnchant = itemsToEnchant;
} }
@ -209,6 +248,11 @@ public class BukkitStage implements Stage {
return itemsToBrew; return itemsToBrew;
} }
@Override
public boolean addItemsToBrew(ItemStack itemToBrew) {
return itemsToBrew.add(itemToBrew);
}
public void setItemsToBrew(final LinkedList<ItemStack> itemsToBrew) { public void setItemsToBrew(final LinkedList<ItemStack> itemsToBrew) {
this.itemsToBrew = itemsToBrew; this.itemsToBrew = itemsToBrew;
} }
@ -217,6 +261,11 @@ public class BukkitStage implements Stage {
return itemsToConsume; return itemsToConsume;
} }
@Override
public boolean addItemToConsume(ItemStack itemToConsume) {
return itemsToConsume.add(itemToConsume);
}
public void setItemsToConsume(final LinkedList<ItemStack> itemsToConsume) { public void setItemsToConsume(final LinkedList<ItemStack> itemsToConsume) {
this.itemsToBrew = itemsToConsume; this.itemsToBrew = itemsToConsume;
} }
@ -225,6 +274,11 @@ public class BukkitStage implements Stage {
return itemsToDeliver; return itemsToDeliver;
} }
@Override
public boolean addItemToDeliver(ItemStack itemToDeliver) {
return itemsToDeliver.add(itemToDeliver);
}
public void setItemsToDeliver(final LinkedList<ItemStack> itemsToDeliver) { public void setItemsToDeliver(final LinkedList<ItemStack> itemsToDeliver) {
this.itemsToDeliver = itemsToDeliver; this.itemsToDeliver = itemsToDeliver;
} }
@ -233,6 +287,11 @@ public class BukkitStage implements Stage {
return itemDeliveryTargets; return itemDeliveryTargets;
} }
@Override
public boolean addItemDeliveryTarget(Integer itemDeliveryTarget) {
return itemDeliveryTargets.add(itemDeliveryTarget);
}
public void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets) { public void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets) {
this.itemDeliveryTargets = itemDeliveryTargets; this.itemDeliveryTargets = itemDeliveryTargets;
} }
@ -241,6 +300,11 @@ public class BukkitStage implements Stage {
return deliverMessages; return deliverMessages;
} }
@Override
public boolean addDeliverMessage(String deliverMessage) {
return deliverMessages.add(deliverMessage);
}
public void setDeliverMessages(final LinkedList<String> deliverMessages) { public void setDeliverMessages(final LinkedList<String> deliverMessages) {
this.deliverMessages = deliverMessages; this.deliverMessages = deliverMessages;
} }
@ -249,6 +313,11 @@ public class BukkitStage implements Stage {
return citizensToInteract; return citizensToInteract;
} }
@Override
public boolean addCitizenToInteract(Integer citizenToInteract) {
return citizensToInteract.add(citizenToInteract);
}
public void setCitizensToInteract(final LinkedList<Integer> citizensToInteract) { public void setCitizensToInteract(final LinkedList<Integer> citizensToInteract) {
this.citizensToInteract = citizensToInteract; this.citizensToInteract = citizensToInteract;
} }
@ -257,6 +326,11 @@ public class BukkitStage implements Stage {
return citizensToKill; return citizensToKill;
} }
@Override
public boolean addCitizenToKill(Integer citizenToKill) {
return citizensToKill.add(citizenToKill);
}
public void setCitizensToKill(final LinkedList<Integer> citizensToKill) { public void setCitizensToKill(final LinkedList<Integer> citizensToKill) {
this.citizensToKill = citizensToKill; this.citizensToKill = citizensToKill;
} }
@ -265,6 +339,11 @@ public class BukkitStage implements Stage {
return citizenNumToKill; return citizenNumToKill;
} }
@Override
public boolean addCitizenNumToKill(Integer citizenNumToKill) {
return this.citizenNumToKill.add(citizenNumToKill);
}
public void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill) { public void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill) {
this.citizenNumToKill = citizenNumToKill; this.citizenNumToKill = citizenNumToKill;
} }
@ -273,6 +352,11 @@ public class BukkitStage implements Stage {
return mobsToKill; return mobsToKill;
} }
@Override
public boolean addMobToKill(EntityType mobToKill) {
return mobsToKill.add(mobToKill);
}
public void setMobsToKill(final LinkedList<EntityType> mobsToKill) { public void setMobsToKill(final LinkedList<EntityType> mobsToKill) {
this.mobsToKill = mobsToKill; this.mobsToKill = mobsToKill;
} }
@ -281,6 +365,11 @@ public class BukkitStage implements Stage {
return mobNumToKill; return mobNumToKill;
} }
@Override
public boolean addMobNumToKill(Integer mobNumToKill) {
return this.mobNumToKill.add(mobNumToKill);
}
public void setMobNumToKill(final LinkedList<Integer> mobNumToKill) { public void setMobNumToKill(final LinkedList<Integer> mobNumToKill) {
this.mobNumToKill = mobNumToKill; this.mobNumToKill = mobNumToKill;
} }
@ -289,6 +378,11 @@ public class BukkitStage implements Stage {
return locationsToKillWithin; return locationsToKillWithin;
} }
@Override
public boolean addLocationToKillWithin(Location locationToKillWithin) {
return locationsToKillWithin.add(locationToKillWithin);
}
public void setLocationsToKillWithin(final LinkedList<Location> locationsToKillWithin) { public void setLocationsToKillWithin(final LinkedList<Location> locationsToKillWithin) {
this.locationsToKillWithin = locationsToKillWithin; this.locationsToKillWithin = locationsToKillWithin;
} }
@ -297,6 +391,11 @@ public class BukkitStage implements Stage {
return radiiToKillWithin; return radiiToKillWithin;
} }
@Override
public boolean addRadiusToKillWithin(Integer radiusToKillWithin) {
return radiiToKillWithin.add(radiusToKillWithin);
}
public void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin) { public void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin) {
this.radiiToKillWithin = radiiToKillWithin; this.radiiToKillWithin = radiiToKillWithin;
} }
@ -305,6 +404,11 @@ public class BukkitStage implements Stage {
return killNames; return killNames;
} }
@Override
public boolean addKillName(String killName) {
return killNames.add(killName);
}
public void setKillNames(final LinkedList<String> killNames) { public void setKillNames(final LinkedList<String> killNames) {
this.killNames = killNames; this.killNames = killNames;
} }
@ -313,6 +417,11 @@ public class BukkitStage implements Stage {
return locationsToReach; return locationsToReach;
} }
@Override
public boolean addLocationToReach(Location locationToReach) {
return locationsToReach.add(locationToReach);
}
public void setLocationsToReach(final LinkedList<Location> locationsToReach) { public void setLocationsToReach(final LinkedList<Location> locationsToReach) {
this.locationsToReach = locationsToReach; this.locationsToReach = locationsToReach;
} }
@ -321,6 +430,11 @@ public class BukkitStage implements Stage {
return radiiToReachWithin; return radiiToReachWithin;
} }
@Override
public boolean addRadiusToReachWithin(Integer radiusToReachWithin) {
return radiiToReachWithin.add(radiusToReachWithin);
}
public void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin) { public void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin) {
this.radiiToReachWithin = radiiToReachWithin; this.radiiToReachWithin = radiiToReachWithin;
} }
@ -329,6 +443,11 @@ public class BukkitStage implements Stage {
return worldsToReachWithin; return worldsToReachWithin;
} }
@Override
public boolean addWorldToReachWithin(World worldToReachWithin) {
return worldsToReachWithin.add(worldToReachWithin);
}
public void setWorldsToReachWithin(final LinkedList<World> worldsToReachWithin) { public void setWorldsToReachWithin(final LinkedList<World> worldsToReachWithin) {
this.worldsToReachWithin = worldsToReachWithin; this.worldsToReachWithin = worldsToReachWithin;
} }
@ -337,6 +456,11 @@ public class BukkitStage implements Stage {
return locationNames; return locationNames;
} }
@Override
public boolean addLocationName(String locationName) {
return locationNames.add(locationName);
}
public void setLocationNames(final LinkedList<String> locationNames) { public void setLocationNames(final LinkedList<String> locationNames) {
this.locationNames = locationNames; this.locationNames = locationNames;
} }
@ -345,6 +469,11 @@ public class BukkitStage implements Stage {
return mobsToTame; return mobsToTame;
} }
@Override
public boolean addMobToTame(EntityType mobToTame) {
return mobsToTame.add(mobToTame);
}
public void setMobsToTame(final LinkedList<EntityType> mobsToTame) { public void setMobsToTame(final LinkedList<EntityType> mobsToTame) {
this.mobsToTame = mobsToTame; this.mobsToTame = mobsToTame;
} }
@ -353,6 +482,11 @@ public class BukkitStage implements Stage {
return mobNumToTame; return mobNumToTame;
} }
@Override
public boolean addMobNumToTame(Integer mobNumToTame) {
return this.mobNumToTame.add(mobNumToTame);
}
public void setMobNumToTame(final LinkedList<Integer> mobNumToTame) { public void setMobNumToTame(final LinkedList<Integer> mobNumToTame) {
this.mobNumToTame = mobNumToTame; this.mobNumToTame = mobNumToTame;
} }
@ -385,6 +519,11 @@ public class BukkitStage implements Stage {
return sheepToShear; return sheepToShear;
} }
@Override
public boolean addSheepToShear(DyeColor sheepToShear) {
return this.sheepToShear.add(sheepToShear);
}
public void setSheepToShear(final LinkedList<DyeColor> sheepToShear) { public void setSheepToShear(final LinkedList<DyeColor> sheepToShear) {
this.sheepToShear = sheepToShear; this.sheepToShear = sheepToShear;
} }
@ -393,6 +532,11 @@ public class BukkitStage implements Stage {
return sheepNumToShear; return sheepNumToShear;
} }
@Override
public boolean addSheepNumToShear(Integer sheepNumToShear) {
return this.sheepNumToShear.add(sheepNumToShear);
}
public void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear) { public void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear) {
this.sheepNumToShear = sheepNumToShear; this.sheepNumToShear = sheepNumToShear;
} }
@ -401,6 +545,11 @@ public class BukkitStage implements Stage {
return passwordDisplays; return passwordDisplays;
} }
@Override
public boolean addPasswordDisplay(String passwordDisplay) {
return passwordDisplays.add(passwordDisplay);
}
public void setPasswordDisplays(final LinkedList<String> passwordDisplays) { public void setPasswordDisplays(final LinkedList<String> passwordDisplays) {
this.passwordDisplays = passwordDisplays; this.passwordDisplays = passwordDisplays;
} }
@ -409,6 +558,11 @@ public class BukkitStage implements Stage {
return passwordPhrases; return passwordPhrases;
} }
@Override
public boolean addPasswordPhrase(String passwordPhrase) {
return passwordPhrases.add(passwordPhrase);
}
public void setPasswordPhrases(final LinkedList<String> passwordPhrases) { public void setPasswordPhrases(final LinkedList<String> passwordPhrases) {
this.passwordPhrases = passwordPhrases; this.passwordPhrases = passwordPhrases;
} }
@ -457,6 +611,11 @@ public class BukkitStage implements Stage {
return chatActions; return chatActions;
} }
@Override
public void addChatAction(Entry<String, Action> chatAction) {
chatActions.put(chatAction.getKey(), chatAction.getValue());
}
public void setChatActions(final Map<String, Action> chatActions) { public void setChatActions(final Map<String, Action> chatActions) {
this.chatActions = chatActions; this.chatActions = chatActions;
} }
@ -465,6 +624,11 @@ public class BukkitStage implements Stage {
return commandActions; return commandActions;
} }
@Override
public void addCommandAction(Entry<String, Action> commandAction) {
commandActions.put(commandAction.getKey(), commandAction.getValue());
}
public void setCommandActions(final Map<String, Action> commandActions) { public void setCommandActions(final Map<String, Action> commandActions) {
this.commandActions = commandActions; this.commandActions = commandActions;
} }
@ -521,6 +685,11 @@ public class BukkitStage implements Stage {
return objectiveOverrides; return objectiveOverrides;
} }
@Override
public boolean addObjectiveOverride(String objectiveOverride) {
return objectiveOverrides.add(objectiveOverride);
}
public void setObjectiveOverrides(final LinkedList<String> objectiveOverrides) { public void setObjectiveOverrides(final LinkedList<String> objectiveOverrides) {
this.objectiveOverrides = objectiveOverrides; this.objectiveOverrides = objectiveOverrides;
} }
@ -529,18 +698,34 @@ public class BukkitStage implements Stage {
return customObjectives; return customObjectives;
} }
public void clearCustomObjectives() {
customObjectives.clear();
}
public LinkedList<Integer> getCustomObjectiveCounts() { public LinkedList<Integer> getCustomObjectiveCounts() {
return customObjectiveCounts; return customObjectiveCounts;
} }
public void clearCustomObjectiveCounts() {
customObjectiveCounts.clear();
}
public LinkedList<String> getCustomObjectiveDisplays() { public LinkedList<String> getCustomObjectiveDisplays() {
return customObjectiveDisplays; return customObjectiveDisplays;
} }
public void clearCustomObjectiveDisplays() {
customObjectiveDisplays.clear();
}
public LinkedList<Entry<String, Object>> getCustomObjectiveData() { public LinkedList<Entry<String, Object>> getCustomObjectiveData() {
return customObjectiveData; return customObjectiveData;
} }
public void clearCustomObjectiveData() {
customObjectiveData.clear();
}
/** /**
* Check if stage has at least one objective<p> * Check if stage has at least one objective<p>
* *

View File

@ -12,7 +12,7 @@
package me.blackvein.quests.storage; 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.Quests;
import me.blackvein.quests.storage.implementation.StorageImplementation; import me.blackvein.quests.storage.implementation.StorageImplementation;
@ -85,11 +85,11 @@ public class Storage {
} }
} }
public CompletableFuture<BukkitQuester> loadQuester(final UUID uniqueId) { public CompletableFuture<Quester> loadQuester(final UUID uniqueId) {
return makeFuture(() -> implementation.loadQuester(uniqueId)); return makeFuture(() -> implementation.loadQuester(uniqueId));
} }
public CompletableFuture<Void> saveQuester(final BukkitQuester quester) { public CompletableFuture<Void> saveQuester(final Quester quester) {
return makeFuture(() -> { return makeFuture(() -> {
try { try {
implementation.saveQuester(quester); implementation.saveQuester(quester);
@ -102,7 +102,7 @@ public class Storage {
public CompletableFuture<Void> saveOfflineQuesters() { public CompletableFuture<Void> saveOfflineQuesters() {
return makeFuture(() -> { return makeFuture(() -> {
try { try {
for (BukkitQuester quester : plugin.getOfflineQuesters()) { for (Quester quester : plugin.getOfflineQuesters()) {
implementation.saveQuester(quester); implementation.saveQuester(quester);
} }
} catch (final Exception e) { } catch (final Exception e) {

View File

@ -12,7 +12,7 @@
package me.blackvein.quests.storage.implementation; package me.blackvein.quests.storage.implementation;
import me.blackvein.quests.player.BukkitQuester; import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import java.util.Collection; import java.util.Collection;
@ -27,9 +27,9 @@ public interface StorageImplementation {
void close(); 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; void deleteQuester(UUID uniqueId) throws Exception;

View File

@ -12,10 +12,11 @@
package me.blackvein.quests.storage.implementation.file; package me.blackvein.quests.storage.implementation.file;
import me.blackvein.quests.quests.BukkitQuest; import me.blackvein.quests.Quest;
import me.blackvein.quests.player.BukkitQuester; import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests; 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 me.blackvein.quests.storage.implementation.StorageImplementation;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -65,9 +66,9 @@ public class SeparatedYamlStorage implements StorageImplementation {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public BukkitQuester loadQuester(final UUID uniqueId) throws Exception { public Quester loadQuester(final UUID uniqueId) throws Exception {
final FileConfiguration data = new YamlConfiguration(); final FileConfiguration data = new YamlConfiguration();
BukkitQuester quester = plugin.getQuester(uniqueId); Quester quester = plugin.getQuester(uniqueId);
if (quester != null) { if (quester != null) {
quester.hardClear(); quester.hardClear();
} else { } else {
@ -87,7 +88,7 @@ public class SeparatedYamlStorage implements StorageImplementation {
if (data.contains("completedRedoableQuests")) { if (data.contains("completedRedoableQuests")) {
final List<String> questIds = data.getStringList("completedRedoableQuests"); final List<String> questIds = data.getStringList("completedRedoableQuests");
final List<Long> questTimes = data.getLongList("completedQuestTimes"); final List<Long> questTimes = data.getLongList("completedQuestTimes");
final ConcurrentHashMap<BukkitQuest, Long> completedTimes = quester.getCompletedTimes(); final ConcurrentHashMap<Quest, Long> completedTimes = quester.getCompletedTimes();
for (int i = 0; i < questIds.size(); i++) { for (int i = 0; i < questIds.size(); i++) {
if (plugin.getQuestById(questIds.get(i)) != null) { if (plugin.getQuestById(questIds.get(i)) != null) {
completedTimes.put(plugin.getQuestById(questIds.get(i)), questTimes.get(i)); completedTimes.put(plugin.getQuestById(questIds.get(i)), questTimes.get(i));
@ -101,7 +102,7 @@ public class SeparatedYamlStorage implements StorageImplementation {
if (data.contains("amountsCompletedQuests")) { if (data.contains("amountsCompletedQuests")) {
final List<String> questIds = data.getStringList("amountsCompletedQuests"); final List<String> questIds = data.getStringList("amountsCompletedQuests");
final List<Integer> questAmounts = data.getIntegerList("amountsCompleted"); final List<Integer> questAmounts = data.getIntegerList("amountsCompleted");
final ConcurrentHashMap<BukkitQuest, Integer> amountsCompleted = quester.getAmountsCompleted(); final ConcurrentHashMap<Quest, Integer> amountsCompleted = quester.getAmountsCompleted();
for (int i = 0; i < questIds.size(); i++) { for (int i = 0; i < questIds.size(); i++) {
if (plugin.getQuestById(questIds.get(i)) != null) { if (plugin.getQuestById(questIds.get(i)) != null) {
amountsCompleted.put(plugin.getQuestById(questIds.get(i)), questAmounts.get(i)); 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.setLastKnownName(data.getString("lastKnownName"));
quester.setQuestPoints(data.getInt("quest-points")); quester.setQuestPoints(data.getInt("quest-points"));
final ConcurrentSkipListSet<BukkitQuest> completedQuests = quester.getCompletedQuests(); final ConcurrentSkipListSet<Quest> completedQuests = quester.getCompletedQuests();
if (data.isList("completed-Quests")) { if (data.isList("completed-Quests")) {
for (final String s : data.getStringList("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 (q.getId().equals(s)) {
if (!quester.getCompletedQuests().contains(q)) { if (!quester.getCompletedQuests().contains(q)) {
completedQuests.add(q); completedQuests.add(q);
@ -138,7 +139,7 @@ public class SeparatedYamlStorage implements StorageImplementation {
final List<String> questIds = data.getStringList("currentQuests"); final List<String> questIds = data.getStringList("currentQuests");
final List<Integer> questStages = data.getIntegerList("currentStages"); final List<Integer> questStages = data.getIntegerList("currentStages");
final int maxSize = Math.min(questIds.size(), questStages.size()); final int maxSize = Math.min(questIds.size(), questStages.size());
final ConcurrentHashMap<BukkitQuest, Integer> currentQuests = quester.getCurrentQuests(); final ConcurrentHashMap<Quest, Integer> currentQuests = quester.getCurrentQuests();
for (int i = 0; i < maxSize; i++) { for (int i = 0; i < maxSize; i++) {
if (plugin.getQuestById(questIds.get(i)) != null) { if (plugin.getQuestById(questIds.get(i)) != null) {
currentQuests.put(plugin.getQuestById(questIds.get(i)), questStages.get(i)); 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)) { for (final String key : dataSec.getKeys(false)) {
final ConfigurationSection questSec = dataSec.getConfigurationSection(key); 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)) { if (quest == null || !quester.getCurrentQuests().containsKey(quest)) {
continue; continue;
} }
final BukkitStage stage = quester.getCurrentStage(quest); final Stage stage = quester.getCurrentStage(quest);
if (stage == null) { if (stage == null) {
quest.completeQuest(quester); quest.completeQuest(quester);
plugin.getLogger().severe("[Quests] Invalid stage number for player: \"" + uniqueId + "\" on Quest \"" plugin.getLogger().severe("[Quests] Invalid stage number for player: \"" + uniqueId + "\" on Quest \""
@ -376,7 +377,7 @@ public class SeparatedYamlStorage implements StorageImplementation {
} }
@Override @Override
public void saveQuester(final BukkitQuester quester) throws Exception { public void saveQuester(final Quester quester) throws Exception {
final FileConfiguration data = quester.getBaseData(); final FileConfiguration data = quester.getBaseData();
try { try {
data.save(new File(directoryPath + File.separator + quester.getUUID() + ".yml")); 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 * @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"); File dataFile = new File(plugin.getDataFolder(), "data" + File.separator + quester.getUUID().toString() + ".yml");
if (!dataFile.exists()) { if (!dataFile.exists()) {
final OfflinePlayer p = quester.getOfflinePlayer(); final OfflinePlayer p = quester.getOfflinePlayer();

View File

@ -12,9 +12,9 @@
package me.blackvein.quests.storage.implementation.sql; 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.QuestData;
import me.blackvein.quests.player.BukkitQuester; import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.storage.implementation.StorageImplementation; import me.blackvein.quests.storage.implementation.StorageImplementation;
import me.blackvein.quests.storage.implementation.sql.connection.ConnectionFactory; import me.blackvein.quests.storage.implementation.sql.connection.ConnectionFactory;
@ -221,8 +221,8 @@ public class SqlStorage implements StorageImplementation {
} }
@Override @Override
public BukkitQuester loadQuester(final UUID uniqueId) throws Exception { public Quester loadQuester(final UUID uniqueId) throws Exception {
final BukkitQuester quester = plugin.getQuester(uniqueId); final Quester quester = plugin.getQuester(uniqueId);
if (quester == null) { if (quester == null) {
return null; return null;
} }
@ -248,21 +248,21 @@ public class SqlStorage implements StorageImplementation {
} }
@Override @Override
public void saveQuester(final BukkitQuester quester) throws Exception { public void saveQuester(final Quester quester) throws Exception {
final UUID uniqueId = quester.getUUID(); final UUID uniqueId = quester.getUUID();
final String lastKnownName = quester.getLastKnownName(); final String lastKnownName = quester.getLastKnownName();
final String oldLastKnownName = getQuesterLastKnownName(uniqueId); final String oldLastKnownName = getQuesterLastKnownName(uniqueId);
final Set<String> currentQuests = quester.getCurrentQuests().keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); final Set<String> currentQuests = quester.getCurrentQuests().keySet().stream().map(Quest::getId).collect(Collectors.toSet());
final Set<String> oldCurrentQuests = getQuesterCurrentQuests(uniqueId).keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); final Set<String> oldCurrentQuests = getQuesterCurrentQuests(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet());
oldCurrentQuests.removeAll(currentQuests); oldCurrentQuests.removeAll(currentQuests);
final Set<String> completedQuests = quester.getCompletedQuests().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); final Set<String> completedQuests = quester.getCompletedQuests().stream().map(Quest::getId).collect(Collectors.toSet());
final Set<String> oldCompletedQuests = getQuesterCompletedQuests(uniqueId).stream().map(BukkitQuest::getId).collect(Collectors.toSet()); final Set<String> oldCompletedQuests = getQuesterCompletedQuests(uniqueId).stream().map(Quest::getId).collect(Collectors.toSet());
oldCompletedQuests.removeAll(completedQuests); oldCompletedQuests.removeAll(completedQuests);
final Set<String> redoableQuests = quester.getCompletedTimes().keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); final Set<String> redoableQuests = quester.getCompletedTimes().keySet().stream().map(Quest::getId).collect(Collectors.toSet());
final Set<String> oldRedoableQuests = getQuesterCompletedTimes(uniqueId).keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); final Set<String> oldRedoableQuests = getQuesterCompletedTimes(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet());
oldRedoableQuests.removeAll(redoableQuests); oldRedoableQuests.removeAll(redoableQuests);
final Set<String> questData = quester.getQuestData().keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); final Set<String> questData = quester.getQuestData().keySet().stream().map(Quest::getId).collect(Collectors.toSet());
final Set<String> oldQuestData = getQuesterQuestData(uniqueId).keySet().stream().map(BukkitQuest::getId).collect(Collectors.toSet()); final Set<String> oldQuestData = getQuesterQuestData(uniqueId).keySet().stream().map(Quest::getId).collect(Collectors.toSet());
oldQuestData.removeAll(questData); oldQuestData.removeAll(questData);
try (final Connection c = connectionFactory.getConnection()) { try (final Connection c = connectionFactory.getConnection()) {
@ -290,7 +290,7 @@ public class SqlStorage implements StorageImplementation {
} }
} }
} else { } else {
for (final Entry<BukkitQuest, Integer> entry : quester.getCurrentQuests().entrySet()) { for (final Entry<Quest, Integer> entry : quester.getCurrentQuests().entrySet()) {
try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_CURRENT_QUESTS_INSERT))) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_CURRENT_QUESTS_INSERT))) {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
ps.setString(2, entry.getKey().getId()); ps.setString(2, entry.getKey().getId());
@ -309,7 +309,7 @@ public class SqlStorage implements StorageImplementation {
} }
} }
} else { } 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))) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_INSERT))) {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
ps.setString(2, quest.getId()); ps.setString(2, quest.getId());
@ -327,7 +327,7 @@ public class SqlStorage implements StorageImplementation {
} }
} }
} else { } else {
for (final Entry<BukkitQuest, Long> entry : quester.getCompletedTimes().entrySet()) { for (final Entry<Quest, Long> entry : quester.getCompletedTimes().entrySet()) {
final int amount = quester.getAmountsCompleted().get(entry.getKey()); final int amount = quester.getAmountsCompleted().get(entry.getKey());
try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_INSERT))) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_INSERT))) {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
@ -348,7 +348,7 @@ public class SqlStorage implements StorageImplementation {
} }
} }
} else { } else {
for (final Entry<BukkitQuest, QuestData> entry : quester.getQuestData().entrySet()) { for (final Entry<Quest, QuestData> entry : quester.getQuestData().entrySet()) {
try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_QUEST_DATA_INSERT))) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_QUEST_DATA_INSERT))) {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
ps.setString(2, entry.getKey().getId()); ps.setString(2, entry.getKey().getId());
@ -424,14 +424,14 @@ public class SqlStorage implements StorageImplementation {
return null; return null;
} }
public ConcurrentHashMap<BukkitQuest, Integer> getQuesterCurrentQuests(final UUID uniqueId) throws Exception { public ConcurrentHashMap<Quest, Integer> getQuesterCurrentQuests(final UUID uniqueId) throws Exception {
final ConcurrentHashMap<BukkitQuest, Integer> currentQuests = new ConcurrentHashMap<>(); final ConcurrentHashMap<Quest, Integer> currentQuests = new ConcurrentHashMap<>();
try (final Connection c = connectionFactory.getConnection()) { try (final Connection c = connectionFactory.getConnection()) {
try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_CURRENT_QUESTS_SELECT_BY_UUID))) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_CURRENT_QUESTS_SELECT_BY_UUID))) {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
try (final ResultSet rs = ps.executeQuery()) { try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {
final BukkitQuest quest = plugin.getQuestById(rs.getString("questid")); final Quest quest = plugin.getQuestById(rs.getString("questid"));
if (quest != null) { if (quest != null) {
currentQuests.put(quest, rs.getInt("stageNum")); currentQuests.put(quest, rs.getInt("stageNum"));
} }
@ -442,15 +442,15 @@ public class SqlStorage implements StorageImplementation {
return currentQuests; return currentQuests;
} }
public ConcurrentHashMap<BukkitQuest, QuestData> getQuesterQuestData(final UUID uniqueId) throws Exception { public ConcurrentHashMap<Quest, QuestData> getQuesterQuestData(final UUID uniqueId) throws Exception {
final BukkitQuester quester = plugin.getQuester(uniqueId); final Quester quester = plugin.getQuester(uniqueId);
final ConcurrentHashMap<BukkitQuest, QuestData> questData = new ConcurrentHashMap<>(); final ConcurrentHashMap<Quest, QuestData> questData = new ConcurrentHashMap<>();
try (final Connection c = connectionFactory.getConnection()) { try (final Connection c = connectionFactory.getConnection()) {
try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_QUEST_DATA_SELECT_BY_UUID))) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_QUEST_DATA_SELECT_BY_UUID))) {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
try (final ResultSet rs = ps.executeQuery()) { try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) { 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); final QuestData data = new QuestData(quester);
if (quest != null && quester.getCurrentStage(quest) != null) { if (quest != null && quester.getCurrentStage(quest) != null) {
data.blocksBroken.addAll(deserializeItemStackProgress(rs.getString("blocks_broken"), data.blocksBroken.addAll(deserializeItemStackProgress(rs.getString("blocks_broken"),
@ -497,14 +497,14 @@ public class SqlStorage implements StorageImplementation {
return questData; return questData;
} }
public ConcurrentSkipListSet<BukkitQuest> getQuesterCompletedQuests(final UUID uniqueId) throws Exception { public ConcurrentSkipListSet<Quest> getQuesterCompletedQuests(final UUID uniqueId) throws Exception {
final ConcurrentSkipListSet<BukkitQuest> completedQuests = new ConcurrentSkipListSet<>(); final ConcurrentSkipListSet<Quest> completedQuests = new ConcurrentSkipListSet<>();
try (final Connection c = connectionFactory.getConnection()) { try (final Connection c = connectionFactory.getConnection()) {
try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_SELECT_BY_UUID))) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_COMPLETED_QUESTS_SELECT_BY_UUID))) {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
try (final ResultSet rs = ps.executeQuery()) { try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {
final BukkitQuest quest = plugin.getQuestById(rs.getString("questid")); final Quest quest = plugin.getQuestById(rs.getString("questid"));
if (quest != null) { if (quest != null) {
completedQuests.add(quest); completedQuests.add(quest);
} }
@ -515,14 +515,14 @@ public class SqlStorage implements StorageImplementation {
return completedQuests; return completedQuests;
} }
public ConcurrentHashMap<BukkitQuest, Long> getQuesterCompletedTimes(final UUID uniqueId) throws Exception { public ConcurrentHashMap<Quest, Long> getQuesterCompletedTimes(final UUID uniqueId) throws Exception {
final ConcurrentHashMap<BukkitQuest, Long> completedTimes = new ConcurrentHashMap<>(); final ConcurrentHashMap<Quest, Long> completedTimes = new ConcurrentHashMap<>();
try (final Connection c = connectionFactory.getConnection()) { try (final Connection c = connectionFactory.getConnection()) {
try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID))) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID))) {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
try (final ResultSet rs = ps.executeQuery()) { try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {
final BukkitQuest quest = plugin.getQuestById(rs.getString("questid")); final Quest quest = plugin.getQuestById(rs.getString("questid"));
if (quest != null) { if (quest != null) {
completedTimes.put(quest, rs.getLong("lasttime")); completedTimes.put(quest, rs.getLong("lasttime"));
} }
@ -533,14 +533,14 @@ public class SqlStorage implements StorageImplementation {
return completedTimes; return completedTimes;
} }
public ConcurrentHashMap<BukkitQuest, Integer> getQuesterAmountsCompleted(final UUID uniqueId) throws Exception { public ConcurrentHashMap<Quest, Integer> getQuesterAmountsCompleted(final UUID uniqueId) throws Exception {
final ConcurrentHashMap<BukkitQuest, Integer> amountsCompleted = new ConcurrentHashMap<>(); final ConcurrentHashMap<Quest, Integer> amountsCompleted = new ConcurrentHashMap<>();
try (final Connection c = connectionFactory.getConnection()) { try (final Connection c = connectionFactory.getConnection()) {
try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID))) { try (final PreparedStatement ps = c.prepareStatement(statementProcessor.apply(PLAYER_REDOABLE_QUESTS_SELECT_BY_UUID))) {
ps.setString(1, uniqueId.toString()); ps.setString(1, uniqueId.toString());
try (final ResultSet rs = ps.executeQuery()) { try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {
final BukkitQuest quest = plugin.getQuestById(rs.getString("questid")); final Quest quest = plugin.getQuestById(rs.getString("questid"));
if (quest != null) { if (quest != null) {
amountsCompleted.put(quest, rs.getInt("amount")); amountsCompleted.put(quest, rs.getInt("amount"));
} }

View File

@ -12,21 +12,20 @@
package me.blackvein.quests.tasks; 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.ChatColor;
import org.bukkit.scheduler.BukkitRunnable; 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 { public class ActionTimer extends BukkitRunnable {
private final BukkitQuester quester; private final Quester quester;
private final BukkitQuest quest; private final Quest quest;
private final int time; private final int time;
private final boolean last; 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.quester = quester;
this.quest = quest; this.quest = quest;
this.time = time; this.time = time;

View File

@ -12,17 +12,17 @@
package me.blackvein.quests.tasks; package me.blackvein.quests.tasks;
import me.blackvein.quests.quests.BukkitQuest; import me.blackvein.quests.Quest;
import me.blackvein.quests.player.BukkitQuester; import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
public class StageTimer implements Runnable { public class StageTimer implements Runnable {
private final BukkitQuester quester; private final Quester quester;
private final Quests plugin; 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.quester = quester;
this.quest = quest; this.quest = quest;
this.plugin = plugin; this.plugin = plugin;

View File

@ -13,7 +13,7 @@
package me.blackvein.quests.util; package me.blackvein.quests.util;
import me.blackvein.quests.Dependencies; import me.blackvein.quests.Dependencies;
import me.blackvein.quests.quests.BukkitQuest; import me.blackvein.quests.Quest;
import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.PlaceholderAPI;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -100,7 +100,7 @@ public class ConfigUtil {
+ loc.getZ(); + 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); String parsed = parseString(s);
if (parsed.contains("<npc>")) { if (parsed.contains("<npc>")) {
if (quest.getNpcStart() != null) { if (quest.getNpcStart() != null) {
@ -115,7 +115,7 @@ public class ConfigUtil {
return parsed.split("\n"); 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); String parsed = parseString(s);
if (parsed.contains("<npc>")) { if (parsed.contains("<npc>")) {
if (quest.getNpcStart() != null) { if (quest.getNpcStart() != null) {
@ -135,7 +135,7 @@ public class ConfigUtil {
return parsed.split("\n"); 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); String parsed = parseString(s);
if (parsed.contains("<npc>")) { if (parsed.contains("<npc>")) {
if (quest.getNpcStart() != null) { if (quest.getNpcStart() != null) {
@ -147,7 +147,7 @@ public class ConfigUtil {
return parsed; 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); String parsed = parseString(s, quest);
if (Dependencies.placeholder != null && player != null) { if (Dependencies.placeholder != null && player != null) {
parsed = PlaceholderAPI.setPlaceholders(player, parsed); parsed = PlaceholderAPI.setPlaceholders(player, parsed);