Refactoring for getter/setter methods, part 1. Bump version number

This commit is contained in:
BuildTools 2019-01-03 03:48:50 -05:00
parent b5e948845e
commit 3d4f94e0ef
11 changed files with 378 additions and 172 deletions

View File

@ -3,7 +3,7 @@
<groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId>
<version>3.5.9</version>
<version>3.6.0</version>
<name>quests</name>
<url>https://github.com/FlyingPikachu/Quests/</url>
<packaging>jar</packaging>

View File

@ -10,7 +10,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************************************/
package me.blackvein.quests;
package me.blackvein.listeners;
import java.text.MessageFormat;
import java.util.LinkedList;
@ -30,6 +30,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.RomanNumeral;
@ -63,7 +66,7 @@ public class NpcListener implements Listener {
ItemStack hand = player.getItemInHand();
ItemStack found = null;
int reasonCode = 0;
for (ItemStack is : quester.getCurrentStage(quest).itemsToDeliver) {
for (ItemStack is : quester.getCurrentStage(quest).getItemsToDeliver()) {
reasonCode = ItemUtil.compareItems(is, hand, true);
if (reasonCode == 0) {
found = is;
@ -72,7 +75,7 @@ public class NpcListener implements Listener {
}
NPC clicked = evt.getNPC();
if (found != null) {
for (Integer n : quester.getCurrentStage(quest).itemDeliveryTargets) {
for (Integer n : quester.getCurrentStage(quest).getItemDeliveryTargets()) {
if (n.equals(clicked.getId())) {
quester.deliverItem(quest, hand);
delivery = true;
@ -81,7 +84,7 @@ public class NpcListener implements Listener {
}
break;
} else if (!hand.getType().equals(Material.AIR)) {
for (Integer n : quester.getCurrentStage(quest).itemDeliveryTargets) {
for (Integer n : quester.getCurrentStage(quest).getItemDeliveryTargets()) {
if (n.equals(clicked.getId())) {
String text = "";
if (hand.hasItemMeta()) {
@ -92,27 +95,36 @@ public class NpcListener implements Listener {
text += (hand.getItemMeta().hasDisplayName() ? ")" : "");
}
text += " x " + ChatColor.DARK_AQUA + hand.getAmount() + ChatColor.GRAY;
plugin.query.sendMessage(player, Lang.get(player, "difference").replace("<item>", text), hand.getType(), hand.getDurability());
plugin.query.sendMessage(player, Lang.get(player, "questInvalidDeliveryItem").replace("<item>", text), hand.getType(), hand.getDurability());
switch(reasonCode) {
case 1:
player.sendMessage(Lang.get(player, "difference").replace("<data>", "one item is null"));
break;
case 0:
// Should never happen
player.sendMessage(Lang.get(player, "difference").replace("<data>", "ERROR"));
break;
case -1:
player.sendMessage(Lang.get(player, "difference").replace("<data>", "name"));
break;
case -2:
player.sendMessage(Lang.get(player, "difference").replace("<data>", "amount"));
break;
case -3:
player.sendMessage(Lang.get(player, "difference").replace("<data>", "durability"));
break;
case -4:
player.sendMessage(Lang.get(player, "difference").replace("<data>", "display name or lore"));
break;
case -5:
player.sendMessage(Lang.get(player, "difference").replace("<data>", "enchantments"));
break;
case -6:
player.sendMessage(Lang.get(player, "difference").replace("<data>", "stored enchants"));
break;
case -7:
player.sendMessage(Lang.get(player, "difference").replace("<data>", "item flags"));
break;
default:
player.sendMessage(Lang.get(player, "difference").replace("<data>", "unknown"));
}
@ -149,7 +161,7 @@ public class NpcListener implements Listener {
for (Quest q : plugin.getQuests()) {
if (quester.currentQuests.containsKey(q))
continue;
if (q.npcStart != null && q.npcStart.getId() == evt.getNPC().getId()) {
if (q.getNpcStart() != null && q.getNpcStart().getId() == evt.getNPC().getId()) {
if (plugin.ignoreLockedQuests && (quester.completedQuests.contains(q.getName()) == false || q.cooldownPlanner > -1)) {
if (q.testRequirements(quester)) {
npcQuests.add(q);
@ -267,6 +279,6 @@ public class NpcListener implements Listener {
}
private String extracted(final Quester quester) {
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.questToTake, ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.questToTake).description);
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.questToTake, ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.questToTake).getDescription());
}
}

View File

@ -10,7 +10,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************************************/
package me.blackvein.quests;
package me.blackvein.listeners;
import java.io.File;
import java.util.Iterator;
@ -64,6 +64,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.blackvein.quests.Quest;
import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.Stage;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import net.citizensnpcs.api.CitizensAPI;
@ -107,8 +111,8 @@ public class PlayerListener implements Listener {
ItemStack clicked = evt.getCurrentItem();
if (clicked != null) {
for (Quest quest : plugin.quests) {
if (quest.guiDisplay != null) {
if (ItemUtil.compareItems(clicked, quest.guiDisplay, false) == 0) {
if (quest.getGUIDisplay() != null) {
if (ItemUtil.compareItems(clicked, quest.getGUIDisplay(), false) == 0) {
if (quester.currentQuests.size() >= plugin.maxQuests && plugin.maxQuests > 0) {
String msg = Lang.get(player, "questMaxAllowed");
msg = msg.replace("<number>", String.valueOf(plugin.maxQuests));
@ -128,14 +132,14 @@ public class PlayerListener implements Listener {
takeable = false;
}
}
if (quest.region != null) {
if (quest.getRegion() != null) {
boolean inRegion = false;
Player p = quester.getPlayer();
RegionManager rm = Quests.worldGuard.getRegionManager(p.getWorld());
Iterator<ProtectedRegion> it = rm.getApplicableRegions(p.getLocation()).iterator();
while (it.hasNext()) {
ProtectedRegion pr = it.next();
if (pr.getId().equalsIgnoreCase(quest.region)) {
if (pr.getId().equalsIgnoreCase(quest.getRegion())) {
inRegion = true;
break;
}
@ -252,8 +256,8 @@ public class PlayerListener implements Listener {
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get(player, "questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
} else if (player.isConversing() == false) {
for (final Quest q : plugin.quests) {
if (q.blockStart != null) {
if (q.blockStart.equals(evt.getClickedBlock().getLocation())) {
if (q.getBlockStart() != null) {
if (q.getBlockStart().equals(evt.getClickedBlock().getLocation())) {
if (quester.currentQuests.size() >= plugin.maxQuests && plugin.maxQuests > 0) {
String msg = Lang.get(player, "questMaxAllowed");
msg = msg.replace("<number>", String.valueOf(plugin.maxQuests));
@ -274,7 +278,7 @@ public class PlayerListener implements Listener {
}
}
quester.questToTake = q.getName();
String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quester.questToTake + ChatColor.GOLD + " -\n" + "\n" + ChatColor.RESET + plugin.getQuest(quester.questToTake).description + "\n";
String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quester.questToTake + ChatColor.GOLD + " -\n" + "\n" + ChatColor.RESET + plugin.getQuest(quester.questToTake).getDescription() + "\n";
for (String msg : s.split("<br>")) {
player.sendMessage(msg);
}

View File

@ -57,11 +57,11 @@ public class EventFactory implements ConversationAbandonedListener {
Quests quests;
Map<UUID, Quest> editSessions = new HashMap<UUID, Quest>();
Map<UUID, Block> selectedExplosionLocations = new HashMap<UUID, Block>();
Map<UUID, Block> selectedEffectLocations = new HashMap<UUID, Block>();
Map<UUID, Block> selectedMobLocations = new HashMap<UUID, Block>();
Map<UUID, Block> selectedLightningLocations = new HashMap<UUID, Block>();
Map<UUID, Block> selectedTeleportLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedExplosionLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedEffectLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedMobLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedLightningLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedTeleportLocations = new HashMap<UUID, Block>();
List<String> names = new LinkedList<String>();
ConversationFactory convoCreator;
File eventsFile;

View File

@ -45,32 +45,17 @@ import net.citizensnpcs.api.npc.NPC;
public class Quest {
public String name;
public String description;
public String finished;
public String region = null;
public ItemStack guiDisplay = null;
public int parties = 0;
protected Quests plugin;
private String name;
protected String description;
protected String finished;
protected String region = null;
protected ItemStack guiDisplay = null;
//private int parties = 0;
private LinkedList<Stage> orderedStages = new LinkedList<Stage>();
NPC npcStart;
Location blockStart;
Quests plugin;
Event initialEvent;
// Requirements
int moneyReq = 0;
int questPointsReq = 0;
List<ItemStack> items = new LinkedList<ItemStack>();
List<Boolean> removeItems = new LinkedList<Boolean>();
List<String> neededQuests = new LinkedList<String>();
List<String> blockQuests = new LinkedList<String>();
List<String> permissionReqs = new LinkedList<String>();
List<String> mcMMOSkillReqs = new LinkedList<String>();
List<Integer> mcMMOAmountReqs = new LinkedList<Integer>();
String heroesPrimaryClassReq = null;
String heroesSecondaryClassReq = null;
Map<String, Map<String, Object>> customRequirements = new HashMap<String, Map<String, Object>>();
Map<String, Map<String, Object>> customRewards = new HashMap<String, Map<String, Object>>();
public String failRequirements = null;
protected NPC npcStart;
protected Location blockStart;
protected Event initialEvent;
// Planner
public String startPlanner = null;
public String endPlanner = null;
@ -88,7 +73,14 @@ public class Quest {
List<String> heroesClasses = new LinkedList<String>();
List<Double> heroesAmounts = new LinkedList<Double>();
List<String> phatLootRewards = new LinkedList<String>();
Map<String, Map<String, Object>> customRewards = new HashMap<String, Map<String, Object>>();
private Requirements reqs = new Requirements();
public Requirements getRequirements() {
return reqs;
}
public String getName() {
return name;
}
@ -97,6 +89,38 @@ public class Quest {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getFinished() {
return finished;
}
public void setFinished(String finished) {
this.finished = finished;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public ItemStack getGUIDisplay() {
return guiDisplay;
}
public void setGUIDisplay(ItemStack guiDisplay) {
this.guiDisplay = guiDisplay;
}
public Stage getStage(int index) {
try {
return orderedStages.get(index);
@ -108,7 +132,36 @@ public class Quest {
public LinkedList<Stage> getStages() {
return orderedStages;
}
public NPC getNpcStart() {
return npcStart;
}
public void setNpcStart(NPC npcStart) {
this.npcStart = npcStart;
}
public Location getBlockStart() {
return blockStart;
}
public void setBlockStart(Location blockStart) {
this.blockStart = blockStart;
}
public Event getInitialEvent() {
return initialEvent;
}
public void setInitialEvent(Event initialEvent) {
this.initialEvent = initialEvent;
}
/**
* Force player to proceed to the next ordered stage
*
* @param q Player to force
*/
public void nextStage(Quester q) {
String stageCompleteMessage = q.getCurrentStage(this).completeMessage;
if (stageCompleteMessage != null) {
@ -152,6 +205,12 @@ public class Quest {
q.updateJournal();
}
/**
* Force player to proceed to the specified stage
* @param quester Player to force
* @param stage Stage number to specify
* @throws InvalidStageException if stage does not exist
*/
public void setStage(Quester quester, int stage) throws InvalidStageException {
if (orderedStages.size() - 1 < stage) {
throw new InvalidStageException(this, stage);
@ -253,16 +312,16 @@ public class Quest {
return testRequirements(quester.getPlayer());
}
public boolean testRequirements(Player player) {
protected boolean testRequirements(Player player) {
Quester quester = plugin.getQuester(player.getUniqueId());
if (moneyReq != 0 && Quests.economy != null) {
if (Quests.economy.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())) < moneyReq) {
if (reqs.getMoney() != 0 && Quests.economy != null) {
if (Quests.economy.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())) < reqs.getMoney()) {
return false;
}
}
PlayerInventory inventory = player.getInventory();
int num = 0;
for (ItemStack is : items) {
for (ItemStack is : reqs.getItems()) {
for (ItemStack stack : inventory.getContents()) {
if (stack != null) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
@ -275,29 +334,29 @@ public class Quest {
}
num = 0;
}
for (String s : permissionReqs) {
for (String s : reqs.getPermissions()) {
if (player.hasPermission(s) == false) {
return false;
}
}
for (String s : mcMMOSkillReqs) {
for (String s : reqs.getMcmmoSkills()) {
final SkillType st = Quests.getMcMMOSkill(s);
final int lvl = mcMMOAmountReqs.get(mcMMOSkillReqs.indexOf(s));
final int lvl = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(s));
if (UserManager.getPlayer(player).getProfile().getSkillLevel(st) < lvl) {
return false;
}
}
if (heroesPrimaryClassReq != null) {
if (plugin.testPrimaryHeroesClass(heroesPrimaryClassReq, player.getUniqueId()) == false) {
if (reqs.getHeroesPrimaryClass() != null) {
if (plugin.testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId()) == false) {
return false;
}
}
if (heroesSecondaryClassReq != null) {
if (plugin.testSecondaryHeroesClass(heroesSecondaryClassReq, player.getUniqueId()) == false) {
if (reqs.getHeroesSecondaryClass() != null) {
if (plugin.testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId()) == false) {
return false;
}
}
for (String s : customRequirements.keySet()) {
for (String s : reqs.getCustomRequirements().keySet()) {
CustomRequirement found = null;
for (CustomRequirement cr : plugin.customRequirements) {
if (cr.getName().equalsIgnoreCase(s)) {
@ -306,7 +365,7 @@ public class Quest {
}
}
if (found != null) {
if (found.testRequirement(player, customRequirements.get(s)) == false) {
if (found.testRequirement(player, reqs.getCustomRequirements().get(s)) == false) {
return false;
}
} else {
@ -314,13 +373,13 @@ public class Quest {
+ "\" could not be found. Does it still exist?");
}
}
if (quester.questPoints < questPointsReq) {
if (quester.questPoints < reqs.getQuestPoints()) {
return false;
}
if (quester.completedQuests.containsAll(neededQuests) == false) {
if (quester.completedQuests.containsAll(reqs.getNeededQuests()) == false) {
return false;
}
for (String q : blockQuests) {
for (String q : reqs.getBlockQuests()) {
Quest questObject = new Quest();
questObject.name = q;
if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(questObject)) {
@ -612,8 +671,12 @@ public class Quest {
}
q.updateJournal();
}
public boolean isInRegion(Quester quester) {
return isInRegion(quester.getPlayer());
}
public boolean isInRegion(Player player) {
private boolean isInRegion(Player player) {
if (region == null) {
return true;
} else {

View File

@ -60,7 +60,7 @@ public class QuestFactory implements ConversationAbandonedListener {
public final Quests plugin;
Map<UUID, Quest> editSessions = new HashMap<UUID, Quest>();
Map<UUID, Block> selectedBlockStarts = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedBlockStarts = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedKillLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedReachLocations = new HashMap<UUID, Block>();
public HashSet<Player> selectingNPCs = new HashSet<Player>();
@ -1313,46 +1313,43 @@ public class QuestFactory implements ConversationAbandonedListener {
cc.setSessionData(CK.Q_GUIDISPLAY, q.guiDisplay);
}
// Requirements
if (q.moneyReq != 0) {
cc.setSessionData(CK.REQ_MONEY, q.moneyReq);
Requirements reqs = q.getRequirements();
if (reqs.getMoney() != 0) {
cc.setSessionData(CK.REQ_MONEY, reqs.getMoney());
}
if (q.questPointsReq != 0) {
cc.setSessionData(CK.REQ_QUEST_POINTS, q.questPointsReq);
if (reqs.getQuestPoints() != 0) {
cc.setSessionData(CK.REQ_QUEST_POINTS, reqs.getQuestPoints());
}
if (q.items.isEmpty() == false) {
cc.setSessionData(CK.REQ_ITEMS, q.items);
cc.setSessionData(CK.REQ_ITEMS_REMOVE, q.removeItems);
if (reqs.getItems().isEmpty() == false) {
cc.setSessionData(CK.REQ_ITEMS, reqs.getItems());
cc.setSessionData(CK.REQ_ITEMS_REMOVE, reqs.getRemoveItems());
}
if (q.neededQuests.isEmpty() == false) {
cc.setSessionData(CK.REQ_QUEST, q.neededQuests);
if (reqs.getNeededQuests().isEmpty() == false) {
cc.setSessionData(CK.REQ_QUEST, reqs.getNeededQuests());
}
if (q.blockQuests.isEmpty() == false) {
cc.setSessionData(CK.REQ_QUEST_BLOCK, q.blockQuests);
if (reqs.getBlockQuests().isEmpty() == false) {
cc.setSessionData(CK.REQ_QUEST_BLOCK, reqs.getBlockQuests());
}
if (q.mcMMOSkillReqs.isEmpty() == false) {
cc.setSessionData(CK.REQ_MCMMO_SKILLS, q.mcMMOSkillReqs);
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, q.mcMMOAmountReqs);
if (reqs.getMcmmoSkills().isEmpty() == false) {
cc.setSessionData(CK.REQ_MCMMO_SKILLS, reqs.getMcmmoAmounts());
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, reqs.getMcmmoAmounts());
}
if (q.permissionReqs.isEmpty() == false) {
cc.setSessionData(CK.REQ_PERMISSION, q.permissionReqs);
if (reqs.getPermissions().isEmpty() == false) {
cc.setSessionData(CK.REQ_PERMISSION, reqs.getPermissions());
}
if (q.heroesPrimaryClassReq != null) {
cc.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, q.heroesPrimaryClassReq);
if (reqs.getHeroesPrimaryClass() != null) {
cc.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, reqs.getHeroesPrimaryClass());
}
if (q.heroesSecondaryClassReq != null) {
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, q.heroesSecondaryClassReq);
if (reqs.getHeroesSecondaryClass() != null) {
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, reqs.getHeroesSecondaryClass());
}
if (q.mcMMOSkillReqs.isEmpty() == false) {
cc.setSessionData(CK.REQ_MCMMO_SKILLS, q.mcMMOSkillReqs);
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, q.mcMMOAmountReqs);
if (reqs.getFailRequirements() != null) {
cc.setSessionData(CK.Q_FAIL_MESSAGE, reqs.getFailRequirements());
}
if (q.failRequirements != null) {
cc.setSessionData(CK.Q_FAIL_MESSAGE, q.failRequirements);
}
if (q.customRequirements.isEmpty() == false) {
if (reqs.getCustomRequirements().isEmpty() == false) {
LinkedList<String> list = new LinkedList<String>();
LinkedList<Map<String, Object>> datamapList = new LinkedList<Map<String, Object>>();
for (Entry<String, Map<String, Object>> entry : q.customRequirements.entrySet()) {
for (Entry<String, Map<String, Object>> entry : reqs.getCustomRequirements().entrySet()) {
list.add(entry.getKey());
datamapList.add(entry.getValue());
}
@ -1505,13 +1502,13 @@ public class QuestFactory implements ConversationAbandonedListener {
cc.setSessionData(pref + CK.S_ENCHANT_NAMES, names);
cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, amounts);
}
if (stage.itemsToDeliver.isEmpty() == false) {
if (stage.getItemsToDeliver().isEmpty() == false) {
LinkedList<ItemStack> items = new LinkedList<ItemStack>();
LinkedList<Integer> npcs = new LinkedList<Integer>();
for (ItemStack is : stage.itemsToDeliver) {
for (ItemStack is : stage.getItemsToDeliver()) {
items.add(is);
}
for (Integer n : stage.itemDeliveryTargets) {
for (Integer n : stage.getItemDeliveryTargets()) {
npcs.add(n);
}
cc.setSessionData(pref + CK.S_DELIVERY_ITEMS, items);
@ -1669,7 +1666,7 @@ public class QuestFactory implements ConversationAbandonedListener {
Quest found = plugin.findQuest(input);
if (found != null) {
for (Quest q : plugin.quests) {
if (q.neededQuests.contains(q.getName()) || q.blockQuests.contains(q.getName())) {
if (q.getRequirements().getNeededQuests().contains(q.getName()) || q.getRequirements().getBlockQuests().contains(q.getName())) {
used.add(q.getName());
}
}

View File

@ -55,9 +55,9 @@ import net.citizensnpcs.api.npc.NPC;
public class Quester {
UUID id;
public UUID id;
boolean editorMode = false;
boolean hasJournal = false;
public boolean hasJournal = false;
public String questToTake;
public ConcurrentHashMap<Integer, Quest> timers = new ConcurrentHashMap<Integer, Quest>();
public ConcurrentHashMap<Quest, Integer> currentQuests = new ConcurrentHashMap<Quest, Integer>() {
@ -150,7 +150,7 @@ public class Quester {
return s;
}
};
Map<String, Long> completedTimes = new HashMap<String, Long>();
public Map<String, Long> completedTimes = new HashMap<String, Long>();
Map<String, Integer> amountsCompleted = new HashMap<String, Integer>() {
private static final long serialVersionUID = 5475202358792520975L;
@ -391,14 +391,15 @@ public class Quester {
+ ". Consider resetting player data or report on Github");
}
Stage stage = q.getStage(0);
Requirements reqs = q.getRequirements();
if (!override) {
if (q.moneyReq > 0) {
if (reqs.getMoney() > 0) {
if (Quests.economy != null) {
Quests.economy.withdrawPlayer(getOfflinePlayer(), q.moneyReq);
Quests.economy.withdrawPlayer(getOfflinePlayer(), reqs.getMoney());
}
}
for (ItemStack is : q.items) {
if (q.removeItems.get(q.items.indexOf(is)) == true) {
for (ItemStack is : reqs.getItems()) {
if (reqs.getRemoveItems().get(reqs.getItems().indexOf(is)) == true) {
Quests.removeItem(player.getInventory(), is);
}
}
@ -441,7 +442,7 @@ public class Quester {
q.updateGPS(this);
saveData();
} else {
player.sendMessage(q.failRequirements);
player.sendMessage(q.getRequirements().getFailRequirements());
}
}
@ -608,13 +609,13 @@ public class Quester {
}
}
int index2 = 0;
for (ItemStack is : getCurrentStage(quest).itemsToDeliver) {
for (ItemStack is : getCurrentStage(quest).getItemsToDeliver()) {
int delivered = 0;
if (getQuestData(quest).itemsDelivered.containsKey(is)) {
delivered = getQuestData(quest).itemsDelivered.get(is);
}
int amt = is.getAmount();
Integer npc = getCurrentStage(quest).itemDeliveryTargets.get(index2);
Integer npc = getCurrentStage(quest).getItemDeliveryTargets().get(index2);
index2++;
if (delivered < amt) {
String obj = Lang.get(getPlayer(), "deliver");
@ -791,7 +792,7 @@ public class Quester {
} else if (s.equalsIgnoreCase("killMob")) {
return !getCurrentStage(quest).mobsToKill.isEmpty();
} else if (s.equalsIgnoreCase("deliverItem")) {
return !getCurrentStage(quest).itemsToDeliver.isEmpty();
return !getCurrentStage(quest).getItemsToDeliver().isEmpty();
} else if (s.equalsIgnoreCase("killPlayer")) {
return getCurrentStage(quest).playersToKill != null;
} else if (s.equalsIgnoreCase("talkToNPC")) {
@ -1244,14 +1245,14 @@ public class Quester {
}
if (found != null) {
int amount = getQuestData(quest).itemsDelivered.get(found);
if (getCurrentStage(quest).itemsToDeliver.indexOf(found) < 0) {
if (getCurrentStage(quest).getItemsToDeliver().indexOf(found) < 0) {
plugin.getLogger().severe("Index out of bounds while delivering " + found.getType() + " x " + found.getAmount() + " for quest "
+ quest.getName() + " with " + i.getType() + " x " + i.getAmount() + " already delivered. Int -amount- reports value of " +
+ amount + ". Please report this error on Github issue #448");
player.sendMessage("Quests had a problem delivering your item, please contact an administrator!");
return;
}
int req = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(found)).getAmount();
int req = getCurrentStage(quest).getItemsToDeliver().get(getCurrentStage(quest).getItemsToDeliver().indexOf(found)).getAmount();
Material m = i.getType();
if (amount < req) {
if ((i.getAmount() + amount) > req) {
@ -1270,7 +1271,7 @@ public class Quester {
getQuestData(quest).itemsDelivered.put(found, (amount + i.getAmount()));
player.getInventory().setItem(player.getInventory().first(i), null);
player.updateInventory();
String message = Quests.parseString(getCurrentStage(quest).deliverMessages.get(random.nextInt(getCurrentStage(quest).deliverMessages.size())), Quests.citizens.getNPCRegistry().getById(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(found))));
String message = Quests.parseString(getCurrentStage(quest).deliverMessages.get(random.nextInt(getCurrentStage(quest).deliverMessages.size())), Quests.citizens.getNPCRegistry().getById(getCurrentStage(quest).getItemDeliveryTargets().get(getCurrentStage(quest).getItemsToDeliver().indexOf(found))));
player.sendMessage(message);
}
}
@ -1409,9 +1410,9 @@ public class Quester {
}
} else if (objective.equalsIgnoreCase("deliverItem")) {
String obj = Lang.get(p, "deliver");
obj = obj.replace("<npc>", plugin.getNPCName(getCurrentStage(quest).itemDeliveryTargets.get(getCurrentStage(quest).itemsToDeliver.indexOf(delivery))));
obj = obj.replace("<npc>", plugin.getNPCName(getCurrentStage(quest).getItemDeliveryTargets().get(getCurrentStage(quest).getItemsToDeliver().indexOf(delivery))));
String message = ChatColor.GREEN + "(" + Lang.get(p, "completed") + ") " + obj;
ItemStack is = getCurrentStage(quest).itemsToDeliver.get(getCurrentStage(quest).itemsToDeliver.indexOf(delivery));
ItemStack is = getCurrentStage(quest).getItemsToDeliver().get(getCurrentStage(quest).getItemsToDeliver().indexOf(delivery));
plugin.query.sendMessage(p, message, is.getType(), is.getDurability());
if (testComplete(quest)) {
quest.nextStage(this);
@ -1586,8 +1587,8 @@ public class Quester {
}
}
data.setPlayersKilled(0);
if (quest.getStage(stage).itemsToDeliver.isEmpty() == false) {
for (ItemStack is : quest.getStage(stage).itemsToDeliver) {
if (quest.getStage(stage).getItemsToDeliver().isEmpty() == false) {
for (ItemStack is : quest.getStage(stage).getItemsToDeliver()) {
data.itemsDelivered.put(is, 0);
}
}
@ -2289,8 +2290,8 @@ public class Quester {
if (questSec.contains("item-delivery-amounts")) {
List<Integer> deliveryAmounts = questSec.getIntegerList("item-delivery-amounts");
for (int i = 0; i < deliveryAmounts.size(); i++) {
if (i < getCurrentStage(quest).itemsToDeliver.size()) {
getQuestData(quest).itemsDelivered.put(getCurrentStage(quest).itemsToDeliver.get(i), deliveryAmounts.get(i));
if (i < getCurrentStage(quest).getItemsToDeliver().size()) {
getQuestData(quest).itemsDelivered.put(getCurrentStage(quest).getItemsToDeliver().get(i), deliveryAmounts.get(i));
}
}
}

View File

@ -93,6 +93,8 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.blackvein.listeners.NpcListener;
import me.blackvein.listeners.PlayerListener;
import me.blackvein.quests.exceptions.InvalidStageException;
import me.blackvein.quests.prompts.QuestAcceptPrompt;
import me.blackvein.quests.util.ItemUtil;
@ -1795,8 +1797,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
cs.sendMessage(" ");
if (showQuestReqs == true) {
cs.sendMessage(ChatColor.GOLD + Lang.get("requirements"));
if (q.permissionReqs.isEmpty() == false) {
for (String perm : q.permissionReqs) {
Requirements reqs = q.getRequirements();
if (reqs.getPermissions().isEmpty() == false) {
for (String perm : reqs.getPermissions()) {
if (permission.has(player, perm)) {
cs.sendMessage(ChatColor.GREEN + Lang.get("permissionDisplay") + " " + perm);
} else {
@ -1804,24 +1807,24 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
}
}
if (q.heroesPrimaryClassReq != null) {
if (this.testPrimaryHeroesClass(q.heroesPrimaryClassReq, player.getUniqueId())) {
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + q.heroesPrimaryClassReq + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass"));
if (reqs.getHeroesPrimaryClass() != null) {
if (this.testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId())) {
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesPrimaryClass() + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass"));
} else {
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + q.heroesPrimaryClassReq + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass"));
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesPrimaryClass() + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass"));
}
}
if (q.heroesSecondaryClassReq != null) {
if (this.testSecondaryHeroesClass(q.heroesSecondaryClassReq, player.getUniqueId())) {
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + q.heroesSecondaryClassReq + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass"));
if (reqs.getHeroesSecondaryClass() != null) {
if (this.testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId())) {
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesSecondaryClass() + ChatColor.RESET + "" + ChatColor.RED + " " + Lang.get("heroesClass"));
} else {
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + q.heroesSecondaryClassReq + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass"));
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesSecondaryClass() + ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + Lang.get("heroesClass"));
}
}
if (q.mcMMOSkillReqs.isEmpty() == false) {
for (String skill : q.mcMMOSkillReqs) {
if (reqs.getMcmmoSkills().isEmpty() == false) {
for (String skill : reqs.getMcmmoSkills()) {
int level = Quests.getMCMMOSkillLevel(Quests.getMcMMOSkill(skill), player.getName());
int req = q.mcMMOAmountReqs.get(q.mcMMOSkillReqs.indexOf(skill));
int req = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(skill));
String skillName = MiscUtil.getCapitalized(skill);
if (level >= req) {
cs.sendMessage(ChatColor.GREEN + skillName + " " + Lang.get("mcMMOLevel") + " " + req);
@ -1830,30 +1833,30 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
}
}
if (q.questPointsReq != 0) {
if (quester.questPoints >= q.questPointsReq) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + q.questPointsReq + " " + Lang.get("questPoints"));
if (reqs.getQuestPoints() != 0) {
if (quester.questPoints >= reqs.getQuestPoints()) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getQuestPoints() + " " + Lang.get("questPoints"));
} else {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + q.questPointsReq + " " + Lang.get("questPoints"));
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getQuestPoints() + " " + Lang.get("questPoints"));
}
}
if (q.moneyReq != 0) {
if (economy != null && economy.getBalance(quester.getOfflinePlayer()) >= q.moneyReq) {
if (q.moneyReq == 1) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + q.moneyReq + " " + Quests.getCurrency(false));
if (reqs.getMoney() != 0) {
if (economy != null && economy.getBalance(quester.getOfflinePlayer()) >= reqs.getMoney()) {
if (reqs.getMoney() == 1) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " " + Quests.getCurrency(false));
} else {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + q.moneyReq + " " + Quests.getCurrency(true));
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " " + Quests.getCurrency(true));
}
} else {
if (q.moneyReq == 1) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + q.moneyReq + " " + Quests.getCurrency(false));
if (reqs.getMoney() == 1) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " " + Quests.getCurrency(false));
} else {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + q.moneyReq + " " + Quests.getCurrency(true));
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " " + Quests.getCurrency(true));
}
}
}
if (q.items.isEmpty() == false) {
for (ItemStack is : q.items) {
if (reqs.getItems().isEmpty() == false) {
for (ItemStack is : reqs.getItems()) {
if (hasItem(player, is) == true) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + ItemUtil.getString(is));
} else {
@ -1861,8 +1864,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
}
}
if (q.neededQuests.isEmpty() == false) {
for (String s : q.neededQuests) {
if (reqs.getNeededQuests().isEmpty() == false) {
for (String s : reqs.getNeededQuests()) {
if (quester.completedQuests.contains(s)) {
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + Lang.get("complete") + " " + ChatColor.ITALIC + s);
} else {
@ -1870,8 +1873,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
}
}
if (q.blockQuests.isEmpty() == false) {
for (String s : q.blockQuests) {
if (reqs.getBlockQuests().isEmpty() == false) {
for (String s : reqs.getBlockQuests()) {
if (quester.completedQuests.contains(s)) {
String msg = Lang.get("haveCompleted");
msg = msg.replace("<quest>", ChatColor.ITALIC + "" + ChatColor.DARK_PURPLE + s + ChatColor.RED);
@ -1961,7 +1964,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
//TODO find a better way to detect a deliver objective
else if (obj.contains(Lang.get(quester.getPlayer(), "deliver").split(" ")[0])) {
for (ItemStack is : stage.itemsToDeliver) {
for (ItemStack is : stage.getItemsToDeliver()) {
if (Material.matchMaterial(serial) != null) {
if (Material.matchMaterial(serial).equals(is.getType())) {
String enchant = "";
@ -2472,8 +2475,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
private void loadQuestRequirements(FileConfiguration config, ConfigurationSection questsSection) throws SkipQuest {
Requirements reqs = quest.getRequirements();
if (config.contains("quests." + questName + ".requirements.fail-requirement-message")) {
quest.failRequirements = parseString(config.getString("quests." + questName + ".requirements.fail-requirement-message"), quest);
reqs.setFailRequirements(parseString(config.getString("quests." + questName + ".requirements.fail-requirement-message"), quest));
} else {
skipQuestProcess("Requirements for Quest " + quest.getName() + " is missing fail-requirement-message:");
}
@ -2481,15 +2485,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (Quests.checkList(config.getList("quests." + questName + ".requirements.items"), String.class)) {
List<String> itemReqs = config.getStringList("quests." + questName + ".requirements.items");
boolean failed = false;
List<ItemStack> temp = reqs.getItems();
for (String item : itemReqs) {
ItemStack stack = ItemUtil.readItemStack(item);
if (stack != null) {
quest.items.add(stack);
temp.add(stack);
} else {
failed = true;
break;
}
}
reqs.setItems(temp);
if (failed == true) {
skipQuestProcess("items: Requirement for Quest " + quest.getName() + " is not formatted correctly!");
}
@ -2498,8 +2504,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
if (config.contains("quests." + questName + ".requirements.remove-items")) {
if (Quests.checkList(config.getList("quests." + questName + ".requirements.remove-items"), Boolean.class)) {
quest.removeItems.clear();
quest.removeItems.addAll(config.getBooleanList("quests." + questName + ".requirements.remove-items"));
reqs.setRemoveItems(config.getBooleanList("quests." + questName + ".requirements.remove-items"));
} else {
skipQuestProcess("remove-items: Requirement for Quest " + quest.getName() + " is not a list of true/false values!");
}
@ -2509,14 +2514,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
if (config.contains("quests." + questName + ".requirements.money")) {
if (config.getInt("quests." + questName + ".requirements.money", -999) != -999) {
quest.moneyReq = config.getInt("quests." + questName + ".requirements.money");
reqs.setMoney(config.getInt("quests." + questName + ".requirements.money"));
} else {
skipQuestProcess("money: Requirement for Quest " + quest.getName() + " is not a number!");
}
}
if (config.contains("quests." + questName + ".requirements.quest-points")) {
if (config.getInt("quests." + questName + ".requirements.quest-points", -999) != -999) {
quest.questPointsReq = config.getInt("quests." + questName + ".requirements.quest-points");
reqs.setQuestPoints(config.getInt("quests." + questName + ".requirements.quest-points"));
} else {
skipQuestProcess("quest-points: Requirement for Quest " + quest.getName() + " is not a number!");
}
@ -2526,11 +2531,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
List<String> names = config.getStringList("quests." + questName + ".requirements.quest-blocks");
boolean failed = false;
String failedQuest = "NULL";
List<String> temp = new LinkedList<String>();
for (String name : names) {
boolean done = false;
for (String string : questsSection.getKeys(false)) {
if (config.getString("quests." + string + ".name").equalsIgnoreCase(name)) {
quest.blockQuests.add(name);
temp.add(name);
done = true;
break;
}
@ -2541,6 +2547,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
break;
}
}
reqs.setNeededQuests(temp);
if (failed) {
skipQuestProcess(new String[] { "" + ChatColor.LIGHT_PURPLE + failedQuest + " inside quests: Requirement for Quest "
+ quest.getName() + " is not a valid Quest name!", "Make sure you aren\'t using the config section identifier." });
@ -2554,11 +2561,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
List<String> names = config.getStringList("quests." + questName + ".requirements.quests");
boolean failed = false;
String failedQuest = "NULL";
List<String> temp = new LinkedList<String>();
for (String name : names) {
boolean done = false;
for (String string : questsSection.getKeys(false)) {
if (config.getString("quests." + string + ".name").equalsIgnoreCase(name)) {
quest.neededQuests.add(name);
temp.add(name);
done = true;
break;
}
@ -2569,6 +2577,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
break;
}
}
reqs.setNeededQuests(temp);
if (failed) {
skipQuestProcess(new String[] { "" + failedQuest + " inside quests: Requirement for Quest "
+ quest.getName() + " is not a valid Quest name!", "Make sure you aren\'t using the config section identifier." });
@ -2579,8 +2588,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
if (config.contains("quests." + questName + ".requirements.permissions")) {
if (Quests.checkList(config.getList("quests." + questName + ".requirements.permissions"), String.class)) {
quest.permissionReqs.clear();
quest.permissionReqs.addAll(config.getStringList("quests." + questName + ".requirements.permissions"));
reqs.setPermissions(config.getStringList("quests." + questName + ".requirements.permissions"));
} else {
skipQuestProcess("permissions: Requirement for Quest " + quest.getName() + " is not a list of permissions!");
}
@ -2594,8 +2602,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (skills.size() != amounts.size()) {
skipQuestProcess("mcmmo-skills: and mcmmo-amounts: in requirements: for Quest " + quest.getName() + " are not the same size!");
}
quest.mcMMOSkillReqs.addAll(skills);
quest.mcMMOAmountReqs.addAll(amounts);
reqs.setMcmmoSkills(skills);
reqs.setMcmmoAmounts(amounts);
} else {
skipQuestProcess("mcmmo-amounts: Requirement for Quest " + quest.getName() + " is not a list of numbers!");
}
@ -2610,7 +2618,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
String className = config.getString("quests." + questName + ".requirements.heroes-primary-class");
HeroClass hc = heroes.getClassManager().getClass(className);
if (hc != null && hc.isPrimary()) {
quest.heroesPrimaryClassReq = hc.getName();
reqs.setHeroesPrimaryClass(hc.getName());
} else if (hc != null) {
skipQuestProcess("heroes-primary-class: Requirement for Quest " + quest.getName() + " is not a primary Heroes class!");
} else {
@ -2621,7 +2629,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
String className = config.getString("quests." + questName + ".requirements.heroes-secondary-class");
HeroClass hc = heroes.getClassManager().getClass(className);
if (hc != null && hc.isSecondary()) {
quest.heroesSecondaryClassReq = hc.getName();
reqs.setHeroesSecondaryClass(hc.getName());
} else if (hc != null) {
skipQuestProcess("heroes-secondary-class: Requirement for Quest " + quest.getName() + " is not a secondary Heroes class!");
} else {
@ -2630,6 +2638,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}
if (config.contains("quests." + questName + ".requirements.custom-requirements")) {
ConfigurationSection sec = config.getConfigurationSection("quests." + questName + ".requirements.custom-requirements");
Map<String, Map<String, Object>> temp = new HashMap<String, Map<String, Object>>();
for (String path : sec.getKeys(false)) {
String name = sec.getString(path + ".name");
Optional<CustomRequirement>found=Optional.empty();
@ -2645,10 +2654,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
}else {
ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data");
Map<String, Object> data=populateCustoms(sec2,found.get().datamap);
quest.customRequirements.put(name, data);
temp.put(name, data);
}
}
reqs.setCustomRequirements(temp);
}
}
@ -3049,8 +3058,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (is != null) {
NPC npc = CitizensAPI.getNPCRegistry().getById(npcId);
if (npc != null) {
oStage.itemsToDeliver.add(is);
oStage.itemDeliveryTargets.add(npcId);
oStage.getItemsToDeliver().add(is);
oStage.getItemDeliveryTargets().add(npcId);
oStage.deliverMessages = deliveryMessages;
} else {
stageFailed("" + npcId + " inside npc-delivery-ids: inside Stage " + s2 + " of Quest " + quest.getName() + " is not a valid NPC id!");

View File

@ -0,0 +1,104 @@
package me.blackvein.quests;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.bukkit.inventory.ItemStack;
public class Requirements {
private int money = 0;
private int questPoints = 0;
private List<ItemStack> items = new LinkedList<ItemStack>();
private List<Boolean> removeItems = new LinkedList<Boolean>();
private List<String> neededQuests = new LinkedList<String>();
private List<String> blockQuests = new LinkedList<String>();
private List<String> permissions = new LinkedList<String>();
private List<String> mcmmoSkills = new LinkedList<String>();
private List<Integer> mcmmoAmounts = new LinkedList<Integer>();
private String heroesPrimaryClass = null;
private String heroesSecondaryClass = null;
private Map<String, Map<String, Object>> customRequirements = new HashMap<String, Map<String, Object>>();
private String failRequirements = null;
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public int getQuestPoints() {
return questPoints;
}
public void setQuestPoints(int questPoints) {
this.questPoints = questPoints;
}
public List<ItemStack> getItems() {
return items;
}
public void setItems(List<ItemStack> items) {
this.items = items;
}
public List<Boolean> getRemoveItems() {
return removeItems;
}
public void setRemoveItems(List<Boolean> removeItems) {
this.removeItems = removeItems;
}
public List<String> getNeededQuests() {
return neededQuests;
}
public void setNeededQuests(List<String> neededQuests) {
this.neededQuests = neededQuests;
}
public List<String> getBlockQuests() {
return blockQuests;
}
public void setBlockQuests(List<String> blockQuests) {
this.blockQuests = blockQuests;
}
public List<String> getPermissions() {
return permissions;
}
public void setPermissions(List<String> permissions) {
this.permissions = permissions;
}
public List<String> getMcmmoSkills() {
return mcmmoSkills;
}
public void setMcmmoSkills(List<String> mcmmoSkills) {
this.mcmmoSkills = mcmmoSkills;
}
public List<Integer> getMcmmoAmounts() {
return mcmmoAmounts;
}
public void setMcmmoAmounts(List<Integer> mcmmoAmounts) {
this.mcmmoAmounts = mcmmoAmounts;
}
public String getHeroesPrimaryClass() {
return heroesPrimaryClass;
}
public void setHeroesPrimaryClass(String heroesPrimaryClass) {
this.heroesPrimaryClass = heroesPrimaryClass;
}
public String getHeroesSecondaryClass() {
return heroesSecondaryClass;
}
public void setHeroesSecondaryClass(String heroesSecondaryClass) {
this.heroesSecondaryClass = heroesSecondaryClass;
}
public Map<String, Map<String, Object>> getCustomRequirements() {
return customRequirements;
}
protected void setCustomRequirements(
Map<String, Map<String, Object>> customRequirements) {
this.customRequirements = customRequirements;
}
public String getFailRequirements() {
return failRequirements;
}
public void setFailRequirements(String failRequirements) {
this.failRequirements = failRequirements;
}
}

View File

@ -35,8 +35,8 @@ public class Stage {
Integer fishToCatch;
Integer playersToKill;
Map<Map<Enchantment, Material>, Integer> itemsToEnchant = new HashMap<Map<Enchantment, Material>, Integer>();
LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
private LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
private LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
private static final long serialVersionUID = -2774443496142382127L;
@ -141,7 +141,7 @@ public class Stage {
if (fishToCatch != null) { return true; }
if (playersToKill != null) { return true; }
if (itemsToEnchant.isEmpty() == false) { return true; }
if (itemsToDeliver.isEmpty() == false) { return true; }
if (getItemsToDeliver().isEmpty() == false) { return true; }
if (citizensToInteract.isEmpty() == false) { return true; }
if (citizensToKill.isEmpty() == false) { return true; }
if (locationsToReach.isEmpty() == false) { return true; }
@ -151,4 +151,20 @@ public class Stage {
if (customObjectives.isEmpty() == false) { return true; }
return false;
}
public LinkedList<ItemStack> getItemsToDeliver() {
return itemsToDeliver;
}
public void setItemsToDeliver(LinkedList<ItemStack> itemsToDeliver) {
this.itemsToDeliver = itemsToDeliver;
}
public LinkedList<Integer> getItemDeliveryTargets() {
return itemDeliveryTargets;
}
public void setItemDeliveryTargets(LinkedList<Integer> itemDeliveryTargets) {
this.itemDeliveryTargets = itemDeliveryTargets;
}
}

View File

@ -114,7 +114,7 @@ public class QuestAcceptPrompt extends StringPrompt {
plugin.conversationFactory.buildConversation((Conversable) player).begin();
}
} else {
player.sendMessage(q.failRequirements);
player.sendMessage(q.getRequirements().getFailRequirements());
}
} else if (quester.currentQuests.containsKey(q) == false) {
String msg = Lang.get("questMaxAllowed");
@ -156,6 +156,6 @@ public class QuestAcceptPrompt extends StringPrompt {
}
private String extracted(final Quester quester) {
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.questToTake, ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.questToTake).description);
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.questToTake, ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.questToTake).getDescription());
}
}