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"
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.1.3</version>
<version>4.2.0</version>
</parent>
<artifactId>quests-api</artifactId>
@ -166,31 +167,6 @@
<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>

View File

@ -12,85 +12,34 @@
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.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 CustomObjective implements Listener {
public interface CustomObjective {
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;
String getModuleName();
public String getModuleName() {
return new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getName()
.replace(".jar", "");
}
Map.Entry<String, Short> getModuleItem();
public Entry<String, Short> getModuleItem() {
return new AbstractMap.SimpleEntry<>("IRON_INGOT", (short) 0);
}
String getName();
public String getName() {
return name;
}
void setName(final String name);
public void setName(final String name) {
this.name = name;
}
String getAuthor();
public String getAuthor() {
return author;
}
void setAuthor(final String author);
public void setAuthor(final String author) {
this.author = author;
}
String getDisplay();
public String getDisplay() {
return display;
}
void setDisplay(final String display);
public void setDisplay(final String display) {
this.display = display;
}
Map.Entry<String, Short> getItem();
public Entry<String, Short> getItem() {
return item;
}
void setItem(final String type, final short durability);
/**
* @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;
}
LinkedList<Map.Entry<String, Object>> getData();
/**
* Add a new prompt<p>
@ -101,128 +50,39 @@ public abstract class CustomObjective implements Listener {
* @param description Description of expected input
* @param defaultValue Value to be used if input is not received
*/
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);
}
void addStringPrompt(final String title, final String description, final Object defaultValue);
public Map<String, String> getDescriptions() {
return descriptions;
}
Map<String, String> getDescriptions();
public int getCount() {
return count;
}
int getCount();
public void setCount(final int count) {
this.count = count;
}
void setCount(final int count);
public String getCountPrompt() {
return countPrompt;
}
String getCountPrompt();
public void setCountPrompt(final String countPrompt) {
this.countPrompt = countPrompt;
}
void setCountPrompt(final String countPrompt);
/**
* Check whether to let user set required amount for objective
*/
public boolean canShowCount() {
return showCount;
}
boolean canShowCount();
/**
* Set whether to let user set required amount for objective
*
* @param showCount Whether to show the count
*/
public void setShowCount(final boolean showCount) {
this.showCount = showCount;
}
void setShowCount(final boolean 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;
}
/**
* Get custom objective data for applicable player
*
* @param player Player attempting this objective
* @param customObj The objective being attempted
* @param quest Current me.blackvein.quests.Quest which includes this objective
* @return data
*/
Map<String, Object> getDataForPlayer(final Player player, final CustomObjective customObj, final Quest quest);
public void incrementObjective(final Player player, final CustomObjective obj, final int count, final Quest quest) {
final Quester quester = plugin.getQuester(player.getUniqueId());
if (quester != null) {
if (quester.hasCustomObjective(quest, obj.getName())) {
int index = -1;
final LinkedList<Integer> customObjCounts = quester.getQuestData(quest).customObjectiveCounts;
for (final CustomObjective co : quester.getCurrentStage(quest).customObjectives) {
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(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);
}
}
}
}
void incrementObjective(final Player player, final CustomObjective obj, final int count, final Quest quest);
}

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;
import org.bukkit.inventory.ItemStack;
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;
}
public interface Objective {
}

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;
public class 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;
}
public interface Options {
}

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;
import java.util.Calendar;
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;
}
public interface Planner {
}

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;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class Requirements {
private int money = 0;
private int questPoints = 0;
private List<ItemStack> items = new LinkedList<>();
private List<Boolean> removeItems = new LinkedList<>();
private List<Quest> neededQuests = new LinkedList<>();
private List<Quest> 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 interface Requirements {
int getMoney();
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<Quest> getNeededQuests() {
return neededQuests;
}
public void setNeededQuests(final List<Quest> neededQuests) {
this.neededQuests = neededQuests;
}
public List<Quest> getBlockQuests() {
return blockQuests;
}
public void setBlockQuests(final List<Quest> 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;
}
void setMoney(final int money);
int getQuestPoints();
void setQuestPoints(final int questPoints);
List<ItemStack> getItems();
void setItems(final List<ItemStack> items);
List<Boolean> getRemoveItems();
void setRemoveItems(final List<Boolean> removeItems);
List<Quest> getNeededQuests();
void setNeededQuests(final List<Quest> neededQuests);
List<Quest> getBlockQuests();
void setBlockQuests(final List<Quest> blockQuests);
List<String> getPermissions();
void setPermissions(final List<String> permissions);
List<String> getMcmmoSkills();
void setMcmmoSkills(final List<String> mcmmoSkills);
List<Integer> getMcmmoAmounts();
void setMcmmoAmounts(final List<Integer> mcmmoAmounts);
String getHeroesPrimaryClass();
void setHeroesPrimaryClass(final String heroesPrimaryClass);
String getHeroesSecondaryClass();
void setHeroesSecondaryClass(final String heroesSecondaryClass);
Map<String, Map<String, Object>> getCustomRequirements();
void setCustomRequirements(final Map<String, Map<String, Object>> customRequirements);
List<String> getDetailsOverride();
void setDetailsOverride(final List<String> 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;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class Rewards {
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;
}
public interface Rewards {
int getMoney();
void setMoney(final int money);
int getQuestPoints();
void setQuestPoints(final int questPoints);
int getExp();
void setExp(final int exp);
List<String> getCommands();
void setCommands(final List<String> commands);
List<String> getCommandsOverrideDisplay();
void setCommandsOverrideDisplay(final List<String> commandsOverrideDisplay);
List<String> getPermissions();
void setPermissions(final List<String> permissions);
List<String> getPermissionWorlds();
void setPermissionWorlds(final List<String> worldNames);
List<ItemStack> getItems();
void setItems(final List<ItemStack> items);
List<String> getMcmmoSkills();
void setMcmmoSkills(final List<String> mcmmoSkills);
List<Integer> getMcmmoAmounts();
void setMcmmoAmounts(final List<Integer> mcmmoAmounts);
List<String> getHeroesClasses();
void setHeroesClasses(final List<String> heroesClasses);
List<Double> getHeroesAmounts();
void setHeroesAmounts(final List<Double> heroesAmounts);
int getPartiesExperience();
void setPartiesExperience(final int partiesExperience);
List<String> getPhatLoots();
void setPhatLoots(final List<String> phatLoots);
Map<String, Map<String, Object>> getCustomRewards();
void setCustomRewards(final Map<String, Map<String, Object>> customRewards);
List<String> getDetailsOverride();
void setDetailsOverride(final List<String> detailsOverride);
}

View File

@ -1,542 +1,215 @@
/*
* 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;
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 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 interface Stage {
LinkedList<ItemStack> getBlocksToBreak();
public void setDeliverMessages(final LinkedList<String> deliverMessages) {
this.deliverMessages = deliverMessages;
}
void setBlocksToBreak(final LinkedList<ItemStack> blocksToBreak);
public LinkedList<Integer> getCitizensToInteract() {
return citizensToInteract;
}
LinkedList<ItemStack> getBlocksToDamage();
public void setCitizensToInteract(final LinkedList<Integer> citizensToInteract) {
this.citizensToInteract = citizensToInteract;
}
void setBlocksToDamage(final LinkedList<ItemStack> blocksToDamage);
public LinkedList<Integer> getCitizensToKill() {
return citizensToKill;
}
LinkedList<ItemStack> getBlocksToPlace();
public void setCitizensToKill(final LinkedList<Integer> citizensToKill) {
this.citizensToKill = citizensToKill;
}
void setBlocksToPlace(final LinkedList<ItemStack> blocksToPlace);
public LinkedList<Integer> getCitizenNumToKill() {
return citizenNumToKill;
}
LinkedList<ItemStack> getBlocksToUse();
public void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill) {
this.citizenNumToKill = citizenNumToKill;
}
void setBlocksToUse(final LinkedList<ItemStack> blocksToUse);
public LinkedList<EntityType> getMobsToKill() {
return mobsToKill;
}
LinkedList<ItemStack> getBlocksToCut();
public void setMobsToKill(final LinkedList<EntityType> mobsToKill) {
this.mobsToKill = mobsToKill;
}
void setBlocksToCut(final LinkedList<ItemStack> blocksToCut);
public LinkedList<Integer> getMobNumToKill() {
return mobNumToKill;
}
LinkedList<ItemStack> getItemsToCraft();
public void setMobNumToKill(final LinkedList<Integer> mobNumToKill) {
this.mobNumToKill = mobNumToKill;
}
void setItemsToCraft(final LinkedList<ItemStack> itemsToCraft);
public LinkedList<Location> getLocationsToKillWithin() {
return locationsToKillWithin;
}
LinkedList<ItemStack> getItemsToSmelt();
public void setLocationsToKillWithin(final LinkedList<Location> locationsToKillWithin) {
this.locationsToKillWithin = locationsToKillWithin;
}
void setItemsToSmelt(final LinkedList<ItemStack> itemsToSmelt);
public LinkedList<Integer> getRadiiToKillWithin() {
return radiiToKillWithin;
}
LinkedList<ItemStack> getItemsToEnchant();
public void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin) {
this.radiiToKillWithin = radiiToKillWithin;
}
void setItemsToEnchant(final LinkedList<ItemStack> itemsToEnchant);
public LinkedList<String> getKillNames() {
return killNames;
}
LinkedList<ItemStack> getItemsToBrew();
public void setKillNames(final LinkedList<String> killNames) {
this.killNames = killNames;
}
void setItemsToBrew(final LinkedList<ItemStack> itemsToBrew);
public LinkedList<Location> getLocationsToReach() {
return locationsToReach;
}
LinkedList<ItemStack> getItemsToConsume();
public void setLocationsToReach(final LinkedList<Location> locationsToReach) {
this.locationsToReach = locationsToReach;
}
void setItemsToConsume(final LinkedList<ItemStack> itemsToConsume);
public LinkedList<Integer> getRadiiToReachWithin() {
return radiiToReachWithin;
}
LinkedList<ItemStack> getItemsToDeliver();
public void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin) {
this.radiiToReachWithin = radiiToReachWithin;
}
void setItemsToDeliver(final LinkedList<ItemStack> itemsToDeliver);
public LinkedList<World> getWorldsToReachWithin() {
return worldsToReachWithin;
}
LinkedList<Integer> getItemDeliveryTargets();
public void setWorldsToReachWithin(final LinkedList<World> worldsToReachWithin) {
this.worldsToReachWithin = worldsToReachWithin;
}
void setItemDeliveryTargets(final LinkedList<Integer> itemDeliveryTargets);
public LinkedList<String> getLocationNames() {
return locationNames;
}
LinkedList<String> getDeliverMessages();
public void setLocationNames(final LinkedList<String> locationNames) {
this.locationNames = locationNames;
}
void setDeliverMessages(final LinkedList<String> deliverMessages);
public LinkedList<EntityType> getMobsToTame() {
return mobsToTame;
}
LinkedList<Integer> getCitizensToInteract();
public void setMobsToTame(final LinkedList<EntityType> mobsToTame) {
this.mobsToTame = mobsToTame;
}
void setCitizensToInteract(final LinkedList<Integer> citizensToInteract);
public LinkedList<Integer> getMobNumToTame() {
return mobNumToTame;
}
LinkedList<Integer> getCitizensToKill();
public void setMobNumToTame(final LinkedList<Integer> mobNumToTame) {
this.mobNumToTame = mobNumToTame;
}
void setCitizensToKill(final LinkedList<Integer> citizensToKill);
public Integer getFishToCatch() {
return fishToCatch;
}
LinkedList<Integer> getCitizenNumToKill();
public void setFishToCatch(final Integer fishToCatch) {
this.fishToCatch = fishToCatch;
}
void setCitizenNumToKill(final LinkedList<Integer> citizenNumToKill);
public Integer getCowsToMilk() {
return cowsToMilk;
}
LinkedList<EntityType> getMobsToKill();
public void setCowsToMilk(final Integer cowsToMilk) {
this.cowsToMilk = cowsToMilk;
}
void setMobsToKill(final LinkedList<EntityType> mobsToKill);
public Integer getPlayersToKill() {
return playersToKill;
}
LinkedList<Integer> getMobNumToKill();
public void setPlayersToKill(final Integer playersToKill) {
this.playersToKill = playersToKill;
}
void setMobNumToKill(final LinkedList<Integer> mobNumToKill);
public LinkedList<DyeColor> getSheepToShear() {
return sheepToShear;
}
LinkedList<Location> getLocationsToKillWithin();
public void setSheepToShear(final LinkedList<DyeColor> sheepToShear) {
this.sheepToShear = sheepToShear;
}
void setLocationsToKillWithin(final LinkedList<Location> locationsToKillWithin);
public LinkedList<Integer> getSheepNumToShear() {
return sheepNumToShear;
}
LinkedList<Integer> getRadiiToKillWithin();
public void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear) {
this.sheepNumToShear = sheepNumToShear;
}
void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin);
public LinkedList<String> getPasswordDisplays() {
return passwordDisplays;
}
LinkedList<String> getKillNames();
public void setPasswordDisplays(final LinkedList<String> passwordDisplays) {
this.passwordDisplays = passwordDisplays;
}
void setKillNames(final LinkedList<String> killNames);
public LinkedList<String> getPasswordPhrases() {
return passwordPhrases;
}
LinkedList<Location> getLocationsToReach();
public void setPasswordPhrases(final LinkedList<String> passwordPhrases) {
this.passwordPhrases = passwordPhrases;
}
void setLocationsToReach(final LinkedList<Location> locationsToReach);
public String getScript() {
return script;
}
LinkedList<Integer> getRadiiToReachWithin();
public void setScript(final String script) {
this.script = script;
}
void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin);
public Action getStartAction() {
return startAction;
}
LinkedList<World> getWorldsToReachWithin();
public void setStartAction(final Action startAction) {
this.startAction = startAction;
}
void setWorldsToReachWithin(final LinkedList<World> worldsToReachWithin);
public Action getFinishAction() {
return finishAction;
}
LinkedList<String> getLocationNames();
public void setFinishAction(final Action finishAction) {
this.finishAction = finishAction;
}
void setLocationNames(final LinkedList<String> locationNames);
public Action getFailAction() {
return failAction;
}
LinkedList<EntityType> getMobsToTame();
public void setFailAction(final Action failAction) {
this.failAction = failAction;
}
void setMobsToTame(final LinkedList<EntityType> mobsToTame);
public Action getDeathAction() {
return deathAction;
}
LinkedList<Integer> getMobNumToTame();
public void setDeathAction(final Action deathAction) {
this.deathAction = deathAction;
}
void setMobNumToTame(final LinkedList<Integer> mobNumToTame);
public Map<String, Action> getChatActions() {
return chatActions;
}
Integer getFishToCatch();
public void setChatActions(final Map<String, Action> chatActions) {
this.chatActions = chatActions;
}
void setFishToCatch(final Integer fishToCatch);
public Map<String, Action> getCommandActions() {
return commandActions;
}
Integer getCowsToMilk();
public void setCommandActions(final Map<String, Action> commandActions) {
this.commandActions = commandActions;
}
void setCowsToMilk(final Integer cowsToMilk);
public Action getDisconnectAction() {
return disconnectAction;
}
Integer getPlayersToKill();
public void setDisconnectAction(final Action disconnectAction) {
this.disconnectAction = disconnectAction;
}
void setPlayersToKill(final Integer playersToKill);
public Condition getCondition() {
return condition;
}
LinkedList<DyeColor> getSheepToShear();
public void setCondition(final Condition condition) {
this.condition = condition;
}
void setSheepToShear(final LinkedList<DyeColor> sheepToShear);
public long getDelay() {
return delay;
}
LinkedList<Integer> getSheepNumToShear();
public void setDelay(final long delay) {
this.delay = delay;
}
void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear);
public String getDelayMessage() {
return delayMessage;
}
LinkedList<String> getPasswordDisplays();
public void setDelayMessage(final String delayMessage) {
this.delayMessage = delayMessage;
}
void setPasswordDisplays(final LinkedList<String> passwordDisplays);
public String getCompleteMessage() {
return completeMessage;
}
LinkedList<String> getPasswordPhrases();
public void setCompleteMessage(final String completeMessage) {
this.completeMessage = completeMessage;
}
void setPasswordPhrases(final LinkedList<String> passwordPhrases);
public String getStartMessage() {
return startMessage;
}
String getScript();
public void setStartMessage(final String startMessage) {
this.startMessage = startMessage;
}
void setScript(final String script);
public LinkedList<String> getObjectiveOverrides() {
return objectiveOverrides;
}
Action getStartAction();
public void setObjectiveOverrides(final LinkedList<String> objectiveOverrides) {
this.objectiveOverrides = objectiveOverrides;
}
void setStartAction(final Action startAction);
public LinkedList<CustomObjective> getCustomObjectives() {
return customObjectives;
}
Action getFinishAction();
public LinkedList<Integer> getCustomObjectiveCounts() {
return customObjectiveCounts;
}
void setFinishAction(final Action finishAction);
public LinkedList<String> getCustomObjectiveDisplays() {
return customObjectiveDisplays;
}
Action getFailAction();
public LinkedList<Entry<String, Object>> getCustomObjectiveData() {
return customObjectiveData;
}
void setFailAction(final Action failAction);
Action getDeathAction();
void setDeathAction(final Action deathAction);
Map<String, Action> getChatActions();
void setChatActions(final Map<String, Action> chatActions);
Map<String, Action> getCommandActions();
void setCommandActions(final Map<String, Action> commandActions);
Action getDisconnectAction();
void setDisconnectAction(final Action disconnectAction);
Condition getCondition();
void setCondition(final Condition condition);
long getDelay();
void setDelay(final long delay);
String getDelayMessage();
void setDelayMessage(final String delayMessage);
String getCompleteMessage();
void setCompleteMessage(final String completeMessage);
String getStartMessage();
void setStartMessage(final String startMessage);
LinkedList<String> getObjectiveOverrides();
void setObjectiveOverrides(final LinkedList<String> objectiveOverrides);
LinkedList<CustomObjective> getCustomObjectives();
LinkedList<Integer> getCustomObjectiveCounts();
LinkedList<String> getCustomObjectiveDisplays();
LinkedList<Map.Entry<String, Object>> getCustomObjectiveData();
/**
* Check if stage has at least one objective<p>
@ -545,47 +218,7 @@ public class Stage {
*
* @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>
*
* 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
* @return true if stage contains specified objective
*/
@Deprecated
public boolean containsObjective(final String type) {
return containsObjective(ObjectiveType.fromName(type));
}
boolean hasObjective();
/**
* Check if stage has the specified type of objective<p>
@ -593,51 +226,5 @@ public class Stage {
* @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;
}
}
boolean containsObjective(final ObjectiveType type);
}

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;
import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestMob;
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.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 Action implements Comparable<Action> {
public interface Action {
String getName();
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>() {
void setName(final String name);
private static final long serialVersionUID = -761974607799449780L;
String getMessage();
@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;
void setMessage(final String message);
public Action(final Quests plugin) {
this.plugin = plugin;
}
boolean isClearInv();
@Override
public int compareTo(final Action action) {
return name.compareTo(action.getName());
}
void setClearInv(final boolean clearInv);
public String getName() {
return name;
}
boolean isFailQuest();
public void setName(final String name) {
this.name = name;
}
void setFailQuest(final boolean failQuest);
public String getMessage() {
return message;
}
LinkedList<Location> getExplosions();
public void setMessage(final String message) {
this.message = message;
}
void setExplosions(final LinkedList<Location> explosions);
public boolean isClearInv() {
return clearInv;
}
Map<Location, Effect> getEffects();
public void setClearInv(final boolean clearInv) {
this.clearInv = clearInv;
}
void setEffects(final Map<Location, Effect> effects);
public boolean isFailQuest() {
return failQuest;
}
LinkedList<ItemStack> getItems();
public void setFailQuest(final boolean failQuest) {
this.failQuest = failQuest;
}
void setItems(final LinkedList<ItemStack> items);
public LinkedList<Location> getExplosions() {
return explosions;
}
World getStormWorld();
public void setExplosions(final LinkedList<Location> explosions) {
this.explosions = explosions;
}
void setStormWorld(final World stormWorld);
public Map<Location, Effect> getEffects() {
return effects;
}
int getStormDuration();
public void setEffects(final Map<Location, Effect> effects) {
this.effects = effects;
}
void setStormDuration(final int stormDuration);
public LinkedList<ItemStack> getItems() {
return items;
}
World getThunderWorld();
public void setItems(final LinkedList<ItemStack> items) {
this.items = items;
}
void setThunderWorld(final World thunderWorld);
public World getStormWorld() {
return stormWorld;
}
int getThunderDuration();
public void setStormWorld(final World stormWorld) {
this.stormWorld = stormWorld;
}
void setThunderDuration(final int thunderDuration);
public int getStormDuration() {
return stormDuration;
}
int getTimer();
public void setStormDuration(final int stormDuration) {
this.stormDuration = stormDuration;
}
void setTimer(final int timer);
public World getThunderWorld() {
return thunderWorld;
}
boolean isCancelTimer();
public void setThunderWorld(final World thunderWorld) {
this.thunderWorld = thunderWorld;
}
void setCancelTimer(final boolean cancelTimer);
public int getThunderDuration() {
return thunderDuration;
}
LinkedList<QuestMob> getMobSpawns();
public void setThunderDuration(final int thunderDuration) {
this.thunderDuration = thunderDuration;
}
void setMobSpawns(final LinkedList<QuestMob> mobSpawns);
public int getTimer() {
return timer;
}
LinkedList<Location> getLightningStrikes();
public void setTimer(final int timer) {
this.timer = timer;
}
void setLightningStrikes(final LinkedList<Location> lightningStrikes);
public boolean isCancelTimer() {
return cancelTimer;
}
LinkedList<String> getCommands();
public void setCancelTimer(final boolean cancelTimer) {
this.cancelTimer = cancelTimer;
}
void setCommands(final LinkedList<String> commands);
public LinkedList<QuestMob> getMobSpawns() {
return mobSpawns;
}
LinkedList<PotionEffect> getPotionEffects();
public void setMobSpawns(final LinkedList<QuestMob> mobSpawns) {
this.mobSpawns = mobSpawns;
}
void setPotionEffects(final LinkedList<PotionEffect> potionEffects);
public LinkedList<Location> getLightningStrikes() {
return lightningStrikes;
}
int getHunger();
public void setLightningStrikes(final LinkedList<Location> lightningStrikes) {
this.lightningStrikes = lightningStrikes;
}
void setHunger(final int hunger);
public LinkedList<String> getCommands() {
return commands;
}
int getSaturation();
public void setCommands(final LinkedList<String> commands) {
this.commands = commands;
}
void setSaturation(final int saturation);
public LinkedList<PotionEffect> getPotionEffects() {
return potionEffects;
}
float getHealth();
public void setPotionEffects(final LinkedList<PotionEffect> potionEffects) {
this.potionEffects = potionEffects;
}
void setHealth(final float health);
public int getHunger() {
return hunger;
}
Location getTeleport();
public void setHunger(final int hunger) {
this.hunger = hunger;
}
void setTeleport(final Location teleport);
public int getSaturation() {
return saturation;
}
String getBook();
public void setSaturation(final int saturation) {
this.saturation = saturation;
}
void setBook(final String book);
public float getHealth() {
return health;
}
String getDenizenScript();
public void setHealth(final float health) {
this.health = health;
}
void setDenizenScript(final String scriptName);
public Location getTeleport() {
return teleport;
void fire(final Quester quester, final Quest quest);
}
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 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;
import me.blackvein.quests.player.BukkitQuester;
public class DenizenTrigger {
private final Quests plugin;
public DenizenTrigger(final Quests plugin) {
this.plugin = plugin;
}
public boolean runDenizenScript(final String scriptName, final Quester quester) {
public boolean runDenizenScript(final String scriptName, final BukkitQuester quester) {
if (scriptName == null) {
return false;
}

View File

@ -22,6 +22,7 @@ import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.characters.Hero;
import me.blackvein.quests.listeners.NpcListener;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.reflect.denizen.DenizenAPI;
import me.blackvein.quests.reflect.worldguard.WorldGuardAPI;
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);
}

View File

@ -12,6 +12,7 @@
package me.blackvein.quests;
import me.blackvein.quests.player.BukkitQuester;
import org.bukkit.inventory.ItemStack;
import java.util.Collection;
@ -22,9 +23,9 @@ import java.util.LinkedList;
*/
public class QuestData {
private final Quester quester;
private final BukkitQuester quester;
public QuestData(final Quester quester) {
public QuestData(final BukkitQuester 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.stages.StageMenuPrompt;
import me.blackvein.quests.interfaces.ReloadCallback;
import me.blackvein.quests.quests.BukkitOptions;
import me.blackvein.quests.quests.BukkitPlanner;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.quests.BukkitRequirements;
import me.blackvein.quests.quests.BukkitRewards;
import me.blackvein.quests.quests.BukkitStage;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ConfigUtil;
import me.blackvein.quests.util.FakeConversable;
@ -157,7 +163,7 @@ public class QuestFactory implements ConversationAbandonedListener {
}
@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.Q_ID, q.getId());
context.setSessionData(CK.Q_NAME, q.getName());
@ -176,7 +182,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (q.getGUIDisplay() != null) {
context.setSessionData(CK.Q_GUIDISPLAY, q.getGUIDisplay());
}
final Requirements requirements = q.getRequirements();
final BukkitRequirements requirements = q.getRequirements();
if (requirements.getMoney() != 0) {
context.setSessionData(CK.REQ_MONEY, requirements.getMoney());
}
@ -188,11 +194,11 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.REQ_ITEMS_REMOVE, requirements.getRemoveItems());
}
if (!requirements.getNeededQuests().isEmpty()) {
final List<String> ids = requirements.getNeededQuests().stream().map(Quest::getId).collect(Collectors.toList());
final List<String> ids = requirements.getNeededQuests().stream().map(BukkitQuest::getId).collect(Collectors.toList());
context.setSessionData(CK.REQ_QUEST, ids);
}
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);
}
if (!requirements.getMcmmoSkills().isEmpty()) {
@ -221,7 +227,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (!requirements.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REQ_FAIL_MESSAGE, requirements.getDetailsOverride());
}
final Rewards rewards = q.getRewards();
final BukkitRewards rewards = q.getRewards();
if (rewards.getMoney() != 0) {
context.setSessionData(CK.REW_MONEY, rewards.getMoney());
}
@ -267,7 +273,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (!rewards.getDetailsOverride().isEmpty()) {
context.setSessionData(CK.REW_DETAILS_OVERRIDE, rewards.getDetailsOverride());
}
final Planner pln = q.getPlanner();
final BukkitPlanner pln = q.getPlanner();
if (pln.getStart() != null) {
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_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_QUITTING, opt.canAllowQuitting());
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());
// Stages (Objectives)
int index = 1;
for (final Stage stage : q.getStages()) {
for (final BukkitStage stage : q.getStages()) {
final String pref = "stage" + index;
index++;
context.setSessionData(pref, Boolean.TRUE);

View File

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

View File

@ -12,9 +12,9 @@
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.Quester;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
import me.blackvein.quests.convo.actions.menu.ActionMenuPrompt;
@ -151,7 +151,7 @@ public class ActionFactory implements ConversationAbandonedListener {
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) {
context.setSessionData(CK.E_MESSAGE, event.message);
}
@ -312,8 +312,8 @@ public class ActionFactory implements ConversationAbandonedListener {
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
plugin.getLogger().info(identifier + " deleted action " + action);
}
for (final Quester q : plugin.getOfflineQuesters()) {
for (final Quest quest : q.getCurrentQuests().keySet()) {
for (final BukkitQuester q : plugin.getOfflineQuesters()) {
for (final BukkitQuest quest : q.getCurrentQuests().keySet()) {
q.checkQuest(quest);
}
}
@ -339,7 +339,7 @@ public class ActionFactory implements ConversationAbandonedListener {
if (context.getSessionData(CK.E_OLD_EVENT) != null
&& !((String) Objects.requireNonNull(context.getSessionData(CK.E_OLD_EVENT))).isEmpty()) {
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)));
plugin.setLoadedActions(temp);
}
@ -469,8 +469,8 @@ public class ActionFactory implements ConversationAbandonedListener {
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
plugin.getLogger().info(identifier + " saved action " + context.getSessionData(CK.E_NAME));
}
for (final Quester q : plugin.getOfflineQuesters()) {
for (final Quest quest : q.getCurrentQuests().keySet()) {
for (final BukkitQuester q : plugin.getOfflineQuesters()) {
for (final BukkitQuest quest : q.getCurrentQuests().keySet()) {
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;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.MiscUtil;
@ -137,7 +137,7 @@ public class Condition implements Comparable<Condition> {
}
@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();
if (!entitiesWhileRiding.isEmpty()) {
for (final String e : entitiesWhileRiding) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@
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.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
@ -139,7 +139,7 @@ public class PlannerPrompt extends QuestsEditorNumericPrompt {
case 5:
final Boolean override = (Boolean) context.getSessionData(CK.PLN_OVERRIDE);
if (override == null) {
final boolean defaultOpt = new Planner().getOverride();
final boolean defaultOpt = new BukkitPlanner().getOverride();
return ChatColor.GRAY + "(" + (defaultOpt ? ChatColor.GREEN
+ Lang.get(String.valueOf(defaultOpt)) : ChatColor.RED
+ 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.herocraftonline.heroes.characters.classes.HeroClass;
import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.CustomRequirement;
import me.blackvein.quests.CustomReward;
import me.blackvein.quests.Quest;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.generic.ItemStackPrompt;
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"
+ ChatColor.DARK_PURPLE);
boolean none = true;
for (final Quest q : plugin.getLoadedQuests()) {
for (final BukkitQuest q : plugin.getLoadedQuests()) {
text.append(q.getName()).append(", ");
none = false;
}

View File

@ -16,8 +16,6 @@ import com.codisimus.plugins.phatloots.PhatLoot;
import com.codisimus.plugins.phatloots.PhatLootsAPI;
import com.gmail.nossr50.datatypes.skills.SkillType;
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.Quests;
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.Quests;
import me.blackvein.quests.actions.Action;
import me.blackvein.quests.actions.BukkitAction;
import me.blackvein.quests.conditions.Condition;
import me.blackvein.quests.convo.QuestsNumericPrompt;
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.MiscUtil;
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 org.bukkit.ChatColor;
import org.bukkit.Location;
@ -1439,7 +1438,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n");
} else {
for (final Action a : plugin.getLoadedActions()) {
for (final BukkitAction a : plugin.getLoadedActions()) {
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();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1506,7 +1505,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else {
for (final Action a : plugin.getLoadedActions()) {
for (final BukkitAction a : plugin.getLoadedActions()) {
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();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1573,7 +1572,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else {
for (final Action a : plugin.getLoadedActions()) {
for (final BukkitAction a : plugin.getLoadedActions()) {
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();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1640,7 +1639,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none")).append("\n");
} else {
for (final Action a : plugin.getLoadedActions()) {
for (final BukkitAction a : plugin.getLoadedActions()) {
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();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1707,7 +1706,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else {
for (final Action a : plugin.getLoadedActions()) {
for (final BukkitAction a : plugin.getLoadedActions()) {
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();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1774,7 +1773,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else {
for (final Action a : plugin.getLoadedActions()) {
for (final BukkitAction a : plugin.getLoadedActions()) {
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();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;
@ -1916,7 +1915,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (plugin.getLoadedActions().isEmpty()) {
text.append(ChatColor.RED).append("- ").append(Lang.get("none"));
} else {
for (final Action a : plugin.getLoadedActions()) {
for (final BukkitAction a : plugin.getLoadedActions()) {
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();
if (input != null && !input.equalsIgnoreCase(Lang.get("cmdCancel"))
&& !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
Action found = null;
for (final Action a : plugin.getLoadedActions()) {
BukkitAction found = null;
for (final BukkitAction a : plugin.getLoadedActions()) {
if (a.getName().equalsIgnoreCase(input)) {
found = a;
break;

View File

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

View File

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

View File

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

View File

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

View File

@ -12,8 +12,8 @@
package me.blackvein.quests.listeners;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.quests.BukkitQuest;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.enums.ObjectiveType;
import org.bukkit.Material;
@ -49,10 +49,10 @@ public class ItemListener implements Listener {
final Player player = (Player) evt.getWhoClicked();
if (plugin.canUseQuests(player.getUniqueId())) {
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 Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) {
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -62,7 +62,7 @@ public class ItemListener implements Listener {
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())) {
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("SMOKER")) {
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 Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) {
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -113,7 +113,7 @@ public class ItemListener implements Listener {
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())) {
q.smeltItem(cq, evt.getCurrentItem());
}
@ -123,10 +123,10 @@ public class ItemListener implements Listener {
}
} else if (evt.getInventory().getType() == InventoryType.BREWING) {
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 Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) {
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -136,7 +136,7 @@ public class ItemListener implements Listener {
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())) {
q.brewItem(cq, evt.getCurrentItem());
}
@ -154,10 +154,10 @@ public class ItemListener implements Listener {
final ItemStack enchantedItem = evt.getItem().clone();
enchantedItem.setAmount(1);
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 Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) {
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
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 (enchantedItem.getType().equals(Material.BOOK)) {
q.enchantBook(cq, enchantedItem, evt.getEnchantsToAdd());
@ -191,10 +191,10 @@ public class ItemListener implements Listener {
if (plugin.canUseQuests(evt.getPlayer().getUniqueId())) {
final ItemStack consumedItem = evt.getItem().clone();
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 Set<String> dispatchedQuestIDs = new HashSet<>();
for (final Quest quest : plugin.getLoadedQuests()) {
for (final BukkitQuest quest : plugin.getLoadedQuests()) {
if (!quester.meetsCondition(quest, true)) {
continue;
}
@ -204,7 +204,7 @@ public class ItemListener implements Listener {
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())) {
q.consumeItem(cq, consumedItem);
}

View File

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

View File

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

View File

@ -12,7 +12,7 @@
package me.blackvein.quests.storage.implementation;
import me.blackvein.quests.Quester;
import me.blackvein.quests.player.BukkitQuester;
import me.blackvein.quests.Quests;
import java.util.Collection;
@ -27,9 +27,9 @@ public interface StorageImplementation {
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;

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