diff --git a/pom.xml b/pom.xml
index e6620e441..e6df0de3e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,10 +30,6 @@
vault-repo
http://ci.herocraftonline.com/plugin/repository/everything
-
- mcMMO-repo
- http://repo.mcmmo.org
-
@@ -61,7 +57,9 @@
com.gmail.nossr50.mcMMO
mcMMO
- LATEST
+ 1.0
+ system
+ ${project.basedir}/lib/mcMMO.jar
me.ThaH3lper
diff --git a/src/main/java/me/blackvein/quests/Event.java b/src/main/java/me/blackvein/quests/Event.java
index cec440be5..b303e166e 100644
--- a/src/main/java/me/blackvein/quests/Event.java
+++ b/src/main/java/me/blackvein/quests/Event.java
@@ -5,10 +5,8 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.QuestMob;
-
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
@@ -26,6 +24,7 @@ public class Event {
String name = "";
String message = null;
boolean clearInv = false;
+ boolean failQuest = false;
LinkedList explosions = new LinkedList();
Map effects = new HashMap();
LinkedList items = new LinkedList();
@@ -34,15 +33,15 @@ public class Event {
World thunderWorld = null;
int thunderDuration = 0;
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;
}
@@ -83,6 +82,10 @@ public class Event {
return false;
}
+ if(other.failQuest != failQuest) {
+ return false;
+ }
+
if (other.explosions.equals(explosions) == false) {
return false;
}
@@ -122,9 +125,13 @@ public class Event {
if (other.thunderDuration != thunderDuration) {
return false;
}
-
- if (other.mobSpawns.equals(mobSpawns) == false)
- return false;
+
+ for(QuestMob qm : mobSpawns){
+
+ if(qm.equals(other.mobSpawns.get(mobSpawns.indexOf(qm))) == false)
+ return false;
+
+ }
if (other.lightningStrikes.equals(lightningStrikes) == false) {
return false;
@@ -171,7 +178,7 @@ public class Event {
}
- public void happen(Quester quester) {
+ public void fire(Quester quester) {
Player player = quester.getPlayer();
@@ -220,9 +227,9 @@ public class Event {
thunderWorld.setThundering(true);
thunderWorld.setThunderDuration(thunderDuration);
}
-
+
if (mobSpawns.isEmpty() == false) {
-
+
for (QuestMob questMob : mobSpawns) {
questMob.spawn();
}
@@ -281,6 +288,12 @@ public class Event {
}
+ if(failQuest == true) {
+
+ quester.currentQuest.failQuest(quester);
+
+ }
+
}
public static Event loadEvent(String name, Quests plugin) {
@@ -316,6 +329,17 @@ public class Event {
}
+ if (data.contains(eventKey + "fail-quest")) {
+
+ if (data.isBoolean(eventKey + "fail-quest")) {
+ event.failQuest = data.getBoolean(eventKey + "fail-quest");
+ } else {
+ Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "fail-quest: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a true/false value!");
+ return null;
+ }
+
+ }
+
if (data.contains(eventKey + "explosions")) {
if (Quests.checkList(data.getList(eventKey + "explosions"), String.class)) {
@@ -465,32 +489,32 @@ public class Event {
}
}
-
+
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");
@@ -504,13 +528,13 @@ public class Event {
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");
-
+ 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);
}
}
diff --git a/src/main/java/me/blackvein/quests/EventFactory.java b/src/main/java/me/blackvein/quests/EventFactory.java
index 1d599c0b4..1b5a62654 100644
--- a/src/main/java/me/blackvein/quests/EventFactory.java
+++ b/src/main/java/me/blackvein/quests/EventFactory.java
@@ -268,13 +268,13 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
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);
}
@@ -415,7 +415,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
for(Stage stage : quest.stages){
- if(stage.event != null && stage.event.name.equalsIgnoreCase(evt.name)){
+ if(stage.finishEvent != null && stage.finishEvent.name.equalsIgnoreCase(evt.name)){
used.add(quest.name);
break;
}
@@ -802,9 +802,9 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
for(Stage s : q.stages){
- if(s.event != null && s.event.name != null){
+ if(s.finishEvent != null && s.finishEvent.name != null){
- if(s.event.name.equalsIgnoreCase(modifiedName)){
+ if(s.finishEvent.name.equalsIgnoreCase(modifiedName)){
modified.add(q.getName());
break;
}
@@ -1010,16 +1010,16 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
try {
if (context.getSessionData(CK.E_MOB_TYPES) != null) {
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());
@@ -1036,7 +1036,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
ss.set("helmet-drop-chance", questMob.dropChances[4]);
count++;
}
-
+
}
} catch (Exception e) {
e.printStackTrace();
@@ -1891,7 +1891,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("done");
} else {
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";
@@ -1909,7 +1909,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
@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);
@@ -1929,8 +1929,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorNotANumber"));
return new MobPrompt();
}
-
- if (inp == types.size() + 1) {
+
+ if (inp == types.size() + 1) {
return new QuestMobPrompt(inp - 1, null);
} else if (inp == types.size() + 2) {
context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
@@ -1944,7 +1944,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
return new QuestMobPrompt(inp - 1, QuestMob.fromString(types.get(inp - 1)));
}
}
-
+
return new MobPrompt();
}
}
@@ -1954,7 +1954,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
private QuestMob questMob;
private Integer itemIndex = -1;
private Integer mobIndex;
-
+
public QuestMobPrompt(int mobIndex, QuestMob questMob) {
this.questMob = questMob;
this.mobIndex = mobIndex;
@@ -1964,13 +1964,13 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
public String getPromptText(ConversationContext context) {
String text = GOLD + "- " + Lang.get("eventEditorAddMobTypes") + " - \n";
-
+
if (questMob == null) {
- questMob = new QuestMob();
+ questMob = new QuestMob();
}
-
+
// Check/add newly made item
-
+
if(context.getSessionData("newItem") != null){
if(itemIndex >= 0){
questMob.inventory[itemIndex] = ((ItemStack) context.getSessionData("tempStack"));
@@ -1981,7 +1981,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
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";
@@ -1996,11 +1996,11 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
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;
}
@@ -2008,7 +2008,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
@SuppressWarnings("unchecked")
@Override
public Prompt acceptInput(ConversationContext context, String input) {
-
+
if (input.equalsIgnoreCase("1")) {
return new MobNamePrompt(mobIndex, questMob);
} else if (input.equalsIgnoreCase("2")) {
@@ -2075,31 +2075,31 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
} 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);
+ return new QuestMobPrompt(mobIndex, questMob);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
questMob.setName(null);
return new QuestMobPrompt(mobIndex, questMob);
@@ -2110,12 +2110,12 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
}
}
-
+
private class MobTypePrompt extends StringPrompt {
-
+
private QuestMob questMob;
private Integer mobIndex;
-
+
public MobTypePrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob;
this.mobIndex = mobIndex;
@@ -2155,7 +2155,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
return mobs + YELLOW + Lang.get("eventEditorSetMobTypesPrompt");
}
-
+
@Override
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
@@ -2165,7 +2165,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
if (Quests.getMobType(input) != null) {
questMob.setType(Quests.getMobType(input));
-
+
} else {
player.sendMessage(PINK + input + " " + RED + Lang.get("eventEditorInvalidMob"));
return new MobTypePrompt(mobIndex, questMob);
@@ -2180,12 +2180,12 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
private QuestMob questMob;
private Integer mobIndex;
-
+
public MobAmountPrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob;
this.mobIndex = mobIndex;
}
-
+
@Override
public String getPromptText(ConversationContext context) {
@@ -2224,10 +2224,10 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
private class MobLocationPrompt extends StringPrompt {
-
+
private QuestMob questMob;
private Integer mobIndex;
-
+
public MobLocationPrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob;
this.mobIndex = mobIndex;
@@ -2275,11 +2275,11 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
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;
@@ -2291,15 +2291,15 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
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) {
@@ -2310,9 +2310,9 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorInvalidDropChance"));
return new MobDropPrompt(invIndex, mobIndex, questMob);
}
-
+
questMob.dropChances[invIndex] = chance;
-
+
return new QuestMobPrompt(mobIndex, questMob);
}
}
diff --git a/src/main/java/me/blackvein/quests/PlayerListener.java b/src/main/java/me/blackvein/quests/PlayerListener.java
index 24616ca07..4f251dd25 100644
--- a/src/main/java/me/blackvein/quests/PlayerListener.java
+++ b/src/main/java/me/blackvein/quests/PlayerListener.java
@@ -1,9 +1,7 @@
package me.blackvein.quests;
import java.io.File;
-
import net.citizensnpcs.api.CitizensAPI;
-
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -50,63 +48,63 @@ public class PlayerListener implements Listener {
quester.useBlock(evt.getClickedBlock().getType());
- }else if (plugin.questFactory.selectedBlockStarts.containsKey(evt.getPlayer())){
+ } else if (plugin.questFactory.selectedBlockStarts.containsKey(evt.getPlayer())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.questFactory.selectedBlockStarts.put(evt.getPlayer(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + "Selected location " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().getId()) + ChatColor.GOLD + ")");
- }else if (plugin.eventFactory.selectedExplosionLocations.containsKey(evt.getPlayer())){
+ } else if (plugin.eventFactory.selectedExplosionLocations.containsKey(evt.getPlayer())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.eventFactory.selectedExplosionLocations.put(evt.getPlayer(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + "Selected location " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().getId()) + ChatColor.GOLD + ")");
- }else if (plugin.eventFactory.selectedEffectLocations.containsKey(evt.getPlayer())){
+ } else if (plugin.eventFactory.selectedEffectLocations.containsKey(evt.getPlayer())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.eventFactory.selectedEffectLocations.put(evt.getPlayer(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + "Selected location " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().getId()) + ChatColor.GOLD + ")");
- }else if (plugin.eventFactory.selectedMobLocations.containsKey(evt.getPlayer())){
+ } else if (plugin.eventFactory.selectedMobLocations.containsKey(evt.getPlayer())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.eventFactory.selectedMobLocations.put(evt.getPlayer(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + "Selected location " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().getId()) + ChatColor.GOLD + ")");
- }else if (plugin.eventFactory.selectedLightningLocations.containsKey(evt.getPlayer())){
+ } else if (plugin.eventFactory.selectedLightningLocations.containsKey(evt.getPlayer())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.eventFactory.selectedLightningLocations.put(evt.getPlayer(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + "Selected location " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().getId()) + ChatColor.GOLD + ")");
- }else if (plugin.eventFactory.selectedTeleportLocations.containsKey(evt.getPlayer())){
+ } else if (plugin.eventFactory.selectedTeleportLocations.containsKey(evt.getPlayer())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.eventFactory.selectedTeleportLocations.put(evt.getPlayer(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + "Selected location " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().getId()) + ChatColor.GOLD + ")");
- }else if (plugin.questFactory.selectedKillLocations.containsKey(evt.getPlayer())){
+ } else if (plugin.questFactory.selectedKillLocations.containsKey(evt.getPlayer())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.questFactory.selectedKillLocations.put(evt.getPlayer(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + "Selected location " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().getId()) + ChatColor.GOLD + ")");
- }else if (plugin.questFactory.selectedReachLocations.containsKey(evt.getPlayer())){
+ } else if (plugin.questFactory.selectedReachLocations.containsKey(evt.getPlayer())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.questFactory.selectedReachLocations.put(evt.getPlayer(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + "Selected location " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().getId()) + ChatColor.GOLD + ")");
- }else if(player.isConversing() == false){
+ } else if (player.isConversing() == false) {
for (final Quest q : plugin.quests) {
@@ -127,7 +125,7 @@ public class PlayerListener implements Listener {
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;
- }else if (quester.completedQuests.contains(q.name) && q.redoDelay < 0) {
+ } else if (quester.completedQuests.contains(q.name) && q.redoDelay < 0) {
player.sendMessage(ChatColor.YELLOW + "You have already completed " + ChatColor.AQUA + q.name + ChatColor.YELLOW + ".");
return;
@@ -144,9 +142,9 @@ public class PlayerListener implements Listener {
+ ChatColor.RESET + plugin.getQuest(quester.questToTake).description + "\n";
for (String msg : s.split("
")) {
- player.sendMessage(msg);
+ player.sendMessage(msg);
}
-
+
plugin.conversationFactory.buildConversation((Conversable) player).begin();
}
@@ -166,6 +164,40 @@ public class PlayerListener implements Listener {
}
+ @EventHandler
+ public void onPlayerChat(AsyncPlayerChatEvent evt) {
+
+ if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
+
+ Quester quester = plugin.getQuester(evt.getPlayer().getName());
+ if (quester.currentStage != null) {
+
+ if (quester.currentStage.chatEvents.isEmpty() == false) {
+
+ String chat = evt.getMessage();
+ for (String s : quester.currentStage.chatEvents.keySet()) {
+
+ if (s.equalsIgnoreCase(chat)) {
+
+ if (quester.eventFired.get(s) == false) {
+
+ quester.currentStage.chatEvents.get(s).fire(quester);
+ quester.eventFired.put(s, true);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
@EventHandler
public void onBlockDamage(BlockDamageEvent evt) {
@@ -374,7 +406,6 @@ public class PlayerListener implements Listener {
* hotbar slots
*
*/
-
@EventHandler
public void onEntityDeath(EntityDeathEvent evt) {
@@ -404,7 +435,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());
}
@@ -471,7 +502,7 @@ public class PlayerListener implements Listener {
if (okay) {
Quester quester = plugin.getQuester(player.getName());
-
+
if (quester.hasObjective("killPlayer")) {
quester.killPlayer(evt.getEntity().getName());
}
@@ -514,13 +545,25 @@ public class PlayerListener implements Listener {
}
+ Player player = evt.getEntity();
+ if (plugin.checkQuester(player.getName()) == false) {
+
+ Quester quester = plugin.getQuester(player.getName());
+ if(quester.currentStage != null){
+ if(quester.currentStage.deathEvent != null){
+ quester.currentStage.deathEvent.fire(quester);
+ }
+ }
+
+ }
+
}
@EventHandler
public void onPlayerFish(PlayerFishEvent evt) {
Player player = evt.getPlayer();
- if(plugin.checkQuester(player.getName()) == false){
+ if (plugin.checkQuester(player.getName()) == false) {
Quester quester = plugin.getQuester(player.getName());
if (quester.hasObjective("catchFish") && evt.getState().equals(State.CAUGHT_FISH)) {
@@ -534,15 +577,17 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent evt) {
- if(plugin.checkQuester(evt.getPlayer().getName()) == false){
+ if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
Quester quester = new Quester(plugin);
quester.name = evt.getPlayer().getName();
if (new File(plugin.getDataFolder(), "data/" + quester.name + ".yml").exists()) {
quester.loadData();
+
} else {
quester.saveData();
}
+
plugin.questers.put(evt.getPlayer().getName(), quester);
for (String s : quester.completedQuests) {
@@ -551,8 +596,9 @@ public class PlayerListener implements Listener {
if (q != null) {
- 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());
+ }
}
@@ -560,9 +606,9 @@ public class PlayerListener implements Listener {
quester.checkQuest();
- if(quester.currentQuest != null){
+ if (quester.currentQuest != null) {
- if(quester.currentStage.delay > -1){
+ if (quester.currentStage.delay > -1) {
quester.startStageTimer();
@@ -577,12 +623,19 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent evt) {
- if(plugin.checkQuester(evt.getPlayer().getName()) == false){
+ if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getName());
- if(quester.currentQuest != null){
- if(quester.currentStage.delay > -1)
+ if (quester.currentQuest != null) {
+
+ if (quester.currentStage.delay > -1) {
quester.stopStageTimer();
+ }
+
+ if(quester.currentStage.disconnectEvent != null){
+ quester.currentStage.disconnectEvent.fire(quester);
+ }
+
}
quester.saveData();
@@ -595,7 +648,7 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerMove(PlayerMoveEvent evt) {
- if(plugin.checkQuester(evt.getPlayer().getName()) == false){
+ if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
boolean isPlayer = true;
if (plugin.citizens != null) {
@@ -619,5 +672,4 @@ public class PlayerListener implements Listener {
}
}
-
}
diff --git a/src/main/java/me/blackvein/quests/Quest.java b/src/main/java/me/blackvein/quests/Quest.java
index 2d8be85a1..3159ac180 100644
--- a/src/main/java/me/blackvein/quests/Quest.java
+++ b/src/main/java/me/blackvein/quests/Quest.java
@@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.gmail.nossr50.util.player.UserManager;
+import me.blackvein.quests.util.Lang;
public class Quest {
@@ -70,8 +71,8 @@ public class Quest {
if(q.currentStage.script != null)
plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, player);
- if(q.currentStage.event != null)
- q.currentStage.event.happen(q);
+ if(q.currentStage.finishEvent != null)
+ q.currentStage.finishEvent.fire(q);
completeQuest(q);
@@ -98,15 +99,19 @@ public class Quest {
return;
}
- q.reset();
+ q.resetObjectives();
if(q.currentStage.script != null)
plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, q.getPlayer());
- if(q.currentStage.event != null)
- q.currentStage.event.happen(q);
+ if(q.currentStage.finishEvent != null)
+ q.currentStage.finishEvent.fire(q);
q.currentStage = stages.get(stage);
+
+ if(q.currentStage.startEvent != null)
+ q.currentStage.startEvent.fire(q);
+
q.addEmpties();
q.getPlayer().sendMessage(ChatColor.GOLD + "---(Objectives)---");
@@ -185,7 +190,7 @@ public class Quest {
public void completeQuest(Quester q){
Player player = plugin.getServer().getPlayerExact(q.name);
- q.reset();
+ q.resetObjectives();
q.completedQuests.add(name);
String none = ChatColor.GRAY + "- (None)";
@@ -287,6 +292,24 @@ public class Quest {
}
+ public void failQuest(Quester q){
+
+ Player player = plugin.getServer().getPlayerExact(q.name);
+ q.resetObjectives();
+
+ player.sendMessage(ChatColor.AQUA + "-- " + ChatColor.DARK_PURPLE + q.currentQuest.name + ChatColor.AQUA + " -- ");
+ player.sendMessage(ChatColor.RED + Lang.get("questFailed"));
+
+ q.currentQuest = null;
+
+ q.currentStage = null;
+ q.currentStageIndex = 0;
+
+ q.saveData();
+ player.updateInventory();
+
+ }
+
@Override
public boolean equals(Object o){
diff --git a/src/main/java/me/blackvein/quests/QuestFactory.java b/src/main/java/me/blackvein/quests/QuestFactory.java
index d9333592f..4e315d3c7 100644
--- a/src/main/java/me/blackvein/quests/QuestFactory.java
+++ b/src/main/java/me/blackvein/quests/QuestFactory.java
@@ -387,25 +387,25 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
loadQuest(context, q);
return new CreateMenuPrompt();
}
-
+
}
-
+
for (Quest q : quests.getQuests()) {
if (q.getName().toLowerCase().startsWith(input.toLowerCase())) {
loadQuest(context, q);
return new CreateMenuPrompt();
}
-
+
}
-
+
for (Quest q : quests.getQuests()) {
if (q.getName().toLowerCase().contains(input.toLowerCase())) {
loadQuest(context, q);
return new CreateMenuPrompt();
}
-
+
}
return new SelectEditPrompt();
@@ -1195,7 +1195,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
mobLocNames = (LinkedList) cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES);
}
}
-
+
if (cc.getSessionData(pref + CK.S_REACH_LOCATIONS) != null) {
reachLocs = (LinkedList) cc.getSessionData(pref + CK.S_REACH_LOCATIONS);
reachRadii = (LinkedList) cc.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS);
@@ -1651,8 +1651,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
- if (stage.event != null) {
- cc.setSessionData(pref + CK.S_EVENT, stage.event.getName());
+ if (stage.finishEvent != null) {
+ cc.setSessionData(pref + CK.S_EVENT, stage.finishEvent.getName());
}
diff --git a/src/main/java/me/blackvein/quests/Quester.java b/src/main/java/me/blackvein/quests/Quester.java
index 08b00f1e6..81f57f242 100644
--- a/src/main/java/me/blackvein/quests/Quester.java
+++ b/src/main/java/me/blackvein/quests/Quester.java
@@ -4,7 +4,6 @@ import java.io.File;
import java.util.*;
import java.util.Map.Entry;
import java.util.logging.Level;
-
import me.blackvein.quests.util.ItemUtil;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
@@ -63,6 +62,7 @@ public class Quester {
LinkedList radiiToReachWithin = new LinkedList();
Map mobsTamed = new EnumMap(EntityType.class);
Map sheepSheared = new EnumMap(DyeColor.class);
+ public Map eventFired = new HashMap();
final Random random = new Random();
public Quester(Quests newPlugin) {
@@ -107,8 +107,21 @@ public class Quester {
if (stageStartMessage != null) {
getPlayer().sendMessage(Quests.parseString(stageStartMessage, currentQuest));
}
+
+ if(currentStage.chatEvents.isEmpty() == false){
+
+ for(String chatTrigger : currentStage.chatEvents.keySet()){
+
+ eventFired.put(chatTrigger, false);
+
+ }
+
+ }
+
if(q.initialEvent != null)
- q.initialEvent.happen(this);
+ q.initialEvent.fire(this);
+ if(currentStage.startEvent != null)
+ currentStage.startEvent.fire(this);
} else {
@@ -365,7 +378,6 @@ public class Quester {
}
-
}
for (NPC n : currentStage.citizensToInteract) {
@@ -394,13 +406,17 @@ public class Quester {
for (NPC n2 : citizensKilled) {
- if (citizenNumKilled.get(citizensKilled.indexOf(n2)) < currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))) {
+ if(n.getId() == n2.getId()){
- unfinishedObjectives.add(ChatColor.GREEN + "Kill " + n.getName() + ChatColor.GREEN + " " + citizenNumKilled.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
+ if (citizenNumKilled.get(citizensKilled.indexOf(n2)) < currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))) {
- } else {
+ unfinishedObjectives.add(ChatColor.GREEN + "Kill " + n.getName() + ChatColor.GREEN + " " + citizenNumKilled.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
- finishedObjectives.add(ChatColor.GRAY + "Kill " + n.getName() + " " + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
+ } else {
+
+ finishedObjectives.add(ChatColor.GRAY + "Kill " + n.getName() + " " + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
+
+ }
}
@@ -1192,6 +1208,9 @@ public class Quester {
public void addEmpties() {
+ System.out.println("Adding empties.");
+ System.out.println("Citizens to kill: " + currentStage.citizensToKill.size());
+
if (currentStage.blocksToDamage.isEmpty() == false) {
for (Material m : currentStage.blocksToDamage.keySet()) {
@@ -1279,6 +1298,7 @@ public class Quester {
if (currentStage.citizensToKill.isEmpty() == false) {
for (NPC n : currentStage.citizensToKill) {
+ System.out.println("Adding..");
citizensKilled.add(n);
citizenNumKilled.add(0);
@@ -1330,7 +1350,7 @@ public class Quester {
}
- public void reset() {
+ public void resetObjectives() {
blocksDamaged.clear();
blocksBroken.clear();
@@ -1963,6 +1983,21 @@ public class Quester {
data.set("stage-delay", delayTimeLeft);
}
+ if(eventFired.isEmpty() == false){
+
+ LinkedList triggers = new LinkedList();
+ for(String trigger : eventFired.keySet()){
+
+ if(eventFired.get(trigger) == true)
+ triggers.add(trigger);
+
+ }
+
+ if(triggers.isEmpty() == false)
+ data.set("chat-triggers", triggers);
+
+ }
+
} else {
@@ -2071,14 +2106,14 @@ public class Quester {
}
}
-
+
if (stage == null) {
currentQuest = quest;
currentQuest.completeQuest(this);
Quests.log.log(Level.SEVERE, "[Quests] Invalid stage for player: \"" + name + "\". Quest ended.");
return true;
}
-
+
currentQuest = quest;
currentStage = stage;
@@ -2360,6 +2395,9 @@ public class Quester {
List ids = data.getIntegerList("citizen-ids-killed");
List num = data.getIntegerList("citizen-amounts-killed");
+ citizensKilled.clear();
+ citizenNumKilled.clear();
+
for (int i : ids) {
citizensKilled.add(CitizensAPI.getNPCRegistry().getById(i));
@@ -2545,6 +2583,27 @@ public class Quester {
}
+ if(currentStage.chatEvents.isEmpty() == false){
+
+ for(String trig : currentStage.chatEvents.keySet()){
+
+ eventFired.put(trig, false);
+
+ }
+
+ }
+
+ if(data.contains("chat-triggers")){
+
+ List triggers = data.getStringList("chat-triggers");
+ for(String s : triggers){
+
+ eventFired.put(s, true);
+
+ }
+
+ }
+
}
return true;
@@ -2601,7 +2660,7 @@ public class Quester {
if (q.equals(currentQuest) == false) {
currentStage = null;
- reset();
+ resetObjectives();
if (plugin.getServer().getPlayer(name) != null) {
plugin.getServer().getPlayer(name).sendMessage(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "Your active Quest " + ChatColor.DARK_PURPLE + currentQuest.name + ChatColor.RED + " has been modified. You have been forced to quit the Quest.");
}
@@ -2618,7 +2677,7 @@ public class Quester {
if (exists == false) {
currentStage = null;
- reset();
+ resetObjectives();
if (plugin.getServer().getPlayer(name) != null) {
plugin.getServer().getPlayer(name).sendMessage(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "Your active Quest " + ChatColor.DARK_PURPLE + currentQuest.name + ChatColor.RED + " no longer exists. You have been forced to quit the Quest.");
}
diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java
index fbf5b140c..87bbb94cd 100644
--- a/src/main/java/me/blackvein/quests/Quests.java
+++ b/src/main/java/me/blackvein/quests/Quests.java
@@ -847,10 +847,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
Quester quester = getQuester(cs.getName());
if (quester.currentQuest != null) {
- quester.reset();
+ quester.resetObjectives();
quester.currentStage = null;
cs.sendMessage(YELLOW + "You have quit " + PURPLE + quester.currentQuest.name + YELLOW + ".");
quester.currentQuest = null;
+ quester.saveData();
+ quester.loadData();
return true;
} else {
@@ -1090,7 +1092,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else {
- quester.reset();
+ quester.resetObjectives();
quester.currentStage = null;
player.sendMessage(GREEN + target.getName() + GOLD + " has forcibly quit the Quest " + PURPLE + quester.currentQuest.name + GOLD + ".");
target.sendMessage(GREEN + player.getName() + GOLD + " has forced you to quit the Quest " + PURPLE + quester.currentQuest.name + GOLD + ".");
@@ -1357,7 +1359,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
Quester quester = getQuester(target.getName());
- quester.reset();
+ quester.resetObjectives();
quester.currentQuest = questToGive;
quester.currentStage = questToGive.stages.getFirst();
@@ -2961,14 +2963,107 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
- if (config.contains("quests." + s + ".stages.ordered." + s2 + ".event")) {
+ if (config.contains("quests." + s + ".stages.ordered." + s2 + ".start-event")) {
- Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".event"), this);
+ Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".start-event"), this);
if (evt != null) {
- stage.event = evt;
+ stage.startEvent = evt;
} else {
- printSevere("[Quests] Event in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
+ printSevere("[Quests] start-event in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
+ stageFailed = true;
+ break;
+ }
+
+ }
+
+ if (config.contains("quests." + s + ".stages.ordered." + s2 + ".death-event")) {
+
+ Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".death-event"), this);
+
+ if (evt != null) {
+ stage.deathEvent = evt;
+ } else {
+ printSevere("[Quests] death-event in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
+ stageFailed = true;
+ break;
+ }
+
+ }
+
+ if (config.contains("quests." + s + ".stages.ordered." + s2 + ".disconnect-event")) {
+
+ Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".disconnect-event"), this);
+
+ if (evt != null) {
+ stage.disconnectEvent = evt;
+ } else {
+ printSevere("[Quests] disconnect-event in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
+ stageFailed = true;
+ break;
+ }
+
+ }
+
+ if (config.contains("quests." + s + ".stages.ordered." + s2 + ".chat-events")) {
+
+ if(config.isList("quests." + s + ".stages.ordered." + s2 + ".chat-events")){
+
+ if(config.contains("quests." + s + ".stages.ordered." + s2 + ".chat-event-triggers")){
+
+ if (config.isList("quests." + s + ".stages.ordered." + s2 + ".chat-event-triggers")) {
+
+ List chatEvents = config.getStringList("quests." + s + ".stages.ordered." + s2 + ".chat-events");
+ List chatEventTriggers = config.getStringList("quests." + s + ".stages.ordered." + s2 + ".chat-event-triggers");
+ boolean loadEventFailed = false;
+
+ for (int i = 0; i < chatEvents.size(); i++) {
+
+ Event evt = Event.loadEvent(chatEvents.get(i), this);
+
+ if (evt != null) {
+ stage.chatEvents.put(chatEventTriggers.get(i), evt);
+ } else {
+ printSevere("[Quests] " + chatEvents.get(i) + " inside of chat-events: in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
+ stageFailed = true;
+ loadEventFailed = true;
+ break;
+ }
+
+ }
+
+ if (loadEventFailed) {
+ break;
+ }
+
+ } else {
+ printSevere("[Quests] chat-event-triggers in Stage " + s2 + " of Quest " + quest.name + " is not in list format!");
+ stageFailed = true;
+ break;
+ }
+
+ }else{
+ printSevere("[Quests] Stage " + s2 + " of Quest " + quest.name + " is missing chat-event-triggers!");
+ stageFailed = true;
+ break;
+ }
+
+ }else{
+ printSevere("[Quests] chat-events in Stage " + s2 + " of Quest " + quest.name + " is not in list format!");
+ stageFailed = true;
+ break;
+ }
+
+ }
+
+ if (config.contains("quests." + s + ".stages.ordered." + s2 + ".finish-event")) {
+
+ Event evt = Event.loadEvent(config.getString("quests." + s + ".stages.ordered." + s2 + ".finish-event"), this);
+
+ if (evt != null) {
+ stage.finishEvent = evt;
+ } else {
+ printSevere("[Quests] finish-event in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
stageFailed = true;
break;
}
diff --git a/src/main/java/me/blackvein/quests/Stage.java b/src/main/java/me/blackvein/quests/Stage.java
index 43c1b48bb..374a383cb 100644
--- a/src/main/java/me/blackvein/quests/Stage.java
+++ b/src/main/java/me/blackvein/quests/Stage.java
@@ -3,11 +3,8 @@ package me.blackvein.quests;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
-
import net.citizensnpcs.api.npc.NPC;
-
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -26,7 +23,7 @@ public class Stage {
Integer fishToCatch;
Integer playersToKill;
Map