This commit is contained in:
Blackvein 2012-10-22 12:04:26 -07:00
parent bb453202f2
commit 9a3ae8c2c0
6 changed files with 98 additions and 13 deletions

View File

@ -1,11 +1,13 @@
package me.blackvein.quests; package me.blackvein.quests;
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 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;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
public class NpcListener implements Listener{ public class NpcListener implements Listener{
@ -18,7 +20,7 @@ public class NpcListener implements Listener{
} }
@EventHandler @EventHandler(priority = EventPriority.LOWEST)
public void onNPCRightClick(NPCRightClickEvent evt){ public void onNPCRightClick(NPCRightClickEvent evt){
if(plugin.questNPCs.contains(evt.getNPC())){ if(plugin.questNPCs.contains(evt.getNPC())){
@ -68,5 +70,14 @@ public class NpcListener implements Listener{
} }
} }
@EventHandler
public void onNPCDespawn(NPCDespawnEvent evt){
}
} }

View File

@ -1053,6 +1053,15 @@ public class Quester {
currentQuest.nextStage(this); currentQuest.nextStage(this);
} }
} else if (objective.equalsIgnoreCase("killNPC")) {
String message = ChatColor.GREEN + "(Completed) Kill " + npc.getName();
message = message + " " + currentStage.citizenNumToKill.
p.sendMessage(message);
if (testComplete()) {
currentQuest.nextStage(this);
}
} else if (objective.equalsIgnoreCase("tameMob")) { } else if (objective.equalsIgnoreCase("tameMob")) {
String message = ChatColor.GREEN + "(Completed) Tame " + getCapitalized(mob.getName()); String message = ChatColor.GREEN + "(Completed) Tame " + getCapitalized(mob.getName());

View File

@ -1334,6 +1334,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
Quest quest = new Quest(); Quest quest = new Quest();
failedToLoad = false; failedToLoad = false;
if (config.contains("quests." + s + ".name")) {
quest.name = parseString(config.getString("quests." + s + ".name"), quest);
} else {
printSevere(ChatColor.GOLD + "[Quests] Quest block \'" + ChatColor.DARK_PURPLE + s + ChatColor.GOLD + "\' is missing " + ChatColor.RED + "name:");
continue;
}
if (config.contains("quests." + s + ".npc-giver-id")) { if (config.contains("quests." + s + ".npc-giver-id")) {
if(citizens.getNPCRegistry().getById(config.getInt("quests." + s + ".npc-giver-id")) != null){ if(citizens.getNPCRegistry().getById(config.getInt("quests." + s + ".npc-giver-id")) != null){
@ -1372,13 +1379,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
} }
if (config.contains("quests." + s + ".name")) {
quest.name = parseString(config.getString("quests." + s + ".name"), quest);
} else {
printSevere(ChatColor.GOLD + "[Quests] Quest block \'" + ChatColor.DARK_PURPLE + s + ChatColor.GOLD + "\' is missing " + ChatColor.RED + "name:");
continue;
}
if (config.contains("quests." + s + ".ask-message")) { if (config.contains("quests." + s + ".ask-message")) {
quest.description = parseString(config.getString("quests." + s + ".ask-message"), quest); quest.description = parseString(config.getString("quests." + s + ".ask-message"), quest);
} else { } else {
@ -2021,6 +2021,61 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener{
} }
} }
List<Integer> npcIdsToKill;
List<Integer> npcKillAmounts;
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".npc-ids-to-kill")) {
if (checkList(config.getList("quests." + s + ".stages.ordered." + s2 + ".npc-ids-to-kill"), Integer.class)) {
if(config.contains("quests." + s + ".stages.ordered." + s2 + ".npc-kill-amounts")){
if(checkList(config.getList("quests." + s + ".stages.ordered." + s2 + ".npc-kill-amounts"), Integer.class)) {
npcIdsToKill = config.getIntegerList("quests." + s + ".stages.ordered." + s2 + ".npc-ids-to-kill");
npcKillAmounts = config.getIntegerList("quests." + s + ".stages.ordered." + s2 + ".npc-kill-amounts");
for (int i : npcIdsToKill) {
if (citizens.getNPCRegistry().getById(i) != null) {
if(npcKillAmounts.get(npcIdsToKill.indexOf(i)) > 0){
stage.citizensToKill.add(citizens.getNPCRegistry().getById(i));
stage.citizenNumToKill.add(npcKillAmounts.get(npcIdsToKill.indexOf(i)));
questNPCs.add(citizens.getNPCRegistry().getById(i));
}else{
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + npcKillAmounts.get(npcIdsToKill.indexOf(i)) + ChatColor.GOLD + " inside " + ChatColor.GREEN + "npc-kill-amounts: " + ChatColor.GOLD + "inside " + ChatColor.LIGHT_PURPLE + "Stage " + s2 + ChatColor.GOLD + " of Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a positive number!");
stageFailed = true;
break;
}
} else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + i + ChatColor.GOLD + " inside " + ChatColor.GREEN + "npc-ids-to-kill: " + ChatColor.GOLD + "inside " + ChatColor.LIGHT_PURPLE + "Stage " + s2 + ChatColor.GOLD + " of Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a valid NPC id!");
stageFailed = true;
break;
}
}
} else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "npc-kill-amounts: " + ChatColor.GOLD + "in " + ChatColor.LIGHT_PURPLE + "Stage " + s2 + ChatColor.GOLD + " of Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of numbers!");
stageFailed = true;
break;
}
} else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.LIGHT_PURPLE + "Stage " + s2 + ChatColor.GOLD + " of Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is missing " + ChatColor.RED + "npc-kill-amounts:");
stageFailed = true;
break;
}
} else {
printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "npc-ids-to-kill: " + ChatColor.GOLD + "in " + ChatColor.LIGHT_PURPLE + "Stage " + s2 + ChatColor.GOLD + " of Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a list of numbers!");
stageFailed = true;
break;
}
}
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".mobs-to-kill")) { if (config.contains("quests." + s + ".stages.ordered." + s2 + ".mobs-to-kill")) {

View File

@ -4,13 +4,13 @@ import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
public class Stage { public class Stage {
@ -40,6 +40,9 @@ public class Stage {
LinkedList<String> areaNames = new LinkedList<String>(); LinkedList<String> areaNames = new LinkedList<String>();
LinkedList<NPC> citizensToInteract = new LinkedList<NPC>(); LinkedList<NPC> citizensToInteract = new LinkedList<NPC>();
LinkedList<NPC> citizensToKill = new LinkedList<NPC>();
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>();
@ -125,6 +128,12 @@ public class Stage {
if(other.citizensToInteract.equals(citizensToInteract) == false) if(other.citizensToInteract.equals(citizensToInteract) == false)
return false; return false;
if(other.citizensToKill.equals(citizensToKill) == false)
return false;
if(other.citizenNumToKill.equals(citizenNumToKill) == false)
return false;
if(other.locationsToReach.equals(locationsToReach) == false) if(other.locationsToReach.equals(locationsToReach) == false)
return false; return false;

View File

@ -212,7 +212,7 @@ public class RequirementPrompt extends FixedSetPrompt{
if(context.getSessionData("itemIdReqs") == null){ if(context.getSessionData("itemIdReqs") == null){
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set item IDs (None set)\n"; text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set item IDs (None set)\n";
text += GRAY + "2 - Set item amounts (No IDs set)\n"; text += GRAY + "2 - Set item amounts (No IDs set)\n";
text += GRAY + "3 - Set remove items (No IDs set)"; text += GRAY + "3 - Set remove items (No IDs set)\n";
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Clear\n"; text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Clear\n";
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Done"; text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Done";
}else{ }else{

View File

@ -6,6 +6,7 @@ quests:
requirements: requirements:
item-ids: [270] item-ids: [270]
item-amounts: [1] item-amounts: [1]
remove-items: [false]
fail-requirement-message: '<red>You must have a <purple>Wooden Pickaxe<red> first.' fail-requirement-message: '<red>You must have a <purple>Wooden Pickaxe<red> first.'
stages: stages:
ordered: ordered: