This commit is contained in:
Blackvein 2012-10-22 15:24:36 -07:00
parent 9a3ae8c2c0
commit ed4472a5b3
5 changed files with 535 additions and 371 deletions

View File

@ -2,7 +2,6 @@ package me.blackvein.quests;
import net.citizensnpcs.api.event.NPCDespawnEvent; import net.citizensnpcs.api.event.NPCDespawnEvent;
import net.citizensnpcs.api.event.NPCRightClickEvent; import net.citizensnpcs.api.event.NPCRightClickEvent;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.conversations.Conversable; import org.bukkit.conversations.Conversable;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -26,7 +25,6 @@ public class NpcListener implements Listener{
if (plugin.questNPCs.contains(evt.getNPC())) { if (plugin.questNPCs.contains(evt.getNPC())) {
final Player player = evt.getClicker(); final Player player = evt.getClicker();
final NPC npc = evt.getNPC();
final Quester quester = plugin.getQuester(player.getName()); final Quester quester = plugin.getQuester(player.getName());
if (quester.hasObjective("talkToNPC")) { if (quester.hasObjective("talkToNPC")) {
@ -52,13 +50,43 @@ public class NpcListener implements Listener{
player.sendMessage(s); player.sendMessage(s);
plugin.conversationFactory.buildConversation((Conversable) player).begin(); plugin.conversationFactory.buildConversation((Conversable) player).begin();
}else { } else if (quester.currentQuest.equals(q) == false) {
player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest."); player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest.");
} }
break; break;
} else if (q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q.name) == true) {
if (quester.currentQuest == null) {
if (quester.getDifference(q) > 0) {
player.sendMessage(ChatColor.YELLOW + "You may not take " + ChatColor.AQUA + q.name + ChatColor.YELLOW + " again for another " + ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW + ".");
} else {
quester.questToTake = q.name;
String s =
ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quester.questToTake + ChatColor.GOLD + " -\n"
+ "\n"
+ ChatColor.RESET + plugin.getQuest(quester.questToTake).description + "\n";
player.sendMessage(s);
plugin.conversationFactory.buildConversation((Conversable) player).begin();
}
} else if (quester.currentQuest.equals(q) == false) {
player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest.");
}
break;
} }
} }
@ -73,11 +101,5 @@ public class NpcListener implements Listener{
@EventHandler @EventHandler
public void onNPCDespawn(NPCDespawnEvent evt) { public void onNPCDespawn(NPCDespawnEvent evt) {
} }
} }

View File

@ -60,6 +60,17 @@ public class PlayerListener implements Listener {
} else { } else {
if (quester.completedQuests.contains(q.name)) {
if (q.redoDelay < 0 || q.redoDelay > -1 && (quester.getDifference(q)) > 0) {
player.sendMessage(ChatColor.YELLOW + "You may not take " + ChatColor.AQUA + q.name + ChatColor.YELLOW + " again for another " + ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW + ".");
return;
}
}
quester.questToTake = q.name; quester.questToTake = q.name;
String s = String s =
@ -72,6 +83,7 @@ public class PlayerListener implements Listener {
} }
break;
} }
} }
@ -104,8 +116,9 @@ public class PlayerListener implements Listener {
Quester quester = plugin.getQuester(evt.getPlayer().getName()); Quester quester = plugin.getQuester(evt.getPlayer().getName());
if (quester.hasObjective("placeBlock")) { if (quester.hasObjective("placeBlock")) {
if(evt.isCancelled() == false) if (evt.isCancelled() == false) {
quester.placeBlock(evt.getBlock().getType()); quester.placeBlock(evt.getBlock().getType());
}
} }
@ -123,8 +136,9 @@ public class PlayerListener implements Listener {
Quester quester = plugin.getQuester(evt.getPlayer().getName()); Quester quester = plugin.getQuester(evt.getPlayer().getName());
if (quester.hasObjective("breakBlock")) { if (quester.hasObjective("breakBlock")) {
if(evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false && evt.isCancelled() == false) if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false && evt.isCancelled() == false) {
quester.breakBlock(evt.getBlock().getType()); quester.breakBlock(evt.getBlock().getType());
}
} }
@ -134,8 +148,9 @@ public class PlayerListener implements Listener {
if (quester.blocksPlaced.get(evt.getBlock().getType()) > 0) { if (quester.blocksPlaced.get(evt.getBlock().getType()) > 0) {
if(evt.isCancelled() == false) if (evt.isCancelled() == false) {
quester.blocksPlaced.put(evt.getBlock().getType(), quester.blocksPlaced.get(evt.getBlock().getType()) - 1); quester.blocksPlaced.put(evt.getBlock().getType(), quester.blocksPlaced.get(evt.getBlock().getType()) - 1);
}
} }
@ -259,8 +274,9 @@ public class PlayerListener implements Listener {
((Player) evt.getWhoClicked()).sendMessage(ChatColor.YELLOW + "You may not modify Quest items in your inventory."); ((Player) evt.getWhoClicked()).sendMessage(ChatColor.YELLOW + "You may not modify Quest items in your inventory.");
evt.setCancelled(true); evt.setCancelled(true);
((Player) evt.getWhoClicked()).updateInventory(); ((Player) evt.getWhoClicked()).updateInventory();
}else if(evt.getInventory().getType().equals(InventoryType.CHEST) == true && evt.getRawSlot() < 53) } else if (evt.getInventory().getType().equals(InventoryType.CHEST) == true && evt.getRawSlot() < 53) {
quester.collectItem(evt.getCurrentItem()); quester.collectItem(evt.getCurrentItem());
}
} }
@ -291,15 +307,17 @@ public class PlayerListener implements Listener {
boolean okay = true; boolean okay = true;
if (plugin.citizens != null) { if (plugin.citizens != null) {
if(plugin.citizens.getNPCRegistry().isNPC(player)) if (plugin.citizens.getNPCRegistry().isNPC(player)) {
okay = false; okay = false;
} }
}
if (okay) { if (okay) {
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getName());
if(quester.hasObjective("killMob")) if (quester.hasObjective("killMob")) {
quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType()); quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType());
}
} }
} }
@ -309,16 +327,18 @@ public class PlayerListener implements Listener {
boolean okay = true; boolean okay = true;
if (plugin.citizens != null) { if (plugin.citizens != null) {
if(plugin.citizens.getNPCRegistry().isNPC(damager)) if (plugin.citizens.getNPCRegistry().isNPC(damager)) {
okay = false; okay = false;
} }
}
if (okay) { if (okay) {
Player player = (Player) damager; Player player = (Player) damager;
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getName());
if(quester.hasObjective("killMob")) if (quester.hasObjective("killMob")) {
quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType()); quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType());
}
} }
} }
@ -350,15 +370,17 @@ public class PlayerListener implements Listener {
boolean okay = true; boolean okay = true;
if (plugin.citizens != null) { if (plugin.citizens != null) {
if(plugin.citizens.getNPCRegistry().isNPC(player) || plugin.citizens.getNPCRegistry().isNPC(evt.getEntity())) if (plugin.citizens.getNPCRegistry().isNPC(player) || plugin.citizens.getNPCRegistry().isNPC(evt.getEntity())) {
okay = false; okay = false;
} }
}
if (okay) { if (okay) {
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getName());
if(quester.hasObjective("killPlayer")) if (quester.hasObjective("killPlayer")) {
quester.killPlayer(evt.getEntity().getName()); quester.killPlayer(evt.getEntity().getName());
}
} }
@ -371,16 +393,18 @@ public class PlayerListener implements Listener {
if (plugin.citizens != null) { if (plugin.citizens != null) {
if(plugin.citizens.getNPCRegistry().isNPC(player) || plugin.citizens.getNPCRegistry().isNPC(evt.getEntity())) if (plugin.citizens.getNPCRegistry().isNPC(player) || plugin.citizens.getNPCRegistry().isNPC(evt.getEntity())) {
okay = false; okay = false;
}
} }
if (okay) { if (okay) {
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getName());
if(quester.hasObjective("killPlayer")) if (quester.hasObjective("killPlayer")) {
quester.killPlayer(evt.getEntity().getName()); quester.killPlayer(evt.getEntity().getName());
}
} }
} }
@ -396,8 +420,9 @@ public class PlayerListener implements Listener {
Player player = evt.getPlayer(); Player player = evt.getPlayer();
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getName());
if(quester.hasObjective("catchFish") && evt.getState().equals(State.CAUGHT_FISH)) if (quester.hasObjective("catchFish") && evt.getState().equals(State.CAUGHT_FISH)) {
quester.catchFish(); quester.catchFish();
}
} }
@ -436,8 +461,9 @@ public class PlayerListener implements Listener {
if (q.name.equalsIgnoreCase(s)) { if (q.name.equalsIgnoreCase(s)) {
if(quester.completedTimes.containsKey(q.name) == false && q.redoDelay > -1) if (quester.completedTimes.containsKey(q.name) == false && q.redoDelay > -1) {
quester.completedTimes.put(q.name, System.currentTimeMillis()); quester.completedTimes.put(q.name, System.currentTimeMillis());
}
} }
@ -464,9 +490,10 @@ public class PlayerListener implements Listener {
boolean isPlayer = true; boolean isPlayer = true;
if (plugin.getServer().getPluginManager().getPlugin("Citizens") != null) { if (plugin.getServer().getPluginManager().getPlugin("Citizens") != null) {
if(plugin.citizens.getNPCRegistry().isNPC(evt.getPlayer())) if (plugin.citizens.getNPCRegistry().isNPC(evt.getPlayer())) {
isPlayer = false; isPlayer = false;
} }
}
if (isPlayer) { if (isPlayer) {
@ -481,5 +508,4 @@ public class PlayerListener implements Listener {
} }
} }
} }

View File

@ -44,6 +44,8 @@ public class Quester {
LinkedList<Location> locationsToKillWithin = new LinkedList<Location>(); LinkedList<Location> locationsToKillWithin = new LinkedList<Location>();
LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>(); LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>();
Map<NPC, Boolean> citizensInteracted = new HashMap<NPC, Boolean>(); Map<NPC, Boolean> citizensInteracted = new HashMap<NPC, Boolean>();
LinkedList<NPC> citizensKilled = new LinkedList<NPC>();
LinkedList<Integer> citizenNumKilled = new LinkedList<Integer>();
LinkedList<Location> locationsReached = new LinkedList<Location>(); LinkedList<Location> locationsReached = new LinkedList<Location>();
LinkedList<Boolean> hasReached = new LinkedList<Boolean>(); LinkedList<Boolean> hasReached = new LinkedList<Boolean>();
LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>(); LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>();
@ -358,7 +360,7 @@ public class Quester {
if (((Boolean) e.getValue()) == false) { if (((Boolean) e.getValue()) == false) {
unfinishedObjectives.add(ChatColor.GREEN + "Talk to " + n.getName()); unfinishedObjectives.add(ChatColor.GREEN + "Talk to " + n.getFullName());
} else { } else {
@ -372,6 +374,24 @@ public class Quester {
} }
for (NPC n : currentStage.citizensToKill) {
for (NPC n2 : citizensKilled) {
if (citizenNumKilled.get(citizensKilled.indexOf(n2)) < currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))) {
unfinishedObjectives.add(ChatColor.GREEN + "Kill " + n.getFullName() + ChatColor.GREEN);
} else {a
finishedObjectives.add(ChatColor.GRAY + "Kill " + n.getFullName());
}
}
}
for (Entry e : currentStage.mobsToTame.entrySet()) { for (Entry e : currentStage.mobsToTame.entrySet()) {
for (Entry e2 : mobsTamed.entrySet()) { for (Entry e2 : mobsTamed.entrySet()) {
@ -1056,7 +1076,7 @@ public class Quester {
} else if (objective.equalsIgnoreCase("killNPC")) { } else if (objective.equalsIgnoreCase("killNPC")) {
String message = ChatColor.GREEN + "(Completed) Kill " + npc.getName(); String message = ChatColor.GREEN + "(Completed) Kill " + npc.getName();
message = message + " " + currentStage.citizenNumToKill. message = message + " " + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(npc)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(npc));
p.sendMessage(message); p.sendMessage(message);
if (testComplete()) { if (testComplete()) {
currentQuest.nextStage(this); currentQuest.nextStage(this);
@ -1204,6 +1224,15 @@ public class Quester {
} }
} }
if (currentStage.citizensToKill.isEmpty() == false) {
for (NPC n : currentStage.citizensToKill) {
citizensKilled.add(n);
citizenNumKilled.add(0);
}
}
if (currentStage.blocksToCut.isEmpty() == false) { if (currentStage.blocksToCut.isEmpty() == false) {
for (Material m : currentStage.blocksToCut.keySet()) { for (Material m : currentStage.blocksToCut.keySet()) {
@ -1264,6 +1293,8 @@ public class Quester {
radiiToKillWithin.clear(); radiiToKillWithin.clear();
playersKilled = 0; playersKilled = 0;
citizensInteracted.clear(); citizensInteracted.clear();
citizensKilled.clear();
citizenNumKilled.clear();
locationsReached.clear(); locationsReached.clear();
hasReached.clear(); hasReached.clear();
radiiToReachWithin.clear(); radiiToReachWithin.clear();
@ -1726,6 +1757,21 @@ public class Quester {
} }
if(citizensKilled.isEmpty() == false) {
LinkedList<Integer> npcIds = new LinkedList<Integer>();
for (NPC n : citizensKilled) {
npcIds.add(n.getId());
}
data.set("citizen-ids-killed", npcIds);
data.set("citizen-amounts-killed", citizenNumKilled);
}
if (locationsReached.isEmpty() == false) { if (locationsReached.isEmpty() == false) {
LinkedList<String> locations = new LinkedList<String>(); LinkedList<String> locations = new LinkedList<String>();
@ -2304,6 +2350,20 @@ public class Quester {
} }
if (data.contains("citizen-ids-killed")) {
List<Integer> ids = data.getIntegerList("citizen-ids-killed");
List<Integer> num = data.getIntegerList("citizen-amounts-killed");
for (int i : ids) {
citizensKilled.add(plugin.citizens.getNPCRegistry().getById(i));
citizenNumKilled.add(num.get(ids.indexOf(i)));
}
}
if (data.contains("locations-to-reach")) { if (data.contains("locations-to-reach")) {
LinkedList<Location> locations = new LinkedList<Location>(); LinkedList<Location> locations = new LinkedList<Location>();

View File

@ -64,13 +64,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
pListener = new PlayerListener(this); pListener = new PlayerListener(this);
npcListener = new NpcListener(this); npcListener = new NpcListener(this);
this.conversationFactory = new ConversationFactory(this) this.conversationFactory = new ConversationFactory(this).withModality(false).withPrefix(new SummoningConversationPrefix()).withFirstPrompt(new QuestPrompt()).withTimeout(20).thatExcludesNonPlayersWithMessage("Console may not perform this conversation!").addConversationAbandonedListener(this);
.withModality(false)
.withPrefix(new SummoningConversationPrefix())
.withFirstPrompt(new QuestPrompt())
.withTimeout(20)
.thatExcludesNonPlayersWithMessage("Console may not perform this conversation!")
.addConversationAbandonedListener(this);
questFactory = new QuestFactory(this); questFactory = new QuestFactory(this);
@ -187,10 +181,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
@Override @Override
public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent) { public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent) {
} }
private class QuestPrompt extends FixedSetPrompt { private class QuestPrompt extends FixedSetPrompt {
public QuestPrompt() { public QuestPrompt() {
super("Yes", "No"); super("Yes", "No");
} }
@ -229,10 +223,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
return ChatColor.GREEN + "Quests: " + ChatColor.GRAY; return ChatColor.GREEN + "Quests: " + ChatColor.GRAY;
} }
} }
public void loadConfig() { public void loadConfig() {
FileConfiguration config = getConfig(); FileConfiguration config = getConfig();
@ -285,9 +277,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
questFactory.convoCreator.buildConversation((Conversable) cs).begin(); questFactory.convoCreator.buildConversation((Conversable) cs).begin();
} } else if (cmd.getName().equalsIgnoreCase("quest")) {
else if (cmd.getName().equalsIgnoreCase("quest")) {
if (cs instanceof Player) { if (cs instanceof Player) {
@ -1358,9 +1348,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
if (config.contains("quests." + s + ".block-start")) { if (config.contains("quests." + s + ".block-start")) {
Location location = getLocation(config.getString("quests." + s + ".block-start")); Location location = getLocation(config.getString("quests." + s + ".block-start"));
if(location != null) if (location != null) {
quest.blockStart = location; quest.blockStart = location;
else{ } else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "block-start: " + ChatColor.GOLD + "for Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not in proper location format!"); printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "block-start: " + ChatColor.GOLD + "for Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not in proper location format!");
printSevere(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); printSevere(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
continue; continue;
@ -2683,9 +2673,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
Event evt = Event.getEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".event"), this, quest); Event evt = Event.getEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".event"), this, quest);
if( evt != null) if (evt != null) {
stage.event = evt; stage.event = evt;
else{ } else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "Event " + ChatColor.GOLD + "in " + ChatColor.LIGHT_PURPLE + "Stage " + s2 + ChatColor.GOLD + " of Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " failed to load."); printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "Event " + ChatColor.GOLD + "in " + ChatColor.LIGHT_PURPLE + "Stage " + s2 + ChatColor.GOLD + " of Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " failed to load.");
stageFailed = true; stageFailed = true;
break; break;
@ -2729,8 +2719,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
} }
if(failed) if (failed) {
continue; continue;
}
} else { } else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "item-amounts: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of numbers!"); printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "item-amounts: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of numbers!");
@ -2773,9 +2764,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
if (config.contains("quests." + s + ".rewards.commands")) { if (config.contains("quests." + s + ".rewards.commands")) {
if(Quests.checkList(config.getList("quests." + s + ".rewards.commands"), String.class)) if (Quests.checkList(config.getList("quests." + s + ".rewards.commands"), String.class)) {
quest.commands = config.getStringList("quests." + s + ".rewards.commands"); quest.commands = config.getStringList("quests." + s + ".rewards.commands");
else{ } else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "commands: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of commands!"); printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "commands: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of commands!");
continue; continue;
} }
@ -2784,9 +2775,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
if (config.contains("quests." + s + ".rewards.permissions")) { if (config.contains("quests." + s + ".rewards.permissions")) {
if(Quests.checkList(config.getList("quests." + s + ".rewards.permissions"), String.class)) if (Quests.checkList(config.getList("quests." + s + ".rewards.permissions"), String.class)) {
quest.permissions = config.getStringList("quests." + s + ".rewards.permissions"); quest.permissions = config.getStringList("quests." + s + ".rewards.permissions");
else{ } else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "permissions: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of permissions!"); printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "permissions: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of permissions!");
continue; continue;
} }
@ -2817,9 +2808,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
if (config.contains("quests." + s + ".rewards.heroes-class")) { if (config.contains("quests." + s + ".rewards.heroes-class")) {
if(heroes.getClassManager().getClass("quests." + s + ".rewards.heroes-class") != null) if (heroes.getClassManager().getClass("quests." + s + ".rewards.heroes-class") != null) {
quest.heroesClass = config.getString("quests." + s + ".rewards.heroes-class"); quest.heroesClass = config.getString("quests." + s + ".rewards.heroes-class");
else{ } else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "heroes-class: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a valid Heroes class name!"); printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "heroes-class: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a valid Heroes class name!");
continue; continue;
} }
@ -2828,9 +2819,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
if (config.contains("quests." + s + ".rewards.heroes-secondary-class")) { if (config.contains("quests." + s + ".rewards.heroes-secondary-class")) {
if(heroes.getClassManager().getClass("quests." + s + ".rewards.heroes-secondary-class") != null) if (heroes.getClassManager().getClass("quests." + s + ".rewards.heroes-secondary-class") != null) {
quest.heroesSecClass = config.getString("quests." + s + ".rewards.heroes-secondary-class"); quest.heroesSecClass = config.getString("quests." + s + ".rewards.heroes-secondary-class");
else{ } else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "heroes-secondary-class: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a valid Heroes secondary class name!"); printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "heroes-secondary-class: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a valid Heroes secondary class name!");
continue; continue;
} }
@ -2853,8 +2844,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
} }
} }
if(failed) if (failed) {
continue; continue;
}
quest.mcmmoSkills = config.getStringList("quests." + s + ".rewards.mcmmo-skills"); quest.mcmmoSkills = config.getStringList("quests." + s + ".rewards.mcmmo-skills");
quest.mcmmoAmounts = config.getIntegerList("quests." + s + ".rewards.mcmmo-levels"); quest.mcmmoAmounts = config.getIntegerList("quests." + s + ".rewards.mcmmo-levels");
@ -3218,8 +3210,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
public static Location getLocation(String arg) { public static Location getLocation(String arg) {
String[] info = arg.split(" "); String[] info = arg.split(" ");
if(info.length != 4) if (info.length != 4) {
return null; return null;
}
double x; double x;
double y; double y;
@ -3233,8 +3226,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
return null; return null;
} }
if(Bukkit.getServer().getWorld(info[0]) == null) if (Bukkit.getServer().getWorld(info[0]) == null) {
return null; return null;
}
Location finalLocation = new Location(Bukkit.getServer().getWorld(info[0]), x, y, z); Location finalLocation = new Location(Bukkit.getServer().getWorld(info[0]), x, y, z);
@ -3553,16 +3547,18 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
public static String getCurrency(boolean plural) { public static String getCurrency(boolean plural) {
if (plural) { if (plural) {
if(Quests.economy.currencyNamePlural().trim().isEmpty()) if (Quests.economy.currencyNamePlural().trim().isEmpty()) {
return "Money"; return "Money";
else
return Quests.economy.currencyNamePlural();
} else { } else {
if(Quests.economy.currencyNameSingular().trim().isEmpty()) return Quests.economy.currencyNamePlural();
}
} else {
if (Quests.economy.currencyNameSingular().trim().isEmpty()) {
return "Money"; return "Money";
else } else {
return Quests.economy.currencyNameSingular(); return Quests.economy.currencyNameSingular();
} }
}
} }
@ -3626,9 +3622,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
public Quest getQuest(String s) { public Quest getQuest(String s) {
for (Quest q : quests) { for (Quest q : quests) {
if(q.name.equalsIgnoreCase(s)) if (q.name.equalsIgnoreCase(s)) {
return q; return q;
} }
}
return null; return null;
} }

View File

@ -15,48 +15,77 @@ import org.bukkit.entity.EntityType;
public class Stage { public class Stage {
public String finished; public String finished;
Map<Material, Integer> blocksToDamage = new EnumMap<Material, Integer>(Material.class); Map<Material, Integer> blocksToDamage = new EnumMap<Material, Integer>(Material.class);
Map<Material, Integer> blocksToBreak = new EnumMap<Material, Integer>(Material.class); Map<Material, Integer> blocksToBreak = new EnumMap<Material, Integer>(Material.class);
Map<Material, Integer> blocksToPlace = new EnumMap<Material, Integer>(Material.class); Map<Material, Integer> blocksToPlace = new EnumMap<Material, Integer>(Material.class);
Map<Map<Material, Integer>, Boolean> itemsToCollect = new HashMap<Map<Material, Integer>, Boolean>(); Map<Map<Material, Integer>, Boolean> itemsToCollect = new HashMap<Map<Material, Integer>, Boolean>();
Map<Material, Integer> blocksToUse = new EnumMap<Material, Integer>(Material.class); Map<Material, Integer> blocksToUse = new EnumMap<Material, Integer>(Material.class);
Map<Material, Integer> blocksToCut = new EnumMap<Material, Integer>(Material.class); Map<Material, Integer> blocksToCut = new EnumMap<Material, Integer>(Material.class);
Integer fishToCatch; Integer fishToCatch;
Integer playersToKill; Integer playersToKill;
Map<Map<Enchantment, Material>, Integer> itemsToEnchant = new HashMap<Map<Enchantment, Material>, Integer>(); Map<Map<Enchantment, Material>, Integer> itemsToEnchant = new HashMap<Map<Enchantment, Material>, Integer>();
LinkedList<EntityType> mobsToKill = new LinkedList<EntityType>(); LinkedList<EntityType> mobsToKill = new LinkedList<EntityType>();
LinkedList<Integer> mobNumToKill = new LinkedList<Integer>(); LinkedList<Integer> mobNumToKill = new LinkedList<Integer>();
LinkedList<Location> locationsToKillWithin = new LinkedList<Location>(); LinkedList<Location> locationsToKillWithin = new LinkedList<Location>();
LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>(); LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>();
LinkedList<String> areaNames = new LinkedList<String>(); LinkedList<String> areaNames = new LinkedList<String>();
LinkedList<NPC> citizensToInteract = new LinkedList<NPC>(){
LinkedList<NPC> citizensToInteract = new LinkedList<NPC>(); @Override
public boolean equals(Object o) {
LinkedList<NPC> citizensToKill = new LinkedList<NPC>(); if (o instanceof LinkedList) {
LinkedList<NPC> otherList = (LinkedList<NPC>) o;
for (NPC n : this) {
NPC other = otherList.get(this.indexOf(n));
if (other.getId() != n.getId()) {
return false;
}
}
}
return true;
}
};
LinkedList<NPC> citizensToKill = new LinkedList<NPC>() {
@Override
public boolean equals(Object o) {
if (o instanceof LinkedList) {
LinkedList<NPC> otherList = (LinkedList<NPC>) o;
for (NPC n : this) {
NPC other = otherList.get(this.indexOf(n));
if (other.getId() != n.getId()) {
return false;
}
}
}
return true;
}
};
LinkedList<Integer> citizenNumToKill = new LinkedList<Integer>(); LinkedList<Integer> citizenNumToKill = new LinkedList<Integer>();
LinkedList<Location> locationsToReach = new LinkedList<Location>(); LinkedList<Location> locationsToReach = new LinkedList<Location>();
LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>(); LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>();
LinkedList<World> worldsToReachWithin = new LinkedList<World>(); LinkedList<World> worldsToReachWithin = new LinkedList<World>();
LinkedList<String> locationNames = new LinkedList<String>(); LinkedList<String> locationNames = new LinkedList<String>();
Map<EntityType, Integer> mobsToTame = new EnumMap<EntityType, Integer>(EntityType.class); Map<EntityType, Integer> mobsToTame = new EnumMap<EntityType, Integer>(EntityType.class);
Map<DyeColor, Integer> sheepToShear = new EnumMap<DyeColor, Integer>(DyeColor.class); Map<DyeColor, Integer> sheepToShear = new EnumMap<DyeColor, Integer>(DyeColor.class);
Map<Material, Integer> itemsToCraft = new EnumMap<Material, Integer>(Material.class); Map<Material, Integer> itemsToCraft = new EnumMap<Material, Integer>(Material.class);
String script; String script;
Event event; Event event;
@Override @Override
@ -67,116 +96,146 @@ public class Stage {
Stage other = (Stage) o; Stage other = (Stage) o;
if (other.finished != null && finished != null) { if (other.finished != null && finished != null) {
if(other.finished.equals(finished) == false) if (other.finished.equals(finished) == false) {
return false; return false;
}
} else if (other.finished != null && finished == null) { } else if (other.finished != null && finished == null) {
return false; return false;
}else if(other.finished == null && finished != null) } else if (other.finished == null && finished != null) {
return false; return false;
}
if(other.blocksToDamage.equals(blocksToDamage) == false) if (other.blocksToDamage.equals(blocksToDamage) == false) {
return false; return false;
}
if(other.blocksToBreak.equals(blocksToBreak) == false) if (other.blocksToBreak.equals(blocksToBreak) == false) {
return false; return false;
}
if(other.blocksToPlace.equals(blocksToPlace) == false) if (other.blocksToPlace.equals(blocksToPlace) == false) {
return false; return false;
}
if(other.itemsToCollect.equals(itemsToCollect) == false) if (other.itemsToCollect.equals(itemsToCollect) == false) {
return false; return false;
}
if(other.blocksToUse.equals(blocksToUse) == false) if (other.blocksToUse.equals(blocksToUse) == false) {
return false; return false;
}
if(other.blocksToCut.equals(blocksToCut) == false) if (other.blocksToCut.equals(blocksToCut) == false) {
return false; return false;
}
if (other.fishToCatch != null && fishToCatch != null) { if (other.fishToCatch != null && fishToCatch != null) {
if(other.fishToCatch.equals(fishToCatch) == false) if (other.fishToCatch.equals(fishToCatch) == false) {
return false; return false;
}
} else if (other.fishToCatch != null && fishToCatch == null) { } else if (other.fishToCatch != null && fishToCatch == null) {
return false; return false;
}else if(other.fishToCatch == null && fishToCatch != null) } else if (other.fishToCatch == null && fishToCatch != null) {
return false; return false;
}
if (other.playersToKill != null && playersToKill != null) { if (other.playersToKill != null && playersToKill != null) {
if(other.playersToKill.equals(playersToKill) == false) if (other.playersToKill.equals(playersToKill) == false) {
return false; return false;
}
} else if (other.playersToKill != null && playersToKill == null) { } else if (other.playersToKill != null && playersToKill == null) {
return false; return false;
}else if(other.playersToKill == null && playersToKill != null) } else if (other.playersToKill == null && playersToKill != null) {
return false; return false;
}
if(other.itemsToEnchant.equals(itemsToEnchant) == false) if (other.itemsToEnchant.equals(itemsToEnchant) == false) {
return false; return false;
}
if(other.mobsToKill.equals(mobsToKill) == false) if (other.mobsToKill.equals(mobsToKill) == false) {
return false; return false;
}
if(other.mobNumToKill.equals(mobNumToKill) == false) if (other.mobNumToKill.equals(mobNumToKill) == false) {
return false; return false;
}
if(other.locationsToKillWithin.equals(locationsToKillWithin) == false) if (other.locationsToKillWithin.equals(locationsToKillWithin) == false) {
return false; return false;
}
if(other.radiiToKillWithin.equals(radiiToKillWithin) == false) if (other.radiiToKillWithin.equals(radiiToKillWithin) == false) {
return false; return false;
}
if(other.areaNames.equals(areaNames) == false) if (other.areaNames.equals(areaNames) == false) {
return false; return false;
}
if(other.citizensToInteract.equals(citizensToInteract) == false) if (other.citizensToInteract.equals(citizensToInteract) == false) {
return false; return false;
}
if(other.citizensToKill.equals(citizensToKill) == false) if (other.citizensToKill.equals(citizensToKill) == false) {
return false; return false;
}
if(other.citizenNumToKill.equals(citizenNumToKill) == false) if (other.citizenNumToKill.equals(citizenNumToKill) == false) {
return false; return false;
}
if(other.locationsToReach.equals(locationsToReach) == false) if (other.locationsToReach.equals(locationsToReach) == false) {
return false; return false;
}
if(other.radiiToReachWithin.equals(radiiToReachWithin) == false) if (other.radiiToReachWithin.equals(radiiToReachWithin) == false) {
return false; return false;
}
if(other.worldsToReachWithin.equals(worldsToReachWithin) == false) if (other.worldsToReachWithin.equals(worldsToReachWithin) == false) {
return false; return false;
}
if(other.locationNames.equals(locationNames) == false) if (other.locationNames.equals(locationNames) == false) {
return false; return false;
}
if(other.mobsToTame.equals(mobsToTame) == false) if (other.mobsToTame.equals(mobsToTame) == false) {
return false; return false;
}
if(other.sheepToShear.equals(sheepToShear) == false) if (other.sheepToShear.equals(sheepToShear) == false) {
return false; return false;
}
if(other.itemsToCraft.equals(itemsToCraft) == false) if (other.itemsToCraft.equals(itemsToCraft) == false) {
return false; return false;
}
if (other.script != null && script != null) { if (other.script != null && script != null) {
if(other.script.equals(script) == false) if (other.script.equals(script) == false) {
return false; return false;
}
} else if (other.script != null && script == null) { } else if (other.script != null && script == null) {
return false; return false;
}else if(other.script == null && script != null) } else if (other.script == null && script != null) {
return false; return false;
}
if (other.event != null && event != null) { if (other.event != null && event != null) {
if(other.event.equals(event) == false) if (other.event.equals(event) == false) {
return false; return false;
}
} else if (other.event != null && event == null) { } else if (other.event != null && event == null) {
return false; return false;
}else if(other.event == null && event != null) } else if (other.event == null && event != null) {
return false; return false;
}
} }
return true; return true;
} }
} }