mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-28 13:45:32 +01:00
NEW Command Event, sorta resolves #118
This commit is contained in:
parent
031af51829
commit
6f9b150818
@ -46,6 +46,7 @@ import org.bukkit.event.inventory.InventoryDragEvent;
|
|||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
import org.bukkit.event.player.PlayerFishEvent.State;
|
import org.bukkit.event.player.PlayerFishEvent.State;
|
||||||
@ -317,6 +318,33 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent evt) {
|
||||||
|
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
|
||||||
|
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
|
||||||
|
if (quester.currentQuests.isEmpty() == false) {
|
||||||
|
for (Quest quest : quester.currentQuests.keySet()) {
|
||||||
|
Stage currentStage = quester.getCurrentStage(quest);
|
||||||
|
if (currentStage == null) {
|
||||||
|
plugin.getLogger().severe("currentStage was null for " + quester.id.toString() + " on command");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (currentStage.commandEvents.isEmpty() == false) {
|
||||||
|
String command = evt.getMessage();
|
||||||
|
for (String s : currentStage.commandEvents.keySet()) {
|
||||||
|
if (command.equalsIgnoreCase("/" + s)) {
|
||||||
|
if (quester.getQuestData(quest).eventFired.get(s) == null || quester.getQuestData(quest).eventFired.get(s) == false) {
|
||||||
|
currentStage.commandEvents.get(s).fire(quester, quest);
|
||||||
|
quester.getQuestData(quest).eventFired.put(s, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockDamage(BlockDamageEvent evt) {
|
public void onBlockDamage(BlockDamageEvent evt) {
|
||||||
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
|
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
|
||||||
|
@ -1078,6 +1078,8 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
String disconnectEvent;
|
String disconnectEvent;
|
||||||
LinkedList<String> chatEvents;
|
LinkedList<String> chatEvents;
|
||||||
LinkedList<String> chatEventTriggers;
|
LinkedList<String> chatEventTriggers;
|
||||||
|
LinkedList<String> commandEvents;
|
||||||
|
LinkedList<String> commandEventTriggers;
|
||||||
Long delay;
|
Long delay;
|
||||||
String overrideDisplay;
|
String overrideDisplay;
|
||||||
String delayMessage;
|
String delayMessage;
|
||||||
@ -1136,6 +1138,8 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
disconnectEvent = null;
|
disconnectEvent = null;
|
||||||
chatEvents = null;
|
chatEvents = null;
|
||||||
chatEventTriggers = null;
|
chatEventTriggers = null;
|
||||||
|
commandEvents = null;
|
||||||
|
commandEventTriggers = null;
|
||||||
delay = null;
|
delay = null;
|
||||||
overrideDisplay = null;
|
overrideDisplay = null;
|
||||||
delayMessage = null;
|
delayMessage = null;
|
||||||
@ -1236,6 +1240,10 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
chatEvents = (LinkedList<String>) cc.getSessionData(pref + CK.S_CHAT_EVENTS);
|
chatEvents = (LinkedList<String>) cc.getSessionData(pref + CK.S_CHAT_EVENTS);
|
||||||
chatEventTriggers = (LinkedList<String>) cc.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS);
|
chatEventTriggers = (LinkedList<String>) cc.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS);
|
||||||
}
|
}
|
||||||
|
if (cc.getSessionData(pref + CK.S_COMMAND_EVENTS) != null) {
|
||||||
|
commandEvents = (LinkedList<String>) cc.getSessionData(pref + CK.S_COMMAND_EVENTS);
|
||||||
|
commandEventTriggers = (LinkedList<String>) cc.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS);
|
||||||
|
}
|
||||||
if (cc.getSessionData(pref + CK.S_DELAY) != null) {
|
if (cc.getSessionData(pref + CK.S_DELAY) != null) {
|
||||||
delay = (Long) cc.getSessionData(pref + CK.S_DELAY);
|
delay = (Long) cc.getSessionData(pref + CK.S_DELAY);
|
||||||
delayMessage = (String) cc.getSessionData(pref + CK.S_DELAY_MESSAGE);
|
delayMessage = (String) cc.getSessionData(pref + CK.S_DELAY_MESSAGE);
|
||||||
@ -1344,6 +1352,10 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
stage.set("chat-events", chatEvents);
|
stage.set("chat-events", chatEvents);
|
||||||
stage.set("chat-event-triggers", chatEventTriggers);
|
stage.set("chat-event-triggers", chatEventTriggers);
|
||||||
}
|
}
|
||||||
|
if (commandEvents != null && commandEvents.isEmpty() == false) {
|
||||||
|
stage.set("command-events", commandEvents);
|
||||||
|
stage.set("command-event-triggers", commandEventTriggers);
|
||||||
|
}
|
||||||
if (delay != null) {
|
if (delay != null) {
|
||||||
stage.set("delay", delay.intValue() / 1000);
|
stage.set("delay", delay.intValue() / 1000);
|
||||||
}
|
}
|
||||||
@ -1693,6 +1705,16 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
cc.setSessionData(pref + CK.S_CHAT_EVENTS, chatEvents);
|
cc.setSessionData(pref + CK.S_CHAT_EVENTS, chatEvents);
|
||||||
cc.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers);
|
cc.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers);
|
||||||
}
|
}
|
||||||
|
if (stage.commandEvents != null) {
|
||||||
|
LinkedList<String> commandEvents = new LinkedList<String>();
|
||||||
|
LinkedList<String> commandEventTriggers = new LinkedList<String>();
|
||||||
|
for (String s : stage.commandEvents.keySet()) {
|
||||||
|
commandEventTriggers.add(s);
|
||||||
|
commandEvents.add(stage.commandEvents.get(s).getName());
|
||||||
|
}
|
||||||
|
cc.setSessionData(pref + CK.S_COMMAND_EVENTS, commandEvents);
|
||||||
|
cc.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers);
|
||||||
|
}
|
||||||
if (stage.delay != -1) {
|
if (stage.delay != -1) {
|
||||||
cc.setSessionData(pref + CK.S_DELAY, stage.delay);
|
cc.setSessionData(pref + CK.S_DELAY, stage.delay);
|
||||||
if (stage.delayMessage != null) {
|
if (stage.delayMessage != null) {
|
||||||
@ -1712,7 +1734,6 @@ public class QuestFactory implements ConversationAbandonedListener {
|
|||||||
cc.setSessionData(pref + CK.S_START_MESSAGE, stage.startMessage);
|
cc.setSessionData(pref + CK.S_START_MESSAGE, stage.startMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SelectDeletePrompt extends StringPrompt {
|
private class SelectDeletePrompt extends StringPrompt {
|
||||||
|
@ -348,6 +348,11 @@ public class Quester {
|
|||||||
questData.get(q).eventFired.put(chatTrigger, false);
|
questData.get(q).eventFired.put(chatTrigger, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (stage.commandEvents.isEmpty() == false) {
|
||||||
|
for (String commandTrigger : stage.commandEvents.keySet()) {
|
||||||
|
questData.get(q).eventFired.put(commandTrigger, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (q.initialEvent != null) {
|
if (q.initialEvent != null) {
|
||||||
q.initialEvent.fire(this, q);
|
q.initialEvent.fire(this, q);
|
||||||
}
|
}
|
||||||
@ -1790,14 +1795,25 @@ public class Quester {
|
|||||||
questSec.set("stage-delay", questData.delayTimeLeft);
|
questSec.set("stage-delay", questData.delayTimeLeft);
|
||||||
}
|
}
|
||||||
if (questData.eventFired.isEmpty() == false) {
|
if (questData.eventFired.isEmpty() == false) {
|
||||||
LinkedList<String> triggers = new LinkedList<String>();
|
LinkedList<String> chatTriggers = new LinkedList<String>();
|
||||||
for (String trigger : questData.eventFired.keySet()) {
|
for (String trigger : questData.eventFired.keySet()) {
|
||||||
if (questData.eventFired.get(trigger) == true) {
|
if (questData.eventFired.get(trigger) == true) {
|
||||||
triggers.add(trigger);
|
chatTriggers.add(trigger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (triggers.isEmpty() == false) {
|
if (chatTriggers.isEmpty() == false) {
|
||||||
questSec.set("chat-triggers", triggers);
|
questSec.set("chat-triggers", chatTriggers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (questData.eventFired.isEmpty() == false) {
|
||||||
|
LinkedList<String> commandTriggers = new LinkedList<String>();
|
||||||
|
for (String commandTrigger : questData.eventFired.keySet()) {
|
||||||
|
if (questData.eventFired.get(commandTrigger) == true) {
|
||||||
|
commandTriggers.add(commandTrigger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (commandTriggers.isEmpty() == false) {
|
||||||
|
questSec.set("command-triggers", commandTriggers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2153,13 +2169,24 @@ public class Quester {
|
|||||||
getQuestData(quest).delayTimeLeft = questSec.getLong("stage-delay");
|
getQuestData(quest).delayTimeLeft = questSec.getLong("stage-delay");
|
||||||
}
|
}
|
||||||
if (getCurrentStage(quest).chatEvents.isEmpty() == false) {
|
if (getCurrentStage(quest).chatEvents.isEmpty() == false) {
|
||||||
for (String trig : getCurrentStage(quest).chatEvents.keySet()) {
|
for (String chatTrig : getCurrentStage(quest).chatEvents.keySet()) {
|
||||||
getQuestData(quest).eventFired.put(trig, false);
|
getQuestData(quest).eventFired.put(chatTrig, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (questSec.contains("chat-triggers")) {
|
if (questSec.contains("chat-triggers")) {
|
||||||
List<String> triggers = questSec.getStringList("chat-triggers");
|
List<String> chatTriggers = questSec.getStringList("chat-triggers");
|
||||||
for (String s : triggers) {
|
for (String s : chatTriggers) {
|
||||||
|
getQuestData(quest).eventFired.put(s, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getCurrentStage(quest).commandEvents.isEmpty() == false) {
|
||||||
|
for (String commandTrig : getCurrentStage(quest).commandEvents.keySet()) {
|
||||||
|
getQuestData(quest).eventFired.put(commandTrig, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (questSec.contains("command-triggers")) {
|
||||||
|
List<String> commandTriggers = questSec.getStringList("command-triggers");
|
||||||
|
for (String s : commandTriggers) {
|
||||||
getQuestData(quest).eventFired.put(s, true);
|
getQuestData(quest).eventFired.put(s, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2288,8 +2315,12 @@ public class Quester {
|
|||||||
newData.set(questName + ".stage-delay", questSec.getLong("stage-delay"));
|
newData.set(questName + ".stage-delay", questSec.getLong("stage-delay"));
|
||||||
}
|
}
|
||||||
if (questSec.contains("chat-triggers")) {
|
if (questSec.contains("chat-triggers")) {
|
||||||
List<String> triggers = questSec.getStringList("chat-triggers");
|
List<String> chatTriggers = questSec.getStringList("chat-triggers");
|
||||||
newData.set(questName + ".chat-triggers", triggers);
|
newData.set(questName + ".chat-triggers", chatTriggers);
|
||||||
|
}
|
||||||
|
if (questSec.contains("command-triggers")) {
|
||||||
|
List<String> commandTriggers = questSec.getStringList("command-triggers");
|
||||||
|
newData.set(questName + ".command-triggers", commandTriggers);
|
||||||
}
|
}
|
||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
|
@ -3266,6 +3266,35 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
stageFailed("chat-events in Stage " + s2 + " of Quest " + quest.name + " is not in list format!");
|
stageFailed("chat-events in Stage " + s2 + " of Quest " + quest.name + " is not in list format!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".command-events")) {
|
||||||
|
if (config.isList("quests." + questName + ".stages.ordered." + s2 + ".command-events")) {
|
||||||
|
if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".command-event-triggers")) {
|
||||||
|
if (config.isList("quests." + questName + ".stages.ordered." + s2 + ".command-event-triggers")) {
|
||||||
|
List<String> commandEvents = config.getStringList("quests." + questName + ".stages.ordered." + s2 + ".command-events");
|
||||||
|
List<String> commandEventTriggers = config.getStringList("quests." + questName + ".stages.ordered." + s2 + ".command-event-triggers");
|
||||||
|
boolean loadEventFailed = false;
|
||||||
|
for (int i = 0; i < commandEvents.size(); i++) {
|
||||||
|
Event evt = Event.loadEvent(commandEvents.get(i), this);
|
||||||
|
if (evt != null) {
|
||||||
|
oStage.commandEvents.put(commandEventTriggers.get(i), evt);
|
||||||
|
} else {
|
||||||
|
loadEventFailed = true;
|
||||||
|
stageFailed("" + commandEvents.get(i) + " inside of command-events: in Stage " + s2 + " of Quest " + quest.name + " failed to load.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (loadEventFailed) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stageFailed("command-event-triggers in Stage " + s2 + " of Quest " + quest.name + " is not in list format!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stageFailed("Stage " + s2 + " of Quest " + quest.name + " is missing command-event-triggers!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stageFailed("command-events in Stage " + s2 + " of Quest " + quest.name + " is not in list format!");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".delay")) {
|
if (config.contains("quests." + questName + ".stages.ordered." + s2 + ".delay")) {
|
||||||
if (config.getLong("quests." + questName + ".stages.ordered." + s2 + ".delay", -999) != -999) {
|
if (config.getLong("quests." + questName + ".stages.ordered." + s2 + ".delay", -999) != -999) {
|
||||||
oStage.delay = config.getInt("quests." + questName + ".stages.ordered." + s2 + ".delay") * 1000;
|
oStage.delay = config.getInt("quests." + questName + ".stages.ordered." + s2 + ".delay") * 1000;
|
||||||
|
@ -117,6 +117,7 @@ public class Stage {
|
|||||||
public Event startEvent = null;
|
public Event startEvent = null;
|
||||||
public Event deathEvent = null;
|
public Event deathEvent = null;
|
||||||
public Map<String, Event> chatEvents = new HashMap<String, Event>();
|
public Map<String, Event> chatEvents = new HashMap<String, Event>();
|
||||||
|
public Map<String, Event> commandEvents = new HashMap<String, Event>();
|
||||||
public Event disconnectEvent = null;
|
public Event disconnectEvent = null;
|
||||||
public Event finishEvent = null;
|
public Event finishEvent = null;
|
||||||
public long delay = -1;
|
public long delay = -1;
|
||||||
@ -278,6 +279,9 @@ public class Stage {
|
|||||||
if (other.chatEvents.equals(chatEvents) == false) {
|
if (other.chatEvents.equals(chatEvents) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (other.commandEvents.equals(commandEvents) == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (other.delay != delay) {
|
if (other.delay != delay) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3127,7 +3127,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
|
|||||||
private class EventListPrompt extends FixedSetPrompt {
|
private class EventListPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
public EventListPrompt() {
|
public EventListPrompt() {
|
||||||
super("1", "2", "3", "4", "5", "6");
|
super("1", "2", "3", "4", "5", "6", "7");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -3164,15 +3164,20 @@ public class CreateStagePrompt extends FixedSetPrompt {
|
|||||||
text += ChatColor.AQUA + " - " + event + ChatColor.BLUE + " (" + Lang.get("stageEditorTriggeredBy") + ": \"" + chatEventTriggers.get(chatEvents.indexOf(event)) + "\")\n";
|
text += ChatColor.AQUA + " - " + event + ChatColor.BLUE + " (" + Lang.get("stageEditorTriggeredBy") + ": \"" + chatEventTriggers.get(chatEvents.indexOf(event)) + "\")\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("back");
|
if (context.getSessionData(pref + CK.S_COMMAND_EVENTS) == null) {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorCommandEvents") + " (" + Lang.get("noneSet") + ")\n";
|
||||||
|
} else {
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorCommandEvents") + "\n";
|
||||||
|
LinkedList<String> commandEvents = (LinkedList<String>) context.getSessionData(pref + CK.S_COMMAND_EVENTS);
|
||||||
|
LinkedList<String> commandEventTriggers = (LinkedList<String>) context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS);
|
||||||
|
for (String event : commandEvents) {
|
||||||
|
text += ChatColor.AQUA + " - " + event + ChatColor.BLUE + " (" + Lang.get("stageEditorTriggeredBy") + ": \"" + commandEventTriggers.get(commandEvents.indexOf(event)) + "\")\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.BLUE + " - " + Lang.get("back");
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* en.put("stageEditorStageEvents", "Stage Events"); en.put("stageEditorStartEvent", "Start Event"); en.put("stageEditorFinishEvent",
|
|
||||||
* "Finish Event"); en.put("stageEditorChatEvents", "Chat Events"); en.put("stageEditorDeathEvent", "Death Event");
|
|
||||||
* en.put("stageEditorDisconnectEvent", "Disconnect Event");
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||||
if (input.equalsIgnoreCase("1")) {
|
if (input.equalsIgnoreCase("1")) {
|
||||||
@ -3186,6 +3191,8 @@ public class CreateStagePrompt extends FixedSetPrompt {
|
|||||||
} else if (input.equalsIgnoreCase("5")) {
|
} else if (input.equalsIgnoreCase("5")) {
|
||||||
return new ChatEventPrompt();
|
return new ChatEventPrompt();
|
||||||
} else if (input.equalsIgnoreCase("6")) {
|
} else if (input.equalsIgnoreCase("6")) {
|
||||||
|
return new CommandEventPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase("7")) {
|
||||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||||
} else {
|
} else {
|
||||||
return new EventListPrompt();
|
return new EventListPrompt();
|
||||||
@ -3460,6 +3467,93 @@ public class CreateStagePrompt extends FixedSetPrompt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class CommandEventPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = ChatColor.DARK_GREEN + "- " + Lang.get("stageEditorCommandEvents") + " -\n";
|
||||||
|
if (questFactory.quests.events.isEmpty()) {
|
||||||
|
text += ChatColor.RED + "- " + Lang.get("none");
|
||||||
|
} else {
|
||||||
|
for (Event e : questFactory.quests.events) {
|
||||||
|
text += ChatColor.GREEN + "- " + e.getName() + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text + ChatColor.YELLOW + Lang.get("stageEditorCommandEventsPrompt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(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(ChatColor.RED + input + ChatColor.YELLOW + " " + Lang.get("stageEditorInvalidEvent"));
|
||||||
|
return new CommandEventPrompt();
|
||||||
|
} else {
|
||||||
|
context.setSessionData(pref + CK.S_COMMAND_TEMP_EVENT, found.getName());
|
||||||
|
return new CommandEventTriggerPrompt();
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
|
return new EventListPrompt();
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||||
|
context.setSessionData(pref + CK.S_COMMAND_EVENTS, null);
|
||||||
|
context.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, null);
|
||||||
|
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorCommandEventsCleared"));
|
||||||
|
return new EventListPrompt();
|
||||||
|
} else {
|
||||||
|
return new CommandEventPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CommandEventTriggerPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String tempEvent = (String) context.getSessionData(pref + CK.S_COMMAND_TEMP_EVENT);
|
||||||
|
String text = ChatColor.GOLD + "- " + Lang.get("stageEditorCommandTrigger") + " -\n";
|
||||||
|
text += ChatColor.YELLOW + Lang.get("stageEditorCommandEventsTriggerPromptA") + " " + ChatColor.AQUA + tempEvent + " " + ChatColor.YELLOW + Lang.get("stageEditorCommandEventsTriggerPromptB");
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||||
|
if (context.getSessionData(pref + CK.S_COMMAND_EVENTS) == null) {
|
||||||
|
LinkedList<String> commandEvents = new LinkedList<String>();
|
||||||
|
LinkedList<String> commandEventTriggers = new LinkedList<String>();
|
||||||
|
String event = (String) context.getSessionData(pref + CK.S_COMMAND_TEMP_EVENT);
|
||||||
|
commandEvents.add(event);
|
||||||
|
commandEventTriggers.add(input.trim());
|
||||||
|
context.setSessionData(pref + CK.S_COMMAND_EVENTS, commandEvents);
|
||||||
|
context.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers);
|
||||||
|
return new EventListPrompt();
|
||||||
|
} else {
|
||||||
|
LinkedList<String> commandEvents = (LinkedList<String>) context.getSessionData(pref + CK.S_COMMAND_EVENTS);
|
||||||
|
LinkedList<String> commandEventTriggers = (LinkedList<String>) context.getSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS);
|
||||||
|
String event = (String) context.getSessionData(pref + CK.S_COMMAND_TEMP_EVENT);
|
||||||
|
commandEvents.add(event);
|
||||||
|
commandEventTriggers.add(input.trim());
|
||||||
|
context.setSessionData(pref + CK.S_COMMAND_EVENTS, commandEvents);
|
||||||
|
context.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers);
|
||||||
|
return new EventListPrompt();
|
||||||
|
}
|
||||||
|
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||||
|
return new EventListPrompt();
|
||||||
|
} else {
|
||||||
|
return new CommandEventTriggerPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class DelayPrompt extends StringPrompt {
|
private class DelayPrompt extends StringPrompt {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,6 +104,9 @@ public class CK {
|
|||||||
public static final String S_CHAT_EVENTS = "chatEvents";
|
public static final String S_CHAT_EVENTS = "chatEvents";
|
||||||
public static final String S_CHAT_EVENT_TRIGGERS = "chatEventTriggers";
|
public static final String S_CHAT_EVENT_TRIGGERS = "chatEventTriggers";
|
||||||
public static final String S_CHAT_TEMP_EVENT = "chatTempEvent";
|
public static final String S_CHAT_TEMP_EVENT = "chatTempEvent";
|
||||||
|
public static final String S_COMMAND_EVENTS = "commandEvents";
|
||||||
|
public static final String S_COMMAND_EVENT_TRIGGERS = "commandEventTriggers";
|
||||||
|
public static final String S_COMMAND_TEMP_EVENT = "commandTempEvent";
|
||||||
public static final String S_DEATH_EVENT = "deathEvent";
|
public static final String S_DEATH_EVENT = "deathEvent";
|
||||||
public static final String S_DISCONNECT_EVENT = "disconnectEvent";
|
public static final String S_DISCONNECT_EVENT = "disconnectEvent";
|
||||||
public static final String S_DELAY = "delay";
|
public static final String S_DELAY = "delay";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
events:
|
events:
|
||||||
ExampleEvent:
|
ApplyPotion:
|
||||||
message: '<red>Event happened!'
|
message: "<blue>You received potion effects!"
|
||||||
potion-effect-types:
|
potion-effect-types:
|
||||||
- Speed
|
- Speed
|
||||||
- Jump
|
- Jump
|
||||||
@ -10,17 +10,21 @@ events:
|
|||||||
potion-effect-amplifiers:
|
potion-effect-amplifiers:
|
||||||
- 3
|
- 3
|
||||||
- 2
|
- 2
|
||||||
GoodJob:
|
NiceFinish:
|
||||||
message: "<green>Good job!"
|
message: "<green>Nice work!"
|
||||||
DeathFail:
|
DeathFail:
|
||||||
fail-quest: true
|
fail-quest: true
|
||||||
FishingStart:
|
RodStart:
|
||||||
message: "<yellow>Type 'rod' in chat to get a fishing rod!"
|
message: "<yellow>Type 'rod' in chat to get a fishing rod!"
|
||||||
RodEvent:
|
GiveRod:
|
||||||
message: "<green>Here you go!"
|
message: "<green>Here you go!"
|
||||||
items:
|
items:
|
||||||
- name-fishing_rod:amount-1
|
- name-fishing_rod:amount-1
|
||||||
TimerEvent:
|
TimerStart:
|
||||||
timer: 40
|
timer: 40
|
||||||
CancelTimer:
|
CancelTimer:
|
||||||
cancel-timer: true
|
cancel-timer: true
|
||||||
|
RunCommand:
|
||||||
|
message: "<red>Did you mean 'help'?"
|
||||||
|
commands:
|
||||||
|
- help
|
@ -38,14 +38,14 @@ quests:
|
|||||||
- Pig
|
- Pig
|
||||||
mob-amounts:
|
mob-amounts:
|
||||||
- 3
|
- 3
|
||||||
finish-event: GoodJob
|
finish-event: NiceFinish
|
||||||
2:
|
2:
|
||||||
death-event: DeathFail
|
death-event: DeathFail
|
||||||
mobs-to-kill:
|
mobs-to-kill:
|
||||||
- Zombie
|
- Zombie
|
||||||
mob-amounts:
|
mob-amounts:
|
||||||
- 2
|
- 2
|
||||||
finish-event: GoodJob
|
finish-event: NiceFinish
|
||||||
3:
|
3:
|
||||||
death-event: DeathFail
|
death-event: DeathFail
|
||||||
mobs-to-kill:
|
mobs-to-kill:
|
||||||
@ -68,10 +68,10 @@ quests:
|
|||||||
stages:
|
stages:
|
||||||
ordered:
|
ordered:
|
||||||
1:
|
1:
|
||||||
start-event: FishingStart
|
start-event: RodStart
|
||||||
death-event: DeathFail
|
death-event: DeathFail
|
||||||
chat-events:
|
chat-events:
|
||||||
- "RodEvent"
|
- "GiveRod"
|
||||||
chat-event-triggers:
|
chat-event-triggers:
|
||||||
- "rod"
|
- "rod"
|
||||||
fish-to-catch: 5
|
fish-to-catch: 5
|
||||||
@ -90,7 +90,7 @@ quests:
|
|||||||
- 10
|
- 10
|
||||||
break-block-durability:
|
break-block-durability:
|
||||||
- 0
|
- 0
|
||||||
start-event: TimerEvent
|
start-event: TimerStart
|
||||||
finish-event: CancelTimer
|
finish-event: CancelTimer
|
||||||
rewards:
|
rewards:
|
||||||
items:
|
items:
|
||||||
|
@ -152,8 +152,11 @@ stageEditorFinishEvent: "Finish Event"
|
|||||||
stageEditorFinishEventCleared: "Finish Event cleared."
|
stageEditorFinishEventCleared: "Finish Event cleared."
|
||||||
stageEditorChatEvents: "Chat Events"
|
stageEditorChatEvents: "Chat Events"
|
||||||
stageEditorChatTrigger: "Chat Trigger"
|
stageEditorChatTrigger: "Chat Trigger"
|
||||||
stageEditorTriggeredBy: "Triggered by"
|
|
||||||
stageEditorChatEventsCleared: "Chat Events cleared."
|
stageEditorChatEventsCleared: "Chat Events cleared."
|
||||||
|
stageEditorCommandEvents: "Command Events"
|
||||||
|
stageEditorCommandTrigger: "Command Trigger"
|
||||||
|
stageEditorCommandEventsCleared: "Command Events cleared."
|
||||||
|
stageEditorTriggeredBy: "Triggered by"
|
||||||
stageEditorDeathEvent: "Death Event"
|
stageEditorDeathEvent: "Death Event"
|
||||||
stageEditorDeathEventCleared: "Death Event cleared."
|
stageEditorDeathEventCleared: "Death Event cleared."
|
||||||
stageEditorDisconnectEvent: "Disconnect Event"
|
stageEditorDisconnectEvent: "Disconnect Event"
|
||||||
@ -229,6 +232,9 @@ stageEditorEventsPrompt: "Enter an event name, or enter 'clear' to clear the eve
|
|||||||
stageEditorChatEventsPrompt: "Enter an event name to add, or enter 'clear' to clear all chat events, or 'cancel' to return"
|
stageEditorChatEventsPrompt: "Enter an event name to add, or enter 'clear' to clear all chat events, or 'cancel' to return"
|
||||||
stageEditorChatEventsTriggerPromptA: "Enter a chat trigger for"
|
stageEditorChatEventsTriggerPromptA: "Enter a chat trigger for"
|
||||||
stageEditorChatEventsTriggerPromptB: "or enter 'cancel' to return."
|
stageEditorChatEventsTriggerPromptB: "or enter 'cancel' to return."
|
||||||
|
stageEditorCommandEventsPrompt: "Enter an event name to add, or enter 'clear' to clear all command events, or 'cancel' to return"
|
||||||
|
stageEditorCommandEventsTriggerPromptA: "Enter a command trigger for"
|
||||||
|
stageEditorCommandEventsTriggerPromptB: "or enter 'cancel' to return."
|
||||||
stageEditorDelayPrompt: "Enter time (in seconds), or enter 'clear' to clear the delay, or 'cancel' to return"
|
stageEditorDelayPrompt: "Enter time (in seconds), or enter 'clear' to clear the delay, or 'cancel' to return"
|
||||||
stageEditorDelayMessagePrompt: "Enter delay message, or enter 'clear' to clear the message, or 'cancel' to return"
|
stageEditorDelayMessagePrompt: "Enter delay message, or enter 'clear' to clear the message, or 'cancel' to return"
|
||||||
stageEditorScriptPrompt: "Enter script name, or enter 'clear' to clear the script, or 'cancel' to return"
|
stageEditorScriptPrompt: "Enter script name, or enter 'clear' to clear the script, or 'cancel' to return"
|
||||||
|
Loading…
Reference in New Issue
Block a user