mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-25 12:15:59 +01:00
More bugfixes (unfinished)
This commit is contained in:
parent
8b57d1e83a
commit
ba8514691b
8
pom.xml
8
pom.xml
@ -30,10 +30,6 @@
|
||||
<id>vault-repo</id>
|
||||
<url>http://ci.herocraftonline.com/plugin/repository/everything</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>mcMMO-repo</id>
|
||||
<url>http://repo.mcmmo.org</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
@ -61,7 +57,9 @@
|
||||
<dependency>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/mcMMO.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.ThaH3lper</groupId>
|
||||
|
@ -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<Location> explosions = new LinkedList<Location>();
|
||||
Map<Location, Effect> effects = new HashMap<Location, Effect>();
|
||||
LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
||||
@ -83,6 +82,10 @@ public class Event {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(other.failQuest != failQuest) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.explosions.equals(explosions) == false) {
|
||||
return false;
|
||||
}
|
||||
@ -123,9 +126,13 @@ public class Event {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.mobSpawns.equals(mobSpawns) == 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();
|
||||
|
||||
@ -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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
@ -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) {
|
||||
|
||||
@ -514,6 +545,18 @@ 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
|
||||
@ -540,9 +583,11 @@ public class PlayerListener implements Listener {
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -581,9 +627,16 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getName());
|
||||
if (quester.currentQuest != null) {
|
||||
if(quester.currentStage.delay > -1)
|
||||
|
||||
if (quester.currentStage.delay > -1) {
|
||||
quester.stopStageTimer();
|
||||
}
|
||||
|
||||
if(quester.currentStage.disconnectEvent != null){
|
||||
quester.currentStage.disconnectEvent.fire(quester);
|
||||
}
|
||||
|
||||
}
|
||||
quester.saveData();
|
||||
|
||||
plugin.questers.remove(quester.name);
|
||||
@ -619,5 +672,4 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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){
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<Integer> radiiToReachWithin = new LinkedList<Integer>();
|
||||
Map<EntityType, Integer> mobsTamed = new EnumMap<EntityType, Integer>(EntityType.class);
|
||||
Map<DyeColor, Integer> sheepSheared = new EnumMap<DyeColor, Integer>(DyeColor.class);
|
||||
public Map<String, Boolean> eventFired = new HashMap<String, Boolean>();
|
||||
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,6 +406,8 @@ public class Quester {
|
||||
|
||||
for (NPC n2 : citizensKilled) {
|
||||
|
||||
if(n.getId() == n2.getId()){
|
||||
|
||||
if (citizenNumKilled.get(citizensKilled.indexOf(n2)) < currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))) {
|
||||
|
||||
unfinishedObjectives.add(ChatColor.GREEN + "Kill " + n.getName() + ChatColor.GREEN + " " + citizenNumKilled.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)));
|
||||
@ -408,6 +422,8 @@ public class Quester {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (String boss : currentStage.bossesToKill) {
|
||||
|
||||
if (bossAmountsKilled.get(bossesKilled.indexOf(boss)) < currentStage.bossAmountsToKill.get(currentStage.bossesToKill.indexOf(boss))) {
|
||||
@ -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<String> triggers = new LinkedList<String>();
|
||||
for(String trigger : eventFired.keySet()){
|
||||
|
||||
if(eventFired.get(trigger) == true)
|
||||
triggers.add(trigger);
|
||||
|
||||
}
|
||||
|
||||
if(triggers.isEmpty() == false)
|
||||
data.set("chat-triggers", triggers);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
@ -2360,6 +2395,9 @@ public class Quester {
|
||||
List<Integer> ids = data.getIntegerList("citizen-ids-killed");
|
||||
List<Integer> 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<String> 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.");
|
||||
}
|
||||
|
@ -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<String> chatEvents = config.getStringList("quests." + s + ".stages.ordered." + s2 + ".chat-events");
|
||||
List<String> 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;
|
||||
}
|
||||
|
@ -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;
|
||||
@ -118,7 +115,11 @@ public class Stage {
|
||||
public Map<DyeColor, Integer> sheepToShear = new EnumMap<DyeColor, Integer>(DyeColor.class);
|
||||
public Map<EnumMap<Material, Integer>, Boolean> itemsToCraft = new HashMap<EnumMap<Material, Integer>, Boolean>();
|
||||
public String script;
|
||||
public Event event;
|
||||
public Event startEvent = null;
|
||||
public Event deathEvent = null;
|
||||
public Map<String, Event> chatEvents = new HashMap<String, Event>();
|
||||
public Event disconnectEvent = null;
|
||||
public Event finishEvent = null;
|
||||
public long delay = -1;
|
||||
public String delayMessage = null;
|
||||
public String completeMessage = null;
|
||||
@ -265,16 +266,39 @@ public class Stage {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.event != null && event != null) {
|
||||
if (other.event.equals(event) == false) {
|
||||
if (other.startEvent != null && startEvent != null) {
|
||||
if (other.startEvent.equals(startEvent) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.event != null && event == null) {
|
||||
} else if (other.startEvent != null && startEvent == null) {
|
||||
return false;
|
||||
} else if (other.event == null && event != null) {
|
||||
} else if (other.startEvent == null && startEvent != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.deathEvent != null && deathEvent != null) {
|
||||
if (other.deathEvent.equals(deathEvent) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.deathEvent != null && deathEvent == null) {
|
||||
return false;
|
||||
} else if (other.deathEvent == null && deathEvent != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.finishEvent != null && finishEvent != null) {
|
||||
if (other.finishEvent.equals(finishEvent) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.finishEvent != null && finishEvent == null) {
|
||||
return false;
|
||||
} else if (other.finishEvent == null && finishEvent != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(other.chatEvents.equals(chatEvents) == false)
|
||||
return false;
|
||||
|
||||
if(other.delay != delay)
|
||||
return false;
|
||||
|
||||
|
@ -28,20 +28,21 @@ public class StageTimer implements Runnable{
|
||||
|
||||
if(quester.currentStage.script != null)
|
||||
plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, player);
|
||||
if(quester.currentStage.event != null)
|
||||
quester.currentStage.event.happen(quester);
|
||||
if(quester.currentStage.finishEvent != null)
|
||||
quester.currentStage.finishEvent.fire(quester);
|
||||
|
||||
quester.currentQuest.completeQuest(quester);
|
||||
|
||||
}else {
|
||||
|
||||
quester.reset();
|
||||
quester.resetObjectives();
|
||||
if(quester.currentStage.script != null)
|
||||
plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, player);
|
||||
if(quester.currentStage.event != null)
|
||||
quester.currentStage.event.happen(quester);
|
||||
if(quester.currentStage.finishEvent != null)
|
||||
quester.currentStage.finishEvent.fire(quester);
|
||||
quester.currentStage = quester.currentQuest.stages.get(quester.currentStageIndex + 1);
|
||||
quester.currentStageIndex++;
|
||||
System.out.println("Adding empties from stage timer");
|
||||
quester.addEmpties();
|
||||
quester.delayStartTime = 0;
|
||||
quester.delayTimeLeft = -1;
|
||||
|
@ -1,12 +0,0 @@
|
||||
Languages
|
||||
|
||||
en - English
|
||||
fr - French
|
||||
es - Spanish
|
||||
de - German
|
||||
sv - Swedish
|
||||
nl - Dutch
|
||||
pl - Polish
|
||||
da - Danish
|
||||
zh - Chinese [Simplified]
|
||||
no - Norwegian
|
@ -1,5 +0,0 @@
|
||||
Parties
|
||||
|
||||
-1 : No parties
|
||||
0 : Parties allowed
|
||||
1+ : Only parties of x size or greater
|
@ -1,16 +0,0 @@
|
||||
damageBlock
|
||||
breakBlock
|
||||
placeBlock
|
||||
useBlock
|
||||
cutBlock
|
||||
catchFish
|
||||
enchantItem
|
||||
killMob
|
||||
deliverItem
|
||||
killPlayer
|
||||
talkToNPC
|
||||
killNPC
|
||||
tameMob
|
||||
shearSheep
|
||||
craftItem
|
||||
reachLocation
|
@ -1,12 +0,0 @@
|
||||
enchant
|
||||
crit
|
||||
spell
|
||||
magiccrit
|
||||
mobspell
|
||||
note
|
||||
portal
|
||||
dust
|
||||
witch
|
||||
snowball
|
||||
splash
|
||||
smoke
|
@ -418,7 +418,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
} else if (input.equalsIgnoreCase("16")) {
|
||||
return new ShearListPrompt();
|
||||
} else if (input.equalsIgnoreCase("17")) {
|
||||
return new EventPrompt();
|
||||
return new EventsPrompt();
|
||||
} else if (input.equalsIgnoreCase("18")) {
|
||||
return new DelayPrompt();
|
||||
} else if (input.equalsIgnoreCase("19")) {
|
||||
@ -3367,6 +3367,67 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private class EventsPrompt extends FixedSetPrompt {
|
||||
|
||||
public EventsPrompt(){
|
||||
|
||||
super("1", "2", "3", "4");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
|
||||
String text = DARKGREEN + "- " + Lang.get("stageEditorEvents") + " -\n";
|
||||
if (questFactory.quests.events.isEmpty()) {
|
||||
text += RED + "- None";
|
||||
} else {
|
||||
for (Event e : questFactory.quests.events) {
|
||||
text += GREEN + "- " + e.getName() + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return text + YELLOW + Lang.get("stageEditorEventsPrompt");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||
|
||||
Player player = (Player) context.getForWhom();
|
||||
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
|
||||
Event found = null;
|
||||
|
||||
for (Event e : questFactory.quests.events) {
|
||||
|
||||
if (e.getName().equalsIgnoreCase(input)) {
|
||||
found = e;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (found == null) {
|
||||
player.sendMessage(RED + input + YELLOW + " " + Lang.get("stageEditorInvalidEvent"));
|
||||
return new EventsPrompt();
|
||||
} else {
|
||||
context.setSessionData(pref + CK.S_EVENT, found.getName());
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(pref + CK.S_EVENT, null);
|
||||
player.sendMessage(YELLOW + "Event cleared.");
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
} else {
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class EventPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
|
@ -1,62 +0,0 @@
|
||||
stage#breakIds
|
||||
stage#breakAmounts
|
||||
|
||||
stage#damageIds
|
||||
stage#damageAmounts
|
||||
|
||||
stage#placeIds
|
||||
stage#placeAmounts
|
||||
|
||||
stage#useIds
|
||||
stage#useAmounts
|
||||
|
||||
stage#cutIds
|
||||
stage#cutAmounts
|
||||
|
||||
stage#fish
|
||||
|
||||
stage#playerKill
|
||||
|
||||
stage#enchantTypes
|
||||
stage#enchantIds
|
||||
stage#enchantAmounts
|
||||
|
||||
stage#deliveryIds
|
||||
stage#deliveryAmounts
|
||||
stage#deliveryNPCs
|
||||
stage#deliveryMessages
|
||||
|
||||
stage#npcIdsToTalkTo
|
||||
|
||||
stage#npcIdsToKill
|
||||
stage#npcAmountsToKill
|
||||
|
||||
stage#mobTypes
|
||||
stage#mobAmounts
|
||||
stage#killLocations
|
||||
stage#killLocationRadii
|
||||
stage#killLocationNames
|
||||
|
||||
stage#bossIds
|
||||
stage#bossAmounts
|
||||
^^^^
|
||||
boss-ids-to-kill
|
||||
boss-amounts-to-kill
|
||||
^^^^
|
||||
|
||||
stage#reachLocations
|
||||
stage#reachLocationRadii
|
||||
stage#reachLocationNames
|
||||
|
||||
stage#tameTypes
|
||||
stage#tameAmounts
|
||||
|
||||
stage#shearColors
|
||||
stage#shearAmounts
|
||||
|
||||
stage#event
|
||||
|
||||
stage#delay
|
||||
stage#delayMessage
|
||||
|
||||
stage#denizen
|
@ -31,6 +31,9 @@ public class Lang {
|
||||
//English
|
||||
//TODO: If finished, completely check everything.
|
||||
//Quests
|
||||
|
||||
en.put("questFailed", "*QUEST FAILED*");
|
||||
|
||||
//Quest create menu
|
||||
en.put("questEditorHeader", "Create Quest");
|
||||
en.put("questEditorCreate", "Create new Quest");
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.blackvein.quests.util;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
|
||||
@ -211,6 +210,8 @@ public class QuestMob {
|
||||
if ((o instanceof QuestMob) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
System.out.println("1");
|
||||
QuestMob other = (QuestMob) o;
|
||||
|
||||
if (name.equalsIgnoreCase(other.name) == false)
|
||||
@ -219,9 +220,13 @@ public class QuestMob {
|
||||
if (entityType != other.entityType)
|
||||
return false;
|
||||
|
||||
System.out.println("2");
|
||||
|
||||
if (dropChances != other.dropChances)
|
||||
return false;
|
||||
|
||||
System.out.println("3");
|
||||
|
||||
if (inventory.length == other.inventory.length) {
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
if (ItemUtil.compareItems(inventory[i], other.inventory[i], false) != 0)
|
||||
@ -231,6 +236,8 @@ public class QuestMob {
|
||||
return false;
|
||||
}
|
||||
|
||||
System.out.println("4");
|
||||
|
||||
if (spawnAmounts != other.spawnAmounts)
|
||||
return false;
|
||||
|
||||
|
@ -10,4 +10,13 @@ events:
|
||||
potion-effect-amplifiers:
|
||||
- 3
|
||||
- 2
|
||||
|
||||
GoodJob:
|
||||
message: "<green>Good job!"
|
||||
DeathFail:
|
||||
fail-quest: true
|
||||
FishingStart:
|
||||
message: "<yellow>Type 'rod' in chat to get a fishing rod!"
|
||||
RodEvent:
|
||||
message: "<green>Here you go!"
|
||||
items:
|
||||
- id-346:amount-1
|
@ -36,16 +36,21 @@ quests:
|
||||
stages:
|
||||
ordered:
|
||||
1:
|
||||
death-event: DeathFail
|
||||
mobs-to-kill:
|
||||
- Pig
|
||||
mob-amounts:
|
||||
- 3
|
||||
finish-event: GoodJob
|
||||
2:
|
||||
death-event: DeathFail
|
||||
mobs-to-kill:
|
||||
- Zombie
|
||||
mob-amounts:
|
||||
- 2
|
||||
finish-event: GoodJob
|
||||
3:
|
||||
death-event: DeathFail
|
||||
mobs-to-kill:
|
||||
- Skeleton
|
||||
mob-amounts:
|
||||
@ -56,3 +61,25 @@ quests:
|
||||
- id-276:amount-1
|
||||
exp: 100
|
||||
quest-points: 1
|
||||
CatchFish:
|
||||
name: 'Catch Fish'
|
||||
ask-message: '<yellow>Catch some fish!'
|
||||
finish-message: '<yellow>Excellent. Here is some <green>experience<yellow>.'
|
||||
parties: 2
|
||||
requirements:
|
||||
quests:
|
||||
- Stone Miner
|
||||
fail-requirement-message: '<red>Complete <purple>Stone Miner<red> first.'
|
||||
stages:
|
||||
ordered:
|
||||
1:
|
||||
start-event: FishingStart
|
||||
death-event: DeathFail
|
||||
chat-events:
|
||||
- "RodEvent"
|
||||
chat-event-triggers:
|
||||
- "rod"
|
||||
fish-to-catch: 5
|
||||
|
||||
rewards:
|
||||
exp: 250
|
Loading…
Reference in New Issue
Block a user