diff --git a/pom.xml b/pom.xml
index 13dc81139..e6620e441 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,129 +1,110 @@
-
- 4.0.0
+
+ 4.0.0
- me.blackvein.quests
- quests
- 1.6.7-SNAPSHOT
- quests
- http://dev.bukkit.org/server-mods/quests/
- jar
-
+ me.blackvein.quests
+ quests
+ 1.6.7-SNAPSHOT
+ quests
+ http://dev.bukkit.org/server-mods/quests/
+ jar
+
-
- UTF-8
- ${project.basedir}/lib
-
+
+ UTF-8
+
-
-
- bukkit-repo
- http://repo.bukkit.org/content/groups/public
-
-
+
+
+ bukkit-repo
+ http://repo.bukkit.org/content/groups/public
+
+
citizens-repo
http://repo.citizensnpcs.com
-
- denizens-repo
- http://repo.citizensnpcs.com
-
-
- vault-repo
- http://ci.herocraftonline.com/plugin/repository/everything
-
-
- mcMMO-repo
- http://repo.mcmmo.org
-
+
+ denizens-repo
+ http://repo.citizensnpcs.com
+
+
+ vault-repo
+ http://ci.herocraftonline.com/plugin/repository/everything
+
+
+ mcMMO-repo
+ http://repo.mcmmo.org
+
-
+
-
-
- org.bukkit
- craftbukkit
- LATEST
-
-
- net.citizensnpcs
- citizens
- 2.0.9-SNAPSHOT
-
-
- net.aufdemrand
- denizen
- 0.9.2-SNAPSHOT
-
-
- net.milkbowl.vault
- Vault
- 1.2.22-SNAPSHOT
-
-
- com.gmail.nossr50.mcMMO
- mcMMO
- LATEST
-
-
- me.ThaH3lper
- EpicBoss
- 1.0
- system
- ${libs.dir}/EpicBossRecoded.jar
-
-
+
+
+ org.bukkit
+ craftbukkit
+ LATEST
+
+
+ net.citizensnpcs
+ citizens
+ 2.0.9-SNAPSHOT
+
+
+ net.aufdemrand
+ denizen
+ 0.9.1-SNAPSHOT
+
+
+ net.milkbowl.vault
+ Vault
+ 1.2.22-SNAPSHOT
+
+
+ com.gmail.nossr50.mcMMO
+ mcMMO
+ LATEST
+
+
+ me.ThaH3lper
+ EpicBoss
+ 1.0
+ system
+ ${project.basedir}/lib/EpicBossRecoded.jar
+
+
-
-
-
- .
- ${basedir}/src/main/resources/
- true
-
- config.yml
- plugin.yml
- events.yml
- quests.yml
- items.txt
-
-
-
- .
- ${basedir}/
- false
-
- README.md
-
-
-
+
+
+
+ .
+ ${basedir}/src/main/resources/
+ true
+
+ config.yml
+ plugin.yml
+ events.yml
+ quests.yml
+ items.txt
+
+
+
+ .
+ ${basedir}/
+ false
+
+ README.md
+
+
+
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.1
-
- true
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 2.4
-
-
- true
-
- true
- true
-
-
- ${project.build.directory}
- ${project.build.finalName}
-
-
-
-
-
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.2
+
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/me/blackvein/quests/Event.java b/src/main/java/me/blackvein/quests/Event.java
index 1b8cea820..cec440be5 100644
--- a/src/main/java/me/blackvein/quests/Event.java
+++ b/src/main/java/me/blackvein/quests/Event.java
@@ -1,9 +1,19 @@
package me.blackvein.quests;
import java.io.File;
-import java.util.*;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
import me.blackvein.quests.util.ItemUtil;
-import org.bukkit.*;
+import me.blackvein.quests.util.QuestMob;
+
+import org.bukkit.ChatColor;
+import org.bukkit.Effect;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType;
@@ -23,9 +33,23 @@ public class Event {
int stormDuration = 0;
World thunderWorld = null;
int thunderDuration = 0;
- LinkedList mobSpawnLocs = new LinkedList();
- LinkedList mobSpawnTypes = new LinkedList();
- LinkedList mobSpawnAmounts = new LinkedList();
+ public LinkedList mobSpawns = new LinkedList() {
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof LinkedList) {
+
+ LinkedList other = (LinkedList) o;
+
+ if (size() != other.size()) return false;
+
+ for (int i = 0; i < size(); i++) {
+ if (get(i).equals(other.get(i)) == false) return false;
+ }
+ }
+ return false;
+ }
+ };
LinkedList lightningStrikes = new LinkedList();
LinkedList commands = new LinkedList();
LinkedList potionEffects = new LinkedList();
@@ -98,18 +122,9 @@ public class Event {
if (other.thunderDuration != thunderDuration) {
return false;
}
-
- if (other.mobSpawnLocs.equals(mobSpawnLocs) == false) {
- return false;
- }
-
- if (other.mobSpawnTypes.equals(mobSpawnTypes) == false) {
- return false;
- }
-
- if (other.mobSpawnAmounts.equals(mobSpawnAmounts) == false) {
- return false;
- }
+
+ if (other.mobSpawns.equals(mobSpawns) == false)
+ return false;
if (other.lightningStrikes.equals(lightningStrikes) == false) {
return false;
@@ -205,19 +220,12 @@ public class Event {
thunderWorld.setThundering(true);
thunderWorld.setThunderDuration(thunderDuration);
}
-
- if (mobSpawnLocs.isEmpty() == false) {
-
- for (Location l : mobSpawnLocs) {
-
- for (int i = 1; i <= mobSpawnAmounts.get(mobSpawnLocs.indexOf(l)); i++) {
-
- l.getWorld().spawnEntity(l, mobSpawnTypes.get(mobSpawnLocs.indexOf(l)));
-
- }
-
- }
-
+
+ if (mobSpawns.isEmpty() == false) {
+
+ for (QuestMob questMob : mobSpawns) {
+ questMob.spawn();
+ }
}
if (lightningStrikes.isEmpty() == false) {
@@ -457,71 +465,54 @@ public class Event {
}
}
-
- if (data.contains(eventKey + "mob-spawn-locations")) {
-
- if (Quests.checkList(data.getList(eventKey + "mob-spawn-locations"), String.class)) {
-
- if (data.contains(eventKey + "mob-spawn-types")) {
-
- if (Quests.checkList(data.getList(eventKey + "mob-spawn-types"), String.class)) {
-
- if (data.contains(eventKey + "mob-spawn-amounts")) {
-
- if (Quests.checkList(data.getList(eventKey + "mob-spawn-amounts"), Integer.class)) {
-
- List mobLocs = data.getStringList(eventKey + "mob-spawn-locations");
- List mobTypes = data.getStringList(eventKey + "mob-spawn-types");
- List mobAmounts = data.getIntegerList(eventKey + "mob-spawn-amounts");
-
- for (String s : mobLocs) {
-
- Location location = Quests.getLocation(s);
- if (location == null) {
- Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
- Quests.printSevere(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
- return null;
- }
-
- EntityType type = Quests.getMobType(mobTypes.get(mobLocs.indexOf(s)));
- if (type == null) {
- Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + mobTypes.get(mobLocs.indexOf(s)) + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid mob name!");
- return null;
- }
-
- int amount = mobAmounts.get(mobLocs.indexOf(s));
-
- event.mobSpawnLocs.add(location);
- event.mobSpawnTypes.add(type);
- event.mobSpawnAmounts.add(amount);
-
- }
-
- } else {
- Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "mob-spawn-amounts: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!");
- return null;
- }
-
- } else {
- Quests.printSevere(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "mob-spawn-amounts:");
- return null;
- }
-
- } else {
- Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "mob-spawn-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of mob names!");
- return null;
- }
-
- } else {
- Quests.printSevere(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "mob-spawn-types:");
+
+ if (data.contains(eventKey + "mob-spawns")) {
+ ConfigurationSection section = data.getConfigurationSection(eventKey + "mob-spawns");
+
+ //is a mob, the keys are just a number or something.
+ for (String s : section.getKeys(false)) {
+ String mobName = section.getString(s + ".name");
+ Location spawnLocation = Quests.getLocation(section.getString(s + ".spawn-location"));
+ EntityType type = Quests.getMobType(section.getString(s + ".mob-type"));
+ Integer mobAmount = section.getInt(s + ".spawn-amounts");
+
+
+ if (spawnLocation == null) {
+ Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
+ Quests.printSevere(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
+ return null;
+ }
+
+ if (type == null) {
+ Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + section.getString(s + ".mob-type") + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid mob name!");
return null;
}
+
+ ItemStack[] inventory = new ItemStack[5];
+ Float[] dropChances = new Float[5];
+
+ inventory[0] = ItemUtil.readItemStack(section.getString(s + ".held-item"));
+ dropChances[0] = (float) section.getDouble(s + ".held-item-drop-chance");
- } else {
- Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "mob-spawn-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!");
- return null;
- }
+ inventory[1] = ItemUtil.readItemStack(section.getString(s + ".boots"));
+ dropChances[1] = (float) section.getDouble(s + ".boots-drop-chance");
+ inventory[2] = ItemUtil.readItemStack(section.getString(s + ".leggings"));
+ dropChances[2] = (float) section.getDouble(s + ".leggings-drop-chance");
+
+ inventory[3] = ItemUtil.readItemStack(section.getString(s + ".chest-plate"));
+ dropChances[3] = (float) section.getDouble(s + ".chest-plate-drop-chance");
+
+ inventory[4] = ItemUtil.readItemStack(section.getString(s + ".helmet"));
+ dropChances[4] = (float) section.getDouble(s + ".helmet-drop-chance");
+
+ QuestMob questMob = new QuestMob(type, spawnLocation, mobAmount);
+ questMob.inventory = inventory;
+ questMob.dropChances = dropChances;
+ questMob.setName(mobName);
+
+ event.mobSpawns.add(questMob);
+ }
}
if (data.contains(eventKey + "lightning-strikes")) {
diff --git a/src/main/java/me/blackvein/quests/EventFactory.java b/src/main/java/me/blackvein/quests/EventFactory.java
index f3ccca647..1d599c0b4 100644
--- a/src/main/java/me/blackvein/quests/EventFactory.java
+++ b/src/main/java/me/blackvein/quests/EventFactory.java
@@ -7,10 +7,12 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+
import me.blackvein.quests.prompts.ItemStackPrompt;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
+import me.blackvein.quests.util.QuestMob;
import net.citizensnpcs.api.CitizensAPI;
import org.apache.commons.lang.StringUtils;
@@ -21,7 +23,15 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.conversations.*;
+import org.bukkit.conversations.ConversationAbandonedEvent;
+import org.bukkit.conversations.ConversationAbandonedListener;
+import org.bukkit.conversations.ConversationContext;
+import org.bukkit.conversations.ConversationFactory;
+import org.bukkit.conversations.ConversationPrefix;
+import org.bukkit.conversations.FixedSetPrompt;
+import org.bukkit.conversations.NumericPrompt;
+import org.bukkit.conversations.Prompt;
+import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@@ -184,8 +194,6 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
context.setSessionData(CK.E_WORLD_THUNDER, null);
context.setSessionData(CK.E_WORLD_THUNDER_DURATION, null);
context.setSessionData(CK.E_MOB_TYPES, null);
- context.setSessionData(CK.E_MOB_AMOUNTS, null);
- context.setSessionData(CK.E_MOB_LOCATIONS, null);
context.setSessionData(CK.E_LIGHTNING, null);
context.setSessionData(CK.E_POTION_TYPES, null);
context.setSessionData(CK.E_POTION_DURATIONS, null);
@@ -233,7 +241,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
LinkedList effs = new LinkedList();
LinkedList locs = new LinkedList();
- for(Entry e : event.effects.entrySet()){
+ for(Entry, ?> e : event.effects.entrySet()){
effs.add(((Effect) e.getKey()).toString());
locs.add(Quests.getLocationInfo((Location) e.getValue()));
@@ -259,24 +267,15 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
- if(event.mobSpawnTypes != null && event.mobSpawnTypes.isEmpty() == false){
-
- LinkedList types = new LinkedList();
- LinkedList locs = new LinkedList();
- LinkedList amounts = new LinkedList();
-
- for(int i = 0; i < event.mobSpawnTypes.size(); i++){
-
- types.add(Quester.prettyMobString(event.mobSpawnTypes.get(i)));
- locs.add(Quests.getLocationInfo(event.mobSpawnLocs.get(i)));
- amounts.add(event.mobSpawnAmounts.get(i));
-
- }
-
- context.setSessionData(CK.E_MOB_TYPES, types);
- context.setSessionData(CK.E_MOB_AMOUNTS, amounts);
- context.setSessionData(CK.E_MOB_LOCATIONS, locs);
-
+ if (event.mobSpawns != null && event.mobSpawns.isEmpty() == false) {
+
+ LinkedList questMobs = new LinkedList();
+
+ for (QuestMob questMob : event.mobSpawns) {
+ questMobs.add(questMob.serialize());
+ }
+
+ context.setSessionData(CK.E_MOB_TYPES, questMobs);
}
if(event.lightningStrikes != null && event.lightningStrikes.isEmpty() == false){
@@ -571,15 +570,12 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
text += BLUE + "" + BOLD + "9" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobSpawns") + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
LinkedList types = (LinkedList) context.getSessionData(CK.E_MOB_TYPES);
- LinkedList amounts = (LinkedList) context.getSessionData(CK.E_MOB_AMOUNTS);
- LinkedList locations = (LinkedList) context.getSessionData(CK.E_MOB_LOCATIONS);
text += BLUE + "" + BOLD + "9" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobSpawns") + "\n";
for (String s : types) {
- int amt = amounts.get(types.indexOf(s));
- String loc = locations.get(types.indexOf(s));
- text += GRAY + " - " + AQUA + s + GRAY + " x " + DARKAQUA + amt + GRAY + " -> " + GREEN + loc + "\n";
+ QuestMob qm = QuestMob.fromString(s);
+ text += GRAY + " - " + AQUA + qm.getType().getName() + ((qm.getName() != null) ? ": " + qm.getName() : "") + GRAY + " x " + DARKAQUA + qm.getSpawnAmounts() + GRAY + " -> " + GREEN + Quests.getLocationInfo(qm.getSpawnLocation()) + "\n";
}
}
@@ -862,7 +858,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
return (String)context.getSessionData(path);
}
- private static LinkedList getCStringList(ConversationContext context, String path){
+ @SuppressWarnings("unchecked")
+ private static LinkedList getCStringList(ConversationContext context, String path){
return (LinkedList)context.getSessionData(path);
}
@@ -870,7 +867,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
return (Integer)context.getSessionData(path);
}
- private static LinkedList getCIntList(ConversationContext context, String path){
+ @SuppressWarnings("unchecked")
+ private static LinkedList getCIntList(ConversationContext context, String path){
return (LinkedList)context.getSessionData(path);
}
@@ -878,7 +876,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
return (Boolean)context.getSessionData(path);
}
- private static LinkedList getCBooleanList(ConversationContext context, String path){
+ @SuppressWarnings("unchecked")
+ private static LinkedList getCBooleanList(ConversationContext context, String path){
return (LinkedList)context.getSessionData(path);
}
@@ -886,7 +885,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
return (Long)context.getSessionData(path);
}
- private static LinkedList getCLongList(ConversationContext context, String path){
+ @SuppressWarnings("unchecked")
+ private static LinkedList getCLongList(ConversationContext context, String path){
return (LinkedList)context.getSessionData(path);
}
//
@@ -1007,16 +1007,39 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
+ try {
if (context.getSessionData(CK.E_MOB_TYPES) != null) {
-
- LinkedList types = getCStringList(context, CK.E_MOB_TYPES);
- LinkedList amounts = getCIntList(context, CK.E_MOB_AMOUNTS);
- LinkedList locations = getCStringList(context, CK.E_MOB_LOCATIONS);
-
- section.set("mob-spawn-types", types);
- section.set("mob-spawn-amounts", amounts);
- section.set("mob-spawn-locations", locations);
-
+ int count = 0;
+
+ for (String s : getCStringList(context, CK.E_MOB_TYPES)) {
+ ConfigurationSection ss = section.getConfigurationSection("mob-spawns." + count);
+ if (ss == null) {
+ ss = section.createSection("mob-spawns." + count);
+ }
+ QuestMob questMob = QuestMob.fromString(s);
+
+ if (questMob == null) continue;
+
+ ss.set("name", questMob.getName());
+ ss.set("spawn-location", Quests.getLocationInfo(questMob.getSpawnLocation()));
+ ss.set("mob-type", questMob.getType().getName());
+ ss.set("spawn-amounts", questMob.getSpawnAmounts());
+ ss.set("held-item", ItemUtil.serialize(questMob.inventory[0]));
+ ss.set("held-item-drop-chance", questMob.dropChances[0]);
+ ss.set("boots", ItemUtil.serialize(questMob.inventory[1]));
+ ss.set("boots-drop-chance", questMob.dropChances[1]);
+ ss.set("leggings", ItemUtil.serialize(questMob.inventory[2]));
+ ss.set("leggings-drop-chance", questMob.dropChances[2]);
+ ss.set("chest-plate", ItemUtil.serialize(questMob.inventory[3]));
+ ss.set("chest-plate-drop-chance", questMob.dropChances[3]);
+ ss.set("helmet", ItemUtil.serialize(questMob.inventory[4]));
+ ss.set("helmet-drop-chance", questMob.dropChances[4]);
+ count++;
+ }
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
}
if (context.getSessionData(CK.E_LIGHTNING) != null) {
@@ -1029,7 +1052,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
if (context.getSessionData(CK.E_COMMANDS) != null) {
LinkedList commands = getCStringList(context, CK.E_COMMANDS);
- section.set("commands", commands);
+ if (commands.isEmpty() == false)
+ section.set("commands", commands);
}
@@ -1855,57 +1879,27 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
}
- private class MobPrompt extends FixedSetPrompt {
-
- public MobPrompt() {
-
- super("1", "2", "3", "4", "5");
-
- }
+ private class MobPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = GOLD + "- " + Lang.get("eventEditorMobSpawns") + " -\n";
if (context.getSessionData(CK.E_MOB_TYPES) == null) {
- text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobTypes") + " (" + Lang.get("noneSet") + ")\n";
- text += GRAY + "2 - " + Lang.get("eventEditorSetMobAmounts") + " " + Lang.get("eventEditorNoTypesSet") + "\n";
- text += GRAY + "3 - " + Lang.get("eventEditorAddSpawnLocation") + " " + Lang.get("eventEditorNoTypesSet") + "\n";
- text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
- text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done");
+ text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("eventEditorAddMobTypes") + " (" + Lang.get("noneSet") + ")\n";
+ text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
+ text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("done");
} else {
-
- text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobTypes") + "\n";
- for (String s : (LinkedList) context.getSessionData(CK.E_MOB_TYPES)) {
- text += GRAY + " - " + AQUA + s + "\n";
+ LinkedList types = (LinkedList) context.getSessionData(CK.E_MOB_TYPES);
+
+ for (int i = 0; i < types.size(); i++) {
+ QuestMob qm = QuestMob.fromString(types.get(i));
+ text += GOLD + " " + (i + 1) + " - Edit: " + AQUA + qm.getType().getName() + ((qm.getName() != null) ? ": " + qm.getName() : "") + GRAY + " x " + DARKAQUA + qm.getSpawnAmounts() + GRAY + " -> " + GREEN + Quests.getLocationInfo(qm.getSpawnLocation()) + "\n";
}
- if (context.getSessionData(CK.E_MOB_AMOUNTS) == null) {
- text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobAmounts") + " (" + Lang.get("noneSet") + ")\n";
- text += GRAY + "3 - " + Lang.get("eventEditorAddSpawnLocation") + Lang.get("eventEditorNoAmountsSet") + "\n";
- } else {
-
- text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobAmounts") + "\n";
- for (int i : (LinkedList) context.getSessionData(CK.E_MOB_AMOUNTS)) {
- text += GRAY + " - " + DARKAQUA + i + "\n";
- }
-
-
- if (context.getSessionData(CK.E_MOB_LOCATIONS) == null) {
- text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("eventEditorAddSpawnLocation") + " (" + Lang.get("noneSet") + ")\n";
- } else {
-
- text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("eventEditorAddSpawnLocation") + "\n";
- for (String s : (LinkedList) context.getSessionData(CK.E_MOB_LOCATIONS)) {
- text += GRAY + " - " + GREEN + s + "\n";
- }
-
- }
-
- }
-
- text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
- text += GREEN + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done");
+ text += BLUE + "" + BOLD + (types.size() + 1) + RESET + YELLOW + " - " + Lang.get("eventEditorAddMobTypes") + "\n";
+ text += BLUE + "" + BOLD + (types.size() + 2) + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
+ text += GREEN + "" + BOLD + (types.size() + 3) + RESET + YELLOW + " - " + Lang.get("done");
}
@@ -1913,78 +1907,223 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
- @Override
- protected Prompt acceptValidatedInput(ConversationContext context, String input) {
-
- if (input.equalsIgnoreCase("1")) {
- return new MobTypesPrompt();
- } else if (input.equalsIgnoreCase("2")) {
- if (context.getSessionData(CK.E_MOB_TYPES) == null) {
- context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobTypesFirst"));
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+
+ if (context.getSessionData(CK.E_MOB_TYPES) == null) {
+ if (input.equalsIgnoreCase("1")) {
+ return new QuestMobPrompt(0, null);
+ } else if (input.equalsIgnoreCase("2")) {
+ context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
+ context.setSessionData(CK.E_MOB_TYPES, null);
return new MobPrompt();
- } else {
- return new MobAmountsPrompt();
- }
- } else if (input.equalsIgnoreCase("3")) {
- if (context.getSessionData(CK.E_MOB_TYPES) == null) {
- context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobTypesAndAmountsFirst"));
- return new MobPrompt();
- } else if (context.getSessionData(CK.E_MOB_AMOUNTS) == null) {
- context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobAmountsFirst"));
- return new MobPrompt();
- } else {
- selectedMobLocations.put((Player) context.getForWhom(), null);
- return new MobLocationPrompt();
- }
- } else if (input.equalsIgnoreCase("4")) {
- context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
- context.setSessionData(CK.E_MOB_TYPES, null);
- context.setSessionData(CK.E_MOB_AMOUNTS, null);
- context.setSessionData(CK.E_MOB_LOCATIONS, null);
- return new MobPrompt();
- } else if (input.equalsIgnoreCase("5")) {
-
- int one;
- int two;
- int three;
-
- if (context.getSessionData(CK.E_MOB_TYPES) != null) {
- one = ((List) context.getSessionData(CK.E_MOB_TYPES)).size();
- } else {
- one = 0;
- }
-
- if (context.getSessionData(CK.E_MOB_AMOUNTS) != null) {
- two = ((List) context.getSessionData(CK.E_MOB_AMOUNTS)).size();
- } else {
- two = 0;
- }
-
- if (context.getSessionData(CK.E_MOB_LOCATIONS) != null) {
- three = ((List) context.getSessionData(CK.E_MOB_LOCATIONS)).size();
- } else {
- three = 0;
- }
-
- if (one == two && two == three) {
- return new CreateMenuPrompt();
- } else {
- context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorListSizeMismatch"));
- return new MobPrompt();
- }
-
- }
- return null;
-
- }
+ } else if (input.equalsIgnoreCase("3")) {
+ return new CreateMenuPrompt();
+ }
+ } else {
+ LinkedList types = (LinkedList) context.getSessionData(CK.E_MOB_TYPES);
+ int inp = -1;
+ try {
+ inp = Integer.parseInt(input);
+ } catch (Exception e) {
+ context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorNotANumber"));
+ return new MobPrompt();
+ }
+
+ if (inp == types.size() + 1) {
+ return new QuestMobPrompt(inp - 1, null);
+ } else if (inp == types.size() + 2) {
+ context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
+ context.setSessionData(CK.E_MOB_TYPES, null);
+ return new MobPrompt();
+ } else if (inp == types.size() + 3) {
+ return new CreateMenuPrompt();
+ } else if (inp > types.size()){
+ return new MobPrompt();
+ } else {
+ return new QuestMobPrompt(inp - 1, QuestMob.fromString(types.get(inp - 1)));
+ }
+ }
+
+ return new MobPrompt();
+ }
}
- private class MobTypesPrompt extends StringPrompt {
+ private class QuestMobPrompt extends StringPrompt {
- @Override
+ private QuestMob questMob;
+ private Integer itemIndex = -1;
+ private Integer mobIndex;
+
+ public QuestMobPrompt(int mobIndex, QuestMob questMob) {
+ this.questMob = questMob;
+ this.mobIndex = mobIndex;
+ }
+
+ @Override
public String getPromptText(ConversationContext context) {
- String mobs = PINK + "- " + Lang.get("mobs") + " - \n";
+ String text = GOLD + "- " + Lang.get("eventEditorAddMobTypes") + " - \n";
+
+ if (questMob == null) {
+ questMob = new QuestMob();
+ }
+
+ // Check/add newly made item
+
+ if(context.getSessionData("newItem") != null){
+ if(itemIndex >= 0){
+ questMob.inventory[itemIndex] = ((ItemStack) context.getSessionData("tempStack"));
+ itemIndex = -1;
+ }
+
+ context.setSessionData("newItem", null);
+ context.setSessionData("tempStack", null);
+
+ }
+
+ text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobName") + GRAY + " (" + ((questMob.getName() == null) ? Lang.get("noneSet") : AQUA + questMob.getName()) + ")\n";
+ text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobType") + GRAY + " (" + ((questMob.getType() == null) ? Lang.get("eventEditorNoTypesSet") : AQUA + questMob.getType().getName()) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("eventEditorAddSpawnLocation") + GRAY + " (" + ((questMob.getSpawnLocation() == null) ? GRAY + Lang.get("noneSet") : AQUA + Quests.getLocationInfo(questMob.getSpawnLocation()) ) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobSpawnAmount") + GRAY +" (" + ((questMob.getSpawnAmounts() == null) ? GRAY + Lang.get("eventEditorNoAmountsSet") : AQUA + "" + questMob.getSpawnAmounts()) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobItemInHand") + GRAY +" (" + ((questMob.inventory[0] == null) ? GRAY + Lang.get("noneSet") : AQUA + ItemUtil.getDisplayString(questMob.inventory[0])) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobItemInHandDrop") + GRAY + " (" + ((questMob.dropChances[0] == null) ? GRAY + Lang.get("noneSet") : AQUA + "" + questMob.dropChances[0]) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobBoots") + GRAY + " (" + ((questMob.inventory[1] == null) ? GRAY + Lang.get("noneSet") : AQUA + ItemUtil.getDisplayString(questMob.inventory[1])) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "8" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobBootsDrop") + GRAY + " (" + ((questMob.dropChances[1] == null) ? GRAY + Lang.get("noneSet") : AQUA + "" + questMob.dropChances[1]) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "9" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobLeggings") + GRAY + " (" + ((questMob.inventory[2] == null) ? GRAY + Lang.get("noneSet") : AQUA + ItemUtil.getDisplayString(questMob.inventory[2])) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "10" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobLeggingsDrop") + GRAY + " (" + ((questMob.dropChances[2] == null) ? GRAY + Lang.get("noneSet") : AQUA + "" + questMob.dropChances[2]) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "11" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobChestPlate") + GRAY + " (" + ((questMob.inventory[3] == null) ? GRAY + Lang.get("noneSet") : AQUA + ItemUtil.getDisplayString(questMob.inventory[3])) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "12" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobChestPlateDrop") + GRAY + " (" + ((questMob.dropChances[3] == null) ? GRAY + Lang.get("noneSet") : AQUA + "" + questMob.dropChances[3]) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "13" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobHelmet") + GRAY + " (" + ((questMob.inventory[4] == null) ? GRAY + Lang.get("noneSet") : AQUA + ItemUtil.getDisplayString(questMob.inventory[4])) + GRAY + ")\n";
+ text += BLUE + "" + BOLD + "14" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobHelmetDrop") + GRAY + " (" + ((questMob.dropChances[4] == null) ? GRAY + Lang.get("noneSet") : AQUA + "" + questMob.dropChances[4]) + GRAY + ")\n";
+
+
+ text += GREEN + "" + BOLD + "15" + RESET + YELLOW + " - " + Lang.get("done") + "\n";
+ text += RED + "" + BOLD + "16" + RESET + YELLOW + " - " + Lang.get("cancel");
+
+ return text;
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+
+ if (input.equalsIgnoreCase("1")) {
+ return new MobNamePrompt(mobIndex, questMob);
+ } else if (input.equalsIgnoreCase("2")) {
+ return new MobTypePrompt(mobIndex, questMob);
+ } else if (input.equalsIgnoreCase("3")) {
+ selectedMobLocations.put((Player) context.getForWhom(), null);
+ return new MobLocationPrompt(mobIndex, questMob);
+ } else if (input.equalsIgnoreCase("4")) {
+ return new MobAmountPrompt(mobIndex, questMob);
+ } else if (input.equalsIgnoreCase("5")) {
+ itemIndex = 0;
+ return new ItemStackPrompt(QuestMobPrompt.this);
+ } else if (input.equalsIgnoreCase("6")) {
+ return new MobDropPrompt(0, mobIndex, questMob);
+ } else if (input.equalsIgnoreCase("7")) {
+ itemIndex = 1;
+ return new ItemStackPrompt(QuestMobPrompt.this);
+ } else if (input.equalsIgnoreCase("8")) {
+ return new MobDropPrompt(1, mobIndex, questMob);
+ } else if (input.equalsIgnoreCase("9")) {
+ itemIndex = 2;
+ return new ItemStackPrompt(QuestMobPrompt.this);
+ } else if (input.equalsIgnoreCase("10")) {
+ return new MobDropPrompt(2, mobIndex, questMob);
+ } else if (input.equalsIgnoreCase("11")) {
+ itemIndex = 3;
+ return new ItemStackPrompt(QuestMobPrompt.this);
+ } else if (input.equalsIgnoreCase("12")) {
+ return new MobDropPrompt(3, mobIndex, questMob);
+ } else if (input.equalsIgnoreCase("13")) {
+ itemIndex = 4;
+ return new ItemStackPrompt(QuestMobPrompt.this);
+ } else if (input.equalsIgnoreCase("14")) {
+ return new MobDropPrompt(4, mobIndex, questMob);
+ } else if (input.equalsIgnoreCase("15")) {
+ if (questMob.getType() == null) {
+ context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobTypesFirst"));
+ return new QuestMobPrompt(mobIndex, questMob);
+ } else if (questMob.getSpawnLocation() == null) {
+ context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobLocationFirst"));
+ return new QuestMobPrompt(mobIndex, questMob);
+ } else if (questMob.getSpawnAmounts() == null) {
+ context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobAmountsFirst"));
+ return new QuestMobPrompt(mobIndex, questMob);
+ }
+ if (context.getSessionData(CK.E_MOB_TYPES) == null) {
+ LinkedList list = new LinkedList();
+ list.add(questMob.serialize());
+ context.setSessionData(CK.E_MOB_TYPES, list);
+ } else {
+ if (((LinkedList) context.getSessionData(CK.E_MOB_TYPES)).isEmpty()) {
+ LinkedList list = new LinkedList();
+ list.add(questMob.serialize());
+ context.setSessionData(CK.E_MOB_TYPES, list);
+ } else {
+ LinkedList list = (LinkedList) context.getSessionData(CK.E_MOB_TYPES);
+ list.set(mobIndex, questMob.serialize());
+ context.setSessionData(CK.E_MOB_TYPES, list);
+ }
+ }
+ return new MobPrompt();
+ } else if (input.equalsIgnoreCase("16")) {
+ return new MobPrompt();
+ } else {
+ return new QuestMobPrompt(mobIndex, questMob);
+ }
+
+ }
+ }
+
+ private class MobNamePrompt extends StringPrompt {
+
+ private QuestMob questMob;
+ private Integer mobIndex;
+
+ public MobNamePrompt (int mobIndex, QuestMob questMob) {
+ this.questMob = questMob;
+ this.mobIndex = mobIndex;
+ }
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ String text = YELLOW + Lang.get("eventEditorSetMobNamePrompt");
+ return text;
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+
+ if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
+ return new QuestMobPrompt(mobIndex, questMob);
+ } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
+ questMob.setName(null);
+ return new QuestMobPrompt(mobIndex, questMob);
+ } else {
+ input = ChatColor.translateAlternateColorCodes('&', input);
+ questMob.setName(input);
+ return new QuestMobPrompt(mobIndex, questMob);
+ }
+ }
+ }
+
+ private class MobTypePrompt extends StringPrompt {
+
+ private QuestMob questMob;
+ private Integer mobIndex;
+
+ public MobTypePrompt (int mobIndex, QuestMob questMob) {
+ this.questMob = questMob;
+ this.mobIndex = mobIndex;
+ }
+
+ @Override
+ public String getPromptText(ConversationContext arg0) {
+ String mobs = PINK + "- " + Lang.get("mobs") + " - \n";
mobs += PURPLE + "Bat, ";
mobs += PURPLE + "Blaze, ";
mobs += PURPLE + "CaveSpider, ";
@@ -2015,40 +2154,38 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
mobs += PURPLE + "Zombie\n";
return mobs + YELLOW + Lang.get("eventEditorSetMobTypesPrompt");
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+ Player player = (Player) context.getForWhom();
- }
+ if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
- @Override
- public Prompt acceptInput(ConversationContext context, String input) {
+ if (Quests.getMobType(input) != null) {
- Player player = (Player) context.getForWhom();
+ questMob.setType(Quests.getMobType(input));
+
+ } else {
+ player.sendMessage(PINK + input + " " + RED + Lang.get("eventEditorInvalidMob"));
+ return new MobTypePrompt(mobIndex, questMob);
+ }
+ }
- if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
-
- LinkedList mobTypes = new LinkedList();
- for (String s : input.split(" ")) {
-
- if (Quests.getMobType(s) != null) {
-
- mobTypes.add(Quester.prettyMobString(Quests.getMobType(s)));
- context.setSessionData(CK.E_MOB_TYPES, mobTypes);
-
- } else {
- player.sendMessage(PINK + s + " " + RED + Lang.get("eventEditorInvalidMob"));
- return new MobTypesPrompt();
- }
-
- }
-
- }
-
- return new MobPrompt();
-
- }
+ return new QuestMobPrompt(mobIndex, questMob);
+ }
}
- private class MobAmountsPrompt extends StringPrompt {
+ private class MobAmountPrompt extends StringPrompt {
+ private QuestMob questMob;
+ private Integer mobIndex;
+
+ public MobAmountPrompt (int mobIndex, QuestMob questMob) {
+ this.questMob = questMob;
+ this.mobIndex = mobIndex;
+ }
+
@Override
public String getPromptText(ConversationContext context) {
@@ -2063,43 +2200,43 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
- LinkedList mobAmounts = new LinkedList();
- for (String s : input.split(" ")) {
-
try {
- int i = Integer.parseInt(s);
+ int i = Integer.parseInt(input);
if (i < 1) {
player.sendMessage(PINK + input + " " + RED + Lang.get("eventEditorNotGreaterThanZero"));
- return new MobAmountsPrompt();
+ return new MobAmountPrompt(mobIndex, questMob);
}
- mobAmounts.add(i);
-
-
+ questMob.setSpawnAmounts(i);
+ return new QuestMobPrompt(mobIndex, questMob);
} catch (Exception e) {
player.sendMessage(PINK + input + " " + RED + Lang.get("eventEditorNotANumber"));
- return new MobAmountsPrompt();
+ return new MobAmountPrompt(mobIndex, questMob);
}
- }
-
- context.setSessionData(CK.E_MOB_AMOUNTS, mobAmounts);
-
}
- return new MobPrompt();
+ return new QuestMobPrompt(mobIndex, questMob);
}
}
private class MobLocationPrompt extends StringPrompt {
+
+ private QuestMob questMob;
+ private Integer mobIndex;
+
+ public MobLocationPrompt (int mobIndex, QuestMob questMob) {
+ this.questMob = questMob;
+ this.mobIndex = mobIndex;
+ }
@Override
public String getPromptText(ConversationContext context) {
- return YELLOW + Lang.get("eventEditorMobLocationPrompt");
+ return YELLOW + Lang.get("eventEditorSetMobLocationPrompt");
}
@@ -2115,36 +2252,71 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
Location loc = block.getLocation();
- LinkedList locs;
- if (context.getSessionData(CK.E_MOB_LOCATIONS) != null) {
- locs = (LinkedList) context.getSessionData(CK.E_MOB_LOCATIONS);
- } else {
- locs = new LinkedList();
- }
-
- locs.add(Quests.getLocationInfo(loc));
- context.setSessionData(CK.E_MOB_LOCATIONS, locs);
+ questMob.setSpawnLocation(loc);
selectedMobLocations.remove(player);
} else {
player.sendMessage(RED + Lang.get("eventEditorSelectBlockFirst"));
- return new MobLocationPrompt();
+ return new MobLocationPrompt(mobIndex, questMob);
}
- return new MobPrompt();
+ return new QuestMobPrompt(mobIndex, questMob);
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
selectedMobLocations.remove(player);
- return new MobPrompt();
+ return new QuestMobPrompt(mobIndex, questMob);
} else {
- return new MobLocationPrompt();
+ return new MobLocationPrompt(mobIndex, questMob);
}
}
}
+ private class MobDropPrompt extends StringPrompt {
+
+ private QuestMob questMob;
+ private Integer mobIndex;
+ private Integer invIndex;
+
+ public MobDropPrompt (int invIndex, int mobIndex ,QuestMob questMob) {
+ this.questMob = questMob;
+ this.mobIndex = mobIndex;
+ this.invIndex = invIndex;
+ }
+
+ @Override
+ public String getPromptText(ConversationContext context) {
+ String text = YELLOW + Lang.get("eventEditorSetDropChance");
+ return text;
+ }
+
+ @Override
+ public Prompt acceptInput(ConversationContext context, String input) {
+ float chance = 0.0F;
+
+ if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
+ return new QuestMobPrompt(mobIndex, questMob);
+ }
+
+ try {
+ chance = Float.parseFloat(input);
+ } catch (Exception e) {
+ context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorInvalidDropChance"));
+ return new MobDropPrompt(invIndex, mobIndex, questMob);
+ }
+ if (chance > 1 || chance < 0) {
+ context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorInvalidDropChance"));
+ return new MobDropPrompt(invIndex, mobIndex, questMob);
+ }
+
+ questMob.dropChances[invIndex] = chance;
+
+ return new QuestMobPrompt(mobIndex, questMob);
+ }
+ }
+
private class LightningPrompt extends StringPrompt {
@Override
diff --git a/src/main/java/me/blackvein/quests/NpcListener.java b/src/main/java/me/blackvein/quests/NpcListener.java
index b7e83b4fb..09cc09ff7 100644
--- a/src/main/java/me/blackvein/quests/NpcListener.java
+++ b/src/main/java/me/blackvein/quests/NpcListener.java
@@ -82,13 +82,17 @@ public class NpcListener implements Listener {
for (Quest q : plugin.getQuests()) {
if (q.npcStart != null && q.npcStart.getId() == evt.getNPC().getId()) {
- npcQuests.add(q);
+ if (Quests.ignoreLockedQuests) {
+ if (q.testRequirements(quester) && (q.redoDelay <= 0)) {
+ npcQuests.add(q);
+ }
+ } else {
+ npcQuests.add(q);
+ }
}
}
-
-
if (npcQuests.isEmpty() == false && npcQuests.size() > 1) {
Conversation c = plugin.NPCConversationFactory.buildConversation((Conversable) player);
diff --git a/src/main/java/me/blackvein/quests/PlayerListener.java b/src/main/java/me/blackvein/quests/PlayerListener.java
index 4fe4e6754..2e6d5a81b 100644
--- a/src/main/java/me/blackvein/quests/PlayerListener.java
+++ b/src/main/java/me/blackvein/quests/PlayerListener.java
@@ -2,6 +2,7 @@ package me.blackvein.quests;
import java.io.File;
+import me.blackvein.quests.events.MiniEvent.MiniEventType;
import net.citizensnpcs.api.CitizensAPI;
import org.bukkit.ChatColor;
@@ -404,6 +405,7 @@ public class PlayerListener implements Listener {
if (okay) {
Quester quester = plugin.getQuester(player.getName());
+
if (quester.hasObjective("killMob")) {
quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType());
}
@@ -470,6 +472,7 @@ public class PlayerListener implements Listener {
if (okay) {
Quester quester = plugin.getQuester(player.getName());
+
if (quester.hasObjective("killPlayer")) {
quester.killPlayer(evt.getEntity().getName());
}
@@ -605,6 +608,14 @@ public class PlayerListener implements Listener {
if (isPlayer) {
Quester quester = plugin.getQuester(evt.getPlayer().getName());
+
+ if (quester.currentStage != null) {
+ boolean isCancelled = quester.currentStage.executeReachEvent(evt.getTo(), quester);
+
+ if(isCancelled) {
+ evt.setCancelled(isCancelled);
+ }
+ }
if (quester.hasObjective("reachLocation")) {
@@ -617,4 +628,20 @@ public class PlayerListener implements Listener {
}
}
+
+ public void onEntityDamage(EntityDamageByEntityEvent evt) {
+ if (evt.getEntity() instanceof Player) {
+ double health = ((Damageable) evt.getEntity()).getHealth();
+ if (evt.getDamage() >= health) {
+ Quester quester = plugin.getQuester(((Player) evt.getEntity()).getName());
+ evt.setCancelled(quester.currentStage.executeEvent(quester, MiniEventType.ONDEATH));
+
+ }
+ } else if (evt.getDamager() instanceof Player) {
+ if (evt.getDamage() >= ((Damageable) evt.getEntity()).getHealth()) {
+ Quester quester = plugin.getQuester(((Player) evt.getDamager()).getName());
+ evt.setCancelled(quester.currentStage.executeKillEvent(quester, evt.getEntityType()));
+ }
+ }
+ }
}
diff --git a/src/main/java/me/blackvein/quests/Quest.java b/src/main/java/me/blackvein/quests/Quest.java
index 4f5a5292e..e49bad226 100644
--- a/src/main/java/me/blackvein/quests/Quest.java
+++ b/src/main/java/me/blackvein/quests/Quest.java
@@ -1,19 +1,19 @@
package me.blackvein.quests;
-import com.gmail.nossr50.api.ExperienceAPI;
-import com.gmail.nossr50.datatypes.player.McMMOPlayer;
-import com.gmail.nossr50.util.player.UserManager;
-
import java.util.LinkedList;
import java.util.List;
+
import me.blackvein.quests.util.ItemUtil;
import net.citizensnpcs.api.npc.NPC;
+
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
+import com.gmail.nossr50.util.player.UserManager;
+
public class Quest {
public String name;
@@ -66,7 +66,7 @@ public class Quest {
if(q.currentStage.delay < 0){
Player player = q.getPlayer();
- if(stages.indexOf(q.currentStage) == (q.currentQuest.stages.size() - 1)){
+ if(q.currentStageIndex == (q.currentQuest.stages.size() - 1)){
if(q.currentStage.script != null)
plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, player);
@@ -76,28 +76,10 @@ public class Quest {
completeQuest(q);
}else {
-
- q.reset();
- if(q.currentStage.script != null)
- plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, player);
- if(q.currentStage.event != null)
- q.currentStage.event.happen(q);
- q.currentStage = stages.get(q.currentStageIndex + 1);
- q.currentStageIndex++;
- q.addEmpties();
-
- player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
- for(String s : q.getObjectives()){
-
- player.sendMessage(s);
-
- }
-
- String stageStartMessage = q.currentStage.startMessage;
- if (stageStartMessage != null) {
- q.getPlayer().sendMessage(Quests.parseString(stageStartMessage, q.currentQuest));
- }
-
+
+ q.currentStageIndex++;
+ setStage(q, q.currentStageIndex);
+
}
q.delayStartTime = 0;
@@ -109,6 +91,37 @@ public class Quest {
}
}
+
+ public void setStage(Quester q, int stage) {
+
+ if (stages.size() - 1 < stage) {
+ return;
+ }
+
+ q.reset();
+
+ if(q.currentStage.script != null)
+ plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, q.getPlayer());
+
+ if(q.currentStage.event != null)
+ q.currentStage.event.happen(q);
+
+ q.currentStage = stages.get(stage);
+ q.addEmpties();
+
+ q.getPlayer().sendMessage(ChatColor.GOLD + "---(Objectives)---");
+ for(String s : q.getObjectives()){
+
+ q.getPlayer().sendMessage(s);
+
+ }
+
+ String stageStartMessage = q.currentStage.startMessage;
+ if (stageStartMessage != null) {
+ q.getPlayer().sendMessage(Quests.parseString(stageStartMessage, q.currentQuest));
+ }
+
+ }
public String getName(){
return name;
diff --git a/src/main/java/me/blackvein/quests/QuestFactory.java b/src/main/java/me/blackvein/quests/QuestFactory.java
index ae6fe3b55..14e842e9a 100644
--- a/src/main/java/me/blackvein/quests/QuestFactory.java
+++ b/src/main/java/me/blackvein/quests/QuestFactory.java
@@ -6,6 +6,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+
+import me.blackvein.quests.events.MiniEvent;
+import me.blackvein.quests.events.MiniEvent.MiniEventType;
import me.blackvein.quests.prompts.RequirementsPrompt;
import me.blackvein.quests.prompts.RewardsPrompt;
import me.blackvein.quests.prompts.StagesPrompt;
@@ -1134,6 +1137,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
delayMessage = null;
startMessage = null;
completeMessage = null;
+
+ Map> miniEvents = null;
if (cc.getSessionData(pref + CK.S_BREAK_IDS) != null) {
@@ -1241,6 +1246,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE) != null) {
completeMessage = (String) cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE);
}
+
+ if (cc.getSessionData(pref + CK.S_MINI_EVENTS) != null) {
+ miniEvents = (Map>) cc.getSessionData(pref + CK.S_MINI_EVENTS);
+ }
if (breakIds != null && breakIds.isEmpty() == false) {
stage.set("break-block-ids", breakIds);
@@ -1305,6 +1314,16 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
stage.set("delay-message", delayMessage);
stage.set("start-message", startMessage);
stage.set("complete-message", completeMessage);
+
+ //TODO change here
+ if (miniEvents != null && miniEvents.isEmpty() == false) {
+ for (Entry> ent : miniEvents.entrySet()) {
+ int count = 1;
+ for (MiniEvent miniEvent : ent.getValue()) {
+ stage.createSection("mini-events." + ent.getKey().getName() + "." + count, miniEvent.getValues());
+ }
+ }
+ }
}
@@ -1683,6 +1702,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (stage.startMessage != null) {
cc.setSessionData(pref + CK.S_START_MESSAGE, stage.startMessage);
}
+
+ if (stage.miniEvents != null && stage.miniEvents.isEmpty() == false) {
+ cc.setSessionData(pref + CK.S_START_MESSAGE, stage.miniEvents);
+ }
}
//
diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java
index 04a3c14e5..bfbd6da71 100644
--- a/src/main/java/me/blackvein/quests/Quester.java
+++ b/src/main/java/me/blackvein/quests/Quester.java
@@ -745,20 +745,20 @@ public class Quester {
public void enchantItem(Enchantment e, Material m) {
- for (Entry entry : itemsEnchanted.entrySet()) {
+ for (Entry