mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-23 01:27:35 +01:00
FIxed denizen lib and EpicBoss error
Removed Mini-Event system (sorry)
This commit is contained in:
parent
263f14b3f2
commit
305e238d9f
Binary file not shown.
BIN
lib/denizen-0.9.1-SNAPSHOT.jar
Normal file
BIN
lib/denizen-0.9.1-SNAPSHOT.jar
Normal file
Binary file not shown.
BIN
lib/mcMMO.jar
BIN
lib/mcMMO.jar
Binary file not shown.
@ -2,7 +2,6 @@ package me.blackvein.quests;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import me.blackvein.quests.events.MiniEvent.MiniEventType;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -609,14 +608,6 @@ public class PlayerListener implements Listener {
|
||||
|
||||
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")) {
|
||||
|
||||
quester.reachLocation(evt.getTo());
|
||||
@ -629,19 +620,4 @@ 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,6 +278,8 @@ public class Quest {
|
||||
player.sendMessage(none);
|
||||
}
|
||||
q.currentQuest = null;
|
||||
|
||||
System.out.println(plugin.getQuester(q.name).currentQuest.getName());
|
||||
q.currentStage = null;
|
||||
q.currentStageIndex = 0;
|
||||
|
||||
|
@ -7,8 +7,6 @@ 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;
|
||||
@ -300,15 +298,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
return new BlockStartPrompt();
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase("6")) {
|
||||
|
||||
if (quests.citizens != null) {
|
||||
selectedBlockStarts.put((Player) context.getForWhom(), null);
|
||||
return new BlockStartPrompt();
|
||||
} else {
|
||||
return new RequirementsPrompt(quests, QuestFactory.this);
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase("6")) {
|
||||
|
||||
if (quests.citizens != null) {
|
||||
@ -709,7 +698,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
}
|
||||
|
||||
if (found == null) {
|
||||
player.sendMessage(RED + input + YELLOW + " " + Lang.get("questEditorInvalidName"));
|
||||
player.sendMessage(RED + input + YELLOW + " " + Lang.get("questEditorInvalidEventName"));
|
||||
return new InitialEventPrompt();
|
||||
} else {
|
||||
context.setSessionData(CK.Q_INITIAL_EVENT, found.getName());
|
||||
@ -1138,9 +1127,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
startMessage = null;
|
||||
completeMessage = null;
|
||||
|
||||
Map<MiniEventType, List<MiniEvent>> miniEvents = null;
|
||||
|
||||
|
||||
if (cc.getSessionData(pref + CK.S_BREAK_IDS) != null) {
|
||||
breakIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_BREAK_IDS);
|
||||
breakAmounts = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_BREAK_AMOUNTS);
|
||||
@ -1247,10 +1233,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
completeMessage = (String) cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE);
|
||||
}
|
||||
|
||||
if (cc.getSessionData(pref + CK.S_MINI_EVENTS) != null) {
|
||||
miniEvents = (Map<MiniEventType, List<MiniEvent>>) cc.getSessionData(pref + CK.S_MINI_EVENTS);
|
||||
}
|
||||
|
||||
if (breakIds != null && breakIds.isEmpty() == false) {
|
||||
stage.set("break-block-ids", breakIds);
|
||||
stage.set("break-block-amounts", breakAmounts);
|
||||
@ -1315,16 +1297,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
stage.set("start-message", startMessage);
|
||||
stage.set("complete-message", completeMessage);
|
||||
|
||||
//TODO change here
|
||||
if (miniEvents != null && miniEvents.isEmpty() == false) {
|
||||
for (Entry<MiniEventType, List<MiniEvent>> ent : miniEvents.entrySet()) {
|
||||
int count = 1;
|
||||
for (MiniEvent miniEvent : ent.getValue()) {
|
||||
stage.createSection("mini-events." + ent.getKey().getName() + "." + count, miniEvent.getValues());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1703,10 +1675,6 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
|
||||
|
@ -5,7 +5,6 @@ import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import me.ThaH3lper.com.LoadBosses.LoadBoss;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
@ -1141,8 +1140,7 @@ public class Quester {
|
||||
|
||||
} else if (objective.equalsIgnoreCase("killBoss")) {
|
||||
|
||||
LoadBoss b = Quests.getBoss(boss);
|
||||
String message = ChatColor.GREEN + "(Completed) Kill " + ChatColor.ITALIC + b.getName() + ChatColor.RESET + ChatColor.GREEN;
|
||||
String message = ChatColor.GREEN + "(Completed) Kill " + ChatColor.ITALIC + boss + ChatColor.RESET + ChatColor.GREEN;
|
||||
message = message + " " + currentStage.bossAmountsToKill.get(currentStage.bossesToKill.indexOf(boss)) + "/" + currentStage.bossAmountsToKill.get(currentStage.bossesToKill.indexOf(boss));
|
||||
p.sendMessage(message);
|
||||
if (testComplete()) {
|
||||
|
@ -21,12 +21,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import me.ThaH3lper.com.EpicBoss;
|
||||
import me.ThaH3lper.com.LoadBosses.LoadBoss;
|
||||
import me.blackvein.quests.events.MiniEvent;
|
||||
import me.blackvein.quests.events.MiniEvent.MiniEventType;
|
||||
import me.blackvein.quests.events.MiniEventChat;
|
||||
import me.blackvein.quests.events.MiniEventKill;
|
||||
import me.blackvein.quests.events.MiniEventNPCInteract;
|
||||
import me.blackvein.quests.events.MiniEventReach;
|
||||
import me.blackvein.quests.prompts.QuestAcceptPrompt;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
@ -3014,68 +3008,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
}
|
||||
|
||||
for (MiniEventType t : MiniEventType.values()) {
|
||||
int meCount = 1;
|
||||
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".mini-events." + t.getName())) {
|
||||
ConfigurationSection configSection = config.createSection("quests." + s + ".stages.ordered." + s2 + ".mini-events." + t.getName());
|
||||
|
||||
LinkedList<MiniEvent> ml = new LinkedList<MiniEvent>();
|
||||
|
||||
for (String string : configSection.getKeys(false)) {
|
||||
|
||||
MiniEvent me = null;
|
||||
ConfigurationSection miniSection = configSection.getConfigurationSection(string);
|
||||
|
||||
switch(t) {
|
||||
case ONDEATH:
|
||||
me = new MiniEvent(miniSection.getValues(false));
|
||||
break;
|
||||
case ONKILL:
|
||||
if (miniSection.contains("data")) {
|
||||
me = new MiniEventKill(quest, miniSection.getValues(false), miniSection.getString("data"));
|
||||
} else {
|
||||
me = new MiniEventKill(quest, miniSection.getValues(false), "");
|
||||
}
|
||||
break;
|
||||
case ONREACH:
|
||||
if (miniSection.contains("data")) {
|
||||
me = new MiniEventReach(quest, miniSection.getValues(false), miniSection.getString("data"));
|
||||
} else {
|
||||
me = new MiniEventReach(quest, miniSection.getValues(false), "");
|
||||
}
|
||||
break;
|
||||
case ONCHAT:
|
||||
if (miniSection.contains("data")) {
|
||||
me = new MiniEventChat(quest, miniSection.getValues(false), miniSection.getString("data"));
|
||||
} else {
|
||||
me = new MiniEventChat(quest, miniSection.getValues(false), "");
|
||||
}
|
||||
break;
|
||||
case ONSTAGEEND:
|
||||
me = new MiniEvent(miniSection.getValues(false));
|
||||
break;
|
||||
case ONQUESTQUIT:
|
||||
me = new MiniEvent(miniSection.getValues(false));
|
||||
break;
|
||||
case ONNPCINTERACT:
|
||||
if (miniSection.contains("data")) {
|
||||
me = new MiniEventNPCInteract(quest, miniSection.getValues(false), miniSection.getString("data"));
|
||||
} else {
|
||||
me = new MiniEventNPCInteract(quest, miniSection.getValues(false), "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (me != null) {
|
||||
ml.add(me);
|
||||
}
|
||||
meCount++;
|
||||
}
|
||||
|
||||
stage.miniEvents.put(t, ml);
|
||||
}
|
||||
}
|
||||
|
||||
stage.citizensToInteract = npcsToTalkTo;
|
||||
|
||||
if (stageFailed) {
|
||||
|
@ -6,10 +6,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.blackvein.quests.events.MiniEvent;
|
||||
import me.blackvein.quests.events.MiniEvent.MiniEventType;
|
||||
import me.blackvein.quests.events.MiniEventKill;
|
||||
import me.blackvein.quests.events.MiniEventReach;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
@ -31,8 +27,6 @@ public class Stage {
|
||||
Integer playersToKill;
|
||||
Map<Map<Enchantment, Material>, Integer> itemsToEnchant = new HashMap<Map<Enchantment, Material>, Integer>();
|
||||
|
||||
Map<MiniEventType, List<MiniEvent>> miniEvents = new HashMap();
|
||||
|
||||
LinkedList<EntityType> mobsToKill = new LinkedList<EntityType>();
|
||||
LinkedList<Integer> mobNumToKill = new LinkedList<Integer>();
|
||||
LinkedList<Location> locationsToKillWithin = new LinkedList<Location>();
|
||||
@ -130,50 +124,6 @@ public class Stage {
|
||||
public String completeMessage = null;
|
||||
public String startMessage = null;
|
||||
|
||||
public boolean executeEvent(Quester quester, MiniEventType type) {
|
||||
|
||||
if (miniEvents.containsKey(type)) {
|
||||
boolean isCancelled = false;
|
||||
for (MiniEvent me : miniEvents.get(type)) {
|
||||
boolean c = me.execute(quester);
|
||||
if (c == true) {
|
||||
isCancelled = true;
|
||||
}
|
||||
}
|
||||
return isCancelled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean executeReachEvent(Location location, Quester quester) {
|
||||
|
||||
if (miniEvents.containsKey(MiniEventType.ONREACH)) {
|
||||
boolean isCancelled = false;
|
||||
for (MiniEvent me : miniEvents.get(MiniEventType.ONREACH)) {
|
||||
boolean c = ((MiniEventReach) me).execute(quester, location);
|
||||
if (c == true) {
|
||||
isCancelled = true;
|
||||
}
|
||||
}
|
||||
return isCancelled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean executeKillEvent(Quester quester, EntityType entityType) {
|
||||
if (miniEvents.containsKey(MiniEventType.ONKILL)) {
|
||||
boolean isCancelled = false;
|
||||
for (MiniEvent me : miniEvents.get(MiniEventType.ONREACH)) {
|
||||
boolean c = ((MiniEventKill) me).execute(quester, entityType);
|
||||
if (c == true) {
|
||||
isCancelled = true;
|
||||
}
|
||||
}
|
||||
return isCancelled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
|
@ -1,157 +0,0 @@
|
||||
package me.blackvein.quests.events;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import me.blackvein.quests.ItemUtil;
|
||||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class MiniEvent {
|
||||
|
||||
protected boolean cancelled = false;
|
||||
protected Map<String, Object> values = new LinkedHashMap<String, Object>();
|
||||
|
||||
public MiniEvent(Map<String, Object> map) {
|
||||
if (map != null) {
|
||||
this.values = map;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean execute(Quester quester) {
|
||||
|
||||
if (quester == null) {
|
||||
return true;
|
||||
}
|
||||
for (Entry<String, Object> ent : values.entrySet()) {
|
||||
String key = ent.getKey();
|
||||
String value = (String)ent.getValue();
|
||||
|
||||
switch(key) {
|
||||
case "cancel":
|
||||
setCancelled(value);
|
||||
break;
|
||||
case "command":
|
||||
executeCommand(value);
|
||||
break;
|
||||
case "send-message":
|
||||
sendMessage(value, quester);
|
||||
break;
|
||||
case "chat-message":
|
||||
chatMessage(value, quester);
|
||||
break;
|
||||
case "broadcast-message":
|
||||
broadcastMessage(value);
|
||||
break;
|
||||
case "set-stage":
|
||||
setStage(value, quester);
|
||||
break;
|
||||
case "teleport":
|
||||
teleport(value, quester);
|
||||
break;
|
||||
case "take-item":
|
||||
takeItem(value, quester);
|
||||
break;
|
||||
case "add-item":
|
||||
addItem(value, quester);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return isCancelled();
|
||||
}
|
||||
|
||||
public void setCancelled(String data) {
|
||||
Boolean c = false;
|
||||
try {
|
||||
c = Boolean.parseBoolean(data);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
cancelled = c;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void executeCommand(String command) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
|
||||
public void sendMessage(String message, Quester quester) {
|
||||
quester.getPlayer().sendMessage(message);
|
||||
}
|
||||
|
||||
public void chatMessage(String message, Quester quester) {
|
||||
quester.getPlayer().chat(message);
|
||||
}
|
||||
|
||||
public void broadcastMessage(String message) {
|
||||
Bukkit.getServer().broadcastMessage(message);
|
||||
}
|
||||
|
||||
public void setStage(String data, Quester quester) {
|
||||
int i = -1;
|
||||
|
||||
try {
|
||||
i = Integer.parseInt(data);
|
||||
} catch (Exception e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
quester.currentQuest.setStage(quester, i - 1);
|
||||
}
|
||||
|
||||
public void teleport(String data, Quester quester) {
|
||||
Location loc = Quests.getLocation(data);
|
||||
if (loc != null) {
|
||||
quester.getPlayer().teleport(loc);
|
||||
}
|
||||
}
|
||||
|
||||
public void takeItem(String data, Quester quester) {
|
||||
ItemStack is = ItemUtil.parseItem(data);
|
||||
PlayerInventory inv = quester.getPlayer().getInventory();
|
||||
|
||||
Quests.removeItem(inv, is);
|
||||
}
|
||||
|
||||
public void addItem(String data, Quester quester) {
|
||||
ItemStack is = ItemUtil.parseItem(data);
|
||||
Quests.addItem(quester.getPlayer(), is);
|
||||
}
|
||||
|
||||
public enum MiniEventType {
|
||||
ONDEATH ("onDeath"),
|
||||
ONKILL ("onKill"),
|
||||
ONREACH("onReach"),
|
||||
ONCHAT("onChat"),
|
||||
ONSTAGEEND("onStageEnd"),
|
||||
ONQUESTQUIT("onQuestQuit"),
|
||||
ONNPCINTERACT("OnNPCInteract");
|
||||
|
||||
private String name;
|
||||
|
||||
MiniEventType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<?, ?> getValues() {
|
||||
return values;
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package me.blackvein.quests.events;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
|
||||
public class MiniEventChat extends MiniEvent {
|
||||
|
||||
private String chatString;
|
||||
|
||||
public MiniEventChat(Quest quest, Map<String, Object> keys, String data) {
|
||||
super(keys);
|
||||
this.chatString = data;
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package me.blackvein.quests.events;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.Quester;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class MiniEventKill extends MiniEvent {
|
||||
|
||||
private List<String> mobTypes;
|
||||
|
||||
public MiniEventKill(Quest quest, Map<String, Object> keys, String mobs) {
|
||||
super(keys);
|
||||
this.mobTypes = Arrays.asList(mobs.split(","));
|
||||
}
|
||||
|
||||
public boolean execute(Quester quester, EntityType type) {
|
||||
if (mobTypes.contains(Quester.prettyMobString(type)) || mobTypes.isEmpty()) {
|
||||
return super.execute(quester);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package me.blackvein.quests.events;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
|
||||
public class MiniEventNPCInteract extends MiniEvent {
|
||||
|
||||
private int npcId = -1;
|
||||
|
||||
public MiniEventNPCInteract(Quest quest, Map<String, Object> map, String data) {
|
||||
super(map);
|
||||
|
||||
try {
|
||||
npcId = Integer.parseInt(data);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package me.blackvein.quests.events;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class MiniEventReach extends MiniEvent{
|
||||
|
||||
private Location location;
|
||||
private int radius;
|
||||
|
||||
public MiniEventReach(Quest quest, Map<String, Object> keys, String data) {
|
||||
super(keys);
|
||||
try {
|
||||
|
||||
this.location = Quests.getLocation(data.split(":")[0]);
|
||||
this.radius = Integer.parseInt(data.split(":")[1]);
|
||||
} catch(Exception e) {
|
||||
location = null;
|
||||
radius = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean execute(Quester quester, Location loc) {
|
||||
if (location == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loc.toVector().distance(location.toVector()) > radius) {
|
||||
return false;
|
||||
} else {
|
||||
return super.execute(quester);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
package me.blackvein.quests.prompts;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.ThaH3lper.com.LoadBosses.LoadBoss;
|
||||
import me.blackvein.quests.ColorUtil;
|
||||
@ -12,8 +10,6 @@ import me.blackvein.quests.Event;
|
||||
import me.blackvein.quests.QuestFactory;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.events.MiniEvent;
|
||||
import me.blackvein.quests.events.MiniEvent.MiniEventType;
|
||||
import me.blackvein.quests.util.CK;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
@ -41,7 +37,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
public CreateStagePrompt(int stageNum, QuestFactory qf, CitizensPlugin cit) {
|
||||
|
||||
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25");
|
||||
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24");
|
||||
this.stageNum = stageNum;
|
||||
this.pref = "stage" + stageNum;
|
||||
this.citizens = cit;
|
||||
@ -359,10 +355,8 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
text += PINK + "" + BOLD + "22 " + RESET + PURPLE + "- " + Lang.get("stageEditorCompleteMessage") + GRAY + "(" + AQUA + "\"" + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + GRAY + ")\n";
|
||||
}
|
||||
|
||||
text += PINK + "" + BOLD + "23 " + RESET + PURPLE + "- " + Lang.get("stageEditorMiniEventMessage") + "\n";
|
||||
|
||||
text += RED + "" + BOLD + "24 " + RESET + PURPLE + "- " + Lang.get("stageEditorDelete") + "\n";
|
||||
text += GREEN + "" + BOLD + "25 " + RESET + PURPLE + "- " + Lang.get("done") + "\n";
|
||||
text += RED + "" + BOLD + "23 " + RESET + PURPLE + "- " + Lang.get("stageEditorDelete") + "\n";
|
||||
text += GREEN + "" + BOLD + "24 " + RESET + PURPLE + "- " + Lang.get("done") + "\n";
|
||||
|
||||
return text;
|
||||
|
||||
@ -446,10 +440,8 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
} else if (input.equalsIgnoreCase("22")) {
|
||||
return new CompleteMessagePrompt();
|
||||
} else if (input.equalsIgnoreCase("23")) {
|
||||
return new MiniEventPrompt();
|
||||
} else if (input.equalsIgnoreCase("24")) {
|
||||
return new DeletePrompt();
|
||||
} else if (input.equalsIgnoreCase("25")) {
|
||||
} else if (input.equalsIgnoreCase("24")) {
|
||||
return new StagesPrompt(questFactory);
|
||||
} else {
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
@ -3829,255 +3821,4 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class MiniEventPrompt extends StringPrompt {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = YELLOW + "- " + GOLD + Lang.get("stageEditorMiniEventMessage") + YELLOW + "-\n";
|
||||
if (context.getSessionData(CK.S_MINI_EVENTS) == null) {
|
||||
text += PINK + "" + BOLD + "1 " + RESET + PURPLE + "- " + "onDeath" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "2 " + RESET + PURPLE + "- " + "onKill" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "3 " + RESET + PURPLE + "- " + "onReach" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "4 " + RESET + PURPLE + "- " + "onStageEnd" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "5 " + RESET + PURPLE + "- " + "onQuestQuit" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "6 " + RESET + PURPLE + "- " + "onNpcTalk" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += GREEN + "" + BOLD + "7 " + RESET + GREEN + "- " + Lang.get("done");
|
||||
} else {
|
||||
Map<MiniEventType, List<MiniEvent>> map = (Map<MiniEventType, List<MiniEvent>>) context.getSessionData(CK.S_MINI_EVENTS);
|
||||
|
||||
if (map.containsKey(MiniEventType.ONDEATH)) {
|
||||
text += PINK + "" + BOLD + "1 " + RESET + PURPLE + "- " + "onDeath" + AQUA + " (" + map.get(MiniEventType.ONDEATH).size() + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "1 " + RESET + PURPLE + "- " + "onDeath" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey(MiniEventType.ONKILL)) {
|
||||
text += PINK + "" + BOLD + "2 " + RESET + PURPLE + "- " + "onKill" + AQUA + " (" + map.get(MiniEventType.ONKILL) + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "2 " + RESET + PURPLE + "- " + "onKill" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey(MiniEventType.ONREACH)) {
|
||||
text += PINK + "" + BOLD + "3 " + RESET + PURPLE + "- " + "onReach" + AQUA + " (" + map.get(MiniEventType.ONREACH).size() + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "3 " + RESET + PURPLE + "- " + "onReach" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey(MiniEventType.ONSTAGEEND)) {
|
||||
text += PINK + "" + BOLD + "4 " + RESET + PURPLE + "- " + "onStageEnd" + AQUA + " (" + map.get(MiniEventType.ONSTAGEEND).size() + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "4 " + RESET + PURPLE + "- " + "onStageEnd" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey(MiniEventType.ONQUESTQUIT)) {
|
||||
text += PINK + "" + BOLD + "5 " + RESET + PURPLE + "- " + "onQuestQuit" + AQUA + " (" + map.get(MiniEventType.ONQUESTQUIT).size() + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "5 " + RESET + PURPLE + "- " + "onQuestQuit" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
if (map.containsKey(MiniEventType.ONNPCINTERACT)) {
|
||||
text += PINK + "" + BOLD + "6 " + RESET + PURPLE + "- " + "onNpcTalk" + AQUA + " (" + map.get(MiniEventType.ONNPCINTERACT).size() + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "6 " + RESET + PURPLE + "- " + "onNpcTalk" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
text += GREEN + "" + BOLD + "7 " + RESET + GREEN + "- " + Lang.get("done");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
MiniEventType type = null;
|
||||
switch (input) {
|
||||
case "1":
|
||||
type = MiniEventType.ONDEATH;
|
||||
break;
|
||||
case "2":
|
||||
type = MiniEventType.ONKILL;
|
||||
break;
|
||||
case "3":
|
||||
type = MiniEventType.ONREACH;
|
||||
break;
|
||||
case "4":
|
||||
type = MiniEventType.ONSTAGEEND;
|
||||
break;
|
||||
case "5":
|
||||
type = MiniEventType.ONQUESTQUIT;
|
||||
break;
|
||||
case "6":
|
||||
type = MiniEventType.ONNPCINTERACT;
|
||||
break;
|
||||
case "7":
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
}
|
||||
|
||||
if (type == null) return new MiniEventPrompt();
|
||||
|
||||
return new MiniEventEditorPrompt(type);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class MiniEventEditorPrompt extends StringPrompt {
|
||||
|
||||
private MiniEventType type;
|
||||
|
||||
public MiniEventEditorPrompt (MiniEventType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = YELLOW + "- " + GOLD + type.getName() + YELLOW + "-\n";
|
||||
if (context.getSessionData(CK.S_MINI_EVENTS) == null) {
|
||||
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorAddMiniEvent") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("done");
|
||||
} else {
|
||||
HashMap<MiniEventType, List<MiniEvent>> types = (HashMap<MiniEventType, List<MiniEvent>>) context.getSessionData(CK.S_MINI_EVENTS);
|
||||
for (int i = 0; i < types.size(); i++) {
|
||||
text += GOLD + " " + (i + 1) + " - Edit: " + AQUA + "Mini-Event: " + (i + 1);
|
||||
}
|
||||
|
||||
text += BLUE + "" + BOLD + (types.size() + 1) + RESET + YELLOW + " - " + Lang.get("stageEditorAddMiniEvent") + "\n";
|
||||
text += BLUE + "" + BOLD + (types.size() + 2) + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
|
||||
text += GREEN + "" + BOLD + (types.size() + 3) + RESET + YELLOW + " - " + Lang.get("done");
|
||||
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
HashMap<MiniEventType, List<MiniEvent>> map = (HashMap<MiniEventType, List<MiniEvent>>) context.getSessionData(CK.S_MINI_EVENTS);
|
||||
boolean none = true;
|
||||
if (map != null) {
|
||||
if (map.containsKey(type)) none = false;
|
||||
}
|
||||
if (none) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
return new MiniEventAddPrompt(0, null);
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
//TODO cleared
|
||||
context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
|
||||
return new MiniEventEditorPrompt(type);
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
}
|
||||
} else {
|
||||
LinkedList<MiniEvent> types = new LinkedList<MiniEvent>(map.get(type));
|
||||
int inp = -1;
|
||||
try {
|
||||
inp = Integer.parseInt(input);
|
||||
} catch (Exception e) {
|
||||
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorNotANumber"));
|
||||
return new MiniEventEditorPrompt(type);
|
||||
}
|
||||
|
||||
if (inp == types.size() + 1) {
|
||||
return new MiniEventAddPrompt(inp - 1, null);
|
||||
} else if (inp == types.size() + 2) {
|
||||
//TODO cleared
|
||||
context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
|
||||
map.put(type, null);
|
||||
context.setSessionData(CK.S_MINI_EVENTS, map);
|
||||
return new MiniEventEditorPrompt(type);
|
||||
} else if (inp == types.size() + 3) {
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
} else if (inp > types.size()){
|
||||
return new MiniEventEditorPrompt(type);
|
||||
} else {
|
||||
return new MiniEventAddPrompt(inp - 1, types.get(inp - 1));
|
||||
}
|
||||
}
|
||||
|
||||
return new MiniEventEditorPrompt(type);
|
||||
}
|
||||
}
|
||||
|
||||
private class MiniEventAddPrompt extends StringPrompt {
|
||||
|
||||
private int index;
|
||||
private MiniEvent miniEvent;
|
||||
|
||||
public MiniEventAddPrompt (int index, MiniEvent miniEvent) {
|
||||
this.index = index;
|
||||
if (miniEvent == null) {
|
||||
this.miniEvent = new MiniEvent(null);
|
||||
} else {
|
||||
this.miniEvent = miniEvent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = "\n";
|
||||
HashMap<String, String> map = (HashMap<String, String>) miniEvent.getValues();
|
||||
|
||||
if (map.containsKey("cancel")) {
|
||||
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventCancel") + GRAY + " (" + map.get("cancel") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventCancel") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("command")) {
|
||||
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventCommand") + GRAY + " (" + map.get("command") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventCommand") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("send-message")) {
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventSendMessage") + GRAY + " (" + map.get("send-message") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventSendMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("chat-message")) {
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventChatMessage") + GRAY + " (" + map.get("chat-message") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventChatMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("broadcast-message")) {
|
||||
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventBroadcastMessage") + GRAY + " (" + map.get("broadcast-message") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventBroadcaseMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("set-stage")) {
|
||||
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventSetStage") + GRAY + " (" + map.get("set-stage") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventSetStage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("teleport")) {
|
||||
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventTeleport") + GRAY + " (" + map.get("teleport") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventTeleport") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("take-item")) {
|
||||
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventTakeItem") + GRAY + " (" + map.get("take-item") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventTakeItem") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("add-item")) {
|
||||
text += BLUE + "" + BOLD + "8" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventAddItem") + GRAY + " (" + map.get("add-item") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "8" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventAddItem") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
text += GREEN + "" + BOLD + "9" + RESET + YELLOW + " - " + Lang.get("done");
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,12 @@ public class ItemUtil implements ColorUtil{
|
||||
*/
|
||||
public static int compareItems(ItemStack one, ItemStack two, boolean ignoreAmount){
|
||||
|
||||
if(one == null && two != null || one != null && two == null)
|
||||
return 0;
|
||||
|
||||
if(one == null && two == null)
|
||||
return 0;
|
||||
|
||||
if(one.getTypeId() != two.getTypeId())
|
||||
return -1;
|
||||
else if( (one.getAmount() != two.getAmount()) && ignoreAmount == false)
|
||||
|
Loading…
Reference in New Issue
Block a user