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;
import me.blackvein.quests.enums.ObjectiveType;
import org.bukkit.inventory.ItemStack;
public interface Objective {
ObjectiveType getType();
int getProgress();
int getGoal();
ItemStack getItemProgress();
ItemStack getItemGoal();
}

View File

@ -1,4 +1,39 @@
package me.blackvein.quests;
public interface Options {
boolean canAllowCommands();
void setAllowCommands(final boolean allowCommands);
boolean canAllowQuitting();
void setAllowQuitting(final boolean allowQuitting);
boolean canIgnoreSilkTouch();
void setIgnoreSilkTouch(final boolean ignoreSilkTouch);
String getExternalPartyPlugin();
void setExternalPartyPlugin(final String externalPartyPlugin);
boolean canUsePartiesPlugin();
void setUsePartiesPlugin(final boolean usePartiesPlugin);
int getShareProgressLevel();
void setShareProgressLevel(final int shareProgressLevel);
boolean canShareSameQuestOnly();
void setShareSameQuestOnly(final boolean shareSameQuestOnly);
double getShareDistance();
void setShareDistance(final double shareDistance);
boolean canHandleOfflinePlayers();
void setHandleOfflinePlayers(final boolean handleOfflinePlayers);
}

View File

@ -1,4 +1,20 @@
package me.blackvein.quests;
public interface Planner {
String getStart();
long getStartInMillis();
boolean hasStart();
void setStart(final String start);
String getEnd();
long getEndInMillis();
boolean hasEnd();
void setEnd(final String end);
long getRepeat();
boolean hasRepeat();
void setRepeat(final long repeat);
long getCooldown();
boolean hasCooldown();
void setCooldown(final long cooldown);
boolean getOverride();
void setOverride(final boolean override);
}

View File

@ -3,54 +3,77 @@ package me.blackvein.quests;
import me.blackvein.quests.actions.Action;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import java.util.LinkedList;
public interface Quest {
public String getId();
public interface Quest extends Comparable<Quest> {
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;
import me.blackvein.quests.player.BukkitQuester;
import org.bukkit.inventory.ItemStack;
import java.util.Collection;
@ -23,9 +22,9 @@ import java.util.LinkedList;
*/
public class QuestData {
private final BukkitQuester quester;
private final Quester quester;
public QuestData(final BukkitQuester quester) {
public QuestData(final Quester quester) {
this.quester = quester;
}

View File

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

View File

@ -1,63 +1,228 @@
package me.blackvein.quests;
import me.blackvein.quests.enums.ObjectiveType;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.ItemStack;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.function.BiFunction;
import java.util.function.Function;
public interface Quester {
public UUID getUUID();
public interface Quester extends Comparable<Quester> {
UUID getUUID();
public void setUUID(final UUID id);
void setUUID(final UUID id);
public String getQuestIdToTake();
String getQuestIdToTake();
public void setQuestIdToTake(final String questIdToTake);
void setQuestIdToTake(final String questIdToTake);
public String getLastKnownName();
String getLastKnownName();
public void setLastKnownName(final String lastKnownName);
void setLastKnownName(final String lastKnownName);
public int getQuestPoints();
int getQuestPoints();
public void setQuestPoints(final int questPoints);
void setQuestPoints(final int questPoints);
/**
* Get compass target quest. Returns null if not set
*
* @return Quest or null
*/
public Quest getCompassTarget();
Quest getCompassTarget();
/**
* Set compass target quest. Does not update in-game
*
* @param quest The target quest
*/
public void setCompassTarget(final Quest quest);
void setCompassTarget(final Quest quest);
public ConcurrentHashMap<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;
import me.blackvein.quests.actions.Action;
import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.enums.ObjectiveType;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.World;
@ -13,110 +15,164 @@ import java.util.Map;
public interface Stage {
LinkedList<ItemStack> getBlocksToBreak();
boolean addBlockToBreak(ItemStack blockToBreak);
void setBlocksToBreak(final LinkedList<ItemStack> blocksToBreak);
LinkedList<ItemStack> getBlocksToDamage();
boolean addBlockToDamage(ItemStack blockToDamage);
void setBlocksToDamage(final LinkedList<ItemStack> blocksToDamage);
LinkedList<ItemStack> getBlocksToPlace();
boolean addBlockToPlace(ItemStack blockToPlace);
void setBlocksToPlace(final LinkedList<ItemStack> blocksToPlace);
LinkedList<ItemStack> getBlocksToUse();
boolean addBlockToUse(ItemStack blockToUse);
void setBlocksToUse(final LinkedList<ItemStack> blocksToUse);
LinkedList<ItemStack> getBlocksToCut();
boolean addBlockToCut(ItemStack blockToCut);
void setBlocksToCut(final LinkedList<ItemStack> blocksToCut);
LinkedList<ItemStack> getItemsToCraft();
boolean addItemToCraft(ItemStack itemToCraft);
void setItemsToCraft(final LinkedList<ItemStack> itemsToCraft);
LinkedList<ItemStack> getItemsToSmelt();
boolean addItemToSmelt(ItemStack itemToSmelt);
void setItemsToSmelt(final LinkedList<ItemStack> itemsToSmelt);
LinkedList<ItemStack> getItemsToEnchant();
boolean addItemToEnchant(ItemStack itemToEnchant);
void setItemsToEnchant(final LinkedList<ItemStack> itemsToEnchant);
LinkedList<ItemStack> getItemsToBrew();
boolean addItemsToBrew(ItemStack itemToBrew);
void setItemsToBrew(final LinkedList<ItemStack> itemsToBrew);
LinkedList<ItemStack> getItemsToConsume();
boolean addItemToConsume(ItemStack itemToConsume);
void setItemsToConsume(final LinkedList<ItemStack> itemsToConsume);
LinkedList<ItemStack> getItemsToDeliver();
boolean addItemToDeliver(ItemStack itemToDeliver);
void setItemsToDeliver(final LinkedList<ItemStack> itemsToDeliver);
LinkedList<Integer> getItemDeliveryTargets();
boolean addItemDeliveryTarget(Integer itemDeliveryTarget);
void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets);
LinkedList<String> getDeliverMessages();
boolean addDeliverMessage(String deliverMessage);
void setDeliverMessages(final LinkedList<String> deliverMessages);
LinkedList<Integer> getCitizensToInteract();
boolean addCitizenToInteract(Integer citizenToInteract);
void setCitizensToInteract(final LinkedList<Integer> citizensToInteract);
LinkedList<Integer> getCitizensToKill();
boolean addCitizenToKill(Integer citizenToKill);
void setCitizensToKill(final LinkedList<Integer> citizensToKill);
LinkedList<Integer> getCitizenNumToKill();
boolean addCitizenNumToKill(Integer citizenNumToKill);
void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill);
LinkedList<EntityType> getMobsToKill();
boolean addMobToKill(EntityType mobToKill);
void setMobsToKill(final LinkedList<EntityType> mobsToKill);
LinkedList<Integer> getMobNumToKill();
boolean addMobNumToKill(Integer mobNumToKill);
void setMobNumToKill(final LinkedList<Integer> mobNumToKill);
LinkedList<Location> getLocationsToKillWithin();
boolean addLocationToKillWithin(Location locationToKillWithin);
void setLocationsToKillWithin(final LinkedList<Location> locationsToKillWithin);
LinkedList<Integer> getRadiiToKillWithin();
boolean addRadiusToKillWithin(Integer radiusToKillWithin);
void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin);
LinkedList<String> getKillNames();
boolean addKillName(String killName);
void setKillNames(final LinkedList<String> killNames);
LinkedList<Location> getLocationsToReach();
boolean addLocationToReach(Location locationToReach);
void setLocationsToReach(final LinkedList<Location> locationsToReach);
LinkedList<Integer> getRadiiToReachWithin();
boolean addRadiusToReachWithin(Integer radiusToReachWithin);
void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin);
LinkedList<World> getWorldsToReachWithin();
boolean addWorldToReachWithin(World worldToReachWithin);
void setWorldsToReachWithin(final LinkedList<World> worldsToReachWithin);
LinkedList<String> getLocationNames();
boolean addLocationName(String locationName);
void setLocationNames(final LinkedList<String> locationNames);
LinkedList<EntityType> getMobsToTame();
boolean addMobToTame(EntityType mobToTame);
void setMobsToTame(final LinkedList<EntityType> mobsToTame);
LinkedList<Integer> getMobNumToTame();
boolean addMobNumToTame(Integer mobNumToTame);
void setMobNumToTame(final LinkedList<Integer> mobNumToTame);
Integer getFishToCatch();
@ -133,18 +189,26 @@ public interface Stage {
LinkedList<DyeColor> getSheepToShear();
boolean addSheepToShear(DyeColor sheepToShear);
void setSheepToShear(final LinkedList<DyeColor> sheepToShear);
LinkedList<Integer> getSheepNumToShear();
boolean addSheepNumToShear(Integer sheepNumToShear);
void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear);
LinkedList<String> getPasswordDisplays();
boolean addPasswordDisplay(String passwordDisplay);
void setPasswordDisplays(final LinkedList<String> passwordDisplays);
LinkedList<String> getPasswordPhrases();
boolean addPasswordPhrase(String passwordPhrase);
void setPasswordPhrases(final LinkedList<String> passwordPhrases);
String getScript();
@ -169,10 +233,14 @@ public interface Stage {
Map<String, Action> getChatActions();
void addChatAction(Map.Entry<String, Action> chatAction);
void setChatActions(final Map<String, Action> chatActions);
Map<String, Action> getCommandActions();
void addCommandAction(Map.Entry<String, Action> commandAction);
void setCommandActions(final Map<String, Action> commandActions);
Action getDisconnectAction();
@ -201,16 +269,26 @@ public interface Stage {
LinkedList<String> getObjectiveOverrides();
boolean addObjectiveOverride(String objectiveOverride);
void setObjectiveOverrides(final LinkedList<String> objectiveOverrides);
LinkedList<CustomObjective> getCustomObjectives();
void clearCustomObjectives();
LinkedList<Integer> getCustomObjectiveCounts();
void clearCustomObjectiveCounts();
LinkedList<String> getCustomObjectiveDisplays();
void clearCustomObjectiveDisplays();
LinkedList<Map.Entry<String, Object>> getCustomObjectiveData();
void clearCustomObjectiveData();
/**
* 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.Quester;
import me.blackvein.quests.entity.QuestMob;
import org.bukkit.Effect;
import org.bukkit.Location;
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;
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
import org.jetbrains.annotations.NotNull;
public class ActionsEditorPostOpenStringPromptEvent extends ActionsEditorEvent {

View File

@ -12,15 +12,13 @@
package me.blackvein.quests;
import me.blackvein.quests.player.BukkitQuester;
public class DenizenTrigger {
private final Quests plugin;
public DenizenTrigger(final Quests plugin) {
this.plugin = plugin;
}
public boolean runDenizenScript(final String scriptName, final BukkitQuester quester) {
public boolean runDenizenScript(final String scriptName, final Quester quester) {
if (scriptName == null) {
return false;
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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.
*/
package me.blackvein.quests;
package me.blackvein.quests.entity;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -24,7 +24,7 @@ import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.MiscUtil;
public class QuestMob {
public class BukkitQuestMob implements QuestMob {
private String name = null;
private EntityType entityType = null;
@ -33,10 +33,10 @@ public class QuestMob {
private ItemStack[] inventory = new ItemStack[5];
private Float[] dropChances = new Float[5];
public QuestMob(){
public BukkitQuestMob(){
}
public QuestMob(final EntityType entityType, final Location spawnLocation, final int spawnAmounts) {
public BukkitQuestMob(final EntityType entityType, final Location spawnLocation, final int spawnAmounts) {
this.entityType = entityType;
this.spawnLocation = spawnLocation;
this.spawnAmounts = spawnAmounts;
@ -189,7 +189,7 @@ public class QuestMob {
return string;
}
public static QuestMob fromString(final String str) {
public static BukkitQuestMob fromString(final String str) {
String name = null;
EntityType entityType = null;
Location loc = null;
@ -258,7 +258,7 @@ public class QuestMob {
}
}
}
final QuestMob qm = new QuestMob(entityType, loc, amounts != null ? amounts : 1);
final BukkitQuestMob qm = new BukkitQuestMob(entityType, loc, amounts != null ? amounts : 1);
qm.setName(name);
qm.inventory = inventory;
qm.dropChances = dropChances;

View File

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

View File

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

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.
*/
package me.blackvein.quests;
package me.blackvein.quests.quests;
import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.Options;
import me.blackvein.quests.Planner;
import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.Requirements;
import me.blackvein.quests.Rewards;
import me.blackvein.quests.Stage;
import me.blackvein.quests.convo.quests.main.QuestMainPrompt;
import me.blackvein.quests.convo.quests.menu.QuestMenuPrompt;
import me.blackvein.quests.convo.quests.stages.StageMenuPrompt;
import me.blackvein.quests.interfaces.ReloadCallback;
import me.blackvein.quests.quests.BukkitOptions;
import me.blackvein.quests.quests.BukkitPlanner;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.quests.BukkitRequirements;
import me.blackvein.quests.quests.BukkitRewards;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.FakeConversable;
@ -59,7 +62,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
public class QuestFactory implements ConversationAbandonedListener {
public class BukkitQuestFactory implements QuestFactory, ConversationAbandonedListener {
private final Quests plugin;
private final ConversationFactory conversationFactory;
@ -69,7 +72,7 @@ public class QuestFactory implements ConversationAbandonedListener {
private Set<UUID> selectingNpcs = new HashSet<>();
private List<String> editingQuestNames = new LinkedList<>();
public QuestFactory(final Quests plugin) {
public BukkitQuestFactory(final Quests plugin) {
this.plugin = plugin;
// Ensure to initialize factory last so that 'this' is fully initialized before it is passed
this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
@ -182,7 +185,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (q.getGUIDisplay() != null) {
context.setSessionData(CK.Q_GUIDISPLAY, q.getGUIDisplay());
}
final BukkitRequirements requirements = q.getRequirements();
final Requirements requirements = q.getRequirements();
if (requirements.getMoney() != 0) {
context.setSessionData(CK.REQ_MONEY, requirements.getMoney());
}
@ -194,11 +197,11 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems());
}
if (!requirements.getNeededQuests().isEmpty()) {
final List<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);
}
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);
}
if (!requirements.getMcmmoSkills().isEmpty()) {
@ -227,7 +230,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (!requirements.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride());
}
final BukkitRewards rewards = q.getRewards();
final Rewards rewards = q.getRewards();
if (rewards.getMoney() != 0) {
context.setSessionData(CK.REW_MONEY, rewards.getMoney());
}
@ -273,7 +276,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (!rewards.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride());
}
final BukkitPlanner pln = q.getPlanner();
final Planner pln = q.getPlanner();
if (pln.getStart() != null) {
context.setSessionData(CK.PLN_START_DATE, pln.getStart());
}
@ -287,7 +290,7 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.PLN_COOLDOWN, pln.getCooldown());
}
context.setSessionData(CK.PLN_OVERRIDE, pln.getOverride());
final BukkitOptions opt = q.getOptions();
final Options opt = q.getOptions();
context.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.canAllowCommands());
context.setSessionData(CK.OPT_ALLOW_QUITTING, opt.canAllowQuitting());
context.setSessionData(CK.OPT_IGNORE_SILK_TOUCH, opt.canIgnoreSilkTouch());
@ -299,7 +302,7 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS, opt.canHandleOfflinePlayers());
// Stages (Objectives)
int index = 1;
for (final BukkitStage stage : q.getStages()) {
for (final Stage stage : q.getStages()) {
final String pref = "stage" + index;
index++;
context.setSessionData(pref, Boolean.TRUE);
@ -454,7 +457,7 @@ public class QuestFactory implements ConversationAbandonedListener {
colors.add(MiscUtil.getPrettyDyeColorName(d));
}
final LinkedList<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_AMOUNTS, amounts);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,21 +12,20 @@
package me.blackvein.quests.tasks;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.util.Lang;
import org.bukkit.ChatColor;
import org.bukkit.scheduler.BukkitRunnable;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.util.Lang;
public class ActionTimer extends BukkitRunnable {
private final BukkitQuester quester;
private final BukkitQuest quest;
private final Quester quester;
private final Quest quest;
private final int time;
private final boolean last;
public ActionTimer(final BukkitQuester quester, final BukkitQuest quest, final int time, final boolean last) {
public ActionTimer(final Quester quester, final Quest quest, final int time, final boolean last) {
this.quester = quester;
this.quest = quest;
this.time = time;

View File

@ -12,17 +12,17 @@
package me.blackvein.quests.tasks;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
public class StageTimer implements Runnable {
private final BukkitQuester quester;
private final Quester quester;
private final Quests plugin;
private final BukkitQuest quest;
private final Quest quest;
public StageTimer(final Quests plugin, final BukkitQuester quester, final BukkitQuest quest) {
public StageTimer(final Quests plugin, final Quester quester, final Quest quest) {
this.quester = quester;
this.quest = quest;
this.plugin = plugin;

View File

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