Refactor to core module, part 1

This commit is contained in:
PikaMug 2022-01-06 10:59:21 -05:00
parent d9d93552a3
commit 182ecb3433
173 changed files with 8565 additions and 7555 deletions

View File

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>me.blackvein.quests</groupId> <groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId> <artifactId>quests-parent</artifactId>
<version>4.1.3</version> <version>4.2.0</version>
</parent> </parent>
<artifactId>quests-api</artifactId> <artifactId>quests-api</artifactId>
@ -166,31 +167,6 @@
<defaultGoal>clean package install</defaultGoal> <defaultGoal>clean package install</defaultGoal>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory> <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>lang/**/*.*</include>
<include>actions.yml</include>
<include>conditions.yml</include>
<include>config.yml</include>
<include>plugin.yml</include>
<include>quests.yml</include>
<include>strings.yml</include>
</includes>
</resource>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/</directory>
<filtering>false</filtering>
<includes>
<include>README.md</include>
</includes>
</resource>
</resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View File

@ -12,85 +12,34 @@
package me.blackvein.quests; package me.blackvein.quests;
import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent;
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
public abstract class CustomObjective implements Listener { public interface CustomObjective {
private final Quests plugin = Quests.getPlugin(Quests.class); String getModuleName();
private String name = null;
private String author = null;
private String display = "Progress: %count%";
private Entry<String, Short> item = new AbstractMap.SimpleEntry<>("BOOK", (short) 0);
private final LinkedList<Entry<String, Object>> data = new LinkedList<>();
private final Map<String, String> descriptions = new HashMap<>();
private String countPrompt = "Enter number";
private boolean showCount = true;
private int count = 1;
public String getModuleName() { Map.Entry<String, Short> getModuleItem();
return new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getName()
.replace(".jar", "");
}
public Entry<String, Short> getModuleItem() { String getName();
return new AbstractMap.SimpleEntry<>("IRON_INGOT", (short) 0);
}
public String getName() { void setName(final String name);
return name;
}
public void setName(final String name) { String getAuthor();
this.name = name;
}
public String getAuthor() { void setAuthor(final String author);
return author;
}
public void setAuthor(final String author) { String getDisplay();
this.author = author;
}
public String getDisplay() { void setDisplay(final String display);
return display;
}
public void setDisplay(final String display) { Map.Entry<String, Short> getItem();
this.display = display;
}
public Entry<String, Short> getItem() { void setItem(final String type, final short durability);
return item;
}
/** LinkedList<Map.Entry<String, Object>> getData();
* @deprecated Use {@link #setItem(String, short)}
*/
public void addItem(final String type, final short durability) {
setItem(type, durability);
}
public void setItem(final String type, final short durability) {
this.item = new AbstractMap.SimpleEntry<>(type, durability);
}
public LinkedList<Entry<String, Object>> getData() {
return data;
}
/** /**
* Add a new prompt<p> * Add a new prompt<p>
@ -101,128 +50,39 @@ public abstract class CustomObjective implements Listener {
* @param description Description of expected input * @param description Description of expected input
* @param defaultValue Value to be used if input is not received * @param defaultValue Value to be used if input is not received
*/ */
public void addStringPrompt(final String title, final String description, final Object defaultValue) { void addStringPrompt(final String title, final String description, final Object defaultValue);
final Entry<String, Object> prompt = new AbstractMap.SimpleEntry<>(title, defaultValue);
data.add(prompt);
descriptions.put(title, description);
}
public Map<String, String> getDescriptions() { Map<String, String> getDescriptions();
return descriptions;
}
public int getCount() { int getCount();
return count;
}
public void setCount(final int count) { void setCount(final int count);
this.count = count;
}
public String getCountPrompt() { String getCountPrompt();
return countPrompt;
}
public void setCountPrompt(final String countPrompt) { void setCountPrompt(final String countPrompt);
this.countPrompt = countPrompt;
}
/** /**
* Check whether to let user set required amount for objective * Check whether to let user set required amount for objective
*/ */
public boolean canShowCount() { boolean canShowCount();
return showCount;
}
/** /**
* Set whether to let user set required amount for objective * Set whether to let user set required amount for objective
* *
* @param showCount Whether to show the count * @param showCount Whether to show the count
*/ */
public void setShowCount(final boolean showCount) { void setShowCount(final boolean showCount);
this.showCount = showCount;
}
public Map<String, Object> getDataForPlayer(final Player player, final CustomObjective customObj, final Quest quest) {
final Quester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
final Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
return null;
}
CustomObjective found = null;
for (final me.blackvein.quests.CustomObjective co : currentStage.customObjectives) {
if (co.getName().equals(customObj.getName())) {
found = co;
break;
}
}
if (found != null) {
final Map<String, Object> m = new HashMap<>();
for (final Entry<String, Object> dataMap : found.getData()) {
for (final Entry<String, Object> e : currentStage.customObjectiveData) {
if (e.getKey().equals(dataMap.getKey())) {
m.put(e.getKey(), e.getValue());
}
}
}
if (!m.isEmpty()) {
return m;
}
}
}
return null;
}
public void incrementObjective(final Player player, final CustomObjective obj, final int count, final Quest quest) { /**
final Quester quester = plugin.getQuester(player.getUniqueId()); * Get custom objective data for applicable player
if (quester != null) { *
if (quester.hasCustomObjective(quest, obj.getName())) { * @param player Player attempting this objective
int index = -1; * @param customObj The objective being attempted
final LinkedList<Integer> customObjCounts = quester.getQuestData(quest).customObjectiveCounts; * @param quest Current me.blackvein.quests.Quest which includes this objective
for (final CustomObjective co : quester.getCurrentStage(quest).customObjectives) { * @return data
index++; */
if (co.getName().equals(this.getName())) { Map<String, Object> getDataForPlayer(final Player player, final CustomObjective customObj, final Quest quest);
if (index >= customObjCounts.size()) {
plugin.getLogger().severe("Index was larger than count for " + obj.getName() + " by " void incrementObjective(final Player player, final CustomObjective obj, final int count, final Quest quest);
+ obj.getAuthor());
continue;
}
final int old = customObjCounts.get(index);
plugin.getQuester(player.getUniqueId()).getQuestData(quest).customObjectiveCounts
.set(index, old + count);
break;
}
}
if (index > -1) {
final int progress = customObjCounts.get(index);
final int goal = quester.getCurrentStage(quest).customObjectiveCounts.get(index);
final ObjectiveType type = ObjectiveType.CUSTOM;
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent(quester, quest, new Objective(type, progress, goal));
plugin.getServer().getPluginManager().callEvent(preEvent);
if (progress >= goal) {
quester.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, obj);
// Multiplayer
final int finalIndex = index;
quester.dispatchMultiplayerObjectives(quest, quester.getCurrentStage(quest), (final Quester q) -> {
final int old = q.getQuestData(quest).customObjectiveCounts.get(finalIndex);
q.getQuestData(quest).customObjectiveCounts.set(finalIndex, old + count);
q.finishObjective(quest, new Objective(type, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, obj);
return null;
});
}
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent(quester, quest, new Objective(type, progress, goal));
plugin.getServer().getPluginManager().callEvent(postEvent);
}
}
}
}
} }

View File

@ -1,62 +1,4 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* 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;
import org.bukkit.inventory.ItemStack; public interface Objective {
import me.blackvein.quests.enums.ObjectiveType;
public class Objective {
private final ObjectiveType type;
private final int progress;
private final int goal;
private final ItemStack progressStack;
private final ItemStack goalStack;
public Objective(final ObjectiveType type, final int progress, final int goal) {
this.type = type;
this.progress = progress;
this.goal = goal;
this.progressStack = null;
this.goalStack = null;
}
public Objective(final ObjectiveType type, final ItemStack progress, final ItemStack goal) {
this.type = type;
this.progress = progress.getAmount();
this.goal = goal.getAmount();
this.progressStack = progress;
this.goalStack = goal;
}
public ObjectiveType getType() {
return type;
}
public int getProgress() {
return progress;
}
public int getGoal() {
return goal;
}
public ItemStack getItemProgress() {
return progressStack;
}
public ItemStack getItemGoal() {
return goalStack;
}
} }

View File

@ -1,97 +1,4 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* 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;
public class Options { public interface Options {
private boolean allowCommands = true;
private boolean allowQuitting = true;
private boolean ignoreSilkTouch = true;
private String externalPartyPlugin = null;
private boolean usePartiesPlugin = true;
private boolean handleOfflinePlayers = false;
private double shareDistance = 0.0D;
private int shareProgressLevel = 1;
private boolean shareSameQuestOnly = true;
public boolean canAllowCommands() {
return allowCommands;
}
public void setAllowCommands(final boolean allowCommands) {
this.allowCommands = allowCommands;
}
public boolean canAllowQuitting() {
return allowQuitting;
}
public void setAllowQuitting(final boolean allowQuitting) {
this.allowQuitting = allowQuitting;
}
public boolean canIgnoreSilkTouch() {
return ignoreSilkTouch;
}
public void setIgnoreSilkTouch(final boolean ignoreSilkTouch) {
this.ignoreSilkTouch = ignoreSilkTouch;
}
public String getExternalPartyPlugin() {
return externalPartyPlugin;
}
public void setExternalPartyPlugin(final String externalPartyPlugin) {
this.externalPartyPlugin = externalPartyPlugin;
}
public boolean canUsePartiesPlugin() {
return usePartiesPlugin;
}
public void setUsePartiesPlugin(final boolean usePartiesPlugin) {
this.usePartiesPlugin = usePartiesPlugin;
}
public int getShareProgressLevel() {
return shareProgressLevel;
}
public void setShareProgressLevel(final int shareProgressLevel) {
this.shareProgressLevel = shareProgressLevel;
}
public boolean canShareSameQuestOnly() {
return shareSameQuestOnly;
}
public void setShareSameQuestOnly(final boolean shareSameQuestOnly) {
this.shareSameQuestOnly = shareSameQuestOnly;
}
public double getShareDistance() {
return shareDistance;
}
public void setShareDistance(final double shareDistance) {
this.shareDistance = shareDistance;
}
public boolean canHandleOfflinePlayers() {
return handleOfflinePlayers;
}
public void setHandleOfflinePlayers(final boolean handleOfflinePlayers) {
this.handleOfflinePlayers = handleOfflinePlayers;
}
} }

View File

@ -1,91 +1,4 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* 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;
import java.util.Calendar; public interface Planner {
import java.util.TimeZone;
public class Planner {
public String start = null;
public String end = null;
public long repeat = -1;
public long cooldown = -1;
public boolean override = false;
public String getStart() {
return start;
}
public long getStartInMillis() {
if (start == null) {
return -1;
}
final Calendar cal = Calendar.getInstance();
final String[] s = start.split(":");
cal.set(Integer.parseInt(s[2]), Integer.parseInt(s[1]), Integer.parseInt(s[0]),
Integer.parseInt(s[3]), Integer.parseInt(s[4]), Integer.parseInt(s[5]));
final TimeZone tz = TimeZone.getTimeZone(s[6]);
cal.setTimeZone(tz);
return cal.getTimeInMillis();
}
public boolean hasStart() {
return start != null;
}
public void setStart(final String start) {
this.start = start;
}
public String getEnd() {
return end;
}
public long getEndInMillis() {
if (end == null) {
return -1;
}
final Calendar cal = Calendar.getInstance();
final String[] s = end.split(":");
cal.set(Integer.parseInt(s[2]), Integer.parseInt(s[1]), Integer.parseInt(s[0]),
Integer.parseInt(s[3]), Integer.parseInt(s[4]), Integer.parseInt(s[5]));
final TimeZone tz = TimeZone.getTimeZone(s[6]);
cal.setTimeZone(tz);
return cal.getTimeInMillis();
}
public boolean hasEnd() {
return end != null;
}
public void setEnd(final String end) {
this.end = end;
}
public long getRepeat() {
return repeat;
}
public boolean hasRepeat() {
return repeat != -1;
}
public void setRepeat(final long repeat) {
this.repeat = repeat;
}
public long getCooldown() {
return cooldown;
}
public boolean hasCooldown() {
return cooldown != -1;
}
public void setCooldown(final long cooldown) {
this.cooldown = cooldown;
}
public boolean getOverride() {
return override;
}
public void setOverride(final boolean override) {
this.override = override;
}
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
package me.blackvein.quests;
import org.bukkit.plugin.Plugin;
import java.util.List;
public interface QuestsAPI extends Plugin {
List<CustomObjective> getCustomObjectives();
List<CustomReward> getCustomRewards();
List<CustomRequirement> getCustomRequirements();
}

View File

@ -1,115 +1,60 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* 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;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class Requirements { public interface Requirements {
private int money = 0; int getMoney();
private int questPoints = 0;
private List<ItemStack> items = new LinkedList<>(); void setMoney(final int money);
private List<Boolean> removeItems = new LinkedList<>();
private List<Quest> neededQuests = new LinkedList<>(); int getQuestPoints();
private List<Quest> blockQuests = new LinkedList<>();
private List<String> permissions = new LinkedList<>(); void setQuestPoints(final int questPoints);
private List<String> mcmmoSkills = new LinkedList<>();
private List<Integer> mcmmoAmounts = new LinkedList<>(); List<ItemStack> getItems();
private String heroesPrimaryClass = null;
private String heroesSecondaryClass = null; void setItems(final List<ItemStack> items);
private Map<String, Map<String, Object>> customRequirements = new HashMap<>();
private List<String> detailsOverride = new LinkedList<>(); List<Boolean> getRemoveItems();
public int getMoney() { void setRemoveItems(final List<Boolean> removeItems);
return money;
} List<Quest> getNeededQuests();
public void setMoney(final int money) {
this.money = money; void setNeededQuests(final List<Quest> neededQuests);
}
public int getQuestPoints() { List<Quest> getBlockQuests();
return questPoints;
} void setBlockQuests(final List<Quest> blockQuests);
public void setQuestPoints(final int questPoints) {
this.questPoints = questPoints; List<String> getPermissions();
}
public List<ItemStack> getItems() { void setPermissions(final List<String> permissions);
return items;
} List<String> getMcmmoSkills();
public void setItems(final List<ItemStack> items) {
this.items = items; void setMcmmoSkills(final List<String> mcmmoSkills);
}
public List<Boolean> getRemoveItems() { List<Integer> getMcmmoAmounts();
return removeItems;
} void setMcmmoAmounts(final List<Integer> mcmmoAmounts);
public void setRemoveItems(final List<Boolean> removeItems) {
this.removeItems = removeItems; String getHeroesPrimaryClass();
}
public List<Quest> getNeededQuests() { void setHeroesPrimaryClass(final String heroesPrimaryClass);
return neededQuests;
} String getHeroesSecondaryClass();
public void setNeededQuests(final List<Quest> neededQuests) {
this.neededQuests = neededQuests; void setHeroesSecondaryClass(final String heroesSecondaryClass);
}
public List<Quest> getBlockQuests() { Map<String, Map<String, Object>> getCustomRequirements();
return blockQuests;
} void setCustomRequirements(final Map<String, Map<String, Object>> customRequirements);
public void setBlockQuests(final List<Quest> blockQuests) {
this.blockQuests = blockQuests; List<String> getDetailsOverride();
}
public List<String> getPermissions() { void setDetailsOverride(final List<String> detailsOverride);
return permissions;
}
public void setPermissions(final List<String> permissions) {
this.permissions = permissions;
}
public List<String> getMcmmoSkills() {
return mcmmoSkills;
}
public void setMcmmoSkills(final List<String> mcmmoSkills) {
this.mcmmoSkills = mcmmoSkills;
}
public List<Integer> getMcmmoAmounts() {
return mcmmoAmounts;
}
public void setMcmmoAmounts(final List<Integer> mcmmoAmounts) {
this.mcmmoAmounts = mcmmoAmounts;
}
public String getHeroesPrimaryClass() {
return heroesPrimaryClass;
}
public void setHeroesPrimaryClass(final String heroesPrimaryClass) {
this.heroesPrimaryClass = heroesPrimaryClass;
}
public String getHeroesSecondaryClass() {
return heroesSecondaryClass;
}
public void setHeroesSecondaryClass(final String heroesSecondaryClass) {
this.heroesSecondaryClass = heroesSecondaryClass;
}
public Map<String, Map<String, Object>> getCustomRequirements() {
return customRequirements;
}
protected void setCustomRequirements(final Map<String, Map<String, Object>> customRequirements) {
this.customRequirements = customRequirements;
}
public List<String> getDetailsOverride() {
return detailsOverride;
}
public void setDetailsOverride(final List<String> detailsOverride) {
this.detailsOverride = detailsOverride;
}
} }

View File

@ -1,136 +1,41 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* 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;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class Rewards { public interface Rewards {
private int money = 0; int getMoney();
private int questPoints = 0; void setMoney(final int money);
private int exp = 0; int getQuestPoints();
private List<String> commands = new LinkedList<>(); void setQuestPoints(final int questPoints);
private List<String> commandsOverrideDisplay = new LinkedList<>(); int getExp();
private List<String> permissions = new LinkedList<>(); void setExp(final int exp);
private List<String> permissionWorlds = new LinkedList<>(); List<String> getCommands();
private List<ItemStack> items = new LinkedList<>(); void setCommands(final List<String> commands);
private List<String> mcmmoSkills = new LinkedList<>(); List<String> getCommandsOverrideDisplay();
private List<Integer> mcmmoAmounts = new LinkedList<>(); void setCommandsOverrideDisplay(final List<String> commandsOverrideDisplay);
private List<String> heroesClasses = new LinkedList<>(); List<String> getPermissions();
private List<Double> heroesAmounts = new LinkedList<>(); void setPermissions(final List<String> permissions);
private int partiesExperience = 0; List<String> getPermissionWorlds();
private List<String> phatLoots = new LinkedList<>(); void setPermissionWorlds(final List<String> worldNames);
private Map<String, Map<String, Object>> customRewards = new HashMap<>(); List<ItemStack> getItems();
private List<String> detailsOverride = new LinkedList<>(); void setItems(final List<ItemStack> items);
List<String> getMcmmoSkills();
public int getMoney() { void setMcmmoSkills(final List<String> mcmmoSkills);
return money; List<Integer> getMcmmoAmounts();
} void setMcmmoAmounts(final List<Integer> mcmmoAmounts);
public void setMoney(final int money) { List<String> getHeroesClasses();
this.money = money; void setHeroesClasses(final List<String> heroesClasses);
} List<Double> getHeroesAmounts();
public int getQuestPoints() { void setHeroesAmounts(final List<Double> heroesAmounts);
return questPoints; int getPartiesExperience();
} void setPartiesExperience(final int partiesExperience);
public void setQuestPoints(final int questPoints) { List<String> getPhatLoots();
this.questPoints = questPoints; void setPhatLoots(final List<String> phatLoots);
} Map<String, Map<String, Object>> getCustomRewards();
public int getExp() { void setCustomRewards(final Map<String, Map<String, Object>> customRewards);
return exp; List<String> getDetailsOverride();
} void setDetailsOverride(final List<String> detailsOverride);
public void setExp(final int exp) {
this.exp = exp;
}
public List<String> getCommands() {
return commands;
}
public void setCommands(final List<String> commands) {
this.commands = commands;
}
public List<String> getCommandsOverrideDisplay() {
return commandsOverrideDisplay;
}
public void setCommandsOverrideDisplay(final List<String> commandsOverrideDisplay) {
this.commandsOverrideDisplay = commandsOverrideDisplay;
}
public List<String> getPermissions() {
return permissions;
}
public void setPermissions(final List<String> permissions) {
this.permissions = permissions;
}
public List<String> getPermissionWorlds() {
return permissionWorlds;
}
public void setPermissionWorlds(final List<String> worldNames) {
this.permissionWorlds = worldNames;
}
public List<ItemStack> getItems() {
return items;
}
public void setItems(final List<ItemStack> items) {
this.items = items;
}
public List<String> getMcmmoSkills() {
return mcmmoSkills;
}
public void setMcmmoSkills(final List<String> mcmmoSkills) {
this.mcmmoSkills = mcmmoSkills;
}
public List<Integer> getMcmmoAmounts() {
return mcmmoAmounts;
}
public void setMcmmoAmounts(final List<Integer> mcmmoAmounts) {
this.mcmmoAmounts = mcmmoAmounts;
}
public List<String> getHeroesClasses() {
return heroesClasses;
}
public void setHeroesClasses(final List<String> heroesClasses) {
this.heroesClasses = heroesClasses;
}
public List<Double> getHeroesAmounts() {
return heroesAmounts;
}
public void setHeroesAmounts(final List<Double> heroesAmounts) {
this.heroesAmounts = heroesAmounts;
}
public int getPartiesExperience() {
return partiesExperience;
}
public void setPartiesExperience(final int partiesExperience) {
this.partiesExperience = partiesExperience;
}
public List<String> getPhatLoots() {
return phatLoots;
}
public void setPhatLoots(final List<String> phatLoots) {
this.phatLoots = phatLoots;
}
public Map<String, Map<String, Object>> getCustomRewards() {
return customRewards;
}
protected void setCustomRewards(final Map<String, Map<String, Object>> customRewards) {
this.customRewards = customRewards;
}
public List<String> getDetailsOverride() {
return detailsOverride;
}
public void setDetailsOverride(final List<String> detailsOverride) {
this.detailsOverride = detailsOverride;
}
} }

View File

@ -1,643 +1,230 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* 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;
import me.blackvein.quests.actions.Action; import me.blackvein.quests.actions.Action;
import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.enums.ObjectiveType;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
public class Stage {
protected LinkedList<ItemStack> blocksToBreak = new LinkedList<>();
protected LinkedList<ItemStack> blocksToDamage = new LinkedList<>();
protected LinkedList<ItemStack> blocksToPlace = new LinkedList<>();
protected LinkedList<ItemStack> blocksToUse = new LinkedList<>();
protected LinkedList<ItemStack> blocksToCut = new LinkedList<>();
protected LinkedList<ItemStack> itemsToCraft = new LinkedList<>();
protected LinkedList<ItemStack> itemsToSmelt = new LinkedList<>();
protected LinkedList<ItemStack> itemsToEnchant = new LinkedList<>();
protected LinkedList<ItemStack> itemsToBrew = new LinkedList<>();
protected LinkedList<ItemStack> itemsToConsume = new LinkedList<>();
protected LinkedList<ItemStack> itemsToDeliver = new LinkedList<>();
protected LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
private static final long serialVersionUID = -2774443496142382127L;
@Override
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
final
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
for (final Integer i : this) {
final Integer other = otherList.get(this.indexOf(i));
if (!other.equals(i)) {
return false;
}
}
}
return true;
}
};
protected LinkedList<String> deliverMessages = new LinkedList<>();
protected LinkedList<Integer> citizensToInteract = new LinkedList<Integer>() {
private static final long serialVersionUID = -4086855121042524435L;
@Override
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
final
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
for (final Integer i : this) {
final Integer other = otherList.get(this.indexOf(i));
if (!other.equals(i)) {
return false;
}
}
}
return true;
}
};
protected LinkedList<Integer> citizensToKill = new LinkedList<Integer>() {
private static final long serialVersionUID = 7705964814014176415L;
@Override
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
final
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
for (final Integer i : this) {
final Integer other = otherList.get(this.indexOf(i));
if (!other.equals(i)) {
return false;
}
}
}
return true;
}
};
protected LinkedList<Integer> citizenNumToKill = new LinkedList<>();
protected LinkedList<EntityType> mobsToKill = new LinkedList<>();
protected LinkedList<Integer> mobNumToKill = new LinkedList<>();
protected LinkedList<Location> locationsToKillWithin = new LinkedList<>();
protected LinkedList<Integer> radiiToKillWithin = new LinkedList<>();
protected LinkedList<String> killNames = new LinkedList<>();
protected LinkedList<EntityType> mobsToTame = new LinkedList<>();
protected LinkedList<Integer> mobNumToTame = new LinkedList<>();
protected Integer fishToCatch;
protected Integer cowsToMilk;
protected LinkedList<DyeColor> sheepToShear = new LinkedList<>();
protected LinkedList<Integer> sheepNumToShear = new LinkedList<>();
protected Integer playersToKill;
protected LinkedList<Location> locationsToReach = new LinkedList<>();
protected LinkedList<Integer> radiiToReachWithin = new LinkedList<>();
protected LinkedList<World> worldsToReachWithin = new LinkedList<>();
protected LinkedList<String> locationNames = new LinkedList<>();
protected LinkedList<String> passwordDisplays = new LinkedList<>();
protected LinkedList<String> passwordPhrases = new LinkedList<>();
protected String script;
protected Action startAction = null;
protected Action finishAction = null;
protected Action failAction = null;
protected Action deathAction = null;
protected Map<String, Action> chatActions = new HashMap<>();
protected Map<String, Action> commandActions = new HashMap<>();
protected Action disconnectAction = null;
protected Condition condition = null;
protected long delay = -1;
protected String delayMessage = null;
protected String completeMessage = null;
protected String startMessage = null;
protected LinkedList<String> objectiveOverrides = new LinkedList<>();
protected LinkedList<CustomObjective> customObjectives = new LinkedList<>();
protected LinkedList<Integer> customObjectiveCounts = new LinkedList<>();
protected LinkedList<String> customObjectiveDisplays = new LinkedList<>();
protected LinkedList<Entry<String, Object>> customObjectiveData = new LinkedList<>();
public LinkedList<ItemStack> getBlocksToBreak() {
return blocksToBreak;
}
public void setBlocksToBreak(final LinkedList<ItemStack> blocksToBreak) {
this.blocksToBreak = blocksToBreak;
}
public LinkedList<ItemStack> getBlocksToDamage() {
return blocksToDamage;
}
public void setBlocksToDamage(final LinkedList<ItemStack> blocksToDamage) {
this.blocksToDamage = blocksToDamage;
}
public LinkedList<ItemStack> getBlocksToPlace() {
return blocksToPlace;
}
public void setBlocksToPlace(final LinkedList<ItemStack> blocksToPlace) {
this.blocksToPlace = blocksToPlace;
}
public LinkedList<ItemStack> getBlocksToUse() {
return blocksToUse;
}
public void setBlocksToUse(final LinkedList<ItemStack> blocksToUse) {
this.blocksToUse = blocksToUse;
}
public LinkedList<ItemStack> getBlocksToCut() {
return blocksToCut;
}
public void setBlocksToCut(final LinkedList<ItemStack> blocksToCut) {
this.blocksToCut = blocksToCut;
}
public LinkedList<ItemStack> getItemsToCraft() {
return itemsToCraft;
}
public void setItemsToCraft(final LinkedList<ItemStack> itemsToCraft) {
this.itemsToCraft = itemsToCraft;
}
public LinkedList<ItemStack> getItemsToSmelt() {
return itemsToSmelt;
}
public void setItemsToSmelt(final LinkedList<ItemStack> itemsToSmelt) {
this.itemsToSmelt = itemsToSmelt;
}
public LinkedList<ItemStack> getItemsToEnchant() {
return itemsToEnchant;
}
public void setItemsToEnchant(final LinkedList<ItemStack> itemsToEnchant) {
this.itemsToEnchant = itemsToEnchant;
}
public LinkedList<ItemStack> getItemsToBrew() {
return itemsToBrew;
}
public void setItemsToBrew(final LinkedList<ItemStack> itemsToBrew) {
this.itemsToBrew = itemsToBrew;
}
public LinkedList<ItemStack> getItemsToConsume() {
return itemsToConsume;
}
public void setItemsToConsume(final LinkedList<ItemStack> itemsToConsume) {
this.itemsToBrew = itemsToConsume;
}
public LinkedList<ItemStack> getItemsToDeliver() {
return itemsToDeliver;
}
public void setItemsToDeliver(final LinkedList<ItemStack> itemsToDeliver) {
this.itemsToDeliver = itemsToDeliver;
}
public LinkedList<Integer> getItemDeliveryTargets() {
return itemDeliveryTargets;
}
public void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets) {
this.itemDeliveryTargets = itemDeliveryTargets;
}
public LinkedList<String> getDeliverMessages() {
return deliverMessages;
}
public void setDeliverMessages(final LinkedList<String> deliverMessages) {
this.deliverMessages = deliverMessages;
}
public LinkedList<Integer> getCitizensToInteract() {
return citizensToInteract;
}
public void setCitizensToInteract(final LinkedList<Integer> citizensToInteract) {
this.citizensToInteract = citizensToInteract;
}
public LinkedList<Integer> getCitizensToKill() {
return citizensToKill;
}
public void setCitizensToKill(final LinkedList<Integer> citizensToKill) {
this.citizensToKill = citizensToKill;
}
public LinkedList<Integer> getCitizenNumToKill() {
return citizenNumToKill;
}
public void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill) {
this.citizenNumToKill = citizenNumToKill;
}
public LinkedList<EntityType> getMobsToKill() {
return mobsToKill;
}
public void setMobsToKill(final LinkedList<EntityType> mobsToKill) {
this.mobsToKill = mobsToKill;
}
public LinkedList<Integer> getMobNumToKill() {
return mobNumToKill;
}
public void setMobNumToKill(final LinkedList<Integer> mobNumToKill) {
this.mobNumToKill = mobNumToKill;
}
public LinkedList<Location> getLocationsToKillWithin() {
return locationsToKillWithin;
}
public void setLocationsToKillWithin(final LinkedList<Location> locationsToKillWithin) {
this.locationsToKillWithin = locationsToKillWithin;
}
public LinkedList<Integer> getRadiiToKillWithin() {
return radiiToKillWithin;
}
public void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin) {
this.radiiToKillWithin = radiiToKillWithin;
}
public LinkedList<String> getKillNames() {
return killNames;
}
public void setKillNames(final LinkedList<String> killNames) {
this.killNames = killNames;
}
public LinkedList<Location> getLocationsToReach() {
return locationsToReach;
}
public void setLocationsToReach(final LinkedList<Location> locationsToReach) {
this.locationsToReach = locationsToReach;
}
public LinkedList<Integer> getRadiiToReachWithin() { public interface Stage {
return radiiToReachWithin; LinkedList<ItemStack> getBlocksToBreak();
}
public void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin) { void setBlocksToBreak(final LinkedList<ItemStack> blocksToBreak);
this.radiiToReachWithin = radiiToReachWithin;
}
public LinkedList<World> getWorldsToReachWithin() { LinkedList<ItemStack> getBlocksToDamage();
return worldsToReachWithin;
} void setBlocksToDamage(final LinkedList<ItemStack> blocksToDamage);
public void setWorldsToReachWithin(final LinkedList<World> worldsToReachWithin) { LinkedList<ItemStack> getBlocksToPlace();
this.worldsToReachWithin = worldsToReachWithin;
} void setBlocksToPlace(final LinkedList<ItemStack> blocksToPlace);
public LinkedList<String> getLocationNames() { LinkedList<ItemStack> getBlocksToUse();
return locationNames;
} void setBlocksToUse(final LinkedList<ItemStack> blocksToUse);
public void setLocationNames(final LinkedList<String> locationNames) { LinkedList<ItemStack> getBlocksToCut();
this.locationNames = locationNames;
} void setBlocksToCut(final LinkedList<ItemStack> blocksToCut);
public LinkedList<EntityType> getMobsToTame() { LinkedList<ItemStack> getItemsToCraft();
return mobsToTame;
} void setItemsToCraft(final LinkedList<ItemStack> itemsToCraft);
public void setMobsToTame(final LinkedList<EntityType> mobsToTame) { LinkedList<ItemStack> getItemsToSmelt();
this.mobsToTame = mobsToTame;
} void setItemsToSmelt(final LinkedList<ItemStack> itemsToSmelt);
public LinkedList<Integer> getMobNumToTame() { LinkedList<ItemStack> getItemsToEnchant();
return mobNumToTame;
} void setItemsToEnchant(final LinkedList<ItemStack> itemsToEnchant);
public void setMobNumToTame(final LinkedList<Integer> mobNumToTame) { LinkedList<ItemStack> getItemsToBrew();
this.mobNumToTame = mobNumToTame;
} void setItemsToBrew(final LinkedList<ItemStack> itemsToBrew);
public Integer getFishToCatch() { LinkedList<ItemStack> getItemsToConsume();
return fishToCatch;
} void setItemsToConsume(final LinkedList<ItemStack> itemsToConsume);
public void setFishToCatch(final Integer fishToCatch) { LinkedList<ItemStack> getItemsToDeliver();
this.fishToCatch = fishToCatch;
} void setItemsToDeliver(final LinkedList<ItemStack> itemsToDeliver);
public Integer getCowsToMilk() { LinkedList<Integer> getItemDeliveryTargets();
return cowsToMilk;
} void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets);
public void setCowsToMilk(final Integer cowsToMilk) { LinkedList<String> getDeliverMessages();
this.cowsToMilk = cowsToMilk;
} void setDeliverMessages(final LinkedList<String> deliverMessages);
public Integer getPlayersToKill() { LinkedList<Integer> getCitizensToInteract();
return playersToKill;
} void setCitizensToInteract(final LinkedList<Integer> citizensToInteract);
public void setPlayersToKill(final Integer playersToKill) { LinkedList<Integer> getCitizensToKill();
this.playersToKill = playersToKill;
} void setCitizensToKill(final LinkedList<Integer> citizensToKill);
public LinkedList<DyeColor> getSheepToShear() { LinkedList<Integer> getCitizenNumToKill();
return sheepToShear;
} void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill);
public void setSheepToShear(final LinkedList<DyeColor> sheepToShear) { LinkedList<EntityType> getMobsToKill();
this.sheepToShear = sheepToShear;
} void setMobsToKill(final LinkedList<EntityType> mobsToKill);
public LinkedList<Integer> getSheepNumToShear() { LinkedList<Integer> getMobNumToKill();
return sheepNumToShear;
} void setMobNumToKill(final LinkedList<Integer> mobNumToKill);
public void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear) { LinkedList<Location> getLocationsToKillWithin();
this.sheepNumToShear = sheepNumToShear;
} void setLocationsToKillWithin(final LinkedList<Location> locationsToKillWithin);
public LinkedList<String> getPasswordDisplays() { LinkedList<Integer> getRadiiToKillWithin();
return passwordDisplays;
} void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin);
public void setPasswordDisplays(final LinkedList<String> passwordDisplays) { LinkedList<String> getKillNames();
this.passwordDisplays = passwordDisplays;
} void setKillNames(final LinkedList<String> killNames);
public LinkedList<String> getPasswordPhrases() { LinkedList<Location> getLocationsToReach();
return passwordPhrases;
} void setLocationsToReach(final LinkedList<Location> locationsToReach);
public void setPasswordPhrases(final LinkedList<String> passwordPhrases) { LinkedList<Integer> getRadiiToReachWithin();
this.passwordPhrases = passwordPhrases;
} void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin);
public String getScript() { LinkedList<World> getWorldsToReachWithin();
return script;
} void setWorldsToReachWithin(final LinkedList<World> worldsToReachWithin);
public void setScript(final String script) { LinkedList<String> getLocationNames();
this.script = script;
} void setLocationNames(final LinkedList<String> locationNames);
public Action getStartAction() { LinkedList<EntityType> getMobsToTame();
return startAction;
} void setMobsToTame(final LinkedList<EntityType> mobsToTame);
public void setStartAction(final Action startAction) { LinkedList<Integer> getMobNumToTame();
this.startAction = startAction;
} void setMobNumToTame(final LinkedList<Integer> mobNumToTame);
public Action getFinishAction() { Integer getFishToCatch();
return finishAction;
} void setFishToCatch(final Integer fishToCatch);
public void setFinishAction(final Action finishAction) { Integer getCowsToMilk();
this.finishAction = finishAction;
} void setCowsToMilk(final Integer cowsToMilk);
public Action getFailAction() { Integer getPlayersToKill();
return failAction;
} void setPlayersToKill(final Integer playersToKill);
public void setFailAction(final Action failAction) { LinkedList<DyeColor> getSheepToShear();
this.failAction = failAction;
} void setSheepToShear(final LinkedList<DyeColor> sheepToShear);
public Action getDeathAction() { LinkedList<Integer> getSheepNumToShear();
return deathAction;
} void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear);
public void setDeathAction(final Action deathAction) { LinkedList<String> getPasswordDisplays();
this.deathAction = deathAction;
} void setPasswordDisplays(final LinkedList<String> passwordDisplays);
public Map<String, Action> getChatActions() { LinkedList<String> getPasswordPhrases();
return chatActions;
} void setPasswordPhrases(final LinkedList<String> passwordPhrases);
public void setChatActions(final Map<String, Action> chatActions) { String getScript();
this.chatActions = chatActions;
} void setScript(final String script);
public Map<String, Action> getCommandActions() { Action getStartAction();
return commandActions;
} void setStartAction(final Action startAction);
public void setCommandActions(final Map<String, Action> commandActions) { Action getFinishAction();
this.commandActions = commandActions;
} void setFinishAction(final Action finishAction);
public Action getDisconnectAction() { Action getFailAction();
return disconnectAction;
} void setFailAction(final Action failAction);
public void setDisconnectAction(final Action disconnectAction) { Action getDeathAction();
this.disconnectAction = disconnectAction;
} void setDeathAction(final Action deathAction);
public Condition getCondition() { Map<String, Action> getChatActions();
return condition;
} void setChatActions(final Map<String, Action> chatActions);
public void setCondition(final Condition condition) { Map<String, Action> getCommandActions();
this.condition = condition;
} void setCommandActions(final Map<String, Action> commandActions);
public long getDelay() { Action getDisconnectAction();
return delay;
} void setDisconnectAction(final Action disconnectAction);
public void setDelay(final long delay) { Condition getCondition();
this.delay = delay;
} void setCondition(final Condition condition);
public String getDelayMessage() { long getDelay();
return delayMessage;
} void setDelay(final long delay);
public void setDelayMessage(final String delayMessage) { String getDelayMessage();
this.delayMessage = delayMessage;
} void setDelayMessage(final String delayMessage);
public String getCompleteMessage() { String getCompleteMessage();
return completeMessage;
} void setCompleteMessage(final String completeMessage);
public void setCompleteMessage(final String completeMessage) { String getStartMessage();
this.completeMessage = completeMessage;
} void setStartMessage(final String startMessage);
public String getStartMessage() { LinkedList<String> getObjectiveOverrides();
return startMessage;
} void setObjectiveOverrides(final LinkedList<String> objectiveOverrides);
public void setStartMessage(final String startMessage) { LinkedList<CustomObjective> getCustomObjectives();
this.startMessage = startMessage;
} LinkedList<Integer> getCustomObjectiveCounts();
public LinkedList<String> getObjectiveOverrides() { LinkedList<String> getCustomObjectiveDisplays();
return objectiveOverrides;
} LinkedList<Map.Entry<String, Object>> getCustomObjectiveData();
public void setObjectiveOverrides(final LinkedList<String> objectiveOverrides) {
this.objectiveOverrides = objectiveOverrides;
}
public LinkedList<CustomObjective> getCustomObjectives() {
return customObjectives;
}
public LinkedList<Integer> getCustomObjectiveCounts() {
return customObjectiveCounts;
}
public LinkedList<String> getCustomObjectiveDisplays() {
return customObjectiveDisplays;
}
public LinkedList<Entry<String, Object>> getCustomObjectiveData() {
return customObjectiveData;
}
/** /**
* Check if stage has at least one objective<p> * Check if stage has at least one objective<p>
* *
* Excludes start/complete message, delay, and objective-override * Excludes start/complete message, delay, and objective-override
* *
* @return true if stage contains an objective * @return true if stage contains an objective
*/ */
public boolean hasObjective() { boolean hasObjective();
if (!blocksToBreak.isEmpty()) { return true; }
if (!blocksToDamage.isEmpty()) { return true; }
if (!blocksToPlace.isEmpty()) { return true; }
if (!blocksToUse.isEmpty()) { return true; }
if (!blocksToCut.isEmpty()) { return true; }
if (cowsToMilk != null) { return true; }
if (fishToCatch != null) { return true; }
if (playersToKill != null) { return true; }
if (!itemsToCraft.isEmpty()) { return true; }
if (!itemsToSmelt.isEmpty()) { return true; }
if (!itemsToEnchant.isEmpty()) { return true; }
if (!itemsToBrew.isEmpty()) { return true; }
if (!itemsToConsume.isEmpty()) { return true; }
if (!itemsToDeliver.isEmpty()) { return true; }
if (!citizensToInteract.isEmpty()) { return true; }
if (!citizensToKill.isEmpty()) { return true; }
if (!locationsToReach.isEmpty()) { return true; }
if (!mobsToTame.isEmpty()) { return true; }
if (!sheepToShear.isEmpty()) { return true; }
if (!passwordDisplays.isEmpty()) { return true; }
return !customObjectives.isEmpty();
}
/** /**
* Check if stage has the specified type of objective<p> * Check if stage has the specified type of objective<p>
* *
* Accepted strings are: breakBlock, damageBlock, placeBlock, useBlock,
* cutBlock, craftItem, smeltItem, enchantItem, brewItem, milkCow, catchFish,
* killMob, deliverItem, killPlayer, talkToNPC, killNPC, tameMob,
* shearSheep, password, reachLocation
*
* @deprecated Use {@link #containsObjective(ObjectiveType)}
*
* @param type The type of objective to check for * @param type The type of objective to check for
* @return true if stage contains specified objective * @return true if stage contains specified objective
*/ */
@Deprecated boolean containsObjective(final ObjectiveType type);
public boolean containsObjective(final String type) {
return containsObjective(ObjectiveType.fromName(type));
}
/**
* Check if stage has the specified type of objective<p>
*
* @param type The type of objective to check for
* @return true if stage contains specified objective
*/
public boolean containsObjective(final ObjectiveType type) {
if (type.equals(ObjectiveType.BREAK_BLOCK)) {
return !blocksToBreak.isEmpty();
} else if (type.equals(ObjectiveType.DAMAGE_BLOCK)) {
return !blocksToDamage.isEmpty();
} else if (type.equals(ObjectiveType.PLACE_BLOCK)) {
return !blocksToPlace.isEmpty();
} else if (type.equals(ObjectiveType.USE_BLOCK)) {
return !blocksToUse.isEmpty();
} else if (type.equals(ObjectiveType.CUT_BLOCK)) {
return !blocksToCut.isEmpty();
} else if (type.equals(ObjectiveType.CRAFT_ITEM)) {
return !itemsToCraft.isEmpty();
} else if (type.equals(ObjectiveType.SMELT_ITEM)) {
return !itemsToSmelt.isEmpty();
} else if (type.equals(ObjectiveType.ENCHANT_ITEM)) {
return !itemsToEnchant.isEmpty();
} else if (type.equals(ObjectiveType.BREW_ITEM)) {
return !itemsToBrew.isEmpty();
} else if (type.equals(ObjectiveType.CONSUME_ITEM)) {
return !itemsToConsume.isEmpty();
} else if (type.equals(ObjectiveType.DELIVER_ITEM)) {
return !itemsToDeliver.isEmpty();
} else if (type.equals(ObjectiveType.MILK_COW)) {
return cowsToMilk != null;
} else if (type.equals(ObjectiveType.CATCH_FISH)) {
return fishToCatch != null;
} else if (type.equals(ObjectiveType.KILL_MOB)) {
return !mobsToKill.isEmpty();
} else if (type.equals(ObjectiveType.KILL_PLAYER)) {
return playersToKill != null;
} else if (type.equals(ObjectiveType.TALK_TO_NPC)) {
return !citizensToInteract.isEmpty();
} else if (type.equals(ObjectiveType.KILL_NPC)) {
return !citizensToKill.isEmpty();
} else if (type.equals(ObjectiveType.TAME_MOB)) {
return !mobsToTame.isEmpty();
} else if (type.equals(ObjectiveType.SHEAR_SHEEP)) {
return !sheepToShear.isEmpty();
} else if (type.equals(ObjectiveType.REACH_LOCATION)) {
return !locationsToReach.isEmpty();
} else if (type.equals(ObjectiveType.PASSWORD)) {
return !passwordPhrases.isEmpty();
} else {
return false;
}
}
} }

View File

@ -1,421 +1,108 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.actions; package me.blackvein.quests.actions;
import me.blackvein.quests.Quest; import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestMob;
import me.blackvein.quests.Quester; import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.tasks.ActionTimer;
import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.InventoryUtil;
import me.blackvein.quests.util.Lang;
import org.bukkit.ChatColor;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
public class Action implements Comparable<Action> { public interface Action {
String getName();
private final Quests plugin; void setName(final String name);
private String name = "";
protected String message = null;
protected boolean clearInv = false;
protected boolean failQuest = false;
protected LinkedList<Location> explosions = new LinkedList<>();
protected Map<Location, Effect> effects = new HashMap<>();
protected LinkedList<ItemStack> items = new LinkedList<>();
protected World stormWorld = null;
protected int stormDuration = 0;
protected World thunderWorld = null;
protected int thunderDuration = 0;
protected int timer = 0;
protected boolean cancelTimer = false;
protected LinkedList<QuestMob> mobSpawns = new LinkedList<QuestMob>() {
private static final long serialVersionUID = -761974607799449780L; String getMessage();
@Override void setMessage(final String message);
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
final
LinkedList<QuestMob> other = (LinkedList<QuestMob>) o;
if (size() != other.size()) {
return false;
}
for (int i = 0; i < size(); i++) {
if (!get(i).equals(other.get(i))) {
return false;
}
}
}
return false;
}
};
protected LinkedList<Location> lightningStrikes = new LinkedList<>();
protected LinkedList<String> commands = new LinkedList<>();
protected LinkedList<PotionEffect> potionEffects = new LinkedList<>();
protected int hunger = -1;
protected int saturation = -1;
protected float health = -1;
protected Location teleport;
protected String book = "";
protected String denizenScript;
public Action(final Quests plugin) { boolean isClearInv();
this.plugin = plugin;
}
@Override
public int compareTo(final Action action) {
return name.compareTo(action.getName());
}
public String getName() { void setClearInv(final boolean clearInv);
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getMessage() { boolean isFailQuest();
return message;
}
public void setMessage(final String message) { void setFailQuest(final boolean failQuest);
this.message = message;
}
public boolean isClearInv() { LinkedList<Location> getExplosions();
return clearInv;
}
public void setClearInv(final boolean clearInv) { void setExplosions(final LinkedList<Location> explosions);
this.clearInv = clearInv;
}
public boolean isFailQuest() { Map<Location, Effect> getEffects();
return failQuest;
}
public void setFailQuest(final boolean failQuest) { void setEffects(final Map<Location, Effect> effects);
this.failQuest = failQuest;
}
public LinkedList<Location> getExplosions() { LinkedList<ItemStack> getItems();
return explosions;
}
public void setExplosions(final LinkedList<Location> explosions) { void setItems(final LinkedList<ItemStack> items);
this.explosions = explosions;
}
public Map<Location, Effect> getEffects() { World getStormWorld();
return effects;
}
public void setEffects(final Map<Location, Effect> effects) { void setStormWorld(final World stormWorld);
this.effects = effects;
}
public LinkedList<ItemStack> getItems() { int getStormDuration();
return items;
}
public void setItems(final LinkedList<ItemStack> items) { void setStormDuration(final int stormDuration);
this.items = items;
}
public World getStormWorld() { World getThunderWorld();
return stormWorld;
}
public void setStormWorld(final World stormWorld) { void setThunderWorld(final World thunderWorld);
this.stormWorld = stormWorld;
}
public int getStormDuration() { int getThunderDuration();
return stormDuration;
}
public void setStormDuration(final int stormDuration) { void setThunderDuration(final int thunderDuration);
this.stormDuration = stormDuration;
}
public World getThunderWorld() { int getTimer();
return thunderWorld;
}
public void setThunderWorld(final World thunderWorld) { void setTimer(final int timer);
this.thunderWorld = thunderWorld;
}
public int getThunderDuration() { boolean isCancelTimer();
return thunderDuration;
}
public void setThunderDuration(final int thunderDuration) { void setCancelTimer(final boolean cancelTimer);
this.thunderDuration = thunderDuration;
}
public int getTimer() { LinkedList<QuestMob> getMobSpawns();
return timer;
}
public void setTimer(final int timer) { void setMobSpawns(final LinkedList<QuestMob> mobSpawns);
this.timer = timer;
}
public boolean isCancelTimer() { LinkedList<Location> getLightningStrikes();
return cancelTimer;
}
public void setCancelTimer(final boolean cancelTimer) { void setLightningStrikes(final LinkedList<Location> lightningStrikes);
this.cancelTimer = cancelTimer;
}
public LinkedList<QuestMob> getMobSpawns() { LinkedList<String> getCommands();
return mobSpawns;
}
public void setMobSpawns(final LinkedList<QuestMob> mobSpawns) { void setCommands(final LinkedList<String> commands);
this.mobSpawns = mobSpawns;
}
public LinkedList<Location> getLightningStrikes() { LinkedList<PotionEffect> getPotionEffects();
return lightningStrikes;
}
public void setLightningStrikes(final LinkedList<Location> lightningStrikes) { void setPotionEffects(final LinkedList<PotionEffect> potionEffects);
this.lightningStrikes = lightningStrikes;
}
public LinkedList<String> getCommands() { int getHunger();
return commands;
}
public void setCommands(final LinkedList<String> commands) { void setHunger(final int hunger);
this.commands = commands;
}
public LinkedList<PotionEffect> getPotionEffects() { int getSaturation();
return potionEffects;
}
public void setPotionEffects(final LinkedList<PotionEffect> potionEffects) { void setSaturation(final int saturation);
this.potionEffects = potionEffects;
}
public int getHunger() { float getHealth();
return hunger;
}
public void setHunger(final int hunger) { void setHealth(final float health);
this.hunger = hunger;
}
public int getSaturation() { Location getTeleport();
return saturation;
}
public void setSaturation(final int saturation) { void setTeleport(final Location teleport);
this.saturation = saturation;
}
public float getHealth() { String getBook();
return health;
}
public void setHealth(final float health) { void setBook(final String book);
this.health = health;
}
public Location getTeleport() { String getDenizenScript();
return teleport;
}
public void setTeleport(final Location teleport) { void setDenizenScript(final String scriptName);
this.teleport = teleport;
}
public String getBook() { void fire(final Quester quester, final Quest quest);
return book;
}
public void setBook(final String book) {
this.book = book;
}
public String getDenizenScript() {
return book;
}
public void setDenizenScript(final String scriptName) {
this.denizenScript = scriptName;
}
public void fire(final Quester quester, final Quest quest) {
final Player player = quester.getPlayer();
if (message != null) {
player.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(message, quest, player));
}
if (clearInv) {
player.getInventory().clear();
}
if (!explosions.isEmpty()) {
for (final Location l : explosions) {
if (l.getWorld() != null) {
l.getWorld().createExplosion(l, 4F, false);
}
}
}
if (!effects.isEmpty()) {
for (final Location l : effects.keySet()) {
if (l.getWorld() != null) {
l.getWorld().playEffect(l, effects.get(l), 1);
}
}
}
if (!items.isEmpty()) {
for (final ItemStack is : items) {
try {
InventoryUtil.addItem(player, is);
} catch (final Exception e) {
plugin.getLogger().severe("Unable to add null item to inventory of "
+ player.getName() + " during quest " + quest.getName() + " event " + name);
player.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
+ "Please contact an administrator.");
}
}
}
if (stormWorld != null) {
stormWorld.setStorm(true);
stormWorld.setWeatherDuration(stormDuration);
}
if (thunderWorld != null) {
thunderWorld.setThundering(true);
thunderWorld.setThunderDuration(thunderDuration);
}
if (!mobSpawns.isEmpty()) {
for (final QuestMob questMob : mobSpawns) {
questMob.spawn();
}
}
if (!lightningStrikes.isEmpty()) {
for (final Location l : lightningStrikes) {
if (l.getWorld() != null) {
l.getWorld().strikeLightning(l);
}
}
}
if (!commands.isEmpty()) {
for (final String s : commands) {
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(),
s.replace("<player>", quester.getPlayer().getName()));
}
}
if (!potionEffects.isEmpty()) {
for (final PotionEffect p : potionEffects) {
player.addPotionEffect(p);
}
}
if (hunger != -1) {
player.setFoodLevel(hunger);
}
if (saturation != -1) {
player.setSaturation(saturation);
}
if (health != -1) {
player.setHealth(health);
}
if (teleport != null) {
if (player.isDead()) {
plugin.getLogger().warning("Tried to fire Action " + name + " but player " + player.getUniqueId()
+ " was dead (known Bukkit limitation).");
} else {
player.teleport(teleport);
}
}
if (book != null) {
if (!book.isEmpty()) {
if (plugin.getDependencies().getCitizensBooksApi() != null) {
if (plugin.getDependencies().getCitizensBooksApi().hasFilter(book)) {
plugin.getDependencies().getCitizensBooksApi().openBook(player, plugin.getDependencies()
.getCitizensBooksApi().getFilter(book));
}
}
}
}
if (failQuest) {
quest.failQuest(quester, true);
}
if (timer > 0) {
player.sendMessage(ChatColor.GREEN + Lang.get(player, "timerStart")
.replace("<time>", ChatColor.RED + String.valueOf(timer) + ChatColor.GREEN));
if (timer > 60) {
quester.getTimers().put(new ActionTimer(quester, quest, 60, false)
.runTaskLater(plugin, (timer - 60) * 20L).getTaskId(), quest);
}
if (timer > 30) {
quester.getTimers().put(new ActionTimer(quester, quest, 30, false)
.runTaskLater(plugin, (timer - 30) * 20L).getTaskId(), quest);
}
if (timer > 10) {
quester.getTimers().put(new ActionTimer(quester, quest, 10, false)
.runTaskLater(plugin, (timer - 10) * 20L).getTaskId(), quest);
}
if (timer > 5) {
quester.getTimers().put(new ActionTimer(quester, quest, 5, false)
.runTaskLater(plugin, (timer - 5) * 20L).getTaskId(), quest);
}
if (timer > 4) {
quester.getTimers().put(new ActionTimer(quester, quest, 4, false)
.runTaskLater(plugin, (timer - 4) * 20L).getTaskId(), quest);
}
if (timer > 3) {
quester.getTimers().put(new ActionTimer(quester, quest, 3, false)
.runTaskLater(plugin, (timer - 3) * 20L).getTaskId(), quest);
}
if (timer > 2) {
quester.getTimers().put(new ActionTimer(quester, quest, 2, false)
.runTaskLater(plugin, (timer - 2) * 20L).getTaskId(), quest);
}
if (timer > 1) {
quester.getTimers().put(new ActionTimer(quester, quest, 1, false)
.runTaskLater(plugin, (timer - 1) * 20L).getTaskId(), quest);
}
quester.getTimers().put(new ActionTimer(quester, quest, 0, true)
.runTaskLater(plugin, timer * 20L).getTaskId(), quest);
}
if (cancelTimer) {
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());
}
}
}
if (denizenScript != null) {
plugin.getDenizenTrigger().runDenizenScript(denizenScript, quester);
}
}
} }

268
core/pom.xml Normal file
View File

@ -0,0 +1,268 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-parent</artifactId>
<version>4.2.0</version>
</parent>
<artifactId>quests-core</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<!-- CitizensBooks, DungeonsXL, GPS, LocaleLib, mcMMO Classic, PhatLoots -->
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<!-- Citizens, Denizen -->
<id>citizens-repo</id>
<url>https://repo.citizensnpcs.co/</url>
</repository>
<repository>
<!-- WorldEdit -->
<id>sk89q-repo</id>
<url>https://maven.sk89q.com/repo/</url>
</repository>
<repository>
<!-- Parties -->
<id>alessiodp-repo</id>
<url>https://repo.alessiodp.com/releases/</url>
</repository>
<repository>
<!-- PlaceholderAPI -->
<id>papi-repo</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<!-- Heroes, Vault -->
<id>hc-repo</id>
<url>https://nexus.hc.to/content/repositories/pub_releases/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizensapi</artifactId>
<version>2.0.21-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.denizenscript</groupId>
<artifactId>denizen</artifactId>
<version>1.1.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.7.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.mcMMO-Dev</groupId>
<artifactId>mcMMO-Classic</artifactId>
<version>master-82f97cbe04-1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.herocraftonline.heroes</groupId>
<artifactId>heroes-stripped</artifactId>
<version>4dd3dd85</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.9.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.nicuch</groupId>
<artifactId>CitizensBooks</artifactId>
<version>2.5.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.RednedEpic</groupId>
<artifactId>PhatLoots</artifactId>
<version>e55d0ba1f6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alessiodp.parties</groupId>
<artifactId>parties-api</artifactId>
<version>3.1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.PikaMug</groupId>
<artifactId>Unite</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.PikaMug</groupId>
<artifactId>LocaleLib</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
<exclusions>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>5.0.0</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.32</version>
</dependency>
<dependency>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests-api</artifactId>
<version>${version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>clean package install</defaultGoal>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>lang/**/*.*</include>
<include>actions.yml</include>
<include>conditions.yml</include>
<include>config.yml</include>
<include>plugin.yml</include>
<include>quests.yml</include>
<include>strings.yml</include>
</includes>
</resource>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/</directory>
<filtering>false</filtering>
<includes>
<include>README.md</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
<configuration>
<artifactSet>
<includes>
<include>me.*</include>
<include>com.github.PikaMug:LocaleLib</include>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-simple</include>
<include>org.slf4j:slf4j-api</include>
<include>mysql</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>me.pikamug.localelib</pattern>
<shadedPattern>me.blackvein.quests.libs.localelib</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>me.blackvein.quests.libs.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>me.blackvein.quests.libs.slf4j</shadedPattern>
</relocation>
<relocation>
<pattern>com.mysql</pattern>
<shadedPattern>me.blackvein.quests.libs.mysql</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

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

View File

@ -22,6 +22,7 @@ import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.Heroes; import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero; import com.herocraftonline.heroes.characters.Hero;
import me.blackvein.quests.listeners.NpcListener; import me.blackvein.quests.listeners.NpcListener;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.reflect.denizen.DenizenAPI; import me.blackvein.quests.reflect.denizen.DenizenAPI;
import me.blackvein.quests.reflect.worldguard.WorldGuardAPI; import me.blackvein.quests.reflect.worldguard.WorldGuardAPI;
import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.Lang;
@ -305,7 +306,7 @@ public class Dependencies {
} }
} }
public boolean runDenizenScript(final String scriptName, final Quester quester) { public boolean runDenizenScript(final String scriptName, final BukkitQuester quester) {
return plugin.getDenizenTrigger().runDenizenScript(scriptName, quester); return plugin.getDenizenTrigger().runDenizenScript(scriptName, quester);
} }

View File

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

View File

@ -16,6 +16,12 @@ import me.blackvein.quests.convo.quests.main.QuestMainPrompt;
import me.blackvein.quests.convo.quests.menu.QuestMenuPrompt; import me.blackvein.quests.convo.quests.menu.QuestMenuPrompt;
import me.blackvein.quests.convo.quests.stages.StageMenuPrompt; import me.blackvein.quests.convo.quests.stages.StageMenuPrompt;
import me.blackvein.quests.interfaces.ReloadCallback; import me.blackvein.quests.interfaces.ReloadCallback;
import me.blackvein.quests.quests.BukkitOptions;
import me.blackvein.quests.quests.BukkitPlanner;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.quests.BukkitRequirements;
import me.blackvein.quests.quests.BukkitRewards;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.util.CK; import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ConfigUtil; import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.FakeConversable; import me.blackvein.quests.util.FakeConversable;
@ -157,7 +163,7 @@ public class QuestFactory implements ConversationAbandonedListener {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void loadQuest(final ConversationContext context, final Quest q) { public void loadQuest(final ConversationContext context, final BukkitQuest q) {
context.setSessionData(CK.ED_QUEST_EDIT, q.getName()); context.setSessionData(CK.ED_QUEST_EDIT, q.getName());
context.setSessionData(CK.Q_ID, q.getId()); context.setSessionData(CK.Q_ID, q.getId());
context.setSessionData(CK.Q_NAME, q.getName()); context.setSessionData(CK.Q_NAME, q.getName());
@ -176,7 +182,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (q.getGUIDisplay() != null) { if (q.getGUIDisplay() != null) {
context.setSessionData(CK.Q_GUIDISPLAY, q.getGUIDisplay()); context.setSessionData(CK.Q_GUIDISPLAY, q.getGUIDisplay());
} }
final Requirements requirements = q.getRequirements(); final BukkitRequirements requirements = q.getRequirements();
if (requirements.getMoney() != 0) { if (requirements.getMoney() != 0) {
context.setSessionData(CK.REQ_MONEY, requirements.getMoney()); context.setSessionData(CK.REQ_MONEY, requirements.getMoney());
} }
@ -188,11 +194,11 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems()); context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems());
} }
if (!requirements.getNeededQuests().isEmpty()) { if (!requirements.getNeededQuests().isEmpty()) {
final List<String> ids = requirements.getNeededQuests().stream().map(Quest::getId).collect(Collectors.toList()); final List<String> ids = requirements.getNeededQuests().stream().map(BukkitQuest::getId).collect(Collectors.toList());
context.setSessionData(CK.REQ_QUEST, ids); context.setSessionData(CK.REQ_QUEST, ids);
} }
if (!requirements.getBlockQuests().isEmpty()) { if (!requirements.getBlockQuests().isEmpty()) {
final List<String> ids = requirements.getBlockQuests().stream().map(Quest::getId).collect(Collectors.toList()); final List<String> ids = requirements.getBlockQuests().stream().map(BukkitQuest::getId).collect(Collectors.toList());
context.setSessionData(CK.REQ_QUEST_BLOCK, ids); context.setSessionData(CK.REQ_QUEST_BLOCK, ids);
} }
if (!requirements.getMcmmoSkills().isEmpty()) { if (!requirements.getMcmmoSkills().isEmpty()) {
@ -221,7 +227,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (!requirements.getDetailsOverride().isEmpty()) { if (!requirements.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride()); context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride());
} }
final Rewards rewards = q.getRewards(); final BukkitRewards rewards = q.getRewards();
if (rewards.getMoney() != 0) { if (rewards.getMoney() != 0) {
context.setSessionData(CK.REW_MONEY, rewards.getMoney()); context.setSessionData(CK.REW_MONEY, rewards.getMoney());
} }
@ -267,7 +273,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (!rewards.getDetailsOverride().isEmpty()) { if (!rewards.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride()); context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride());
} }
final Planner pln = q.getPlanner(); final BukkitPlanner pln = q.getPlanner();
if (pln.getStart() != null) { if (pln.getStart() != null) {
context.setSessionData(CK.PLN_START_DATE, pln.getStart()); context.setSessionData(CK.PLN_START_DATE, pln.getStart());
} }
@ -281,7 +287,7 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.PLN_COOLDOWN, pln.getCooldown()); context.setSessionData(CK.PLN_COOLDOWN, pln.getCooldown());
} }
context.setSessionData(CK.PLN_OVERRIDE, pln.getOverride()); context.setSessionData(CK.PLN_OVERRIDE, pln.getOverride());
final Options opt = q.getOptions(); final BukkitOptions opt = q.getOptions();
context.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.canAllowCommands()); context.setSessionData(CK.OPT_ALLOW_COMMANDS, opt.canAllowCommands());
context.setSessionData(CK.OPT_ALLOW_QUITTING, opt.canAllowQuitting()); context.setSessionData(CK.OPT_ALLOW_QUITTING, opt.canAllowQuitting());
context.setSessionData(CK.OPT_IGNORE_SILK_TOUCH, opt.canIgnoreSilkTouch()); context.setSessionData(CK.OPT_IGNORE_SILK_TOUCH, opt.canIgnoreSilkTouch());
@ -293,7 +299,7 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS, opt.canHandleOfflinePlayers()); context.setSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS, opt.canHandleOfflinePlayers());
// Stages (Objectives) // Stages (Objectives)
int index = 1; int index = 1;
for (final Stage stage : q.getStages()) { for (final BukkitStage stage : q.getStages()) {
final String pref = "stage" + index; final String pref = "stage" + index;
index++; index++;
context.setSessionData(pref, Boolean.TRUE); context.setSessionData(pref, Boolean.TRUE);

View File

@ -15,7 +15,7 @@ package me.blackvein.quests;
import com.codisimus.plugins.phatloots.PhatLootsAPI; import com.codisimus.plugins.phatloots.PhatLootsAPI;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.herocraftonline.heroes.characters.classes.HeroClass; import com.herocraftonline.heroes.characters.classes.HeroClass;
import me.blackvein.quests.actions.Action; import me.blackvein.quests.actions.BukkitAction;
import me.blackvein.quests.actions.ActionFactory; import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.conditions.Condition; import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.conditions.ConditionFactory; import me.blackvein.quests.conditions.ConditionFactory;
@ -35,6 +35,13 @@ import me.blackvein.quests.listeners.NpcListener;
import me.blackvein.quests.listeners.PartiesListener; import me.blackvein.quests.listeners.PartiesListener;
import me.blackvein.quests.listeners.PlayerListener; import me.blackvein.quests.listeners.PlayerListener;
import me.blackvein.quests.listeners.UniteListener; import me.blackvein.quests.listeners.UniteListener;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.quests.BukkitOptions;
import me.blackvein.quests.quests.BukkitPlanner;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.quests.BukkitRequirements;
import me.blackvein.quests.quests.BukkitRewards;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.statistics.Metrics; import me.blackvein.quests.statistics.Metrics;
import me.blackvein.quests.storage.Storage; import me.blackvein.quests.storage.Storage;
import me.blackvein.quests.storage.StorageFactory; import me.blackvein.quests.storage.StorageFactory;
@ -116,18 +123,18 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.logging.Level; import java.util.logging.Level;
public class Quests extends JavaPlugin { public class Quests extends JavaPlugin implements QuestsAPI {
private boolean loading = true; private boolean loading = true;
private String bukkitVersion = "0"; private String bukkitVersion = "0";
private Dependencies depends; private Dependencies depends;
private Settings settings; private Settings settings;
private final List<CustomObjective> customObjectives = new LinkedList<>();
private final List<CustomRequirement> customRequirements = new LinkedList<>(); private final List<CustomRequirement> customRequirements = new LinkedList<>();
private final List<CustomReward> customRewards = new LinkedList<>(); private final List<CustomReward> customRewards = new LinkedList<>();
private final List<CustomObjective> customObjectives = new LinkedList<>(); private Collection<BukkitQuester> questers = new ConcurrentSkipListSet<>();
private Collection<Quester> questers = new ConcurrentSkipListSet<>(); private final Collection<BukkitQuest> quests = new ConcurrentSkipListSet<>();
private final Collection<Quest> quests = new ConcurrentSkipListSet<>(); private Collection<BukkitAction> actions = new ConcurrentSkipListSet<>();
private Collection<Action> actions = new ConcurrentSkipListSet<>();
private Collection<Condition> conditions = new ConcurrentSkipListSet<>(); private Collection<Condition> conditions = new ConcurrentSkipListSet<>();
private LinkedList<Integer> questNpcIds = new LinkedList<>(); private LinkedList<Integer> questNpcIds = new LinkedList<>();
private CommandExecutor cmdExecutor; private CommandExecutor cmdExecutor;
@ -258,7 +265,7 @@ public class Quests extends JavaPlugin {
public void onDisable() { public void onDisable() {
getLogger().info("Saving Quester data..."); getLogger().info("Saving Quester data...");
for (final Player p : getServer().getOnlinePlayers()) { for (final Player p : getServer().getOnlinePlayers()) {
final Quester quester = getQuester(p.getUniqueId()); final BukkitQuester quester = getQuester(p.getUniqueId());
quester.saveData(); quester.saveData();
} }
Bukkit.getScheduler().cancelTasks(this); Bukkit.getScheduler().cancelTasks(this);
@ -284,32 +291,7 @@ public class Quests extends JavaPlugin {
return settings; return settings;
} }
public List<CustomRequirement> getCustomRequirements() { @Override
return customRequirements;
}
public Optional<CustomRequirement> getCustomRequirement(final String className) {
for (final CustomRequirement cr : customRequirements) {
if (cr.getClass().getName().equals(className)) {
return Optional.of(cr);
}
}
return Optional.empty();
}
public List<CustomReward> getCustomRewards() {
return customRewards;
}
public Optional<CustomReward> getCustomReward(final String className) {
for (final CustomReward cr : customRewards) {
if (cr.getClass().getName().equals(className)) {
return Optional.of(cr);
}
}
return Optional.empty();
}
public List<CustomObjective> getCustomObjectives() { public List<CustomObjective> getCustomObjectives() {
return customObjectives; return customObjectives;
} }
@ -323,6 +305,34 @@ public class Quests extends JavaPlugin {
return Optional.empty(); return Optional.empty();
} }
@Override
public List<CustomRequirement> getCustomRequirements() {
return customRequirements;
}
public Optional<CustomRequirement> getCustomRequirement(final String className) {
for (final CustomRequirement cr : customRequirements) {
if (cr.getClass().getName().equals(className)) {
return Optional.of(cr);
}
}
return Optional.empty();
}
@Override
public List<CustomReward> getCustomRewards() {
return customRewards;
}
public Optional<CustomReward> getCustomReward(final String className) {
for (final CustomReward cr : customRewards) {
if (cr.getClass().getName().equals(className)) {
return Optional.of(cr);
}
}
return Optional.empty();
}
/** /**
* Get every Quest loaded in memory * Get every Quest loaded in memory
* *
@ -330,7 +340,7 @@ public class Quests extends JavaPlugin {
* @return a list of all Quests * @return a list of all Quests
*/ */
@Deprecated @Deprecated
public LinkedList<Quest> getQuests() { public LinkedList<BukkitQuest> getQuests() {
return new LinkedList<>(quests); return new LinkedList<>(quests);
} }
@ -339,7 +349,7 @@ public class Quests extends JavaPlugin {
* *
* @return a collection of all Quests * @return a collection of all Quests
*/ */
public Collection<Quest> getLoadedQuests() { public Collection<BukkitQuest> getLoadedQuests() {
return quests; return quests;
} }
@ -350,7 +360,7 @@ public class Quests extends JavaPlugin {
* @return a list of all Actions * @return a list of all Actions
*/ */
@Deprecated @Deprecated
public LinkedList<Action> getActions() { public LinkedList<BukkitAction> getActions() {
return new LinkedList<>(actions); return new LinkedList<>(actions);
} }
@ -359,7 +369,7 @@ public class Quests extends JavaPlugin {
* *
* @return a collection of all Actions * @return a collection of all Actions
*/ */
public Collection<Action> getLoadedActions() { public Collection<BukkitAction> getLoadedActions() {
return actions; return actions;
} }
@ -369,7 +379,7 @@ public class Quests extends JavaPlugin {
* @deprecated Use {@link #setLoadedActions(Collection)} * @deprecated Use {@link #setLoadedActions(Collection)}
*/ */
@Deprecated @Deprecated
public void setActions(final LinkedList<Action> actions) { public void setActions(final LinkedList<BukkitAction> actions) {
this.actions = actions; this.actions = actions;
} }
@ -377,7 +387,7 @@ public class Quests extends JavaPlugin {
* Set every Action loaded in memory * Set every Action loaded in memory
* *
*/ */
public void setLoadedActions(final Collection<Action> actions) { public void setLoadedActions(final Collection<BukkitAction> actions) {
this.actions = actions; this.actions = actions;
} }
@ -425,23 +435,23 @@ public class Quests extends JavaPlugin {
* @param id Player UUID * @param id Player UUID
* @return Quester, or null if UUID is null * @return Quester, or null if UUID is null
*/ */
public Quester getQuester(final UUID id) { public BukkitQuester getQuester(final UUID id) {
if (id == null) { if (id == null) {
return null; return null;
} }
final ConcurrentSkipListSet<Quester> set = (ConcurrentSkipListSet<Quester>) questers; final ConcurrentSkipListSet<BukkitQuester> set = (ConcurrentSkipListSet<BukkitQuester>) questers;
for (final Quester q: set) { for (final BukkitQuester q: set) {
if (q != null && q.getUUID().equals(id)) { if (q != null && q.getUUID().equals(id)) {
return q; return q;
} }
} }
final Quester quester = new Quester(this, id); final BukkitQuester quester = new BukkitQuester(this, id);
if (depends.getCitizens() != null) { if (depends.getCitizens() != null) {
if (depends.getCitizens().getNPCRegistry().getByUniqueId(id) != null) { if (depends.getCitizens().getNPCRegistry().getByUniqueId(id) != null) {
return quester; return quester;
} }
} }
final Quester q = new Quester(this, id); final BukkitQuester q = new BukkitQuester(this, id);
questers.add(q); questers.add(q);
return q; return q;
} }
@ -453,7 +463,7 @@ public class Quests extends JavaPlugin {
* @return a list of all Questers * @return a list of all Questers
*/ */
@Deprecated @Deprecated
public LinkedList<Quester> getQuesters() { public LinkedList<BukkitQuester> getQuesters() {
return new LinkedList<>(questers); return new LinkedList<>(questers);
} }
@ -464,7 +474,7 @@ public class Quests extends JavaPlugin {
* @param questers a list of Questers * @param questers a list of Questers
*/ */
@Deprecated @Deprecated
public void setQuesters(final LinkedList<Quester> questers) { public void setQuesters(final LinkedList<BukkitQuester> questers) {
this.questers = new ConcurrentSkipListSet<>(questers); this.questers = new ConcurrentSkipListSet<>(questers);
} }
@ -473,9 +483,9 @@ public class Quests extends JavaPlugin {
* *
* @return a collection of all online Questers * @return a collection of all online Questers
*/ */
public Collection<Quester> getOnlineQuesters() { public Collection<BukkitQuester> getOnlineQuesters() {
final Collection<Quester> questers = new ConcurrentSkipListSet<>(); final Collection<BukkitQuester> questers = new ConcurrentSkipListSet<>();
for (final Quester q : getOfflineQuesters()) { for (final BukkitQuester q : getOfflineQuesters()) {
if (q.getOfflinePlayer().isOnline()) { if (q.getOfflinePlayer().isOnline()) {
// Workaround for issues with the compass on fast join // Workaround for issues with the compass on fast join
q.findCompassTarget(); q.findCompassTarget();
@ -490,7 +500,7 @@ public class Quests extends JavaPlugin {
* *
* @return a collection of all Questers * @return a collection of all Questers
*/ */
public Collection<Quester> getOfflineQuesters() { public Collection<BukkitQuester> getOfflineQuesters() {
return questers; return questers;
} }
@ -499,7 +509,7 @@ public class Quests extends JavaPlugin {
* *
* @param questers a collection of Questers * @param questers a collection of Questers
*/ */
public void setOfflineQuesters(final Collection<Quester> questers) { public void setOfflineQuesters(final Collection<BukkitQuester> questers) {
this.questers = new ConcurrentSkipListSet<>(questers); this.questers = new ConcurrentSkipListSet<>(questers);
} }
@ -666,10 +676,10 @@ public class Quests extends JavaPlugin {
final Player player = (Player) context.getForWhom(); final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("y") if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("y")
|| input.equalsIgnoreCase(Lang.get(player, "yesWord"))) { || input.equalsIgnoreCase(Lang.get(player, "yesWord"))) {
Quester quester = getQuester(player.getUniqueId()); BukkitQuester quester = getQuester(player.getUniqueId());
if (quester == null) { if (quester == null) {
// Must be new player // Must be new player
quester = new Quester(Quests.this, player.getUniqueId()); quester = new BukkitQuester(Quests.this, player.getUniqueId());
if (quester.saveData()) { if (quester.saveData()) {
getLogger().info("Created new data for player " + player.getName()); getLogger().info("Created new data for player " + player.getName());
} else { } else {
@ -796,7 +806,7 @@ public class Quests extends JavaPlugin {
getLogger().log(Level.INFO, "Loaded " + quests.size() + " Quest(s), " + actions.size() + " Action(s), " getLogger().log(Level.INFO, "Loaded " + quests.size() + " Quest(s), " + actions.size() + " Action(s), "
+ conditions.size() + " Condition(s) and " + Lang.size() + " Phrase(s)"); + conditions.size() + " Condition(s) and " + Lang.size() + " Phrase(s)");
for (final Player p : getServer().getOnlinePlayers()) { for (final Player p : getServer().getOnlinePlayers()) {
final Quester quester = new Quester(Quests.this, p.getUniqueId()); final BukkitQuester quester = new BukkitQuester(Quests.this, p.getUniqueId());
if (!quester.hasData()) { if (!quester.hasData()) {
quester.saveData(); quester.saveData();
} }
@ -853,12 +863,12 @@ public class Quests extends JavaPlugin {
int count = 0; int count = 0;
for (final String questKey : questsSection.getKeys(false)) { for (final String questKey : questsSection.getKeys(false)) {
try { try {
for (final Quest lq : getLoadedQuests()) { for (final BukkitQuest lq : getLoadedQuests()) {
if (lq.getId().equals(questKey)) { if (lq.getId().equals(questKey)) {
throw new QuestFormatException("id already exists", questKey); throw new QuestFormatException("id already exists", questKey);
} }
} }
final Quest quest = loadQuest(config, questKey); final BukkitQuest quest = loadQuest(config, questKey);
if (config.contains("quests." + questKey + ".requirements")) { if (config.contains("quests." + questKey + ".requirements")) {
loadQuestRequirements(config, questsSection, quest, questKey); loadQuestRequirements(config, questsSection, quest, questKey);
} }
@ -1028,7 +1038,7 @@ public class Quests extends JavaPlugin {
* @param ignoreOverrides Whether to ignore objective-overrides * @param ignoreOverrides Whether to ignore objective-overrides
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void showObjectives(final Quest quest, final Quester quester, final boolean ignoreOverrides) { public void showObjectives(final BukkitQuest quest, final BukkitQuester quester, final boolean ignoreOverrides) {
if (quest == null) { if (quest == null) {
getLogger().severe("Quest was null when getting objectives for " + quester.getLastKnownName()); getLogger().severe("Quest was null when getting objectives for " + quester.getLastKnownName());
return; return;
@ -1053,7 +1063,7 @@ public class Quests extends JavaPlugin {
return; return;
} }
final QuestData data = quester.getQuestData(quest); final QuestData data = quester.getQuestData(quest);
final Stage stage = quester.getCurrentStage(quest); final BukkitStage stage = quester.getCurrentStage(quest);
for (final ItemStack e : stage.blocksToBreak) { for (final ItemStack e : stage.blocksToBreak) {
for (final ItemStack e2 : data.blocksBroken) { for (final ItemStack e2 : data.blocksBroken) {
if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) { if (e2.getType().equals(e.getType()) && e2.getDurability() == e.getDurability()) {
@ -1570,14 +1580,14 @@ public class Quests extends JavaPlugin {
* @param quester Quester to show the list * @param quester Quester to show the list
* @param page Page to display, with 7 quests per page * @param page Page to display, with 7 quests per page
*/ */
public void listQuests(final Quester quester, final int page) { public void listQuests(final BukkitQuester quester, final int page) {
// Although we could copy the quests list to a new object, we instead opt to // Although we could copy the quests list to a new object, we instead opt to
// duplicate code to improve efficiency if ignore-locked-quests is set to 'false' // duplicate code to improve efficiency if ignore-locked-quests is set to 'false'
final int rows = 7; final int rows = 7;
final Player player = quester.getPlayer(); final Player player = quester.getPlayer();
if (getSettings().canIgnoreLockedQuests()) { if (getSettings().canIgnoreLockedQuests()) {
final LinkedList<Quest> available = new LinkedList<>(); final LinkedList<BukkitQuest> available = new LinkedList<>();
for (final Quest q : quests) { for (final BukkitQuest q : quests) {
if (!quester.getCompletedQuests().contains(q)) { if (!quester.getCompletedQuests().contains(q)) {
if (q.testRequirements(player)) { if (q.testRequirements(player)) {
available.add(q); available.add(q);
@ -1593,14 +1603,14 @@ public class Quests extends JavaPlugin {
} else { } else {
Lang.send(player, ChatColor.GOLD + Lang.get(player, "questListTitle")); Lang.send(player, ChatColor.GOLD + Lang.get(player, "questListTitle"));
int fromOrder = (page - 1) * rows; int fromOrder = (page - 1) * rows;
final List<Quest> subQuests; final List<BukkitQuest> subQuests;
if (available.size() >= (fromOrder + rows)) { if (available.size() >= (fromOrder + rows)) {
subQuests = available.subList((fromOrder), (fromOrder + rows)); subQuests = available.subList((fromOrder), (fromOrder + rows));
} else { } else {
subQuests = available.subList((fromOrder), available.size()); subQuests = available.subList((fromOrder), available.size());
} }
fromOrder++; fromOrder++;
for (final Quest q : subQuests) { for (final BukkitQuest q : subQuests) {
if (quester.canAcceptOffer(q, false)) { if (quester.canAcceptOffer(q, false)) {
quester.sendMessage(ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName()); quester.sendMessage(ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName());
} else { } else {
@ -1620,14 +1630,14 @@ public class Quests extends JavaPlugin {
} else { } else {
Lang.send(player, ChatColor.GOLD + Lang.get(player, "questListTitle")); Lang.send(player, ChatColor.GOLD + Lang.get(player, "questListTitle"));
int fromOrder = (page - 1) * rows; int fromOrder = (page - 1) * rows;
final List<Quest> subQuests; final List<BukkitQuest> subQuests;
if (quests.size() >= (fromOrder + rows)) { if (quests.size() >= (fromOrder + rows)) {
subQuests = getQuests().subList((fromOrder), (fromOrder + rows)); subQuests = getQuests().subList((fromOrder), (fromOrder + rows));
} else { } else {
subQuests = getQuests().subList((fromOrder), quests.size()); subQuests = getQuests().subList((fromOrder), quests.size());
} }
fromOrder++; fromOrder++;
for (final Quest q : subQuests) { for (final BukkitQuest q : subQuests) {
if (quester.canAcceptOffer(q, false)) { if (quester.canAcceptOffer(q, false)) {
Lang.send(player, ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName()); Lang.send(player, ChatColor.YELLOW + Integer.toString(fromOrder) + ". " + q.getName());
} else { } else {
@ -1668,10 +1678,10 @@ public class Quests extends JavaPlugin {
loadConditions(); loadConditions();
final CompletableFuture<Void> loadFuture = saveFuture.thenRunAsync(() -> { final CompletableFuture<Void> loadFuture = saveFuture.thenRunAsync(() -> {
try { try {
for (final Quester quester : questers) { for (final BukkitQuester quester : questers) {
final CompletableFuture<Quester> cf = getStorage().loadQuester(quester.getUUID()); final CompletableFuture<BukkitQuester> cf = getStorage().loadQuester(quester.getUUID());
final Quester loaded = cf.get(); final BukkitQuester loaded = cf.get();
for (final Quest q : loaded.currentQuests.keySet()) { for (final BukkitQuest q : loaded.currentQuests.keySet()) {
loaded.checkQuest(q); loaded.checkQuest(q);
} }
} }
@ -1737,7 +1747,7 @@ public class Quests extends JavaPlugin {
} }
for (final String questKey : questsSection.getKeys(false)) { for (final String questKey : questsSection.getKeys(false)) {
try { try {
final Quest quest = loadQuest(config, questKey); final BukkitQuest quest = loadQuest(config, questKey);
if (config.contains("quests." + questKey + ".requirements")) { if (config.contains("quests." + questKey + ".requirements")) {
loadQuestRequirements(config, questsSection, quest, questKey); loadQuestRequirements(config, questsSection, quest, questKey);
} }
@ -1770,9 +1780,9 @@ public class Quests extends JavaPlugin {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private Quest loadQuest(final FileConfiguration config, final String questKey) throws QuestFormatException, private BukkitQuest loadQuest(final FileConfiguration config, final String questKey) throws QuestFormatException,
ActionFormatException { ActionFormatException {
final Quest quest = new Quest(); final BukkitQuest quest = new BukkitQuest();
quest.id = questKey; quest.id = questKey;
if (config.contains("quests." + questKey + ".name")) { if (config.contains("quests." + questKey + ".name")) {
quest.setName(ConfigUtil.parseString(config.getString("quests." + questKey + ".name"), quest)); quest.setName(ConfigUtil.parseString(config.getString("quests." + questKey + ".name"), quest));
@ -1861,14 +1871,14 @@ public class Quests extends JavaPlugin {
} }
} }
if (config.contains("quests." + questKey + ".action")) { if (config.contains("quests." + questKey + ".action")) {
final Action action = loadAction(config.getString("quests." + questKey + ".action")); final BukkitAction action = loadAction(config.getString("quests." + questKey + ".action"));
if (action != null) { if (action != null) {
quest.initialAction = action; quest.initialAction = action;
} else { } else {
throw new QuestFormatException("action failed to load", questKey); throw new QuestFormatException("action failed to load", questKey);
} }
} else if (config.contains("quests." + questKey + ".event")) { } else if (config.contains("quests." + questKey + ".event")) {
final Action action = loadAction(config.getString("quests." + questKey + ".event")); final BukkitAction action = loadAction(config.getString("quests." + questKey + ".event"));
if (action != null) { if (action != null) {
quest.initialAction = action; quest.initialAction = action;
} else { } else {
@ -1879,9 +1889,9 @@ public class Quests extends JavaPlugin {
} }
@SuppressWarnings({"unchecked", "deprecation"}) @SuppressWarnings({"unchecked", "deprecation"})
private void loadQuestRewards(final FileConfiguration config, final Quest quest, final String questKey) private void loadQuestRewards(final FileConfiguration config, final BukkitQuest quest, final String questKey)
throws QuestFormatException { throws QuestFormatException {
final Rewards rewards = quest.getRewards(); final BukkitRewards rewards = quest.getRewards();
if (config.contains("quests." + questKey + ".rewards.items")) { if (config.contains("quests." + questKey + ".rewards.items")) {
final LinkedList<ItemStack> temp = new LinkedList<>(); final LinkedList<ItemStack> temp = new LinkedList<>();
final List<ItemStack> stackList = (List<ItemStack>) config.get("quests." + questKey + ".rewards.items"); final List<ItemStack> stackList = (List<ItemStack>) config.get("quests." + questKey + ".rewards.items");
@ -2066,8 +2076,8 @@ public class Quests extends JavaPlugin {
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings({ "unchecked", "deprecation" })
private void loadQuestRequirements(final FileConfiguration config, final ConfigurationSection questsSection, private void loadQuestRequirements(final FileConfiguration config, final ConfigurationSection questsSection,
final Quest quest, final String questKey) throws QuestFormatException { final BukkitQuest quest, final String questKey) throws QuestFormatException {
final Requirements requires = quest.getRequirements(); final BukkitRequirements requires = quest.getRequirements();
if (config.contains("quests." + questKey + ".requirements.fail-requirement-message")) { if (config.contains("quests." + questKey + ".requirements.fail-requirement-message")) {
final Object o = config.get("quests." + questKey + ".requirements.fail-requirement-message"); final Object o = config.get("quests." + questKey + ".requirements.fail-requirement-message");
if (o instanceof List) { if (o instanceof List) {
@ -2142,7 +2152,7 @@ public class Quests extends JavaPlugin {
final List<String> nodes = config.getStringList("quests." + questKey + ".requirements.quest-blocks"); final List<String> nodes = config.getStringList("quests." + questKey + ".requirements.quest-blocks");
boolean failed = false; boolean failed = false;
String failedQuest = "NULL"; String failedQuest = "NULL";
final List<Quest> temp = new LinkedList<>(); final List<BukkitQuest> temp = new LinkedList<>();
for (final String node : nodes) { for (final String node : nodes) {
boolean done = false; boolean done = false;
for (final String id : questsSection.getKeys(false)) { for (final String id : questsSection.getKeys(false)) {
@ -2181,7 +2191,7 @@ public class Quests extends JavaPlugin {
final List<String> nodes = config.getStringList("quests." + questKey + ".requirements.quests"); final List<String> nodes = config.getStringList("quests." + questKey + ".requirements.quests");
boolean failed = false; boolean failed = false;
String failedQuest = "NULL"; String failedQuest = "NULL";
final List<Quest> temp = new LinkedList<>(); final List<BukkitQuest> temp = new LinkedList<>();
for (final String node : nodes) { for (final String node : nodes) {
boolean done = false; boolean done = false;
for (final String id : questsSection.getKeys(false)) { for (final String id : questsSection.getKeys(false)) {
@ -2283,9 +2293,9 @@ public class Quests extends JavaPlugin {
} }
} }
private void loadQuestPlanner(final FileConfiguration config, final Quest quest, final String questKey) private void loadQuestPlanner(final FileConfiguration config, final BukkitQuest quest, final String questKey)
throws QuestFormatException { throws QuestFormatException {
final Planner pln = quest.getPlanner(); final BukkitPlanner pln = quest.getPlanner();
if (config.contains("quests." + questKey + ".planner.start")) { if (config.contains("quests." + questKey + ".planner.start")) {
pln.setStart(config.getString("quests." + questKey + ".planner.start")); pln.setStart(config.getString("quests." + questKey + ".planner.start"));
} }
@ -2311,9 +2321,9 @@ public class Quests extends JavaPlugin {
} }
} }
private void loadQuestOptions(final FileConfiguration config, final Quest quest, final String questKey) private void loadQuestOptions(final FileConfiguration config, final BukkitQuest quest, final String questKey)
throws QuestFormatException { throws QuestFormatException {
final Options opts = quest.getOptions(); final BukkitOptions opts = quest.getOptions();
if (config.contains("quests." + questKey + ".options.allow-commands")) { if (config.contains("quests." + questKey + ".options.allow-commands")) {
opts.setAllowCommands(config.getBoolean("quests." + questKey + ".options.allow-commands")); opts.setAllowCommands(config.getBoolean("quests." + questKey + ".options.allow-commands"));
} }
@ -2347,7 +2357,7 @@ public class Quests extends JavaPlugin {
} }
@SuppressWarnings({ "unchecked", "unused", "deprecation" }) @SuppressWarnings({ "unchecked", "unused", "deprecation" })
private void loadQuestStages(final Quest quest, final FileConfiguration config, final String questKey) private void loadQuestStages(final BukkitQuest quest, final FileConfiguration config, final String questKey)
throws StageFormatException, ActionFormatException, ConditionFormatException { throws StageFormatException, ActionFormatException, ConditionFormatException {
final ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey final ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey
+ ".stages.ordered"); + ".stages.ordered");
@ -2363,7 +2373,7 @@ public class Quests extends JavaPlugin {
getLogger().severe("Stage key " + stage + "must be a number!"); getLogger().severe("Stage key " + stage + "must be a number!");
continue; continue;
} }
final Stage oStage = new Stage(); final BukkitStage oStage = new BukkitStage();
List<String> breakNames = new LinkedList<>(); List<String> breakNames = new LinkedList<>();
List<Integer> breakAmounts = new LinkedList<>(); List<Integer> breakAmounts = new LinkedList<>();
List<Short> breakDurability = new LinkedList<>(); List<Short> breakDurability = new LinkedList<>();
@ -3268,7 +3278,7 @@ public class Quests extends JavaPlugin {
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-event")) { if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".start-event")) {
final Action action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum final BukkitAction action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum
+ ".start-event")); + ".start-event"));
if (action != null) { if (action != null) {
oStage.startAction = action; oStage.startAction = action;
@ -3277,7 +3287,7 @@ public class Quests extends JavaPlugin {
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".finish-event")) { if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".finish-event")) {
final Action action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum final BukkitAction action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum
+ ".finish-event")); + ".finish-event"));
if (action != null) { if (action != null) {
oStage.finishAction = action; oStage.finishAction = action;
@ -3286,7 +3296,7 @@ public class Quests extends JavaPlugin {
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fail-event")) { if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".fail-event")) {
final Action action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum final BukkitAction action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum
+ ".fail-event")); + ".fail-event"));
if (action != null) { if (action != null) {
oStage.failAction = action; oStage.failAction = action;
@ -3295,7 +3305,7 @@ public class Quests extends JavaPlugin {
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".death-event")) { if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".death-event")) {
final Action action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum final BukkitAction action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum
+ ".death-event")); + ".death-event"));
if (action != null) { if (action != null) {
oStage.deathAction = action; oStage.deathAction = action;
@ -3304,7 +3314,7 @@ public class Quests extends JavaPlugin {
} }
} }
if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".disconnect-event")) { if (config.contains("quests." + questKey + ".stages.ordered." + stageNum + ".disconnect-event")) {
final Action action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum final BukkitAction action = loadAction(config.getString("quests." + questKey + ".stages.ordered." + stageNum
+ ".disconnect-event")); + ".disconnect-event"));
if (action != null) { if (action != null) {
oStage.disconnectAction = action; oStage.disconnectAction = action;
@ -3323,7 +3333,7 @@ public class Quests extends JavaPlugin {
final List<String> chatEventTriggers = config.getStringList("quests." + questKey final List<String> chatEventTriggers = config.getStringList("quests." + questKey
+ ".stages.ordered." + stageNum + ".chat-event-triggers"); + ".stages.ordered." + stageNum + ".chat-event-triggers");
for (int i = 0; i < chatEvents.size(); i++) { for (int i = 0; i < chatEvents.size(); i++) {
final Action action = loadAction(chatEvents.get(i)); final BukkitAction action = loadAction(chatEvents.get(i));
if (action != null) { if (action != null) {
if (i < chatEventTriggers.size()) { if (i < chatEventTriggers.size()) {
oStage.chatActions.put(chatEventTriggers.get(i), action); oStage.chatActions.put(chatEventTriggers.get(i), action);
@ -3358,7 +3368,7 @@ public class Quests extends JavaPlugin {
final List<String> commandEventTriggers = config.getStringList("quests." + questKey final List<String> commandEventTriggers = config.getStringList("quests." + questKey
+ ".stages.ordered." + stageNum + ".command-event-triggers"); + ".stages.ordered." + stageNum + ".command-event-triggers");
for (int i = 0; i < commandEvents.size(); i++) { for (int i = 0; i < commandEvents.size(); i++) {
final Action action = loadAction(commandEvents.get(i)); final BukkitAction action = loadAction(commandEvents.get(i));
if (action != null) { if (action != null) {
if (i < commandEventTriggers.size()) { if (i < commandEventTriggers.size()) {
oStage.commandActions.put(commandEventTriggers.get(i), action); oStage.commandActions.put(commandEventTriggers.get(i), action);
@ -3416,7 +3426,7 @@ public class Quests extends JavaPlugin {
} }
@SuppressWarnings({ "unchecked", "deprecation" }) @SuppressWarnings({ "unchecked", "deprecation" })
protected Action loadAction(final String name) throws ActionFormatException { protected BukkitAction loadAction(final String name) throws ActionFormatException {
if (name == null) { if (name == null) {
return null; return null;
} }
@ -3437,7 +3447,7 @@ public class Quests extends JavaPlugin {
if (data.contains(legacyName)) { if (data.contains(legacyName)) {
actionKey = legacyName + "."; actionKey = legacyName + ".";
} }
final Action action = new Action(this); final BukkitAction action = new BukkitAction(this);
action.setName(name); action.setName(name);
if (data.contains(actionKey + "message")) { if (data.contains(actionKey + "message")) {
action.setMessage(ConfigUtil.parseString(data.getString(actionKey + "message"))); action.setMessage(ConfigUtil.parseString(data.getString(actionKey + "message")));
@ -3903,7 +3913,7 @@ public class Quests extends JavaPlugin {
return condition; return condition;
} }
private void loadCustomSections(final Quest quest, final FileConfiguration config, final String questKey) private void loadCustomSections(final BukkitQuest quest, final FileConfiguration config, final String questKey)
throws StageFormatException, QuestFormatException { throws StageFormatException, QuestFormatException {
final ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey + ".stages.ordered"); final ConfigurationSection questStages = config.getConfigurationSection("quests." + questKey + ".stages.ordered");
if (questStages != null) { if (questStages != null) {
@ -3917,7 +3927,7 @@ public class Quests extends JavaPlugin {
+ " for " + quest.getName() + " was null"); + " for " + quest.getName() + " was null");
return; return;
} }
final Stage oStage = quest.getStage(Integer.parseInt(stageNum) - 1); final BukkitStage oStage = quest.getStage(Integer.parseInt(stageNum) - 1);
oStage.customObjectives.clear(); oStage.customObjectives.clear();
oStage.customObjectiveCounts.clear(); oStage.customObjectiveCounts.clear();
oStage.customObjectiveData.clear(); oStage.customObjectiveData.clear();
@ -3952,7 +3962,7 @@ public class Quests extends JavaPlugin {
} }
} }
} }
final Rewards rews = quest.getRewards(); final BukkitRewards rews = quest.getRewards();
if (config.contains("quests." + questKey + ".rewards.custom-rewards")) { if (config.contains("quests." + questKey + ".rewards.custom-rewards")) {
final ConfigurationSection sec = config.getConfigurationSection("quests." + questKey final ConfigurationSection sec = config.getConfigurationSection("quests." + questKey
+ ".rewards.custom-rewards"); + ".rewards.custom-rewards");
@ -3978,7 +3988,7 @@ public class Quests extends JavaPlugin {
} }
rews.setCustomRewards(temp); rews.setCustomRewards(temp);
} }
final Requirements reqs = quest.getRequirements(); final BukkitRequirements reqs = quest.getRequirements();
if (config.contains("quests." + questKey + ".requirements.custom-requirements")) { if (config.contains("quests." + questKey + ".requirements.custom-requirements")) {
final ConfigurationSection sec = config.getConfigurationSection("quests." + questKey final ConfigurationSection sec = config.getConfigurationSection("quests." + questKey
+ ".requirements.custom-requirements"); + ".requirements.custom-requirements");
@ -4091,7 +4101,7 @@ public class Quests extends JavaPlugin {
} }
if (sec != null) { if (sec != null) {
for (final String s : sec.getKeys(false)) { for (final String s : sec.getKeys(false)) {
Action action = null; BukkitAction action = null;
try { try {
action = loadAction(s); action = loadAction(s);
} catch (final ActionFormatException e) { } catch (final ActionFormatException e) {
@ -4236,11 +4246,11 @@ public class Quests extends JavaPlugin {
* @return Exact match or null if not found * @return Exact match or null if not found
* @since 3.8.6 * @since 3.8.6
*/ */
public Quest getQuestById(final String id) { public BukkitQuest getQuestById(final String id) {
if (id == null) { if (id == null) {
return null; return null;
} }
for (final Quest q : quests) { for (final BukkitQuest q : quests) {
if (q.getId().equals(id)) { if (q.getId().equals(id)) {
return q; return q;
} }
@ -4254,21 +4264,21 @@ public class Quests extends JavaPlugin {
* @param name Name of the quest * @param name Name of the quest
* @return Closest match or null if not found * @return Closest match or null if not found
*/ */
public Quest getQuest(final String name) { public BukkitQuest getQuest(final String name) {
if (name == null) { if (name == null) {
return null; return null;
} }
for (final Quest q : quests) { for (final BukkitQuest q : quests) {
if (q.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) { if (q.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) {
return q; return q;
} }
} }
for (final Quest q : quests) { for (final BukkitQuest q : quests) {
if (q.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { if (q.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
return q; return q;
} }
} }
for (final Quest q : quests) { for (final BukkitQuest q : quests) {
if (q.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { if (q.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
return q; return q;
} }
@ -4282,21 +4292,21 @@ public class Quests extends JavaPlugin {
* @param name Name of the action * @param name Name of the action
* @return Closest match or null if not found * @return Closest match or null if not found
*/ */
public Action getAction(final String name) { public BukkitAction getAction(final String name) {
if (name == null) { if (name == null) {
return null; return null;
} }
for (final Action a : actions) { for (final BukkitAction a : actions) {
if (a.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) { if (a.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) {
return a; return a;
} }
} }
for (final Action a : actions) { for (final BukkitAction a : actions) {
if (a.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { if (a.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
return a; return a;
} }
} }
for (final Action a : actions) { for (final BukkitAction a : actions) {
if (a.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) { if (a.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
return a; return a;
} }
@ -4339,8 +4349,8 @@ public class Quests extends JavaPlugin {
* @param quester The player to check * @param quester The player to check
* @return true if at least one available quest has not yet been completed * @return true if at least one available quest has not yet been completed
*/ */
public boolean hasQuest(final NPC npc, final Quester quester) { public boolean hasQuest(final NPC npc, final BukkitQuester quester) {
for (final Quest q : quests) { for (final BukkitQuest q : quests) {
if (q.npcStart != null && !quester.completedQuests.contains(q)) { if (q.npcStart != null && !quester.completedQuests.contains(q)) {
if (q.npcStart.getId() == npc.getId()) { if (q.npcStart.getId() == npc.getId()) {
final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests();
@ -4361,8 +4371,8 @@ public class Quests extends JavaPlugin {
* @param quester The player to check * @param quester The player to check
* @return true if at least one available quest has been completed * @return true if at least one available quest has been completed
*/ */
public boolean hasCompletedQuest(final NPC npc, final Quester quester) { public boolean hasCompletedQuest(final NPC npc, final BukkitQuester quester) {
for (final Quest q : quests) { for (final BukkitQuest q : quests) {
if (q.npcStart != null && quester.completedQuests.contains(q)) { if (q.npcStart != null && quester.completedQuests.contains(q)) {
if (q.npcStart.getId() == npc.getId()) { if (q.npcStart.getId() == npc.getId()) {
final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests();
@ -4382,8 +4392,8 @@ public class Quests extends JavaPlugin {
* @param quester The player to check * @param quester The player to check
* @return true if at least one available, redoable quest has been completed * @return true if at least one available, redoable quest has been completed
*/ */
public boolean hasCompletedRedoableQuest(final NPC npc, final Quester quester) { public boolean hasCompletedRedoableQuest(final NPC npc, final BukkitQuester quester) {
for (final Quest q : quests) { for (final BukkitQuest q : quests) {
if (q.npcStart != null && quester.completedQuests.contains(q) && q.getPlanner().getCooldown() > -1) { if (q.npcStart != null && quester.completedQuests.contains(q) && q.getPlanner().getCooldown() > -1) {
if (q.npcStart.getId() == npc.getId()) { if (q.npcStart.getId() == npc.getId()) {
final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests(); final boolean ignoreLockedQuests = settings.canIgnoreLockedQuests();

View File

@ -12,9 +12,9 @@
package me.blackvein.quests.actions; package me.blackvein.quests.actions;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.QuestMob; import me.blackvein.quests.QuestMob;
import me.blackvein.quests.Quester; import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.actions.main.ActionMainPrompt; import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
import me.blackvein.quests.convo.actions.menu.ActionMenuPrompt; import me.blackvein.quests.convo.actions.menu.ActionMenuPrompt;
@ -151,7 +151,7 @@ public class ActionFactory implements ConversationAbandonedListener {
return new ActionMainPrompt(context); return new ActionMainPrompt(context);
} }
public void loadData(final Action event, final ConversationContext context) { public void loadData(final BukkitAction event, final ConversationContext context) {
if (event.message != null) { if (event.message != null) {
context.setSessionData(CK.E_MESSAGE, event.message); context.setSessionData(CK.E_MESSAGE, event.message);
} }
@ -312,8 +312,8 @@ public class ActionFactory implements ConversationAbandonedListener {
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
plugin.getLogger().info(identifier + " deleted action " + action); plugin.getLogger().info(identifier + " deleted action " + action);
} }
for (final Quester q : plugin.getOfflineQuesters()) { for (final BukkitQuester q : plugin.getOfflineQuesters()) {
for (final Quest quest : q.getCurrentQuests().keySet()) { for (final BukkitQuest quest : q.getCurrentQuests().keySet()) {
q.checkQuest(quest); q.checkQuest(quest);
} }
} }
@ -339,7 +339,7 @@ public class ActionFactory implements ConversationAbandonedListener {
if (context.getSessionData(CK.E_OLD_EVENT) != null if (context.getSessionData(CK.E_OLD_EVENT) != null
&& !((String) Objects.requireNonNull(context.getSessionData(CK.E_OLD_EVENT))).isEmpty()) { && !((String) Objects.requireNonNull(context.getSessionData(CK.E_OLD_EVENT))).isEmpty()) {
data.set(key + "." + context.getSessionData(CK.E_OLD_EVENT), null); data.set(key + "." + context.getSessionData(CK.E_OLD_EVENT), null);
final Collection<Action> temp = plugin.getLoadedActions(); final Collection<BukkitAction> temp = plugin.getLoadedActions();
temp.remove(plugin.getAction((String) context.getSessionData(CK.E_OLD_EVENT))); temp.remove(plugin.getAction((String) context.getSessionData(CK.E_OLD_EVENT)));
plugin.setLoadedActions(temp); plugin.setLoadedActions(temp);
} }
@ -469,8 +469,8 @@ public class ActionFactory implements ConversationAbandonedListener {
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
plugin.getLogger().info(identifier + " saved action " + context.getSessionData(CK.E_NAME)); plugin.getLogger().info(identifier + " saved action " + context.getSessionData(CK.E_NAME));
} }
for (final Quester q : plugin.getOfflineQuesters()) { for (final BukkitQuester q : plugin.getOfflineQuesters()) {
for (final Quest quest : q.getCurrentQuests().keySet()) { for (final BukkitQuest quest : q.getCurrentQuests().keySet()) {
q.checkQuest(quest); q.checkQuest(quest);
} }
} }

View File

@ -0,0 +1,421 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
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.Quests;
import me.blackvein.quests.tasks.ActionTimer;
import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.InventoryUtil;
import me.blackvein.quests.util.Lang;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
public class BukkitAction implements Comparable<BukkitAction> {
private final Quests plugin;
private String name = "";
protected String message = null;
protected boolean clearInv = false;
protected boolean failQuest = false;
protected LinkedList<Location> explosions = new LinkedList<>();
protected Map<Location, Effect> effects = new HashMap<>();
protected LinkedList<ItemStack> items = new LinkedList<>();
protected World stormWorld = null;
protected int stormDuration = 0;
protected World thunderWorld = null;
protected int thunderDuration = 0;
protected int timer = 0;
protected boolean cancelTimer = false;
protected LinkedList<QuestMob> mobSpawns = new LinkedList<QuestMob>() {
private static final long serialVersionUID = -761974607799449780L;
@Override
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
final
LinkedList<QuestMob> other = (LinkedList<QuestMob>) o;
if (size() != other.size()) {
return false;
}
for (int i = 0; i < size(); i++) {
if (!get(i).equals(other.get(i))) {
return false;
}
}
}
return false;
}
};
protected LinkedList<Location> lightningStrikes = new LinkedList<>();
protected LinkedList<String> commands = new LinkedList<>();
protected LinkedList<PotionEffect> potionEffects = new LinkedList<>();
protected int hunger = -1;
protected int saturation = -1;
protected float health = -1;
protected Location teleport;
protected String book = "";
protected String denizenScript;
public BukkitAction(final Quests plugin) {
this.plugin = plugin;
}
@Override
public int compareTo(final BukkitAction action) {
return name.compareTo(action.getName());
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public String getMessage() {
return message;
}
public void setMessage(final String message) {
this.message = message;
}
public boolean isClearInv() {
return clearInv;
}
public void setClearInv(final boolean clearInv) {
this.clearInv = clearInv;
}
public boolean isFailQuest() {
return failQuest;
}
public void setFailQuest(final boolean failQuest) {
this.failQuest = failQuest;
}
public LinkedList<Location> getExplosions() {
return explosions;
}
public void setExplosions(final LinkedList<Location> explosions) {
this.explosions = explosions;
}
public Map<Location, Effect> getEffects() {
return effects;
}
public void setEffects(final Map<Location, Effect> effects) {
this.effects = effects;
}
public LinkedList<ItemStack> getItems() {
return items;
}
public void setItems(final LinkedList<ItemStack> items) {
this.items = items;
}
public World getStormWorld() {
return stormWorld;
}
public void setStormWorld(final World stormWorld) {
this.stormWorld = stormWorld;
}
public int getStormDuration() {
return stormDuration;
}
public void setStormDuration(final int stormDuration) {
this.stormDuration = stormDuration;
}
public World getThunderWorld() {
return thunderWorld;
}
public void setThunderWorld(final World thunderWorld) {
this.thunderWorld = thunderWorld;
}
public int getThunderDuration() {
return thunderDuration;
}
public void setThunderDuration(final int thunderDuration) {
this.thunderDuration = thunderDuration;
}
public int getTimer() {
return timer;
}
public void setTimer(final int timer) {
this.timer = timer;
}
public boolean isCancelTimer() {
return cancelTimer;
}
public void setCancelTimer(final boolean cancelTimer) {
this.cancelTimer = cancelTimer;
}
public LinkedList<QuestMob> getMobSpawns() {
return mobSpawns;
}
public void setMobSpawns(final LinkedList<QuestMob> mobSpawns) {
this.mobSpawns = mobSpawns;
}
public LinkedList<Location> getLightningStrikes() {
return lightningStrikes;
}
public void setLightningStrikes(final LinkedList<Location> lightningStrikes) {
this.lightningStrikes = lightningStrikes;
}
public LinkedList<String> getCommands() {
return commands;
}
public void setCommands(final LinkedList<String> commands) {
this.commands = commands;
}
public LinkedList<PotionEffect> getPotionEffects() {
return potionEffects;
}
public void setPotionEffects(final LinkedList<PotionEffect> potionEffects) {
this.potionEffects = potionEffects;
}
public int getHunger() {
return hunger;
}
public void setHunger(final int hunger) {
this.hunger = hunger;
}
public int getSaturation() {
return saturation;
}
public void setSaturation(final int saturation) {
this.saturation = saturation;
}
public float getHealth() {
return health;
}
public void setHealth(final float health) {
this.health = health;
}
public Location getTeleport() {
return teleport;
}
public void setTeleport(final Location teleport) {
this.teleport = teleport;
}
public String getBook() {
return book;
}
public void setBook(final String book) {
this.book = book;
}
public String getDenizenScript() {
return book;
}
public void setDenizenScript(final String scriptName) {
this.denizenScript = scriptName;
}
public void fire(final BukkitQuester quester, final BukkitQuest quest) {
final Player player = quester.getPlayer();
if (message != null) {
player.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(message, quest, player));
}
if (clearInv) {
player.getInventory().clear();
}
if (!explosions.isEmpty()) {
for (final Location l : explosions) {
if (l.getWorld() != null) {
l.getWorld().createExplosion(l, 4F, false);
}
}
}
if (!effects.isEmpty()) {
for (final Location l : effects.keySet()) {
if (l.getWorld() != null) {
l.getWorld().playEffect(l, effects.get(l), 1);
}
}
}
if (!items.isEmpty()) {
for (final ItemStack is : items) {
try {
InventoryUtil.addItem(player, is);
} catch (final Exception e) {
plugin.getLogger().severe("Unable to add null item to inventory of "
+ player.getName() + " during quest " + quest.getName() + " event " + name);
player.sendMessage(ChatColor.RED + "Quests encountered a problem with an item. "
+ "Please contact an administrator.");
}
}
}
if (stormWorld != null) {
stormWorld.setStorm(true);
stormWorld.setWeatherDuration(stormDuration);
}
if (thunderWorld != null) {
thunderWorld.setThundering(true);
thunderWorld.setThunderDuration(thunderDuration);
}
if (!mobSpawns.isEmpty()) {
for (final QuestMob questMob : mobSpawns) {
questMob.spawn();
}
}
if (!lightningStrikes.isEmpty()) {
for (final Location l : lightningStrikes) {
if (l.getWorld() != null) {
l.getWorld().strikeLightning(l);
}
}
}
if (!commands.isEmpty()) {
for (final String s : commands) {
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(),
s.replace("<player>", quester.getPlayer().getName()));
}
}
if (!potionEffects.isEmpty()) {
for (final PotionEffect p : potionEffects) {
player.addPotionEffect(p);
}
}
if (hunger != -1) {
player.setFoodLevel(hunger);
}
if (saturation != -1) {
player.setSaturation(saturation);
}
if (health != -1) {
player.setHealth(health);
}
if (teleport != null) {
if (player.isDead()) {
plugin.getLogger().warning("Tried to fire Action " + name + " but player " + player.getUniqueId()
+ " was dead (known Bukkit limitation).");
} else {
player.teleport(teleport);
}
}
if (book != null) {
if (!book.isEmpty()) {
if (plugin.getDependencies().getCitizensBooksApi() != null) {
if (plugin.getDependencies().getCitizensBooksApi().hasFilter(book)) {
plugin.getDependencies().getCitizensBooksApi().openBook(player, plugin.getDependencies()
.getCitizensBooksApi().getFilter(book));
}
}
}
}
if (failQuest) {
quest.failQuest(quester, true);
}
if (timer > 0) {
player.sendMessage(ChatColor.GREEN + Lang.get(player, "timerStart")
.replace("<time>", ChatColor.RED + String.valueOf(timer) + ChatColor.GREEN));
if (timer > 60) {
quester.getTimers().put(new ActionTimer(quester, quest, 60, false)
.runTaskLater(plugin, (timer - 60) * 20L).getTaskId(), quest);
}
if (timer > 30) {
quester.getTimers().put(new ActionTimer(quester, quest, 30, false)
.runTaskLater(plugin, (timer - 30) * 20L).getTaskId(), quest);
}
if (timer > 10) {
quester.getTimers().put(new ActionTimer(quester, quest, 10, false)
.runTaskLater(plugin, (timer - 10) * 20L).getTaskId(), quest);
}
if (timer > 5) {
quester.getTimers().put(new ActionTimer(quester, quest, 5, false)
.runTaskLater(plugin, (timer - 5) * 20L).getTaskId(), quest);
}
if (timer > 4) {
quester.getTimers().put(new ActionTimer(quester, quest, 4, false)
.runTaskLater(plugin, (timer - 4) * 20L).getTaskId(), quest);
}
if (timer > 3) {
quester.getTimers().put(new ActionTimer(quester, quest, 3, false)
.runTaskLater(plugin, (timer - 3) * 20L).getTaskId(), quest);
}
if (timer > 2) {
quester.getTimers().put(new ActionTimer(quester, quest, 2, false)
.runTaskLater(plugin, (timer - 2) * 20L).getTaskId(), quest);
}
if (timer > 1) {
quester.getTimers().put(new ActionTimer(quester, quest, 1, false)
.runTaskLater(plugin, (timer - 1) * 20L).getTaskId(), quest);
}
quester.getTimers().put(new ActionTimer(quester, quest, 0, true)
.runTaskLater(plugin, timer * 20L).getTaskId(), quest);
}
if (cancelTimer) {
for (final Map.Entry<Integer, BukkitQuest> entry : quester.getTimers().entrySet()) {
if (entry.getValue().getName().equals(quest.getName())) {
plugin.getServer().getScheduler().cancelTask(entry.getKey());
quester.getTimers().remove(entry.getKey());
}
}
}
if (denizenScript != null) {
plugin.getDenizenTrigger().runDenizenScript(denizenScript, quester);
}
}
}

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.conditions; package me.blackvein.quests.conditions;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quester; import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.MiscUtil; import me.blackvein.quests.util.MiscUtil;
@ -137,7 +137,7 @@ public class Condition implements Comparable<Condition> {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean check(final Quester quester, final Quest quest) { public boolean check(final BukkitQuester quester, final BukkitQuest quest) {
final Player player = quester.getPlayer(); final Player player = quester.getPlayer();
if (!entitiesWhileRiding.isEmpty()) { if (!entitiesWhileRiding.isEmpty()) {
for (final String e : entitiesWhileRiding) { for (final String e : entitiesWhileRiding) {

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.conditions; package me.blackvein.quests.conditions;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quester; import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt; import me.blackvein.quests.convo.conditions.main.ConditionMainPrompt;
import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt; import me.blackvein.quests.convo.conditions.menu.ConditionMenuPrompt;
@ -179,8 +179,8 @@ public class ConditionFactory implements ConversationAbandonedListener {
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
plugin.getLogger().info(identifier + " deleted condition " + condition); plugin.getLogger().info(identifier + " deleted condition " + condition);
} }
for (final Quester q : plugin.getOfflineQuesters()) { for (final BukkitQuester q : plugin.getOfflineQuesters()) {
for (final Quest quest : q.getCurrentQuests().keySet()) { for (final BukkitQuest quest : q.getCurrentQuests().keySet()) {
q.checkQuest(quest); q.checkQuest(quest);
} }
} }
@ -267,8 +267,8 @@ public class ConditionFactory implements ConversationAbandonedListener {
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE"; "Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
plugin.getLogger().info(identifier + " saved condition " + context.getSessionData(CK.C_NAME)); plugin.getLogger().info(identifier + " saved condition " + context.getSessionData(CK.C_NAME));
} }
for (final Quester q : plugin.getOfflineQuesters()) { for (final BukkitQuester q : plugin.getOfflineQuesters()) {
for (final Quest quest : q.getCurrentQuests().keySet()) { for (final BukkitQuest quest : q.getCurrentQuests().keySet()) {
q.checkQuest(quest); q.checkQuest(quest);
} }
} }

View File

@ -12,11 +12,11 @@
package me.blackvein.quests.convo.actions.main; package me.blackvein.quests.convo.actions.main;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.QuestMob; import me.blackvein.quests.QuestMob;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.Stage; import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.actions.Action; import me.blackvein.quests.actions.BukkitAction;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
@ -271,7 +271,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
return null; return null;
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
return new ActionNamePrompt(context); return new ActionNamePrompt(context);
@ -1013,8 +1013,8 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
super(context); super(context);
if (modifiedName != null) { if (modifiedName != null) {
modName = modifiedName; modName = modifiedName;
for (final Quest q : plugin.getLoadedQuests()) { for (final BukkitQuest q : plugin.getLoadedQuests()) {
for (final Stage s : q.getStages()) { for (final BukkitStage s : q.getStages()) {
if (s.getFinishAction() != null && s.getFinishAction().getName() != null) { if (s.getFinishAction() != null && s.getFinishAction().getName() != null) {
if (s.getFinishAction().getName().equalsIgnoreCase(modifiedName)) { if (s.getFinishAction().getName().equalsIgnoreCase(modifiedName)) {
modified.add(q.getName()); modified.add(q.getName());

View File

@ -12,10 +12,10 @@
package me.blackvein.quests.convo.actions.menu; package me.blackvein.quests.convo.actions.menu;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.Stage; import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.actions.Action; import me.blackvein.quests.actions.BukkitAction;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt; import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt; import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
@ -28,7 +28,6 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt; import org.bukkit.conversations.Prompt;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.LinkedList; import java.util.LinkedList;
@ -187,7 +186,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
} }
input = input.trim(); input = input.trim();
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
return new ActionSelectCreatePrompt(context); return new ActionSelectCreatePrompt(context);
@ -237,7 +236,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
final ActionsEditorPostOpenStringPromptEvent event final ActionsEditorPostOpenStringPromptEvent event
= new ActionsEditorPostOpenStringPromptEvent(context, this); = new ActionsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedActions().stream().map(Action::getName).collect(Collectors.toList()); final List<String> names = plugin.getLoadedActions().stream().map(BukkitAction::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context); return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
} }
@ -247,7 +246,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
return null; return null;
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final Action a = plugin.getAction(input); final BukkitAction a = plugin.getAction(input);
if (a != null) { if (a != null) {
context.setSessionData(CK.E_OLD_EVENT, a.getName()); context.setSessionData(CK.E_OLD_EVENT, a.getName());
context.setSessionData(CK.E_NAME, a.getName()); context.setSessionData(CK.E_NAME, a.getName());
@ -283,7 +282,7 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
final ActionsEditorPostOpenStringPromptEvent event final ActionsEditorPostOpenStringPromptEvent event
= new ActionsEditorPostOpenStringPromptEvent(context, this); = new ActionsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedActions().stream().map(Action::getName).collect(Collectors.toList()); final List<String> names = plugin.getLoadedActions().stream().map(BukkitAction::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context); return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
} }
@ -294,10 +293,10 @@ public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final LinkedList<String> used = new LinkedList<String>(); final LinkedList<String> used = new LinkedList<String>();
final Action a = plugin.getAction(input); final BukkitAction a = plugin.getAction(input);
if (a != null) { if (a != null) {
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Stage stage : quest.getStages()) { for (final BukkitStage stage : quest.getStages()) {
if (stage.getFinishAction() != null if (stage.getFinishAction() != null
&& stage.getFinishAction().getName().equalsIgnoreCase(a.getName())) { && stage.getFinishAction().getName().equalsIgnoreCase(a.getName())) {
used.add(quest.getName()); used.add(quest.getName());

View File

@ -12,9 +12,9 @@
package me.blackvein.quests.convo.conditions.main; package me.blackvein.quests.convo.conditions.main;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.Stage; import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.conditions.Condition; import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt;
@ -482,8 +482,8 @@ public class ConditionMainPrompt extends ConditionsEditorNumericPrompt {
super(context); super(context);
if (modifiedName != null) { if (modifiedName != null) {
modName = modifiedName; modName = modifiedName;
for (final Quest q : plugin.getLoadedQuests()) { for (final BukkitQuest q : plugin.getLoadedQuests()) {
for (final Stage s : q.getStages()) { for (final BukkitStage s : q.getStages()) {
if (s.getCondition() != null && s.getCondition().getName() != null) { if (s.getCondition() != null && s.getCondition().getName() != null) {
if (s.getCondition().getName().equalsIgnoreCase(modifiedName)) { if (s.getCondition().getName().equalsIgnoreCase(modifiedName)) {
modified.add(q.getName()); modified.add(q.getName());

View File

@ -12,9 +12,9 @@
package me.blackvein.quests.convo.conditions.menu; package me.blackvein.quests.convo.conditions.menu;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.Stage; import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.conditions.Condition; import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt; import me.blackvein.quests.convo.conditions.ConditionsEditorNumericPrompt;
@ -28,7 +28,6 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt; import org.bukkit.conversations.Prompt;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.LinkedList; import java.util.LinkedList;
@ -295,8 +294,8 @@ public class ConditionMenuPrompt extends ConditionsEditorNumericPrompt {
final LinkedList<String> used = new LinkedList<>(); final LinkedList<String> used = new LinkedList<>();
final Condition c = plugin.getCondition(input); final Condition c = plugin.getCondition(input);
if (c != null) { if (c != null) {
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
for (final Stage stage : quest.getStages()) { for (final BukkitStage stage : quest.getStages()) {
if (stage.getCondition() != null if (stage.getCondition() != null
&& stage.getCondition().getName().equalsIgnoreCase(c.getName())) { && stage.getCondition().getName().equalsIgnoreCase(c.getName())) {
used.add(quest.getName()); used.add(quest.getName());

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.convo.misc; package me.blackvein.quests.convo.misc;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quester; import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.events.misc.MiscPostNpcOfferQuestEvent; import me.blackvein.quests.events.misc.MiscPostNpcOfferQuestEvent;
import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.Lang;
@ -64,12 +64,12 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public ChatColor getNumberColor(final ConversationContext context, final int number) { public ChatColor getNumberColor(final ConversationContext context, final int number) {
final Quests plugin = (Quests)context.getPlugin(); final Quests plugin = (Quests)context.getPlugin();
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests"); final LinkedList<BukkitQuest> quests = (LinkedList<BukkitQuest>) context.getSessionData("npcQuests");
if (plugin != null) { if (plugin != null) {
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId()); final BukkitQuester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
if (quests != null && number > 0) { if (quests != null && number > 0) {
if (number < (quests.size() + 1)) { if (number < (quests.size() + 1)) {
final Quest quest = quests.get(number - 1); final BukkitQuest quest = quests.get(number - 1);
if (quester.getCompletedQuests().contains(quest)) { if (quester.getCompletedQuests().contains(quest)) {
return ChatColor.GREEN; return ChatColor.GREEN;
} else { } else {
@ -87,12 +87,12 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public String getSelectionText(final ConversationContext context, final int number) { public String getSelectionText(final ConversationContext context, final int number) {
final Quests plugin = (Quests)context.getPlugin(); final Quests plugin = (Quests)context.getPlugin();
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests"); final LinkedList<BukkitQuest> quests = (LinkedList<BukkitQuest>) context.getSessionData("npcQuests");
if (plugin != null) { if (plugin != null) {
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId()); final BukkitQuester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
if (quests != null && number > 0) { if (quests != null && number > 0) {
if (number < (quests.size() + 1)) { if (number < (quests.size() + 1)) {
final Quest quest = quests.get(number - 1); final BukkitQuest quest = quests.get(number - 1);
if (quester.getCompletedQuests().contains(quest)) { if (quester.getCompletedQuests().contains(quest)) {
return ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName(); return ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName();
} else { } else {
@ -109,12 +109,12 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public String getAdditionalText(final ConversationContext context, final int number) { public String getAdditionalText(final ConversationContext context, final int number) {
final Quests plugin = (Quests)context.getPlugin(); final Quests plugin = (Quests)context.getPlugin();
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests"); final LinkedList<BukkitQuest> quests = (LinkedList<BukkitQuest>) context.getSessionData("npcQuests");
if (plugin != null) { if (plugin != null) {
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId()); final BukkitQuester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
if (quests != null && number > 0) { if (quests != null && number > 0) {
if (number < (quests.size() + 1)) { if (number < (quests.size() + 1)) {
final Quest quest = quests.get(number - 1); final BukkitQuest quest = quests.get(number - 1);
if (quester.getCompletedQuests().contains(quest)) { if (quester.getCompletedQuests().contains(quest)) {
return ChatColor.GREEN + "" + Lang.get("redoCompleted"); return ChatColor.GREEN + "" + Lang.get("redoCompleted");
} }
@ -133,12 +133,12 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
public @Nonnull String getPromptText(final ConversationContext context) { public @Nonnull String getPromptText(final ConversationContext context) {
this.cc = context; this.cc = context;
final Quests plugin = (Quests)context.getPlugin(); final Quests plugin = (Quests)context.getPlugin();
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests"); final LinkedList<BukkitQuest> quests = (LinkedList<BukkitQuest>) context.getSessionData("npcQuests");
final String npc = (String) context.getSessionData("npc"); final String npc = (String) context.getSessionData("npc");
if (plugin == null || quests == null || npc == null) { if (plugin == null || quests == null || npc == null) {
return ChatColor.YELLOW + Lang.get("unknownError"); return ChatColor.YELLOW + Lang.get("unknownError");
} }
quests.sort(Comparator.comparing(Quest::getName)); quests.sort(Comparator.comparing(BukkitQuest::getName));
final MiscPostNpcOfferQuestEvent event = new MiscPostNpcOfferQuestEvent(context, this); final MiscPostNpcOfferQuestEvent event = new MiscPostNpcOfferQuestEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
@ -179,11 +179,11 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
@Override @Override
public Prompt acceptInput(final ConversationContext context, final String input) { public Prompt acceptInput(final ConversationContext context, final String input) {
final Quests plugin = (Quests)context.getPlugin(); final Quests plugin = (Quests)context.getPlugin();
final LinkedList<Quest> quests = (LinkedList<Quest>) context.getSessionData("npcQuests"); final LinkedList<BukkitQuest> quests = (LinkedList<BukkitQuest>) context.getSessionData("npcQuests");
if (plugin == null || quests == null) { if (plugin == null || quests == null) {
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} }
final Quester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId()); final BukkitQuester quester = plugin.getQuester(((Player) context.getForWhom()).getUniqueId());
int numInput = -1; int numInput = -1;
try { try {
numInput = Integer.parseInt(input); numInput = Integer.parseInt(input);
@ -194,15 +194,15 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("cancelled")); context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("cancelled"));
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} else { } else {
Quest q = null; BukkitQuest q = null;
for (final Quest quest : quests) { for (final BukkitQuest quest : quests) {
if (quest.getName().equalsIgnoreCase(input)) { if (quest.getName().equalsIgnoreCase(input)) {
q = quest; q = quest;
break; break;
} }
} }
if (q == null) { if (q == null) {
for (final Quest quest : quests) { for (final BukkitQuest quest : quests) {
if (numInput == (quests.indexOf(quest) + 1)) { if (numInput == (quests.indexOf(quest) + 1)) {
q = quest; q = quest;
break; break;
@ -210,7 +210,7 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
} }
} }
if (q == null) { if (q == null) {
for (final Quest quest : quests) { for (final BukkitQuest quest : quests) {
if (quest.getName().toLowerCase().contains(input.toLowerCase())) { if (quest.getName().toLowerCase().contains(input.toLowerCase())) {
q = quest; q = quest;
break; break;
@ -238,8 +238,8 @@ public class NpcOfferQuestPrompt extends MiscStringPrompt {
} }
} }
private String extracted(final Quests plugin, final Quester quester) { private String extracted(final Quests plugin, final BukkitQuester quester) {
final Quest quest = plugin.getQuestById(quester.getQuestIdToTake()); final BukkitQuest quest = plugin.getQuestById(quester.getQuestIdToTake());
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE,
quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription()); quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription());
} }

View File

@ -13,7 +13,7 @@
package me.blackvein.quests.convo.quests.main; package me.blackvein.quests.convo.quests.main;
import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.managers.RegionManager;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.generic.ItemStackPrompt; import me.blackvein.quests.convo.generic.ItemStackPrompt;
@ -341,7 +341,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
return null; return null;
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final Quest q : plugin.getLoadedQuests()) { for (final BukkitQuest q : plugin.getLoadedQuests()) {
if (q.getName().equalsIgnoreCase(input)) { if (q.getName().equalsIgnoreCase(input)) {
String s = null; String s = null;
if (context.getSessionData(CK.ED_QUEST_EDIT) != null) { if (context.getSessionData(CK.ED_QUEST_EDIT) != null) {
@ -732,7 +732,7 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData("tempStack") != null) { if (context.getSessionData("tempStack") != null) {
final ItemStack stack = (ItemStack) context.getSessionData("tempStack"); final ItemStack stack = (ItemStack) context.getSessionData("tempStack");
boolean failed = false; boolean failed = false;
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (quest.getGUIDisplay() != null) { if (quest.getGUIDisplay() != null) {
if (ItemUtil.compareItems(stack, quest.getGUIDisplay(), false) == 0) { if (ItemUtil.compareItems(stack, quest.getGUIDisplay(), false) == 0) {
String error = Lang.get("questGUIError"); String error = Lang.get("questGUIError");

View File

@ -12,7 +12,7 @@
package me.blackvein.quests.convo.quests.menu; package me.blackvein.quests.convo.quests.menu;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt; import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
@ -26,7 +26,6 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt; import org.bukkit.conversations.Prompt;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.LinkedList; import java.util.LinkedList;
@ -170,7 +169,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
} }
input = input.trim(); input = input.trim();
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
for (final Quest q : plugin.getLoadedQuests()) { for (final BukkitQuest q : plugin.getLoadedQuests()) {
if (q.getName().equalsIgnoreCase(input)) { if (q.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNameExists")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNameExists"));
return new QuestSelectCreatePrompt(context); return new QuestSelectCreatePrompt(context);
@ -222,7 +221,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
final QuestsEditorPostOpenStringPromptEvent event final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this); = new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedQuests().stream().map(Quest::getName).collect(Collectors.toList()); final List<String> names = plugin.getLoadedQuests().stream().map(BukkitQuest::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context); return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
} }
@ -232,7 +231,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
return null; return null;
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final Quest q = plugin.getQuest(input); final BukkitQuest q = plugin.getQuest(input);
if (q != null) { if (q != null) {
plugin.getQuestFactory().loadQuest(context, q); plugin.getQuestFactory().loadQuest(context, q);
return new QuestMainPrompt(context); return new QuestMainPrompt(context);
@ -265,7 +264,7 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
final QuestsEditorPostOpenStringPromptEvent event final QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, this); = new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
final List<String> names = plugin.getLoadedQuests().stream().map(Quest::getName).collect(Collectors.toList()); final List<String> names = plugin.getLoadedQuests().stream().map(BukkitQuest::getName).collect(Collectors.toList());
return sendClickableMenu(getTitle(context), names, getQueryText(context), context); return sendClickableMenu(getTitle(context), names, getQueryText(context), context);
} }
@ -276,9 +275,9 @@ public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
} }
if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (!input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final LinkedList<String> used = new LinkedList<>(); final LinkedList<String> used = new LinkedList<>();
final Quest found = plugin.getQuest(input); final BukkitQuest found = plugin.getQuest(input);
if (found != null) { if (found != null) {
for (final Quest q : plugin.getLoadedQuests()) { for (final BukkitQuest q : plugin.getLoadedQuests()) {
if (q.getRequirements().getNeededQuests().contains(q) if (q.getRequirements().getNeededQuests().contains(q)
|| q.getRequirements().getBlockQuests().contains(q)) { || q.getRequirements().getBlockQuests().contains(q)) {
used.add(q.getName()); used.add(q.getName());

View File

@ -12,7 +12,7 @@
package me.blackvein.quests.convo.quests.options; package me.blackvein.quests.convo.quests.options;
import me.blackvein.quests.Options; import me.blackvein.quests.quests.BukkitOptions;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt; import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt; import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
@ -459,7 +459,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
case 1: case 1:
final Boolean commandsOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS); final Boolean commandsOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS);
if (commandsOpt == null) { if (commandsOpt == null) {
final boolean defaultOpt = new Options().canAllowCommands(); final boolean defaultOpt = new BukkitOptions().canAllowCommands();
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED + Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")"; + Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";
@ -471,7 +471,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
case 2: case 2:
final Boolean quittingOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING); final Boolean quittingOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING);
if (quittingOpt == null) { if (quittingOpt == null) {
final boolean defaultOpt = new Options().canAllowQuitting(); final boolean defaultOpt = new BukkitOptions().canAllowQuitting();
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED + Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")"; + Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";
@ -483,7 +483,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
case 3: case 3:
final Boolean ignoreOpt = (Boolean) context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH); final Boolean ignoreOpt = (Boolean) context.getSessionData(CK.OPT_IGNORE_SILK_TOUCH);
if (ignoreOpt == null) { if (ignoreOpt == null) {
final boolean defaultOpt = new Options().canIgnoreSilkTouch(); final boolean defaultOpt = new BukkitOptions().canIgnoreSilkTouch();
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED + Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")"; + Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";
@ -617,7 +617,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
case 2: case 2:
final Boolean partiesOpt = (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN); final Boolean partiesOpt = (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN);
if (partiesOpt == null) { if (partiesOpt == null) {
final boolean defaultOpt = new Options().canUsePartiesPlugin(); final boolean defaultOpt = new BukkitOptions().canUsePartiesPlugin();
return ChatColor.GRAY + "("+ (defaultOpt ? ChatColor.GREEN return ChatColor.GRAY + "("+ (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED + Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")"; + Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";
@ -629,7 +629,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
case 3: case 3:
final Integer shareOpt = (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL); final Integer shareOpt = (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL);
if (shareOpt == null) { if (shareOpt == null) {
final int defaultOpt = new Options().getShareProgressLevel(); final int defaultOpt = new BukkitOptions().getShareProgressLevel();
return ChatColor.GRAY + "(" + ChatColor.AQUA + defaultOpt + ChatColor.GRAY + ")"; return ChatColor.GRAY + "(" + ChatColor.AQUA + defaultOpt + ChatColor.GRAY + ")";
} else { } else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + shareOpt + ChatColor.GRAY + ")"; return ChatColor.GRAY + "(" + ChatColor.AQUA + shareOpt + ChatColor.GRAY + ")";
@ -637,7 +637,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
case 4: case 4:
final Boolean requireOpt = (Boolean) context.getSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY); final Boolean requireOpt = (Boolean) context.getSessionData(CK.OPT_SHARE_SAME_QUEST_ONLY);
if (requireOpt == null) { if (requireOpt == null) {
final boolean defaultOpt = new Options().canShareSameQuestOnly(); final boolean defaultOpt = new BukkitOptions().canShareSameQuestOnly();
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED + Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")"; + Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";
@ -649,7 +649,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
case 5: case 5:
final Double distanceOpt = (Double) context.getSessionData(CK.OPT_SHARE_DISTANCE); final Double distanceOpt = (Double) context.getSessionData(CK.OPT_SHARE_DISTANCE);
if (distanceOpt == null) { if (distanceOpt == null) {
final double defaultOpt = new Options().getShareDistance(); final double defaultOpt = new BukkitOptions().getShareDistance();
return ChatColor.GRAY + "(" + ChatColor.AQUA + defaultOpt + ChatColor.GRAY + ")"; return ChatColor.GRAY + "(" + ChatColor.AQUA + defaultOpt + ChatColor.GRAY + ")";
} else { } else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + distanceOpt + ChatColor.GRAY + ")"; return ChatColor.GRAY + "(" + ChatColor.AQUA + distanceOpt + ChatColor.GRAY + ")";
@ -657,7 +657,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
case 6: case 6:
final Boolean handleOpt = (Boolean) context.getSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS); final Boolean handleOpt = (Boolean) context.getSessionData(CK.OPT_HANDLE_OFFLINE_PLAYERS);
if (handleOpt == null) { if (handleOpt == null) {
final boolean defaultOpt = new Options().canHandleOfflinePlayers(); final boolean defaultOpt = new BukkitOptions().canHandleOfflinePlayers();
return ChatColor.GRAY + "("+ (defaultOpt ? ChatColor.GREEN return ChatColor.GRAY + "("+ (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED + Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")"; + Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";

View File

@ -12,7 +12,7 @@
package me.blackvein.quests.convo.quests.planner; package me.blackvein.quests.convo.quests.planner;
import me.blackvein.quests.Planner; import me.blackvein.quests.quests.BukkitPlanner;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt; import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt; import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
@ -139,7 +139,7 @@ public class PlannerPrompt extends QuestsEditorNumericPrompt {
case 5: case 5:
final Boolean override = (Boolean) context.getSessionData(CK.PLN_OVERRIDE); final Boolean override = (Boolean) context.getSessionData(CK.PLN_OVERRIDE);
if (override == null) { if (override == null) {
final boolean defaultOpt = new Planner().getOverride(); final boolean defaultOpt = new BukkitPlanner().getOverride();
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED + Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")"; + Lang.get(String.valueOf(defaultOpt))) + ChatColor.GRAY + ")";

View File

@ -14,10 +14,8 @@ package me.blackvein.quests.convo.quests.requirements;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.herocraftonline.heroes.characters.classes.HeroClass; import com.herocraftonline.heroes.characters.classes.HeroClass;
import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.CustomRequirement; import me.blackvein.quests.CustomRequirement;
import me.blackvein.quests.CustomReward; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.generic.ItemStackPrompt; import me.blackvein.quests.convo.generic.ItemStackPrompt;
import me.blackvein.quests.convo.generic.OverridePrompt; import me.blackvein.quests.convo.generic.OverridePrompt;
@ -856,7 +854,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n" StringBuilder text = new StringBuilder(ChatColor.LIGHT_PURPLE + getTitle(context) + "\n"
+ ChatColor.DARK_PURPLE); + ChatColor.DARK_PURPLE);
boolean none = true; boolean none = true;
for (final Quest q : plugin.getLoadedQuests()) { for (final BukkitQuest q : plugin.getLoadedQuests()) {
text.append(q.getName()).append(", "); text.append(q.getName()).append(", ");
none = false; none = false;
} }

View File

@ -16,8 +16,6 @@ import com.codisimus.plugins.phatloots.PhatLoot;
import com.codisimus.plugins.phatloots.PhatLootsAPI; import com.codisimus.plugins.phatloots.PhatLootsAPI;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.herocraftonline.heroes.characters.classes.HeroClass; import com.herocraftonline.heroes.characters.classes.HeroClass;
import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.CustomRequirement;
import me.blackvein.quests.CustomReward; import me.blackvein.quests.CustomReward;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.generic.ItemStackPrompt; import me.blackvein.quests.convo.generic.ItemStackPrompt;

View File

@ -14,7 +14,7 @@ package me.blackvein.quests.convo.quests.stages;
import me.blackvein.quests.CustomObjective; import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.Action; import me.blackvein.quests.actions.BukkitAction;
import me.blackvein.quests.conditions.Condition; import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.convo.QuestsNumericPrompt; import me.blackvein.quests.convo.QuestsNumericPrompt;
import me.blackvein.quests.convo.generic.OverridePrompt; import me.blackvein.quests.convo.generic.OverridePrompt;
@ -31,7 +31,6 @@ import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil; import me.blackvein.quests.util.MiscUtil;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -1439,7 +1438,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) { if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n"); text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n");
} else { } else {
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n"); text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
} }
} }
@ -1451,8 +1450,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom(); final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel")) if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) { && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null; BukkitAction found = null;
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
found = a; found = a;
break; break;
@ -1506,7 +1505,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) { if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")); text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else { } else {
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n"); text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
} }
} }
@ -1518,8 +1517,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom(); final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel")) if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) { && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null; BukkitAction found = null;
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
found = a; found = a;
break; break;
@ -1573,7 +1572,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) { if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")); text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else { } else {
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n"); text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
} }
} }
@ -1585,8 +1584,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom(); final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel")) if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) { && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null; BukkitAction found = null;
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
found = a; found = a;
break; break;
@ -1640,7 +1639,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) { if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n"); text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n");
} else { } else {
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n"); text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
} }
} }
@ -1652,8 +1651,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom(); final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel")) if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) { && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null; BukkitAction found = null;
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
found = a; found = a;
break; break;
@ -1707,7 +1706,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) { if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")); text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else { } else {
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n"); text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
} }
} }
@ -1719,8 +1718,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom(); final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel")) if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) { && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null; BukkitAction found = null;
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
found = a; found = a;
break; break;
@ -1774,7 +1773,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) { if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")); text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else { } else {
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n"); text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
} }
} }
@ -1786,8 +1785,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom(); final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel")) if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) { && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null; BukkitAction found = null;
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
found = a; found = a;
break; break;
@ -1916,7 +1915,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) { if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")); text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else { } else {
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n"); text.append(ChatColor.GREEN).append("- ").append(a.getName()).append("\n");
} }
} }
@ -1928,8 +1927,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
final Player player = (Player) context.getForWhom(); final Player player = (Player) context.getForWhom();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel")) if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) { && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null; BukkitAction found = null;
for (final Action a : plugin.getLoadedActions()) { for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) { if (a.getName().equalsIgnoreCase(input)) {
found = a; found = a;
break; break;

View File

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

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.item; package me.blackvein.quests.item;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quester; import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.Lang;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -27,10 +27,10 @@ import java.util.stream.Collectors;
public class QuestJournal { public class QuestJournal {
final Quester owner; final BukkitQuester owner;
ItemStack journal = new ItemStack(Material.WRITTEN_BOOK); ItemStack journal = new ItemStack(Material.WRITTEN_BOOK);
public QuestJournal(final Quester owner) { public QuestJournal(final BukkitQuester owner) {
this.owner = owner; this.owner = owner;
final BookMeta book = (BookMeta) journal.getItemMeta(); final BookMeta book = (BookMeta) journal.getItemMeta();
if (book != null) { if (book != null) {
@ -45,10 +45,10 @@ public class QuestJournal {
int currentLength = 0; int currentLength = 0;
int currentLines = 0; int currentLines = 0;
StringBuilder page = new StringBuilder(); StringBuilder page = new StringBuilder();
final List<Quest> sortedList = owner.getCurrentQuests().keySet().stream() final List<BukkitQuest> sortedList = owner.getCurrentQuests().keySet().stream()
.sorted(Comparator.comparing(Quest::getName)) .sorted(Comparator.comparing(BukkitQuest::getName))
.collect(Collectors.toList()); .collect(Collectors.toList());
for (final Quest quest : sortedList) { for (final BukkitQuest quest : sortedList) {
if ((currentLength + quest.getName().length() > 240) || (currentLines if ((currentLength + quest.getName().length() > 240) || (currentLines
+ ((quest.getName().length() % 19) == 0 ? (quest.getName().length() / 19) + ((quest.getName().length() % 19) == 0 ? (quest.getName().length() / 19)
: ((quest.getName().length() / 19) + 1))) > 13) { : ((quest.getName().length() / 19) + 1))) > 13) {
@ -90,7 +90,7 @@ public class QuestJournal {
} }
} }
public Quester getOwner() { public BukkitQuester getOwner() {
return owner; return owner;
} }

View File

@ -12,11 +12,11 @@
package me.blackvein.quests.listeners; package me.blackvein.quests.listeners;
import me.blackvein.quests.Objective; import me.blackvein.quests.quests.BukkitObjective;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quester; import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.Stage; import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.enums.ObjectiveType; import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent; import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent;
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent; import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
@ -55,20 +55,20 @@ public class BlockListener implements Listener {
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState() final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState()
.getData().toItemStack().getDurability()); .getData().toItemStack().getDurability());
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType breakType = ObjectiveType.BREAK_BLOCK; final ObjectiveType breakType = ObjectiveType.BREAK_BLOCK;
final ObjectiveType placeType = ObjectiveType.PLACE_BLOCK; final ObjectiveType placeType = ObjectiveType.PLACE_BLOCK;
final ObjectiveType cutType = ObjectiveType.CUT_BLOCK; final ObjectiveType cutType = ObjectiveType.CUT_BLOCK;
final Set<String> dispatchedBreakQuestIDs = new HashSet<>(); final Set<String> dispatchedBreakQuestIDs = new HashSet<>();
final Set<String> dispatchedPlaceQuestIDs = new HashSet<>(); final Set<String> dispatchedPlaceQuestIDs = new HashSet<>();
final Set<String> dispatchedCutQuestIDs = new HashSet<>(); final Set<String> dispatchedCutQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!evt.isCancelled()) { if (!evt.isCancelled()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
if (quester.getCurrentQuests().containsKey(quest)) { if (quester.getCurrentQuests().containsKey(quest)) {
final Stage currentStage = quester.getCurrentStage(quest); final BukkitStage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) { if (currentStage == null) {
plugin.getLogger().severe("Player " + player.getName() + " (" + player.getUniqueId() plugin.getLogger().severe("Player " + player.getName() + " (" + player.getUniqueId()
+ ") has invalid stage for quest " + quest.getName() + " (" + quest.getId() + ")"); + ") has invalid stage for quest " + quest.getName() + " (" + quest.getId() + ")");
@ -84,7 +84,7 @@ public class BlockListener implements Listener {
// Multiplayer // Multiplayer
dispatchedBreakQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, breakType, dispatchedBreakQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, breakType,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedBreakQuestIDs.contains(cq.getId())) { if (!dispatchedBreakQuestIDs.contains(cq.getId())) {
q.breakBlock(cq, blockItemStack); q.breakBlock(cq, blockItemStack);
} }
@ -104,7 +104,7 @@ public class BlockListener implements Listener {
final QuesterPreUpdateObjectiveEvent preEvent final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent(quester, quest, = new QuesterPreUpdateObjectiveEvent(quester, quest,
new Objective(placeType, is.getAmount(), toPlace.getAmount())); new BukkitObjective(placeType, is.getAmount(), toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final int index = quester.getQuestData(quest).blocksPlaced.indexOf(is); final int index = quester.getQuestData(quest).blocksPlaced.indexOf(is);
@ -114,13 +114,13 @@ public class BlockListener implements Listener {
final QuesterPostUpdateObjectiveEvent postEvent final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent(quester, quest, = new QuesterPostUpdateObjectiveEvent(quester, quest,
new Objective(placeType, newAmount, toPlace.getAmount())); new BukkitObjective(placeType, newAmount, toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent); plugin.getServer().getPluginManager().callEvent(postEvent);
} }
} }
} }
dispatchedPlaceQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, placeType, dispatchedPlaceQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, placeType,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedPlaceQuestIDs.contains(cq.getId())) { if (!dispatchedPlaceQuestIDs.contains(cq.getId())) {
for (final ItemStack is : q.getQuestData(cq).blocksPlaced) { for (final ItemStack is : q.getQuestData(cq).blocksPlaced) {
if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) { if (evt.getBlock().getType().equals(is.getType()) && is.getAmount() > 0) {
@ -133,7 +133,7 @@ public class BlockListener implements Listener {
final QuesterPreUpdateObjectiveEvent preEvent final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent(q, cq, = new QuesterPreUpdateObjectiveEvent(q, cq,
new Objective(placeType, is.getAmount(), toPlace.getAmount())); new BukkitObjective(placeType, is.getAmount(), toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
final int index = q.getQuestData(cq).blocksPlaced.indexOf(is); final int index = q.getQuestData(cq).blocksPlaced.indexOf(is);
@ -143,7 +143,7 @@ public class BlockListener implements Listener {
final QuesterPostUpdateObjectiveEvent postEvent final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent(q, cq, = new QuesterPostUpdateObjectiveEvent(q, cq,
new Objective(placeType, newAmount, toPlace.getAmount())); new BukkitObjective(placeType, newAmount, toPlace.getAmount()));
plugin.getServer().getPluginManager().callEvent(postEvent); plugin.getServer().getPluginManager().callEvent(postEvent);
} }
} }
@ -156,7 +156,7 @@ public class BlockListener implements Listener {
} }
} }
dispatchedCutQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, cutType, dispatchedCutQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, cutType,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedCutQuestIDs.contains(cq.getId())) { if (!dispatchedCutQuestIDs.contains(cq.getId())) {
if (player.getItemInHand().getType().equals(Material.SHEARS)) { if (player.getItemInHand().getType().equals(Material.SHEARS)) {
q.cutBlock(cq, blockItemStack); q.cutBlock(cq, blockItemStack);
@ -177,10 +177,10 @@ public class BlockListener implements Listener {
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState() final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState()
.getData().toItemStack().getDurability()); .getData().toItemStack().getDurability());
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.DAMAGE_BLOCK; final ObjectiveType type = ObjectiveType.DAMAGE_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -191,7 +191,7 @@ public class BlockListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.placeBlock(cq, blockItemStack); q.placeBlock(cq, blockItemStack);
} }
@ -208,10 +208,10 @@ public class BlockListener implements Listener {
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState() final ItemStack blockItemStack = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState()
.getData().toItemStack().getDurability()); .getData().toItemStack().getDurability());
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.PLACE_BLOCK; final ObjectiveType type = ObjectiveType.PLACE_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!evt.isCancelled()) { if (!evt.isCancelled()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
@ -223,7 +223,7 @@ public class BlockListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.placeBlock(cq, blockItemStack); q.placeBlock(cq, blockItemStack);
} }
@ -246,7 +246,7 @@ public class BlockListener implements Listener {
if (e == null || e.equals(EquipmentSlot.HAND)) { //If the event is fired by HAND (main hand) if (e == null || e.equals(EquipmentSlot.HAND)) { //If the event is fired by HAND (main hand)
final Player player = evt.getPlayer(); final Player player = evt.getPlayer();
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) { if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
if (quester.isSelectingBlock()) { if (quester.isSelectingBlock()) {
return; return;
} }
@ -256,7 +256,7 @@ public class BlockListener implements Listener {
.getClickedBlock().getState().getData().toItemStack().getDurability()); .getClickedBlock().getState().getData().toItemStack().getDurability());
final ObjectiveType type = ObjectiveType.USE_BLOCK; final ObjectiveType type = ObjectiveType.USE_BLOCK;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -267,7 +267,7 @@ public class BlockListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.useBlock(cq, blockItemStack); q.useBlock(cq, blockItemStack);
} }

View File

@ -12,11 +12,11 @@
package me.blackvein.quests.listeners; package me.blackvein.quests.listeners;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quester; import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.Requirements; import me.blackvein.quests.quests.BukkitRequirements;
import me.blackvein.quests.Stage; import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent; import me.blackvein.quests.events.command.QuestsCommandPreQuestsEditorEvent;
import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent; import me.blackvein.quests.events.command.QuestsCommandPreQuestsJournalEvent;
import me.blackvein.quests.events.command.QuestsCommandPreQuestsListEvent; import me.blackvein.quests.events.command.QuestsCommandPreQuestsListEvent;
@ -196,10 +196,10 @@ public class CmdExecutor implements CommandExecutor {
if (cs.hasPermission("quests.quest")) { if (cs.hasPermission("quests.quest")) {
if (args.length == 0) { if (args.length == 0) {
final Player player = (Player) cs; final Player player = (Player) cs;
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
if (!quester.getCurrentQuests().isEmpty()) { if (!quester.getCurrentQuests().isEmpty()) {
for (final Quest q : quester.getCurrentQuests().keySet()) { for (final BukkitQuest q : quester.getCurrentQuests().keySet()) {
final Stage stage = quester.getCurrentStage(q); final BukkitStage stage = quester.getCurrentStage(q);
q.updateCompass(quester, stage); q.updateCompass(quester, stage);
if (plugin.getQuester(player.getUniqueId()).getQuestData(q).getDelayStartTime() == 0) { if (plugin.getQuester(player.getUniqueId()).getQuestData(q).getDelayStartTime() == 0) {
final String msg = Lang.get(player, "questObjectivesTitle") final String msg = Lang.get(player, "questObjectivesTitle")
@ -344,10 +344,10 @@ public class CmdExecutor implements CommandExecutor {
index++; index++;
} }
} }
final Quest q = plugin.getQuest(name.toString()); final BukkitQuest q = plugin.getQuest(name.toString());
if (q != null) { if (q != null) {
final Player player = (Player) cs; final Player player = (Player) cs;
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
cs.sendMessage(ChatColor.GOLD + "- " + q.getName() + " -"); cs.sendMessage(ChatColor.GOLD + "- " + q.getName() + " -");
cs.sendMessage(" "); cs.sendMessage(" ");
if (q.getNpcStart() != null) { if (q.getNpcStart() != null) {
@ -360,7 +360,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(" "); cs.sendMessage(" ");
if (plugin.getSettings().canShowQuestReqs()) { if (plugin.getSettings().canShowQuestReqs()) {
cs.sendMessage(ChatColor.GOLD + Lang.get("requirements")); cs.sendMessage(ChatColor.GOLD + Lang.get("requirements"));
final Requirements reqs = q.getRequirements(); final BukkitRequirements reqs = q.getRequirements();
if (!reqs.getPermissions().isEmpty()) { if (!reqs.getPermissions().isEmpty()) {
for (final String perm : reqs.getPermissions()) { for (final String perm : reqs.getPermissions()) {
if (plugin.getDependencies().getVaultPermission().has(player, perm)) { if (plugin.getDependencies().getVaultPermission().has(player, perm)) {
@ -442,7 +442,7 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
if (!reqs.getNeededQuests().isEmpty()) { if (!reqs.getNeededQuests().isEmpty()) {
for (final Quest quest : reqs.getNeededQuests()) { for (final BukkitQuest quest : reqs.getNeededQuests()) {
if (quester.getCompletedQuests().contains(quest)) { if (quester.getCompletedQuests().contains(quest)) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " " cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " "
+ ChatColor.ITALIC + quest.getName()); + ChatColor.ITALIC + quest.getName());
@ -453,7 +453,7 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
if (!reqs.getBlockQuests().isEmpty()) { if (!reqs.getBlockQuests().isEmpty()) {
for (final Quest quest : reqs.getBlockQuests()) { for (final BukkitQuest quest : reqs.getBlockQuests()) {
if (quester.getCompletedQuests().contains(quest)) { if (quester.getCompletedQuests().contains(quest)) {
String msg = Lang.get("haveCompleted"); String msg = Lang.get("haveCompleted");
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE
@ -526,7 +526,7 @@ public class CmdExecutor implements CommandExecutor {
if (!c.isConversing()) { if (!c.isConversing()) {
final Conversation cn = plugin.getQuestFactory().getConversationFactory().buildConversation(c); final Conversation cn = plugin.getQuestFactory().getConversationFactory().buildConversation(c);
if (cs instanceof Player) { if (cs instanceof Player) {
final Quester quester = plugin.getQuester(((Player)cs).getUniqueId()); final BukkitQuester quester = plugin.getQuester(((Player)cs).getUniqueId());
final QuestsCommandPreQuestsEditorEvent event final QuestsCommandPreQuestsEditorEvent event
= new QuestsCommandPreQuestsEditorEvent(quester, cn.getContext()); = new QuestsCommandPreQuestsEditorEvent(quester, cn.getContext());
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
@ -619,7 +619,7 @@ public class CmdExecutor implements CommandExecutor {
} else { } else {
target = Bukkit.getOfflinePlayer(((Player)cs).getUniqueId()); target = Bukkit.getOfflinePlayer(((Player)cs).getUniqueId());
} }
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
cs.sendMessage(ChatColor.GOLD + "- " + target.getName() + " -"); cs.sendMessage(ChatColor.GOLD + "- " + target.getName() + " -");
cs.sendMessage(ChatColor.YELLOW + Lang.get("questPoints") + " - " + ChatColor.DARK_PURPLE cs.sendMessage(ChatColor.YELLOW + Lang.get("questPoints") + " - " + ChatColor.DARK_PURPLE
+ quester.getQuestPoints()); + quester.getQuestPoints());
@ -627,8 +627,8 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest") + " " + ChatColor.DARK_PURPLE+ Lang.get("none")); cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest") + " " + ChatColor.DARK_PURPLE+ Lang.get("none"));
} else { } else {
cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest")); cs.sendMessage(ChatColor.YELLOW + Lang.get("currentQuest"));
for (final Entry<Quest, Integer> set : quester.getCurrentQuests().entrySet()) { for (final Entry<BukkitQuest, Integer> set : quester.getCurrentQuests().entrySet()) {
final Quest q = set.getKey(); final BukkitQuest q = set.getKey();
final String msg = ChatColor.LIGHT_PURPLE + " - " + ChatColor.DARK_PURPLE + q.getName() final String msg = ChatColor.LIGHT_PURPLE + " - " + ChatColor.DARK_PURPLE + q.getName()
+ ChatColor.LIGHT_PURPLE + " (" + Lang.get("stageEditorStage") + " " + (set.getValue() + 1) + ")"; + ChatColor.LIGHT_PURPLE + " (" + Lang.get("stageEditorStage") + " " + (set.getValue() + 1) + ")";
cs.sendMessage(msg); cs.sendMessage(msg);
@ -641,7 +641,7 @@ public class CmdExecutor implements CommandExecutor {
} else { } else {
final StringBuilder completed = new StringBuilder(" "); final StringBuilder completed = new StringBuilder(" ");
int index = 1; int index = 1;
for (final Quest q : quester.getCompletedQuests()) { for (final BukkitQuest q : quester.getCompletedQuests()) {
completed.append(ChatColor.DARK_PURPLE).append(q.getName()); completed.append(ChatColor.DARK_PURPLE).append(q.getName());
if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) { if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) {
completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted() completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted()
@ -660,7 +660,7 @@ public class CmdExecutor implements CommandExecutor {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private void questsJournal(final Player player) { private void questsJournal(final Player player) {
if (player.hasPermission("quests.journal")) { if (player.hasPermission("quests.journal")) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final QuestsCommandPreQuestsJournalEvent preEvent = new QuestsCommandPreQuestsJournalEvent(quester); final QuestsCommandPreQuestsJournalEvent preEvent = new QuestsCommandPreQuestsJournalEvent(quester);
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) { if (preEvent.isCancelled()) {
@ -702,9 +702,9 @@ public class CmdExecutor implements CommandExecutor {
Lang.send(player, ChatColor.RED + Lang.get(player, "COMMAND_QUIT_HELP")); Lang.send(player, ChatColor.RED + Lang.get(player, "COMMAND_QUIT_HELP"));
return; return;
} }
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
if (!quester.getCurrentQuests().isEmpty()) { if (!quester.getCurrentQuests().isEmpty()) {
final Quest quest = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' ')); final BukkitQuest quest = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
if (quest != null) { if (quest != null) {
if (quest.getOptions().canAllowQuitting()) { if (quest.getOptions().canAllowQuitting()) {
final QuestQuitEvent event = new QuestQuitEvent(quest, quester); final QuestQuitEvent event = new QuestQuitEvent(quest, quester);
@ -735,10 +735,10 @@ public class CmdExecutor implements CommandExecutor {
if (args.length == 1) { if (args.length == 1) {
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "COMMAND_TAKE_USAGE")); Lang.send(player, ChatColor.YELLOW + Lang.get(player, "COMMAND_TAKE_USAGE"));
} else { } else {
final Quest questToFind = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' ')); final BukkitQuest questToFind = plugin.getQuest(concatArgArray(args, 1, args.length - 1, ' '));
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
if (questToFind != null) { if (questToFind != null) {
for (final Quest q : quester.getCurrentQuests().keySet()) { for (final BukkitQuest q : quester.getCurrentQuests().keySet()) {
if (q.getId().equals(questToFind.getId())) { if (q.getId().equals(questToFind.getId())) {
Lang.send(player, ChatColor.RED + Lang.get(player, "questAlreadyOn")); Lang.send(player, ChatColor.RED + Lang.get(player, "questAlreadyOn"));
return; return;
@ -762,7 +762,7 @@ public class CmdExecutor implements CommandExecutor {
if (!(cs instanceof Player)) { if (!(cs instanceof Player)) {
int num = 1; int num = 1;
cs.sendMessage(ChatColor.GOLD + Lang.get("questListTitle")); cs.sendMessage(ChatColor.GOLD + Lang.get("questListTitle"));
for (final Quest q : plugin.getLoadedQuests()) { for (final BukkitQuest q : plugin.getLoadedQuests()) {
cs.sendMessage(ChatColor.YELLOW + "" + num + ". " + q.getName()); cs.sendMessage(ChatColor.YELLOW + "" + num + ". " + q.getName());
num++; num++;
} }
@ -770,7 +770,7 @@ public class CmdExecutor implements CommandExecutor {
} }
final Player player = (Player)cs; final Player player = (Player)cs;
if (args.length == 1) { if (args.length == 1) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final QuestsCommandPreQuestsListEvent preEvent = new QuestsCommandPreQuestsListEvent(quester, 1); final QuestsCommandPreQuestsListEvent preEvent = new QuestsCommandPreQuestsListEvent(quester, 1);
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) { if (preEvent.isCancelled()) {
@ -785,7 +785,7 @@ public class CmdExecutor implements CommandExecutor {
if (page < 1) { if (page < 1) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionPosNum")); cs.sendMessage(ChatColor.YELLOW + Lang.get("pageSelectionPosNum"));
} else { } else {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final QuestsCommandPreQuestsListEvent preEvent = new QuestsCommandPreQuestsListEvent(quester, page); final QuestsCommandPreQuestsListEvent preEvent = new QuestsCommandPreQuestsListEvent(quester, page);
plugin.getServer().getPluginManager().callEvent(preEvent); plugin.getServer().getPluginManager().callEvent(preEvent);
if (preEvent.isCancelled()) { if (preEvent.isCancelled()) {
@ -941,7 +941,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum")); cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
return; return;
} }
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(quester.getQuestPoints() + Math.abs(points)); quester.setQuestPoints(quester.getQuestPoints() + Math.abs(points));
String msg1 = Lang.get("giveQuestPoints").replace("<points>", Lang.get("questPoints")); String msg1 = Lang.get("giveQuestPoints").replace("<points>", Lang.get("questPoints"));
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD); msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
@ -978,7 +978,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum")); cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
return; return;
} }
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(quester.getQuestPoints() - Math.abs(points)); quester.setQuestPoints(quester.getQuestPoints() - Math.abs(points));
String msg1 = Lang.get("takeQuestPoints").replace("<points>", Lang.get("questPoints")); String msg1 = Lang.get("takeQuestPoints").replace("<points>", Lang.get("questPoints"));
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD); msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
@ -1015,7 +1015,7 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum")); cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
return; return;
} }
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
quester.setQuestPoints(points); quester.setQuestPoints(points);
String msg1 = Lang.get("setQuestPoints").replace("<points>", Lang.get("questPoints")); String msg1 = Lang.get("setQuestPoints").replace("<points>", Lang.get("questPoints"));
msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD); msg1 = msg1.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);
@ -1045,7 +1045,7 @@ public class CmdExecutor implements CommandExecutor {
return; return;
} }
} }
final Quest questToGive; final BukkitQuest questToGive;
StringBuilder name = new StringBuilder(); StringBuilder name = new StringBuilder();
if (args.length == 3) { if (args.length == 3) {
name = new StringBuilder(args[2].toLowerCase()); name = new StringBuilder(args[2].toLowerCase());
@ -1063,8 +1063,8 @@ public class CmdExecutor implements CommandExecutor {
if (questToGive == null) { if (questToGive == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound")); cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound"));
} else { } else {
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
for (final Quest q : quester.getCurrentQuests().keySet()) { for (final BukkitQuest q : quester.getCurrentQuests().keySet()) {
if (q.getName().equalsIgnoreCase(questToGive.getName())) { if (q.getName().equalsIgnoreCase(questToGive.getName())) {
String msg = Lang.get("questsPlayerHasQuestAlready"); String msg = Lang.get("questsPlayerHasQuestAlready");
msg = msg.replace("<player>", ChatColor.ITALIC + "" + ChatColor.GREEN + target.getName() msg = msg.replace("<player>", ChatColor.ITALIC + "" + ChatColor.GREEN + target.getName()
@ -1109,7 +1109,7 @@ public class CmdExecutor implements CommandExecutor {
} }
cs.sendMessage(ChatColor.YELLOW + Lang.get("settingAllQuestPoints") cs.sendMessage(ChatColor.YELLOW + Lang.get("settingAllQuestPoints")
.replace("<points>", Lang.get("questPoints"))); .replace("<points>", Lang.get("questPoints")));
for (final Quester q : plugin.getOfflineQuesters()) { for (final BukkitQuester q : plugin.getOfflineQuesters()) {
q.setQuestPoints(amount); q.setQuestPoints(amount);
} }
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
@ -1164,13 +1164,13 @@ public class CmdExecutor implements CommandExecutor {
return; return;
} }
} }
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) { if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
String msg = Lang.get("noCurrentQuest"); String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName()); msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg); cs.sendMessage(ChatColor.YELLOW + msg);
} else { } else {
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' ')); final BukkitQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
if (quest == null) { if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return; return;
@ -1216,13 +1216,13 @@ public class CmdExecutor implements CommandExecutor {
cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_USAGE")); cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_USAGE"));
return; return;
} }
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) { if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
String msg = Lang.get("noCurrentQuest"); String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName()); msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg); cs.sendMessage(ChatColor.YELLOW + msg);
} else { } else {
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 2, ' ')); final BukkitQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 2, ' '));
if (quest == null) { if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return; return;
@ -1252,13 +1252,13 @@ public class CmdExecutor implements CommandExecutor {
return; return;
} }
} }
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) { if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
String msg = Lang.get("noCurrentQuest"); String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName()); msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg); cs.sendMessage(ChatColor.YELLOW + msg);
} else { } else {
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' ')); final BukkitQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
if (quest == null) { if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return; return;
@ -1293,13 +1293,13 @@ public class CmdExecutor implements CommandExecutor {
return; return;
} }
} }
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) { if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
String msg = Lang.get("noCurrentQuest"); String msg = Lang.get("noCurrentQuest");
msg = msg.replace("<player>", target.getName()); msg = msg.replace("<player>", target.getName());
cs.sendMessage(ChatColor.YELLOW + msg); cs.sendMessage(ChatColor.YELLOW + msg);
} else { } else {
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' ')); final BukkitQuest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
if (quest == null) { if (quest == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return; return;
@ -1330,10 +1330,10 @@ public class CmdExecutor implements CommandExecutor {
} }
} }
final UUID id = target.getUniqueId(); final UUID id = target.getUniqueId();
final ConcurrentSkipListSet<Quester> temp = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters(); final ConcurrentSkipListSet<BukkitQuester> temp = (ConcurrentSkipListSet<BukkitQuester>) plugin.getOfflineQuesters();
temp.removeIf(quester -> quester.getUUID().equals(id)); temp.removeIf(quester -> quester.getUUID().equals(id));
plugin.setOfflineQuesters(temp); plugin.setOfflineQuesters(temp);
Quester quester = plugin.getQuester(id); BukkitQuester quester = plugin.getQuester(id);
try { try {
quester.hardClear(); quester.hardClear();
quester.saveData(); quester.saveData();
@ -1351,9 +1351,9 @@ public class CmdExecutor implements CommandExecutor {
} catch (final Exception e) { } catch (final Exception e) {
plugin.getLogger().info("Data file does not exist for " + id); plugin.getLogger().info("Data file does not exist for " + id);
} }
quester = new Quester(plugin, id); quester = new BukkitQuester(plugin, id);
quester.saveData(); quester.saveData();
final ConcurrentSkipListSet<Quester> temp2 = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters(); final ConcurrentSkipListSet<BukkitQuester> temp2 = (ConcurrentSkipListSet<BukkitQuester>) plugin.getOfflineQuesters();
temp2.add(quester); temp2.add(quester);
plugin.setOfflineQuesters(temp2); plugin.setOfflineQuesters(temp2);
} else { } else {
@ -1380,12 +1380,12 @@ public class CmdExecutor implements CommandExecutor {
return; return;
} }
} }
final Quest toRemove = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' ')); final BukkitQuest toRemove = plugin.getQuest(concatArgArray(args, 2, args.length - 1, ' '));
if (toRemove == null) { if (toRemove == null) {
cs.sendMessage(ChatColor.RED + Lang.get("questNotFound")); cs.sendMessage(ChatColor.RED + Lang.get("questNotFound"));
return; return;
} }
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
String msg = Lang.get("questRemoved"); String msg = Lang.get("questRemoved");
if (target.getName() != null) { if (target.getName() != null) {
msg = msg.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD); msg = msg.replace("<player>", ChatColor.GREEN + target.getName() + ChatColor.GOLD);

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.listeners; package me.blackvein.quests.listeners;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quester; import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.enums.ObjectiveType; import me.blackvein.quests.enums.ObjectiveType;
import org.bukkit.Material; import org.bukkit.Material;
@ -49,10 +49,10 @@ public class ItemListener implements Listener {
final Player player = (Player) evt.getWhoClicked(); final Player player = (Player) evt.getWhoClicked();
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final ItemStack craftedItem = getCraftedItem(evt); final ItemStack craftedItem = getCraftedItem(evt);
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.CRAFT_ITEM; final ObjectiveType type = ObjectiveType.CRAFT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -62,7 +62,7 @@ public class ItemListener implements Listener {
quester.craftItem(quest, craftedItem); quester.craftItem(quest, craftedItem);
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final Quester q, final Quest cq) -> { dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.craftItem(cq, craftedItem); q.craftItem(cq, craftedItem);
} }
@ -100,10 +100,10 @@ public class ItemListener implements Listener {
|| evt.getInventory().getType().name().equals("BLAST_FURNACE") || evt.getInventory().getType().name().equals("BLAST_FURNACE")
|| evt.getInventory().getType().name().equals("SMOKER")) { || evt.getInventory().getType().name().equals("SMOKER")) {
if (evt.getSlotType() == SlotType.RESULT) { if (evt.getSlotType() == SlotType.RESULT) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.SMELT_ITEM; final ObjectiveType type = ObjectiveType.SMELT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -113,7 +113,7 @@ public class ItemListener implements Listener {
quester.smeltItem(quest, evt.getCurrentItem()); quester.smeltItem(quest, evt.getCurrentItem());
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final Quester q, final Quest cq) -> { dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.smeltItem(cq, evt.getCurrentItem()); q.smeltItem(cq, evt.getCurrentItem());
} }
@ -123,10 +123,10 @@ public class ItemListener implements Listener {
} }
} else if (evt.getInventory().getType() == InventoryType.BREWING) { } else if (evt.getInventory().getType() == InventoryType.BREWING) {
if (evt.getSlotType() == SlotType.CRAFTING) { if (evt.getSlotType() == SlotType.CRAFTING) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.BREW_ITEM; final ObjectiveType type = ObjectiveType.BREW_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -136,7 +136,7 @@ public class ItemListener implements Listener {
quester.brewItem(quest, evt.getCurrentItem()); quester.brewItem(quest, evt.getCurrentItem());
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final Quester q, final Quest cq) -> { dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.brewItem(cq, evt.getCurrentItem()); q.brewItem(cq, evt.getCurrentItem());
} }
@ -154,10 +154,10 @@ public class ItemListener implements Listener {
final ItemStack enchantedItem = evt.getItem().clone(); final ItemStack enchantedItem = evt.getItem().clone();
enchantedItem.setAmount(1); enchantedItem.setAmount(1);
enchantedItem.addUnsafeEnchantments(evt.getEnchantsToAdd()); enchantedItem.addUnsafeEnchantments(evt.getEnchantsToAdd());
final Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId()); final BukkitQuester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
final ObjectiveType type = ObjectiveType.ENCHANT_ITEM; final ObjectiveType type = ObjectiveType.ENCHANT_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -171,7 +171,7 @@ public class ItemListener implements Listener {
} }
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final Quester q, final Quest cq) -> { dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
if (enchantedItem.getType().equals(Material.BOOK)) { if (enchantedItem.getType().equals(Material.BOOK)) {
q.enchantBook(cq, enchantedItem, evt.getEnchantsToAdd()); q.enchantBook(cq, enchantedItem, evt.getEnchantsToAdd());
@ -191,10 +191,10 @@ public class ItemListener implements Listener {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) { if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final ItemStack consumedItem = evt.getItem().clone(); final ItemStack consumedItem = evt.getItem().clone();
consumedItem.setAmount(1); consumedItem.setAmount(1);
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); final BukkitQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final ObjectiveType type = ObjectiveType.CONSUME_ITEM; final ObjectiveType type = ObjectiveType.CONSUME_ITEM;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -204,7 +204,7 @@ public class ItemListener implements Listener {
quester.consumeItem(quest, consumedItem); quester.consumeItem(quest, consumedItem);
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final Quester q, final Quest cq) -> { dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.consumeItem(cq, consumedItem); q.consumeItem(cq, consumedItem);
} }

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.listeners; package me.blackvein.quests.listeners;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quester; import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.enums.ObjectiveType; import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.ItemUtil;
@ -64,8 +64,8 @@ public class NpcListener implements Listener {
} }
if (!evt.getClicker().isConversing()) { if (!evt.getClicker().isConversing()) {
final Player player = evt.getClicker(); final Player player = evt.getClicker();
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
for (final Quest quest : quester.getCurrentQuests().keySet()) { for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.DELIVER_ITEM)) { if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.DELIVER_ITEM)) {
final ItemStack hand = player.getItemInHand(); final ItemStack hand = player.getItemInHand();
int currentIndex = -1; int currentIndex = -1;
@ -183,7 +183,7 @@ public class NpcListener implements Listener {
} }
if (plugin.getQuestNpcIds().contains(evt.getNPC().getId())) { if (plugin.getQuestNpcIds().contains(evt.getNPC().getId())) {
boolean hasObjective = false; boolean hasObjective = false;
for (final Quest quest : quester.getCurrentQuests().keySet()) { for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.TALK_TO_NPC)) { if (quester.getCurrentStage(quest).containsObjective(ObjectiveType.TALK_TO_NPC)) {
final int npcIndex final int npcIndex
= quester.getCurrentStage(quest).getCitizensToInteract().indexOf(evt.getNPC().getId()); = quester.getCurrentStage(quest).getCitizensToInteract().indexOf(evt.getNPC().getId());
@ -196,8 +196,8 @@ public class NpcListener implements Listener {
} }
if (!hasObjective) { if (!hasObjective) {
boolean hasAtLeastOneGUI = false; boolean hasAtLeastOneGUI = false;
final LinkedList<Quest> npcQuests = new LinkedList<>(); final LinkedList<BukkitQuest> npcQuests = new LinkedList<>();
for (final Quest q : plugin.getLoadedQuests()) { for (final BukkitQuest q : plugin.getLoadedQuests()) {
if (quester.getCurrentQuests().containsKey(q)) if (quester.getCurrentQuests().containsKey(q))
continue; continue;
if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) { if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) {
@ -219,7 +219,7 @@ public class NpcListener implements Listener {
} }
} }
if (npcQuests.size() == 1) { if (npcQuests.size() == 1) {
final Quest q = npcQuests.get(0); final BukkitQuest q = npcQuests.get(0);
if (quester.canAcceptOffer(q, true)) { if (quester.canAcceptOffer(q, true)) {
quester.setQuestIdToTake(q.getId()); quester.setQuestIdToTake(q.getId());
if (!plugin.getSettings().canAskConfirmation()) { if (!plugin.getSettings().canAskConfirmation()) {
@ -289,8 +289,8 @@ public class NpcListener implements Listener {
player = (Player) damager; player = (Player) damager;
} }
if (player != null) { if (player != null) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
for (final Quest quest : quester.getCurrentQuests().keySet()) { for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -301,7 +301,7 @@ public class NpcListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.killNPC(cq, evt.getNPC()); q.killNPC(cq, evt.getNPC());
} }
@ -312,8 +312,8 @@ public class NpcListener implements Listener {
} }
} }
private String extracted(final Quester quester) { private String extracted(final BukkitQuester quester) {
final Quest quest = plugin.getQuestById(quester.getQuestIdToTake()); final BukkitQuest quest = plugin.getQuestById(quester.getQuestIdToTake());
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE,
quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription()); quest.getName(), ChatColor.GOLD, ChatColor.RESET, quest.getDescription());
} }

View File

@ -12,10 +12,10 @@
package me.blackvein.quests.listeners; package me.blackvein.quests.listeners;
import me.blackvein.quests.Quest; import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quester; import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.Stage; import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.enums.ObjectiveType; import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.Lang;
@ -119,12 +119,12 @@ public class PlayerListener implements Listener {
return; return;
} }
} }
final Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId()); final BukkitQuester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
final Player player = (Player) evt.getWhoClicked(); final Player player = (Player) evt.getWhoClicked();
if (evt.getView().getTitle().contains(Lang.get(player, "quests"))) { if (evt.getView().getTitle().contains(Lang.get(player, "quests"))) {
final ItemStack clicked = evt.getCurrentItem(); final ItemStack clicked = evt.getCurrentItem();
if (ItemUtil.isItem(clicked)) { if (ItemUtil.isItem(clicked)) {
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (quest.getGUIDisplay() != null) { if (quest.getGUIDisplay() != null) {
if (ItemUtil.compareItems(clicked, quest.getGUIDisplay(), false) == 0) { if (ItemUtil.compareItems(clicked, quest.getGUIDisplay(), false) == 0) {
if (quester.canAcceptOffer(quest, true)) { if (quester.canAcceptOffer(quest, true)) {
@ -213,12 +213,12 @@ public class PlayerListener implements Listener {
} }
} }
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) { if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); final BukkitQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final Player player = evt.getPlayer(); final Player player = evt.getPlayer();
if (evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { if (evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
boolean hasObjective = false; boolean hasObjective = false;
if (!evt.isCancelled()) { if (!evt.isCancelled()) {
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (quester.getCurrentQuests().containsKey(quest) if (quester.getCurrentQuests().containsKey(quest)
&& quester.getCurrentStage(quest).containsObjective("useBlock")) { && quester.getCurrentStage(quest).containsObjective("useBlock")) {
hasObjective = true; hasObjective = true;
@ -363,7 +363,7 @@ public class PlayerListener implements Listener {
} }
evt.setCancelled(true); evt.setCancelled(true);
} else if (!player.isConversing()) { } else if (!player.isConversing()) {
for (final Quest q : plugin.getLoadedQuests()) { for (final BukkitQuest q : plugin.getLoadedQuests()) {
if (q.getBlockStart() != null && evt.getClickedBlock() != null) { if (q.getBlockStart() != null && evt.getClickedBlock() != null) {
if (q.getBlockStart().equals(evt.getClickedBlock().getLocation())) { if (q.getBlockStart().equals(evt.getClickedBlock().getLocation())) {
if (quester.getCurrentQuests().size() >= plugin.getSettings().getMaxQuests() if (quester.getCurrentQuests().size() >= plugin.getSettings().getMaxQuests()
@ -397,7 +397,7 @@ public class PlayerListener implements Listener {
if (!plugin.getSettings().canAskConfirmation()) { if (!plugin.getSettings().canAskConfirmation()) {
quester.takeQuest(q, false); quester.takeQuest(q, false);
} else { } else {
final Quest quest = plugin.getQuestById(quester.getQuestIdToTake()); final BukkitQuest quest = plugin.getQuestById(quester.getQuestIdToTake());
final String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE final String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE
+ quest.getName() + ChatColor.GOLD + " -\n" + "\n" + quest.getName() + ChatColor.GOLD + " -\n" + "\n"
+ ChatColor.RESET + quest.getDescription() + "\n"; + ChatColor.RESET + quest.getDescription() + "\n";
@ -449,10 +449,10 @@ public class PlayerListener implements Listener {
if (evt.getItemStack() != null && evt.getItemStack().getType() == Material.MILK_BUCKET) { if (evt.getItemStack() != null && evt.getItemStack().getType() == Material.MILK_BUCKET) {
final Player player = evt.getPlayer(); final Player player = evt.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.MILK_COW; final ObjectiveType type = ObjectiveType.MILK_COW;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -463,7 +463,7 @@ public class PlayerListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.milkCow(cq); q.milkCow(cq);
} }
@ -477,14 +477,14 @@ public class PlayerListener implements Listener {
@EventHandler @EventHandler
public void onPlayerChat(final AsyncPlayerChatEvent evt) { public void onPlayerChat(final AsyncPlayerChatEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) { if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); final BukkitQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
if (quester.getCurrentQuests().containsKey(quest)) { if (quester.getCurrentQuests().containsKey(quest)) {
final Stage currentStage = quester.getCurrentStage(quest); final BukkitStage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) { if (currentStage == null) {
continue; continue;
} }
@ -515,7 +515,7 @@ public class PlayerListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.sayPassword(cq, evt); q.sayPassword(cq, evt);
} }
@ -529,9 +529,9 @@ public class PlayerListener implements Listener {
@EventHandler @EventHandler
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent evt) { public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) { if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); final BukkitQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (!quester.getCurrentQuests().isEmpty()) { if (!quester.getCurrentQuests().isEmpty()) {
for (final Quest quest : quester.getCurrentQuests().keySet()) { for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
if (!quest.getOptions().canAllowCommands()) { if (!quest.getOptions().canAllowCommands()) {
if (!evt.getMessage().startsWith("/quest")) { if (!evt.getMessage().startsWith("/quest")) {
final Player player = evt.getPlayer(); final Player player = evt.getPlayer();
@ -544,7 +544,7 @@ public class PlayerListener implements Listener {
return; return;
} }
} }
final Stage currentStage = quester.getCurrentStage(quest); final BukkitStage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) { if (currentStage == null) {
plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString() plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString()
+ " on command for quest " + quest.getName()); + " on command for quest " + quest.getName());
@ -569,10 +569,10 @@ public class PlayerListener implements Listener {
final Player player = evt.getPlayer(); final Player player = evt.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final Sheep sheep = (Sheep) evt.getEntity(); final Sheep sheep = (Sheep) evt.getEntity();
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.SHEAR_SHEEP; final ObjectiveType type = ObjectiveType.SHEAR_SHEEP;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -583,7 +583,7 @@ public class PlayerListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.shearSheep(cq, sheep.getColor()); q.shearSheep(cq, sheep.getColor());
} }
@ -599,10 +599,10 @@ public class PlayerListener implements Listener {
if (evt.getOwner() instanceof Player) { if (evt.getOwner() instanceof Player) {
final Player player = (Player) evt.getOwner(); final Player player = (Player) evt.getOwner();
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.TAME_MOB; final ObjectiveType type = ObjectiveType.TAME_MOB;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -613,7 +613,7 @@ public class PlayerListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.tameMob(cq, evt.getEntityType()); q.tameMob(cq, evt.getEntityType());
} }
@ -644,7 +644,7 @@ public class PlayerListener implements Listener {
} else if (damager instanceof Wolf) { } else if (damager instanceof Wolf) {
final Wolf wolf = (Wolf) damager; final Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() != null) { if (wolf.isTamed() && wolf.getOwner() != null) {
final Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId()); final BukkitQuester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
if (quester != null) { if (quester != null) {
preKillPlayer(quester.getPlayer(), evt.getEntity()); preKillPlayer(quester.getPlayer(), evt.getEntity());
} }
@ -670,10 +670,10 @@ public class PlayerListener implements Listener {
if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) { if (plugin.getDependencies().getCitizens() != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
return; return;
} }
final Quester quester = plugin.getQuester(damager.getUniqueId()); final BukkitQuester quester = plugin.getQuester(damager.getUniqueId());
final ObjectiveType type = ObjectiveType.KILL_MOB; final ObjectiveType type = ObjectiveType.KILL_MOB;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -686,7 +686,7 @@ public class PlayerListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.killMob(cq, target.getLocation(), target.getType()); q.killMob(cq, target.getLocation(), target.getType());
} }
@ -721,7 +721,7 @@ public class PlayerListener implements Listener {
} else if (damager instanceof Wolf) { } else if (damager instanceof Wolf) {
final Wolf wolf = (Wolf) damager; final Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() != null) { if (wolf.isTamed() && wolf.getOwner() != null) {
final Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId()); final BukkitQuester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
preKillPlayer(quester.getPlayer(), evt.getEntity()); preKillPlayer(quester.getPlayer(), evt.getEntity());
} }
} else { } else {
@ -731,9 +731,9 @@ public class PlayerListener implements Listener {
final Player target = evt.getEntity(); final Player target = evt.getEntity();
if (plugin.canUseQuests(target.getUniqueId())) { if (plugin.canUseQuests(target.getUniqueId())) {
final Quester quester = plugin.getQuester(target.getUniqueId()); final BukkitQuester quester = plugin.getQuester(target.getUniqueId());
for (final Quest quest : quester.getCurrentQuests().keySet()) { for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
final Stage stage = quester.getCurrentStage(quest); final BukkitStage stage = quester.getCurrentStage(quest);
if (stage != null && stage.getDeathAction() != null) { if (stage != null && stage.getDeathAction() != null) {
quester.getCurrentStage(quest).getDeathAction().fire(quester, quest); quester.getCurrentStage(quest).getDeathAction().fire(quester, quest);
} }
@ -774,10 +774,10 @@ public class PlayerListener implements Listener {
return; return;
} }
} }
final Quester quester = plugin.getQuester(damager.getUniqueId()); final BukkitQuester quester = plugin.getQuester(damager.getUniqueId());
final ObjectiveType type = ObjectiveType.KILL_PLAYER; final ObjectiveType type = ObjectiveType.KILL_PLAYER;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -790,7 +790,7 @@ public class PlayerListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.killPlayer(cq, (Player)target); q.killPlayer(cq, (Player)target);
} }
@ -804,10 +804,10 @@ public class PlayerListener implements Listener {
public void onPlayerFish(final PlayerFishEvent evt) { public void onPlayerFish(final PlayerFishEvent evt) {
final Player player = evt.getPlayer(); final Player player = evt.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
final ObjectiveType type = ObjectiveType.CATCH_FISH; final ObjectiveType type = ObjectiveType.CATCH_FISH;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -819,7 +819,7 @@ public class PlayerListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
q.catchFish(cq); q.catchFish(cq);
} }
@ -834,9 +834,9 @@ public class PlayerListener implements Listener {
public void onPlayerChangeWorld(final PlayerChangedWorldEvent event) { public void onPlayerChangeWorld(final PlayerChangedWorldEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
quester.findCompassTarget(); quester.findCompassTarget();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
quester.meetsCondition(quest, true); quester.meetsCondition(quest, true);
} }
} }
@ -846,7 +846,7 @@ public class PlayerListener implements Listener {
public void onPlayerRespawn(final PlayerRespawnEvent event) { public void onPlayerRespawn(final PlayerRespawnEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final Quester quester = plugin.getQuester(player.getUniqueId()); final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
Bukkit.getScheduler().runTaskLater(plugin, quester::findCompassTarget, 10); Bukkit.getScheduler().runTaskLater(plugin, quester::findCompassTarget, 10);
} }
} }
@ -865,29 +865,29 @@ public class PlayerListener implements Listener {
}); });
} }
if (plugin.canUseQuests(player.getUniqueId())) { if (plugin.canUseQuests(player.getUniqueId())) {
final Quester noobCheck = new Quester(plugin, player.getUniqueId()); final BukkitQuester noobCheck = new BukkitQuester(plugin, player.getUniqueId());
if (plugin.getSettings().canGenFilesOnJoin() && !noobCheck.hasData()) { if (plugin.getSettings().canGenFilesOnJoin() && !noobCheck.hasData()) {
noobCheck.saveData(); noobCheck.saveData();
} }
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
final CompletableFuture<Quester> cf = plugin.getStorage().loadQuester(player.getUniqueId()); final CompletableFuture<BukkitQuester> cf = plugin.getStorage().loadQuester(player.getUniqueId());
try { try {
final Quester quester = cf.get(); final BukkitQuester quester = cf.get();
if (quester == null) { if (quester == null) {
return; return;
} }
for (final Quest q : quester.getCompletedQuests()) { for (final BukkitQuest q : quester.getCompletedQuests()) {
if (q != null) { if (q != null) {
if (!quester.getCompletedTimes().containsKey(q) && q.getPlanner().getCooldown() > -1) { if (!quester.getCompletedTimes().containsKey(q) && q.getPlanner().getCooldown() > -1) {
quester.getCompletedTimes().put(q, System.currentTimeMillis()); quester.getCompletedTimes().put(q, System.currentTimeMillis());
} }
} }
} }
for (final Quest quest : quester.getCurrentQuests().keySet()) { for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
quester.checkQuest(quest); quester.checkQuest(quest);
} }
for (final Quest quest : quester.getCurrentQuests().keySet()) { for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
if (quester.getCurrentStage(quest).getDelay() > -1) { if (quester.getCurrentStage(quest).getDelay() > -1) {
quester.startStageTimer(quest); quester.startStageTimer(quest);
} }
@ -910,9 +910,9 @@ public class PlayerListener implements Listener {
@EventHandler @EventHandler
public void onPlayerQuit(final PlayerQuitEvent evt) { public void onPlayerQuit(final PlayerQuitEvent evt) {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) { if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId()); final BukkitQuester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (final Quest quest : quester.getCurrentQuests().keySet()) { for (final BukkitQuest quest : quester.getCurrentQuests().keySet()) {
final Stage currentStage = quester.getCurrentStage(quest); final BukkitStage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) { if (currentStage == null) {
plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString() plugin.getLogger().severe("currentStage was null for " + quester.getUUID().toString()
+ " on quit for quest " + quest.getName()); + " on quit for quest " + quest.getName());
@ -945,7 +945,7 @@ public class PlayerListener implements Listener {
temp.remove(evt.getPlayer().getUniqueId()); temp.remove(evt.getPlayer().getUniqueId());
plugin.getQuestFactory().setSelectingNpcs(temp); plugin.getQuestFactory().setSelectingNpcs(temp);
} }
final ConcurrentSkipListSet<Quester> temp = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters(); final ConcurrentSkipListSet<BukkitQuester> temp = (ConcurrentSkipListSet<BukkitQuester>) plugin.getOfflineQuesters();
temp.removeIf(q -> q.getUUID().equals(quester.getUUID())); temp.removeIf(q -> q.getUUID().equals(quester.getUUID()));
plugin.setOfflineQuesters(temp); plugin.setOfflineQuesters(temp);
} }
@ -978,12 +978,12 @@ public class PlayerListener implements Listener {
*/ */
public void playerMove(final UUID uuid, final Location location) { public void playerMove(final UUID uuid, final Location location) {
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> { plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
final Quester quester = plugin.getQuester(uuid); final BukkitQuester quester = plugin.getQuester(uuid);
if (quester != null) { if (quester != null) {
if (plugin.canUseQuests(uuid)) { if (plugin.canUseQuests(uuid)) {
final ObjectiveType type = ObjectiveType.REACH_LOCATION; final ObjectiveType type = ObjectiveType.REACH_LOCATION;
final Set<String> dispatchedQuestIDs = new HashSet<>(); final Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) { for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) { if (!quester.meetsCondition(quest, true)) {
continue; continue;
} }
@ -997,7 +997,7 @@ public class PlayerListener implements Listener {
} }
dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type, dispatchedQuestIDs.addAll(quester.dispatchMultiplayerEverything(quest, type,
(final Quester q, final Quest cq) -> { (final BukkitQuester q, final BukkitQuest cq) -> {
if (!dispatchedQuestIDs.contains(cq.getId())) { if (!dispatchedQuestIDs.contains(cq.getId())) {
plugin.getServer().getScheduler().runTask(plugin, () -> q plugin.getServer().getScheduler().runTask(plugin, () -> q
.reachLocation(cq, location)); .reachLocation(cq, location));

View File

@ -0,0 +1,251 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.module;
import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.Quest;
import me.blackvein.quests.quests.BukkitObjective;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.enums.ObjectiveType;
import me.blackvein.quests.events.quester.QuesterPostUpdateObjectiveEvent;
import me.blackvein.quests.events.quester.QuesterPreUpdateObjectiveEvent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
public abstract class BukkitCustomObjective implements CustomObjective, Listener {
private final Quests plugin = Quests.getPlugin(Quests.class);
private String name = null;
private String author = null;
private String display = "Progress: %count%";
private Entry<String, Short> item = new AbstractMap.SimpleEntry<>("BOOK", (short) 0);
private final LinkedList<Entry<String, Object>> data = new LinkedList<>();
private final Map<String, String> descriptions = new HashMap<>();
private String countPrompt = "Enter number";
private boolean showCount = true;
private int count = 1;
@Override
public String getModuleName() {
return new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getName()
.replace(".jar", "");
}
@Override
public Entry<String, Short> getModuleItem() {
return new AbstractMap.SimpleEntry<>("IRON_INGOT", (short) 0);
}
@Override
public String getName() {
return name;
}
@Override
public void setName(final String name) {
this.name = name;
}
@Override
public String getAuthor() {
return author;
}
@Override
public void setAuthor(final String author) {
this.author = author;
}
@Override
public String getDisplay() {
return display;
}
@Override
public void setDisplay(final String display) {
this.display = display;
}
@Override
public Entry<String, Short> getItem() {
return item;
}
@Override
public void setItem(final String type, final short durability) {
this.item = new AbstractMap.SimpleEntry<>(type, durability);
}
@Override
public LinkedList<Entry<String, Object>> getData() {
return data;
}
/**
* Add a new prompt<p>
*
* Note that the "defaultValue" Object will be cast to a String internally
*
* @param title Prompt name
* @param description Description of expected input
* @param defaultValue Value to be used if input is not received
*/
@Override
public void addStringPrompt(final String title, final String description, final Object defaultValue) {
final Entry<String, Object> prompt = new AbstractMap.SimpleEntry<>(title, defaultValue);
data.add(prompt);
descriptions.put(title, description);
}
@Override
public Map<String, String> getDescriptions() {
return descriptions;
}
@Override
public int getCount() {
return count;
}
@Override
public void setCount(final int count) {
this.count = count;
}
@Override
public String getCountPrompt() {
return countPrompt;
}
@Override
public void setCountPrompt(final String countPrompt) {
this.countPrompt = countPrompt;
}
/**
* Check whether to let user set required amount for objective
*/
@Override
public boolean canShowCount() {
return showCount;
}
/**
* Set whether to let user set required amount for objective
*
* @param showCount Whether to show the count
*/
@Override
public void setShowCount(final boolean showCount) {
this.showCount = showCount;
}
@Override
public Map<String, Object> getDataForPlayer(final Player player, final CustomObjective customObj,
final Quest quest) {
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
final BukkitStage currentStage = quester.getCurrentStage((BukkitQuest) quest);
if (currentStage == null) {
return null;
}
CustomObjective found = null;
for (final CustomObjective co : currentStage.getCustomObjectives()) {
if (co.getName().equals(customObj.getName())) {
found = co;
break;
}
}
if (found != null) {
final Map<String, Object> m = new HashMap<>();
for (final Entry<String, Object> dataMap : found.getData()) {
for (final Entry<String, Object> e : currentStage.getCustomObjectiveData()) {
if (e.getKey().equals(dataMap.getKey())) {
m.put(e.getKey(), e.getValue());
}
}
}
if (!m.isEmpty()) {
return m;
}
}
}
return null;
}
@Override
public void incrementObjective(final Player player, final CustomObjective obj, final int count, final Quest quest) {
final BukkitQuest bQuest = (BukkitQuest) quest;
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
if (quester.hasCustomObjective(bQuest, obj.getName())) {
int index = -1;
final LinkedList<Integer> customObjCounts = quester.getQuestData(bQuest).customObjectiveCounts;
for (final CustomObjective co : quester.getCurrentStage(bQuest).getCustomObjectives()) {
index++;
if (co.getName().equals(this.getName())) {
if (index >= customObjCounts.size()) {
plugin.getLogger().severe("Index was larger than count for " + obj.getName() + " by "
+ obj.getAuthor());
continue;
}
final int old = customObjCounts.get(index);
plugin.getQuester(player.getUniqueId()).getQuestData(bQuest).customObjectiveCounts
.set(index, old + count);
break;
}
}
if (index > -1) {
final int progress = customObjCounts.get(index);
final int goal = quester.getCurrentStage(bQuest).getCustomObjectiveCounts().get(index);
final ObjectiveType type = ObjectiveType.CUSTOM;
final QuesterPreUpdateObjectiveEvent preEvent
= new QuesterPreUpdateObjectiveEvent(quester, quest, new BukkitObjective(type, progress, goal));
plugin.getServer().getPluginManager().callEvent(preEvent);
if (progress >= goal) {
quester.finishObjective(bQuest, new BukkitObjective(type, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, obj);
// Multiplayer
final int finalIndex = index;
quester.dispatchMultiplayerObjectives(bQuest, quester.getCurrentStage(bQuest), (final BukkitQuester q) -> {
final int old = q.getQuestData(bQuest).customObjectiveCounts.get(finalIndex);
q.getQuestData(bQuest).customObjectiveCounts.set(finalIndex, old + count);
q.finishObjective(bQuest, new BukkitObjective(type, new ItemStack(Material.AIR, 1),
new ItemStack(Material.AIR, goal)), null, null, null, null, null, null, obj);
return null;
});
}
final QuesterPostUpdateObjectiveEvent postEvent
= new QuesterPostUpdateObjectiveEvent(quester, quest, new BukkitObjective(type, progress, goal));
plugin.getServer().getPluginManager().callEvent(postEvent);
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.quests;
import me.blackvein.quests.Objective;
import org.bukkit.inventory.ItemStack;
import me.blackvein.quests.enums.ObjectiveType;
public class BukkitObjective implements Objective {
private final ObjectiveType type;
private final int progress;
private final int goal;
private final ItemStack progressStack;
private final ItemStack goalStack;
public BukkitObjective(final ObjectiveType type, final int progress, final int goal) {
this.type = type;
this.progress = progress;
this.goal = goal;
this.progressStack = null;
this.goalStack = null;
}
public BukkitObjective(final ObjectiveType type, final ItemStack progress, final ItemStack goal) {
this.type = type;
this.progress = progress.getAmount();
this.goal = goal.getAmount();
this.progressStack = progress;
this.goalStack = goal;
}
public ObjectiveType getType() {
return type;
}
public int getProgress() {
return progress;
}
public int getGoal() {
return goal;
}
public ItemStack getItemProgress() {
return progressStack;
}
public ItemStack getItemGoal() {
return goalStack;
}
}

View File

@ -0,0 +1,97 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.quests;
public class BukkitOptions {
private boolean allowCommands = true;
private boolean allowQuitting = true;
private boolean ignoreSilkTouch = true;
private String externalPartyPlugin = null;
private boolean usePartiesPlugin = true;
private boolean handleOfflinePlayers = false;
private double shareDistance = 0.0D;
private int shareProgressLevel = 1;
private boolean shareSameQuestOnly = true;
public boolean canAllowCommands() {
return allowCommands;
}
public void setAllowCommands(final boolean allowCommands) {
this.allowCommands = allowCommands;
}
public boolean canAllowQuitting() {
return allowQuitting;
}
public void setAllowQuitting(final boolean allowQuitting) {
this.allowQuitting = allowQuitting;
}
public boolean canIgnoreSilkTouch() {
return ignoreSilkTouch;
}
public void setIgnoreSilkTouch(final boolean ignoreSilkTouch) {
this.ignoreSilkTouch = ignoreSilkTouch;
}
public String getExternalPartyPlugin() {
return externalPartyPlugin;
}
public void setExternalPartyPlugin(final String externalPartyPlugin) {
this.externalPartyPlugin = externalPartyPlugin;
}
public boolean canUsePartiesPlugin() {
return usePartiesPlugin;
}
public void setUsePartiesPlugin(final boolean usePartiesPlugin) {
this.usePartiesPlugin = usePartiesPlugin;
}
public int getShareProgressLevel() {
return shareProgressLevel;
}
public void setShareProgressLevel(final int shareProgressLevel) {
this.shareProgressLevel = shareProgressLevel;
}
public boolean canShareSameQuestOnly() {
return shareSameQuestOnly;
}
public void setShareSameQuestOnly(final boolean shareSameQuestOnly) {
this.shareSameQuestOnly = shareSameQuestOnly;
}
public double getShareDistance() {
return shareDistance;
}
public void setShareDistance(final double shareDistance) {
this.shareDistance = shareDistance;
}
public boolean canHandleOfflinePlayers() {
return handleOfflinePlayers;
}
public void setHandleOfflinePlayers(final boolean handleOfflinePlayers) {
this.handleOfflinePlayers = handleOfflinePlayers;
}
}

View File

@ -0,0 +1,91 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.quests;
import java.util.Calendar;
import java.util.TimeZone;
public class BukkitPlanner {
public String start = null;
public String end = null;
public long repeat = -1;
public long cooldown = -1;
public boolean override = false;
public String getStart() {
return start;
}
public long getStartInMillis() {
if (start == null) {
return -1;
}
final Calendar cal = Calendar.getInstance();
final String[] s = start.split(":");
cal.set(Integer.parseInt(s[2]), Integer.parseInt(s[1]), Integer.parseInt(s[0]),
Integer.parseInt(s[3]), Integer.parseInt(s[4]), Integer.parseInt(s[5]));
final TimeZone tz = TimeZone.getTimeZone(s[6]);
cal.setTimeZone(tz);
return cal.getTimeInMillis();
}
public boolean hasStart() {
return start != null;
}
public void setStart(final String start) {
this.start = start;
}
public String getEnd() {
return end;
}
public long getEndInMillis() {
if (end == null) {
return -1;
}
final Calendar cal = Calendar.getInstance();
final String[] s = end.split(":");
cal.set(Integer.parseInt(s[2]), Integer.parseInt(s[1]), Integer.parseInt(s[0]),
Integer.parseInt(s[3]), Integer.parseInt(s[4]), Integer.parseInt(s[5]));
final TimeZone tz = TimeZone.getTimeZone(s[6]);
cal.setTimeZone(tz);
return cal.getTimeInMillis();
}
public boolean hasEnd() {
return end != null;
}
public void setEnd(final String end) {
this.end = end;
}
public long getRepeat() {
return repeat;
}
public boolean hasRepeat() {
return repeat != -1;
}
public void setRepeat(final long repeat) {
this.repeat = repeat;
}
public long getCooldown() {
return cooldown;
}
public boolean hasCooldown() {
return cooldown != -1;
}
public void setCooldown(final long cooldown) {
this.cooldown = cooldown;
}
public boolean getOverride() {
return override;
}
public void setOverride(final boolean override) {
this.override = override;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,115 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.quests;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class BukkitRequirements {
private int money = 0;
private int questPoints = 0;
private List<ItemStack> items = new LinkedList<>();
private List<Boolean> removeItems = new LinkedList<>();
private List<BukkitQuest> neededQuests = new LinkedList<>();
private List<BukkitQuest> blockQuests = new LinkedList<>();
private List<String> permissions = new LinkedList<>();
private List<String> mcmmoSkills = new LinkedList<>();
private List<Integer> mcmmoAmounts = new LinkedList<>();
private String heroesPrimaryClass = null;
private String heroesSecondaryClass = null;
private Map<String, Map<String, Object>> customRequirements = new HashMap<>();
private List<String> detailsOverride = new LinkedList<>();
public int getMoney() {
return money;
}
public void setMoney(final int money) {
this.money = money;
}
public int getQuestPoints() {
return questPoints;
}
public void setQuestPoints(final int questPoints) {
this.questPoints = questPoints;
}
public List<ItemStack> getItems() {
return items;
}
public void setItems(final List<ItemStack> items) {
this.items = items;
}
public List<Boolean> getRemoveItems() {
return removeItems;
}
public void setRemoveItems(final List<Boolean> removeItems) {
this.removeItems = removeItems;
}
public List<BukkitQuest> getNeededQuests() {
return neededQuests;
}
public void setNeededQuests(final List<BukkitQuest> neededQuests) {
this.neededQuests = neededQuests;
}
public List<BukkitQuest> getBlockQuests() {
return blockQuests;
}
public void setBlockQuests(final List<BukkitQuest> blockQuests) {
this.blockQuests = blockQuests;
}
public List<String> getPermissions() {
return permissions;
}
public void setPermissions(final List<String> permissions) {
this.permissions = permissions;
}
public List<String> getMcmmoSkills() {
return mcmmoSkills;
}
public void setMcmmoSkills(final List<String> mcmmoSkills) {
this.mcmmoSkills = mcmmoSkills;
}
public List<Integer> getMcmmoAmounts() {
return mcmmoAmounts;
}
public void setMcmmoAmounts(final List<Integer> mcmmoAmounts) {
this.mcmmoAmounts = mcmmoAmounts;
}
public String getHeroesPrimaryClass() {
return heroesPrimaryClass;
}
public void setHeroesPrimaryClass(final String heroesPrimaryClass) {
this.heroesPrimaryClass = heroesPrimaryClass;
}
public String getHeroesSecondaryClass() {
return heroesSecondaryClass;
}
public void setHeroesSecondaryClass(final String heroesSecondaryClass) {
this.heroesSecondaryClass = heroesSecondaryClass;
}
public Map<String, Map<String, Object>> getCustomRequirements() {
return customRequirements;
}
protected void setCustomRequirements(final Map<String, Map<String, Object>> customRequirements) {
this.customRequirements = customRequirements;
}
public List<String> getDetailsOverride() {
return detailsOverride;
}
public void setDetailsOverride(final List<String> detailsOverride) {
this.detailsOverride = detailsOverride;
}
}

View File

@ -0,0 +1,136 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.quests;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class BukkitRewards {
private int money = 0;
private int questPoints = 0;
private int exp = 0;
private List<String> commands = new LinkedList<>();
private List<String> commandsOverrideDisplay = new LinkedList<>();
private List<String> permissions = new LinkedList<>();
private List<String> permissionWorlds = new LinkedList<>();
private List<ItemStack> items = new LinkedList<>();
private List<String> mcmmoSkills = new LinkedList<>();
private List<Integer> mcmmoAmounts = new LinkedList<>();
private List<String> heroesClasses = new LinkedList<>();
private List<Double> heroesAmounts = new LinkedList<>();
private int partiesExperience = 0;
private List<String> phatLoots = new LinkedList<>();
private Map<String, Map<String, Object>> customRewards = new HashMap<>();
private List<String> detailsOverride = new LinkedList<>();
public int getMoney() {
return money;
}
public void setMoney(final int money) {
this.money = money;
}
public int getQuestPoints() {
return questPoints;
}
public void setQuestPoints(final int questPoints) {
this.questPoints = questPoints;
}
public int getExp() {
return exp;
}
public void setExp(final int exp) {
this.exp = exp;
}
public List<String> getCommands() {
return commands;
}
public void setCommands(final List<String> commands) {
this.commands = commands;
}
public List<String> getCommandsOverrideDisplay() {
return commandsOverrideDisplay;
}
public void setCommandsOverrideDisplay(final List<String> commandsOverrideDisplay) {
this.commandsOverrideDisplay = commandsOverrideDisplay;
}
public List<String> getPermissions() {
return permissions;
}
public void setPermissions(final List<String> permissions) {
this.permissions = permissions;
}
public List<String> getPermissionWorlds() {
return permissionWorlds;
}
public void setPermissionWorlds(final List<String> worldNames) {
this.permissionWorlds = worldNames;
}
public List<ItemStack> getItems() {
return items;
}
public void setItems(final List<ItemStack> items) {
this.items = items;
}
public List<String> getMcmmoSkills() {
return mcmmoSkills;
}
public void setMcmmoSkills(final List<String> mcmmoSkills) {
this.mcmmoSkills = mcmmoSkills;
}
public List<Integer> getMcmmoAmounts() {
return mcmmoAmounts;
}
public void setMcmmoAmounts(final List<Integer> mcmmoAmounts) {
this.mcmmoAmounts = mcmmoAmounts;
}
public List<String> getHeroesClasses() {
return heroesClasses;
}
public void setHeroesClasses(final List<String> heroesClasses) {
this.heroesClasses = heroesClasses;
}
public List<Double> getHeroesAmounts() {
return heroesAmounts;
}
public void setHeroesAmounts(final List<Double> heroesAmounts) {
this.heroesAmounts = heroesAmounts;
}
public int getPartiesExperience() {
return partiesExperience;
}
public void setPartiesExperience(final int partiesExperience) {
this.partiesExperience = partiesExperience;
}
public List<String> getPhatLoots() {
return phatLoots;
}
public void setPhatLoots(final List<String> phatLoots) {
this.phatLoots = phatLoots;
}
public Map<String, Map<String, Object>> getCustomRewards() {
return customRewards;
}
protected void setCustomRewards(final Map<String, Map<String, Object>> customRewards) {
this.customRewards = customRewards;
}
public List<String> getDetailsOverride() {
return detailsOverride;
}
public void setDetailsOverride(final List<String> detailsOverride) {
this.detailsOverride = detailsOverride;
}
}

View File

@ -0,0 +1,628 @@
/*
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package me.blackvein.quests.quests;
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;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
public class BukkitStage implements Stage {
private LinkedList<ItemStack> blocksToBreak = new LinkedList<>();
private LinkedList<ItemStack> blocksToDamage = new LinkedList<>();
private LinkedList<ItemStack> blocksToPlace = new LinkedList<>();
private LinkedList<ItemStack> blocksToUse = new LinkedList<>();
private LinkedList<ItemStack> blocksToCut = new LinkedList<>();
private LinkedList<ItemStack> itemsToCraft = new LinkedList<>();
private LinkedList<ItemStack> itemsToSmelt = new LinkedList<>();
private LinkedList<ItemStack> itemsToEnchant = new LinkedList<>();
private LinkedList<ItemStack> itemsToBrew = new LinkedList<>();
private LinkedList<ItemStack> itemsToConsume = new LinkedList<>();
private LinkedList<ItemStack> itemsToDeliver = new LinkedList<>();
private LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
private static final long serialVersionUID = -2774443496142382127L;
@Override
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
final
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
for (final Integer i : this) {
final Integer other = otherList.get(this.indexOf(i));
if (!other.equals(i)) {
return false;
}
}
}
return true;
}
};
private LinkedList<String> deliverMessages = new LinkedList<>();
private LinkedList<Integer> citizensToInteract = new LinkedList<Integer>() {
private static final long serialVersionUID = -4086855121042524435L;
@Override
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
final
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
for (final Integer i : this) {
final Integer other = otherList.get(this.indexOf(i));
if (!other.equals(i)) {
return false;
}
}
}
return true;
}
};
private LinkedList<Integer> citizensToKill = new LinkedList<Integer>() {
private static final long serialVersionUID = 7705964814014176415L;
@Override
public boolean equals(final Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
final
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
for (final Integer i : this) {
final Integer other = otherList.get(this.indexOf(i));
if (!other.equals(i)) {
return false;
}
}
}
return true;
}
};
private LinkedList<Integer> citizenNumToKill = new LinkedList<>();
private LinkedList<EntityType> mobsToKill = new LinkedList<>();
private LinkedList<Integer> mobNumToKill = new LinkedList<>();
private LinkedList<Location> locationsToKillWithin = new LinkedList<>();
private LinkedList<Integer> radiiToKillWithin = new LinkedList<>();
private LinkedList<String> killNames = new LinkedList<>();
private LinkedList<EntityType> mobsToTame = new LinkedList<>();
private LinkedList<Integer> mobNumToTame = new LinkedList<>();
private Integer fishToCatch;
private Integer cowsToMilk;
private LinkedList<DyeColor> sheepToShear = new LinkedList<>();
private LinkedList<Integer> sheepNumToShear = new LinkedList<>();
private Integer playersToKill;
private LinkedList<Location> locationsToReach = new LinkedList<>();
private LinkedList<Integer> radiiToReachWithin = new LinkedList<>();
private LinkedList<World> worldsToReachWithin = new LinkedList<>();
private LinkedList<String> locationNames = new LinkedList<>();
private LinkedList<String> passwordDisplays = new LinkedList<>();
private LinkedList<String> passwordPhrases = new LinkedList<>();
private String script;
private Action startAction = null;
private Action finishAction = null;
private Action failAction = null;
private Action deathAction = null;
private Map<String, Action> chatActions = new HashMap<>();
private Map<String, Action> commandActions = new HashMap<>();
private Action disconnectAction = null;
private Condition condition = null;
private long delay = -1;
private String delayMessage = null;
private String completeMessage = null;
private String startMessage = null;
private LinkedList<String> objectiveOverrides = new LinkedList<>();
private LinkedList<CustomObjective> customObjectives = new LinkedList<>();
private LinkedList<Integer> customObjectiveCounts = new LinkedList<>();
private LinkedList<String> customObjectiveDisplays = new LinkedList<>();
private LinkedList<Entry<String, Object>> customObjectiveData = new LinkedList<>();
public LinkedList<ItemStack> getBlocksToBreak() {
return blocksToBreak;
}
public void setBlocksToBreak(final LinkedList<ItemStack> blocksToBreak) {
this.blocksToBreak = blocksToBreak;
}
public LinkedList<ItemStack> getBlocksToDamage() {
return blocksToDamage;
}
public void setBlocksToDamage(final LinkedList<ItemStack> blocksToDamage) {
this.blocksToDamage = blocksToDamage;
}
public LinkedList<ItemStack> getBlocksToPlace() {
return blocksToPlace;
}
public void setBlocksToPlace(final LinkedList<ItemStack> blocksToPlace) {
this.blocksToPlace = blocksToPlace;
}
public LinkedList<ItemStack> getBlocksToUse() {
return blocksToUse;
}
public void setBlocksToUse(final LinkedList<ItemStack> blocksToUse) {
this.blocksToUse = blocksToUse;
}
public LinkedList<ItemStack> getBlocksToCut() {
return blocksToCut;
}
public void setBlocksToCut(final LinkedList<ItemStack> blocksToCut) {
this.blocksToCut = blocksToCut;
}
public LinkedList<ItemStack> getItemsToCraft() {
return itemsToCraft;
}
public void setItemsToCraft(final LinkedList<ItemStack> itemsToCraft) {
this.itemsToCraft = itemsToCraft;
}
public LinkedList<ItemStack> getItemsToSmelt() {
return itemsToSmelt;
}
public void setItemsToSmelt(final LinkedList<ItemStack> itemsToSmelt) {
this.itemsToSmelt = itemsToSmelt;
}
public LinkedList<ItemStack> getItemsToEnchant() {
return itemsToEnchant;
}
public void setItemsToEnchant(final LinkedList<ItemStack> itemsToEnchant) {
this.itemsToEnchant = itemsToEnchant;
}
public LinkedList<ItemStack> getItemsToBrew() {
return itemsToBrew;
}
public void setItemsToBrew(final LinkedList<ItemStack> itemsToBrew) {
this.itemsToBrew = itemsToBrew;
}
public LinkedList<ItemStack> getItemsToConsume() {
return itemsToConsume;
}
public void setItemsToConsume(final LinkedList<ItemStack> itemsToConsume) {
this.itemsToBrew = itemsToConsume;
}
public LinkedList<ItemStack> getItemsToDeliver() {
return itemsToDeliver;
}
public void setItemsToDeliver(final LinkedList<ItemStack> itemsToDeliver) {
this.itemsToDeliver = itemsToDeliver;
}
public LinkedList<Integer> getItemDeliveryTargets() {
return itemDeliveryTargets;
}
public void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets) {
this.itemDeliveryTargets = itemDeliveryTargets;
}
public LinkedList<String> getDeliverMessages() {
return deliverMessages;
}
public void setDeliverMessages(final LinkedList<String> deliverMessages) {
this.deliverMessages = deliverMessages;
}
public LinkedList<Integer> getCitizensToInteract() {
return citizensToInteract;
}
public void setCitizensToInteract(final LinkedList<Integer> citizensToInteract) {
this.citizensToInteract = citizensToInteract;
}
public LinkedList<Integer> getCitizensToKill() {
return citizensToKill;
}
public void setCitizensToKill(final LinkedList<Integer> citizensToKill) {
this.citizensToKill = citizensToKill;
}
public LinkedList<Integer> getCitizenNumToKill() {
return citizenNumToKill;
}
public void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill) {
this.citizenNumToKill = citizenNumToKill;
}
public LinkedList<EntityType> getMobsToKill() {
return mobsToKill;
}
public void setMobsToKill(final LinkedList<EntityType> mobsToKill) {
this.mobsToKill = mobsToKill;
}
public LinkedList<Integer> getMobNumToKill() {
return mobNumToKill;
}
public void setMobNumToKill(final LinkedList<Integer> mobNumToKill) {
this.mobNumToKill = mobNumToKill;
}
public LinkedList<Location> getLocationsToKillWithin() {
return locationsToKillWithin;
}
public void setLocationsToKillWithin(final LinkedList<Location> locationsToKillWithin) {
this.locationsToKillWithin = locationsToKillWithin;
}
public LinkedList<Integer> getRadiiToKillWithin() {
return radiiToKillWithin;
}
public void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin) {
this.radiiToKillWithin = radiiToKillWithin;
}
public LinkedList<String> getKillNames() {
return killNames;
}
public void setKillNames(final LinkedList<String> killNames) {
this.killNames = killNames;
}
public LinkedList<Location> getLocationsToReach() {
return locationsToReach;
}
public void setLocationsToReach(final LinkedList<Location> locationsToReach) {
this.locationsToReach = locationsToReach;
}
public LinkedList<Integer> getRadiiToReachWithin() {
return radiiToReachWithin;
}
public void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin) {
this.radiiToReachWithin = radiiToReachWithin;
}
public LinkedList<World> getWorldsToReachWithin() {
return worldsToReachWithin;
}
public void setWorldsToReachWithin(final LinkedList<World> worldsToReachWithin) {
this.worldsToReachWithin = worldsToReachWithin;
}
public LinkedList<String> getLocationNames() {
return locationNames;
}
public void setLocationNames(final LinkedList<String> locationNames) {
this.locationNames = locationNames;
}
public LinkedList<EntityType> getMobsToTame() {
return mobsToTame;
}
public void setMobsToTame(final LinkedList<EntityType> mobsToTame) {
this.mobsToTame = mobsToTame;
}
public LinkedList<Integer> getMobNumToTame() {
return mobNumToTame;
}
public void setMobNumToTame(final LinkedList<Integer> mobNumToTame) {
this.mobNumToTame = mobNumToTame;
}
public Integer getFishToCatch() {
return fishToCatch;
}
public void setFishToCatch(final Integer fishToCatch) {
this.fishToCatch = fishToCatch;
}
public Integer getCowsToMilk() {
return cowsToMilk;
}
public void setCowsToMilk(final Integer cowsToMilk) {
this.cowsToMilk = cowsToMilk;
}
public Integer getPlayersToKill() {
return playersToKill;
}
public void setPlayersToKill(final Integer playersToKill) {
this.playersToKill = playersToKill;
}
public LinkedList<DyeColor> getSheepToShear() {
return sheepToShear;
}
public void setSheepToShear(final LinkedList<DyeColor> sheepToShear) {
this.sheepToShear = sheepToShear;
}
public LinkedList<Integer> getSheepNumToShear() {
return sheepNumToShear;
}
public void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear) {
this.sheepNumToShear = sheepNumToShear;
}
public LinkedList<String> getPasswordDisplays() {
return passwordDisplays;
}
public void setPasswordDisplays(final LinkedList<String> passwordDisplays) {
this.passwordDisplays = passwordDisplays;
}
public LinkedList<String> getPasswordPhrases() {
return passwordPhrases;
}
public void setPasswordPhrases(final LinkedList<String> passwordPhrases) {
this.passwordPhrases = passwordPhrases;
}
public String getScript() {
return script;
}
public void setScript(final String script) {
this.script = script;
}
public Action getStartAction() {
return startAction;
}
public void setStartAction(final Action startAction) {
this.startAction = startAction;
}
public Action getFinishAction() {
return finishAction;
}
public void setFinishAction(final Action finishAction) {
this.finishAction = finishAction;
}
public Action getFailAction() {
return failAction;
}
public void setFailAction(final Action failAction) {
this.failAction = failAction;
}
public Action getDeathAction() {
return deathAction;
}
public void setDeathAction(final Action deathAction) {
this.deathAction = deathAction;
}
public Map<String, Action> getChatActions() {
return chatActions;
}
public void setChatActions(final Map<String, Action> chatActions) {
this.chatActions = chatActions;
}
public Map<String, Action> getCommandActions() {
return commandActions;
}
public void setCommandActions(final Map<String, Action> commandActions) {
this.commandActions = commandActions;
}
public Action getDisconnectAction() {
return disconnectAction;
}
public void setDisconnectAction(final Action disconnectAction) {
this.disconnectAction = disconnectAction;
}
public Condition getCondition() {
return condition;
}
public void setCondition(final Condition condition) {
this.condition = condition;
}
public long getDelay() {
return delay;
}
public void setDelay(final long delay) {
this.delay = delay;
}
public String getDelayMessage() {
return delayMessage;
}
public void setDelayMessage(final String delayMessage) {
this.delayMessage = delayMessage;
}
public String getCompleteMessage() {
return completeMessage;
}
public void setCompleteMessage(final String completeMessage) {
this.completeMessage = completeMessage;
}
public String getStartMessage() {
return startMessage;
}
public void setStartMessage(final String startMessage) {
this.startMessage = startMessage;
}
public LinkedList<String> getObjectiveOverrides() {
return objectiveOverrides;
}
public void setObjectiveOverrides(final LinkedList<String> objectiveOverrides) {
this.objectiveOverrides = objectiveOverrides;
}
public LinkedList<CustomObjective> getCustomObjectives() {
return customObjectives;
}
public LinkedList<Integer> getCustomObjectiveCounts() {
return customObjectiveCounts;
}
public LinkedList<String> getCustomObjectiveDisplays() {
return customObjectiveDisplays;
}
public LinkedList<Entry<String, Object>> getCustomObjectiveData() {
return customObjectiveData;
}
/**
* Check if stage has at least one objective<p>
*
* Excludes start/complete message, delay, and objective-override
*
* @return true if stage contains an objective
*/
public boolean hasObjective() {
if (!blocksToBreak.isEmpty()) { return true; }
if (!blocksToDamage.isEmpty()) { return true; }
if (!blocksToPlace.isEmpty()) { return true; }
if (!blocksToUse.isEmpty()) { return true; }
if (!blocksToCut.isEmpty()) { return true; }
if (cowsToMilk != null) { return true; }
if (fishToCatch != null) { return true; }
if (playersToKill != null) { return true; }
if (!itemsToCraft.isEmpty()) { return true; }
if (!itemsToSmelt.isEmpty()) { return true; }
if (!itemsToEnchant.isEmpty()) { return true; }
if (!itemsToBrew.isEmpty()) { return true; }
if (!itemsToConsume.isEmpty()) { return true; }
if (!itemsToDeliver.isEmpty()) { return true; }
if (!citizensToInteract.isEmpty()) { return true; }
if (!citizensToKill.isEmpty()) { return true; }
if (!locationsToReach.isEmpty()) { return true; }
if (!mobsToTame.isEmpty()) { return true; }
if (!sheepToShear.isEmpty()) { return true; }
if (!passwordDisplays.isEmpty()) { return true; }
return !customObjectives.isEmpty();
}
/**
* Check if stage has the specified type of objective<p>
*
* @param type The type of objective to check for
* @return true if stage contains specified objective
*/
public boolean containsObjective(final ObjectiveType type) {
if (type.equals(ObjectiveType.BREAK_BLOCK)) {
return !blocksToBreak.isEmpty();
} else if (type.equals(ObjectiveType.DAMAGE_BLOCK)) {
return !blocksToDamage.isEmpty();
} else if (type.equals(ObjectiveType.PLACE_BLOCK)) {
return !blocksToPlace.isEmpty();
} else if (type.equals(ObjectiveType.USE_BLOCK)) {
return !blocksToUse.isEmpty();
} else if (type.equals(ObjectiveType.CUT_BLOCK)) {
return !blocksToCut.isEmpty();
} else if (type.equals(ObjectiveType.CRAFT_ITEM)) {
return !itemsToCraft.isEmpty();
} else if (type.equals(ObjectiveType.SMELT_ITEM)) {
return !itemsToSmelt.isEmpty();
} else if (type.equals(ObjectiveType.ENCHANT_ITEM)) {
return !itemsToEnchant.isEmpty();
} else if (type.equals(ObjectiveType.BREW_ITEM)) {
return !itemsToBrew.isEmpty();
} else if (type.equals(ObjectiveType.CONSUME_ITEM)) {
return !itemsToConsume.isEmpty();
} else if (type.equals(ObjectiveType.DELIVER_ITEM)) {
return !itemsToDeliver.isEmpty();
} else if (type.equals(ObjectiveType.MILK_COW)) {
return cowsToMilk != null;
} else if (type.equals(ObjectiveType.CATCH_FISH)) {
return fishToCatch != null;
} else if (type.equals(ObjectiveType.KILL_MOB)) {
return !mobsToKill.isEmpty();
} else if (type.equals(ObjectiveType.KILL_PLAYER)) {
return playersToKill != null;
} else if (type.equals(ObjectiveType.TALK_TO_NPC)) {
return !citizensToInteract.isEmpty();
} else if (type.equals(ObjectiveType.KILL_NPC)) {
return !citizensToKill.isEmpty();
} else if (type.equals(ObjectiveType.TAME_MOB)) {
return !mobsToTame.isEmpty();
} else if (type.equals(ObjectiveType.SHEAR_SHEEP)) {
return !sheepToShear.isEmpty();
} else if (type.equals(ObjectiveType.REACH_LOCATION)) {
return !locationsToReach.isEmpty();
} else if (type.equals(ObjectiveType.PASSWORD)) {
return !passwordPhrases.isEmpty();
} else {
return false;
}
}
}

View File

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

View File

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

Some files were not shown because too many files have changed in this diff Show More