mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-28 05:35:33 +01:00
Denizen scripts are now under Actions
This commit is contained in:
parent
21c19f7e28
commit
776e28cb0a
@ -18,7 +18,7 @@ public class DenizenTrigger {
|
||||
public DenizenTrigger(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
protected boolean runDenizenScript(String scriptName, Quester quester) {
|
||||
public boolean runDenizenScript(String scriptName, Quester quester) {
|
||||
if (scriptName == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -208,8 +208,8 @@ public class Quest {
|
||||
quester.findCompassTarget();
|
||||
}
|
||||
if (currentStage.delay < 0) {
|
||||
if (currentStage.finishEvent != null) {
|
||||
currentStage.finishEvent.fire(quester, this);
|
||||
if (currentStage.finishAction != null) {
|
||||
currentStage.finishAction.fire(quester, this);
|
||||
}
|
||||
if (quester.currentQuests.get(this) == (orderedStages.size() - 1)) {
|
||||
if (currentStage.script != null) {
|
||||
@ -266,8 +266,8 @@ public class Quest {
|
||||
if (currentStage.script != null) {
|
||||
plugin.getDenizenTrigger().runDenizenScript(currentStage.script, quester);
|
||||
}
|
||||
if (nextStage.startEvent != null) {
|
||||
nextStage.startEvent.fire(quester, this);
|
||||
if (nextStage.startAction != null) {
|
||||
nextStage.startAction.fire(quester, this);
|
||||
}
|
||||
updateCompass(quester, nextStage);
|
||||
String msg = Lang.get(quester.getPlayer(), "questObjectivesTitle");
|
||||
|
@ -885,34 +885,34 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, countList);
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, datamapList);
|
||||
}
|
||||
if (stage.startEvent != null) {
|
||||
cc.setSessionData(pref + CK.S_START_EVENT, stage.startEvent.getName());
|
||||
if (stage.startAction != null) {
|
||||
cc.setSessionData(pref + CK.S_START_EVENT, stage.startAction.getName());
|
||||
}
|
||||
if (stage.finishEvent != null) {
|
||||
cc.setSessionData(pref + CK.S_FINISH_EVENT, stage.finishEvent.getName());
|
||||
if (stage.finishAction != null) {
|
||||
cc.setSessionData(pref + CK.S_FINISH_EVENT, stage.finishAction.getName());
|
||||
}
|
||||
if (stage.deathEvent != null) {
|
||||
cc.setSessionData(pref + CK.S_DEATH_EVENT, stage.deathEvent.getName());
|
||||
if (stage.deathAction != null) {
|
||||
cc.setSessionData(pref + CK.S_DEATH_EVENT, stage.deathAction.getName());
|
||||
}
|
||||
if (stage.disconnectEvent != null) {
|
||||
cc.setSessionData(pref + CK.S_DISCONNECT_EVENT, stage.disconnectEvent.getName());
|
||||
if (stage.disconnectAction != null) {
|
||||
cc.setSessionData(pref + CK.S_DISCONNECT_EVENT, stage.disconnectAction.getName());
|
||||
}
|
||||
if (stage.chatEvents != null) {
|
||||
if (stage.chatActions != null) {
|
||||
LinkedList<String> chatEvents = new LinkedList<String>();
|
||||
LinkedList<String> chatEventTriggers = new LinkedList<String>();
|
||||
for (String s : stage.chatEvents.keySet()) {
|
||||
for (String s : stage.chatActions.keySet()) {
|
||||
chatEventTriggers.add(s);
|
||||
chatEvents.add(stage.chatEvents.get(s).getName());
|
||||
chatEvents.add(stage.chatActions.get(s).getName());
|
||||
}
|
||||
cc.setSessionData(pref + CK.S_CHAT_EVENTS, chatEvents);
|
||||
cc.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, chatEventTriggers);
|
||||
}
|
||||
if (stage.commandEvents != null) {
|
||||
if (stage.commandActions != null) {
|
||||
LinkedList<String> commandEvents = new LinkedList<String>();
|
||||
LinkedList<String> commandEventTriggers = new LinkedList<String>();
|
||||
for (String s : stage.commandEvents.keySet()) {
|
||||
for (String s : stage.commandActions.keySet()) {
|
||||
commandEventTriggers.add(s);
|
||||
commandEvents.add(stage.commandEvents.get(s).getName());
|
||||
commandEvents.add(stage.commandActions.get(s).getName());
|
||||
}
|
||||
cc.setSessionData(pref + CK.S_COMMAND_EVENTS, commandEvents);
|
||||
cc.setSessionData(pref + CK.S_COMMAND_EVENT_TRIGGERS, commandEventTriggers);
|
||||
|
@ -523,21 +523,21 @@ public class Quester {
|
||||
getPlayer().sendMessage(ConfigUtil
|
||||
.parseStringWithPossibleLineBreaks(stageStartMessage, q, getPlayer()));
|
||||
}
|
||||
if (stage.chatEvents.isEmpty() == false) {
|
||||
for (String chatTrigger : stage.chatEvents.keySet()) {
|
||||
if (stage.chatActions.isEmpty() == false) {
|
||||
for (String chatTrigger : stage.chatActions.keySet()) {
|
||||
questData.get(q).eventFired.put(chatTrigger, false);
|
||||
}
|
||||
}
|
||||
if (stage.commandEvents.isEmpty() == false) {
|
||||
for (String commandTrigger : stage.commandEvents.keySet()) {
|
||||
if (stage.commandActions.isEmpty() == false) {
|
||||
for (String commandTrigger : stage.commandActions.keySet()) {
|
||||
questData.get(q).eventFired.put(commandTrigger, false);
|
||||
}
|
||||
}
|
||||
if (q.initialAction != null) {
|
||||
q.initialAction.fire(this, q);
|
||||
}
|
||||
if (stage.startEvent != null) {
|
||||
stage.startEvent.fire(this, q);
|
||||
if (stage.startAction != null) {
|
||||
stage.startAction.fire(this, q);
|
||||
}
|
||||
q.updateCompass(this, stage);
|
||||
saveData();
|
||||
@ -3078,8 +3078,8 @@ public class Quester {
|
||||
if (questSec.contains("stage-delay")) {
|
||||
getQuestData(quest).delayTimeLeft = questSec.getLong("stage-delay");
|
||||
}
|
||||
if (getCurrentStage(quest).chatEvents.isEmpty() == false) {
|
||||
for (String chatTrig : getCurrentStage(quest).chatEvents.keySet()) {
|
||||
if (getCurrentStage(quest).chatActions.isEmpty() == false) {
|
||||
for (String chatTrig : getCurrentStage(quest).chatActions.keySet()) {
|
||||
getQuestData(quest).eventFired.put(chatTrig, false);
|
||||
}
|
||||
}
|
||||
@ -3089,8 +3089,8 @@ public class Quester {
|
||||
getQuestData(quest).eventFired.put(s, true);
|
||||
}
|
||||
}
|
||||
if (getCurrentStage(quest).commandEvents.isEmpty() == false) {
|
||||
for (String commandTrig : getCurrentStage(quest).commandEvents.keySet()) {
|
||||
if (getCurrentStage(quest).commandActions.isEmpty() == false) {
|
||||
for (String commandTrig : getCurrentStage(quest).commandActions.keySet()) {
|
||||
getQuestData(quest).eventFired.put(commandTrig, false);
|
||||
}
|
||||
}
|
||||
|
@ -2829,7 +2829,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
Action evt = Action.loadAction(config.getString("quests." + questKey + ".stages.ordered." + s2
|
||||
+ ".start-event"), this);
|
||||
if (evt != null) {
|
||||
oStage.startEvent = evt;
|
||||
oStage.startAction = evt;
|
||||
} else {
|
||||
stageFailed("start-event: in Stage " + s2 + " of Quest " + quest.getName() + " failed to load.");
|
||||
}
|
||||
@ -2838,7 +2838,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
Action evt = Action.loadAction(config.getString("quests." + questKey + ".stages.ordered." + s2
|
||||
+ ".finish-event"), this);
|
||||
if (evt != null) {
|
||||
oStage.finishEvent = evt;
|
||||
oStage.finishAction = evt;
|
||||
} else {
|
||||
stageFailed("finish-event: in Stage " + s2 + " of Quest " + quest.getName() + " failed to load.");
|
||||
}
|
||||
@ -2847,7 +2847,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
Action evt = Action.loadAction(config.getString("quests." + questKey + ".stages.ordered." + s2
|
||||
+ ".death-event"), this);
|
||||
if (evt != null) {
|
||||
oStage.deathEvent = evt;
|
||||
oStage.deathAction = evt;
|
||||
} else {
|
||||
stageFailed("death-event: in Stage " + s2 + " of Quest " + quest.getName() + " failed to load.");
|
||||
}
|
||||
@ -2856,7 +2856,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
Action evt = Action.loadAction(config.getString("quests." + questKey + ".stages.ordered." + s2
|
||||
+ ".disconnect-event"), this);
|
||||
if (evt != null) {
|
||||
oStage.disconnectEvent = evt;
|
||||
oStage.disconnectAction = evt;
|
||||
} else {
|
||||
stageFailed("disconnect-event: in Stage " + s2 + " of Quest " + quest.getName()
|
||||
+ " failed to load.");
|
||||
@ -2874,7 +2874,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
for (int i = 0; i < chatEvents.size(); i++) {
|
||||
Action evt = Action.loadAction(chatEvents.get(i), this);
|
||||
if (evt != null) {
|
||||
oStage.chatEvents.put(chatEventTriggers.get(i), evt);
|
||||
oStage.chatActions.put(chatEventTriggers.get(i), evt);
|
||||
} else {
|
||||
loadEventFailed = true;
|
||||
stageFailed("" + chatEvents.get(i) + " inside of chat-events: in Stage " + s2
|
||||
@ -2909,7 +2909,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
for (int i = 0; i < commandEvents.size(); i++) {
|
||||
Action evt = Action.loadAction(commandEvents.get(i), this);
|
||||
if (evt != null) {
|
||||
oStage.commandEvents.put(commandEventTriggers.get(i), evt);
|
||||
oStage.commandActions.put(commandEventTriggers.get(i), evt);
|
||||
} else {
|
||||
loadEventFailed = true;
|
||||
stageFailed("" + commandEvents.get(i) + " inside of command-events: in Stage " + s2
|
||||
|
@ -116,12 +116,12 @@ public class Stage {
|
||||
protected LinkedList<String> passwordDisplays = new LinkedList<String>();
|
||||
protected LinkedList<LinkedList<String>> passwordPhrases = new LinkedList<LinkedList<String>>();
|
||||
protected String script;
|
||||
protected Action startEvent = null;
|
||||
protected Action deathEvent = null;
|
||||
protected Map<String, Action> chatEvents = new HashMap<String, Action>();
|
||||
protected Map<String, Action> commandEvents = new HashMap<String, Action>();
|
||||
protected Action disconnectEvent = null;
|
||||
protected Action finishEvent = null;
|
||||
protected Action startAction = null;
|
||||
protected Action deathAction = null;
|
||||
protected Map<String, Action> chatActions = new HashMap<String, Action>();
|
||||
protected Map<String, Action> commandActions = new HashMap<String, Action>();
|
||||
protected Action disconnectAction = null;
|
||||
protected Action finishAction = null;
|
||||
protected long delay = -1;
|
||||
protected String delayMessage = null;
|
||||
protected String completeMessage = null;
|
||||
@ -395,52 +395,52 @@ public class Stage {
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
public Action getStartEvent() {
|
||||
return startEvent;
|
||||
public Action getStartAction() {
|
||||
return startAction;
|
||||
}
|
||||
|
||||
public void setStartEvent(Action startEvent) {
|
||||
this.startEvent = startEvent;
|
||||
public void setStartAction(Action startAction) {
|
||||
this.startAction = startAction;
|
||||
}
|
||||
|
||||
public Action getDeathEvent() {
|
||||
return deathEvent;
|
||||
public Action getDeathAction() {
|
||||
return deathAction;
|
||||
}
|
||||
|
||||
public void setDeathEvent(Action deathEvent) {
|
||||
this.deathEvent = deathEvent;
|
||||
public void setDeathAction(Action deathAction) {
|
||||
this.deathAction = deathAction;
|
||||
}
|
||||
|
||||
public Map<String, Action> getChatEvents() {
|
||||
return chatEvents;
|
||||
public Map<String, Action> getChatActions() {
|
||||
return chatActions;
|
||||
}
|
||||
|
||||
public void setChatEvents(Map<String, Action> chatEvents) {
|
||||
this.chatEvents = chatEvents;
|
||||
public void setChatActions(Map<String, Action> chatActions) {
|
||||
this.chatActions = chatActions;
|
||||
}
|
||||
|
||||
public Map<String, Action> getCommandEvents() {
|
||||
return commandEvents;
|
||||
public Map<String, Action> getCommandActions() {
|
||||
return commandActions;
|
||||
}
|
||||
|
||||
public void setCommandEvents(Map<String, Action> commandEvents) {
|
||||
this.commandEvents = commandEvents;
|
||||
public void setCommandActions(Map<String, Action> commandActions) {
|
||||
this.commandActions = commandActions;
|
||||
}
|
||||
|
||||
public Action getDisconnectEvent() {
|
||||
return disconnectEvent;
|
||||
public Action getDisconnectAction() {
|
||||
return disconnectAction;
|
||||
}
|
||||
|
||||
public void setDisconnectEvent(Action disconnectEvent) {
|
||||
this.disconnectEvent = disconnectEvent;
|
||||
public void setDisconnectAction(Action disconnectAction) {
|
||||
this.disconnectAction = disconnectAction;
|
||||
}
|
||||
|
||||
public Action getFinishEvent() {
|
||||
return finishEvent;
|
||||
public Action getFinishAction() {
|
||||
return finishAction;
|
||||
}
|
||||
|
||||
public void setFinishEvent(Action finishEvent) {
|
||||
this.finishEvent = finishEvent;
|
||||
public void setFinishAction(Action finishAction) {
|
||||
this.finishAction = finishAction;
|
||||
}
|
||||
|
||||
public long getDelay() {
|
||||
|
@ -89,6 +89,7 @@ public class Action {
|
||||
protected float health = -1;
|
||||
protected Location teleport;
|
||||
protected String book = "";
|
||||
protected String denizenScript;
|
||||
|
||||
public Action(final Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -270,6 +271,14 @@ public class Action {
|
||||
this.book = book;
|
||||
}
|
||||
|
||||
public String getDenizenScript() {
|
||||
return book;
|
||||
}
|
||||
|
||||
public void setDenizenScript(String scriptName) {
|
||||
this.denizenScript = scriptName;
|
||||
}
|
||||
|
||||
public void fire(Quester quester, Quest quest) {
|
||||
Player player = quester.getPlayer();
|
||||
if (message != null) {
|
||||
@ -399,6 +408,9 @@ public class Action {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (denizenScript != null) {
|
||||
plugin.getDenizenTrigger().runDenizenScript(denizenScript, quester);
|
||||
}
|
||||
}
|
||||
|
||||
public static Action loadAction(String name, Quests plugin) {
|
||||
@ -689,7 +701,8 @@ public class Action {
|
||||
if (data.contains(actionKey + "potion-effect-durations")) {
|
||||
if (ConfigUtil.checkList(data.getList(actionKey + "potion-effect-durations"), Integer.class)) {
|
||||
if (data.contains(actionKey + "potion-effect-amplifiers")) {
|
||||
if (ConfigUtil.checkList(data.getList(actionKey + "potion-effect-amplifiers"), Integer.class)) {
|
||||
if (ConfigUtil.checkList(data.getList(actionKey + "potion-effect-amplifiers"),
|
||||
Integer.class)) {
|
||||
List<String> types = data.getStringList(actionKey + "potion-effect-types");
|
||||
List<Integer> durations = data.getIntegerList(actionKey + "potion-effect-durations");
|
||||
List<Integer> amplifiers = data.getIntegerList(actionKey + "potion-effect-amplifiers");
|
||||
@ -802,6 +815,9 @@ public class Action {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (data.contains(actionKey + "denizen-script")) {
|
||||
action.denizenScript = data.getString(actionKey + "denizen-script");
|
||||
}
|
||||
return action;
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
}
|
||||
|
||||
public class ActionMainPrompt extends NumericPrompt {
|
||||
private final int size = 9;
|
||||
private final int size = 10;
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
@ -273,10 +273,16 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
return ChatColor.BLUE;
|
||||
if (plugin.getDependencies().getDenizenAPI() == null) {
|
||||
return ChatColor.GRAY;
|
||||
} else {
|
||||
return ChatColor.BLUE;
|
||||
}
|
||||
case 8:
|
||||
return ChatColor.GREEN;
|
||||
return ChatColor.BLUE;
|
||||
case 9:
|
||||
return ChatColor.GREEN;
|
||||
case 10:
|
||||
return ChatColor.RED;
|
||||
default:
|
||||
return null;
|
||||
@ -298,10 +304,16 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
case 6:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorSetMobSpawns");
|
||||
case 7:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorFailQuest") + ":";
|
||||
if (plugin.getDependencies().getDenizenAPI() == null) {
|
||||
return ChatColor.GRAY + Lang.get("stageEditorDenizenScript");
|
||||
} else {
|
||||
return ChatColor.YELLOW + Lang.get("stageEditorDenizenScript");
|
||||
}
|
||||
case 8:
|
||||
return ChatColor.GREEN + Lang.get("save");
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorFailQuest") + ":";
|
||||
case 9:
|
||||
return ChatColor.GREEN + Lang.get("save");
|
||||
case 10:
|
||||
return ChatColor.RED + Lang.get("exit");
|
||||
default:
|
||||
return null;
|
||||
@ -333,12 +345,23 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
return text;
|
||||
}
|
||||
case 7:
|
||||
if (plugin.getDependencies().getDenizenAPI() == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||
} else {
|
||||
if (context.getSessionData(CK.E_DENIZEN) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.E_DENIZEN)
|
||||
+ ChatColor.GRAY + ")";
|
||||
}
|
||||
}
|
||||
case 8:
|
||||
if (context.getSessionData(CK.E_FAIL_QUEST) == null) {
|
||||
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord"));
|
||||
}
|
||||
return "" + ChatColor.AQUA + context.getSessionData(CK.E_FAIL_QUEST);
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
@ -375,6 +398,8 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
case 6:
|
||||
return new MobPrompt();
|
||||
case 7:
|
||||
return new DenizenPrompt();
|
||||
case 8:
|
||||
String s = (String) context.getSessionData(CK.E_FAIL_QUEST);
|
||||
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord"));
|
||||
@ -382,13 +407,13 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord"));
|
||||
}
|
||||
return new ActionMainPrompt();
|
||||
case 8:
|
||||
case 9:
|
||||
if (context.getSessionData(CK.E_OLD_EVENT) != null) {
|
||||
return new SavePrompt((String) context.getSessionData(CK.E_OLD_EVENT));
|
||||
} else {
|
||||
return new SavePrompt(null);
|
||||
}
|
||||
case 9:
|
||||
case 10:
|
||||
return new ExitPrompt();
|
||||
default:
|
||||
return null;
|
||||
@ -577,8 +602,8 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
if (a != null) {
|
||||
for (Quest quest : plugin.getQuests()) {
|
||||
for (Stage stage : quest.getStages()) {
|
||||
if (stage.getFinishEvent() != null
|
||||
&& stage.getFinishEvent().getName().equalsIgnoreCase(a.getName())) {
|
||||
if (stage.getFinishAction() != null
|
||||
&& stage.getFinishAction().getName().equalsIgnoreCase(a.getName())) {
|
||||
used.add(quest.getName());
|
||||
break;
|
||||
}
|
||||
@ -945,8 +970,8 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
modName = modifiedName;
|
||||
for (Quest q : plugin.getQuests()) {
|
||||
for (Stage s : q.getStages()) {
|
||||
if (s.getFinishEvent() != null && s.getFinishEvent().getName() != null) {
|
||||
if (s.getFinishEvent().getName().equalsIgnoreCase(modifiedName)) {
|
||||
if (s.getFinishAction() != null && s.getFinishAction().getName() != null) {
|
||||
if (s.getFinishAction().getName().equalsIgnoreCase(modifiedName)) {
|
||||
modified.add(q.getName());
|
||||
break;
|
||||
}
|
||||
@ -1253,6 +1278,9 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
section.set("cancel-timer", true);
|
||||
}
|
||||
}
|
||||
if (context.getSessionData(CK.E_DENIZEN) != null) {
|
||||
section.set("denizen-script", getCString(context, CK.E_DENIZEN));
|
||||
}
|
||||
try {
|
||||
data.save(actionsFile);
|
||||
} catch (IOException e) {
|
||||
@ -2673,4 +2701,37 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class DenizenPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = ChatColor.DARK_AQUA + "- " + Lang.get("stageEditorDenizenScript") + " -\n";
|
||||
for (String s : plugin.getDependencies().getDenizenAPI()._getScriptNames()) {
|
||||
text += ChatColor.AQUA + "- " + s + "\n";
|
||||
}
|
||||
return text + ChatColor.YELLOW + Lang.get("stageEditorScriptPrompt");
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (plugin.getDependencies().getDenizenAPI().containsScript(input)) {
|
||||
context.setSessionData(CK.E_DENIZEN, input.toUpperCase());
|
||||
return new ActionMainPrompt();
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + Lang.get("stageEditorInvalidScript"));
|
||||
return new DenizenPrompt();
|
||||
}
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(CK.E_DENIZEN, null);
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDenizenCleared"));
|
||||
return new ActionMainPrompt();
|
||||
} else {
|
||||
return new ActionMainPrompt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -402,16 +402,16 @@ public class PlayerListener implements Listener {
|
||||
+ " on chat for quest " + quest.getName());
|
||||
continue;
|
||||
}
|
||||
if (currentStage.getChatEvents().isEmpty() == false) {
|
||||
if (currentStage.getChatActions().isEmpty() == false) {
|
||||
String chat = evt.getMessage();
|
||||
for (final String s : currentStage.getChatEvents().keySet()) {
|
||||
for (final String s : currentStage.getChatActions().keySet()) {
|
||||
if (s.equalsIgnoreCase(chat)) {
|
||||
if (quester.getQuestData(quest).eventFired.get(s) == null
|
||||
|| quester.getQuestData(quest).eventFired.get(s) == false) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
currentStage.getChatEvents().get(s).fire(quester, quest);
|
||||
currentStage.getChatActions().get(s).fire(quester, quest);
|
||||
}
|
||||
|
||||
}.runTask(this.plugin);
|
||||
@ -456,13 +456,13 @@ public class PlayerListener implements Listener {
|
||||
+ " on command for quest " + quest.getName());
|
||||
continue;
|
||||
}
|
||||
if (currentStage.getCommandEvents().isEmpty() == false) {
|
||||
if (currentStage.getCommandActions().isEmpty() == false) {
|
||||
String command = evt.getMessage();
|
||||
for (String s : currentStage.getCommandEvents().keySet()) {
|
||||
for (String s : currentStage.getCommandActions().keySet()) {
|
||||
if (command.equalsIgnoreCase("/" + s)) {
|
||||
if (quester.getQuestData(quest).eventFired.get(s) == null
|
||||
|| quester.getQuestData(quest).eventFired.get(s) == false) {
|
||||
currentStage.getCommandEvents().get(s).fire(quester, quest);
|
||||
currentStage.getCommandActions().get(s).fire(quester, quest);
|
||||
quester.getQuestData(quest).eventFired.put(s, true);
|
||||
}
|
||||
}
|
||||
@ -833,8 +833,8 @@ public class PlayerListener implements Listener {
|
||||
Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
for (Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
Stage stage = quester.getCurrentStage(quest);
|
||||
if (stage != null && stage.getDeathEvent() != null) {
|
||||
quester.getCurrentStage(quest).getDeathEvent().fire(quester, quest);
|
||||
if (stage != null && stage.getDeathAction() != null) {
|
||||
quester.getCurrentStage(quest).getDeathAction().fire(quester, quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -982,8 +982,8 @@ public class PlayerListener implements Listener {
|
||||
if (currentStage.getDelay() > -1) {
|
||||
quester.stopStageTimer(quest);
|
||||
}
|
||||
if (currentStage.getDisconnectEvent() != null) {
|
||||
currentStage.getDisconnectEvent().fire(quester, quest);
|
||||
if (currentStage.getDisconnectAction() != null) {
|
||||
currentStage.getDisconnectAction().fire(quester, quest);
|
||||
}
|
||||
}
|
||||
for (Integer timerId : quester.getTimers().keySet()) {
|
||||
|
@ -47,7 +47,7 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
private final String pref;
|
||||
private final QuestFactory questFactory;
|
||||
private boolean hasObjective = false;
|
||||
private final int size = 17;
|
||||
private final int size = 16;
|
||||
|
||||
public StageMainPrompt(Quests plugin, int stageNum, QuestFactory qf) {
|
||||
this.plugin = plugin;
|
||||
@ -94,16 +94,6 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
return ChatColor.BLUE;
|
||||
}
|
||||
case 12:
|
||||
if (plugin.getDependencies().getDenizenAPI() == null) {
|
||||
return ChatColor.GRAY;
|
||||
} else {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY;
|
||||
} else {
|
||||
return ChatColor.BLUE;
|
||||
}
|
||||
}
|
||||
case 13:
|
||||
if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY;
|
||||
@ -113,7 +103,7 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
} else {
|
||||
return ChatColor.BLUE;
|
||||
}
|
||||
case 14:
|
||||
case 13:
|
||||
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY;
|
||||
@ -123,7 +113,7 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
} else {
|
||||
return ChatColor.BLUE;
|
||||
}
|
||||
case 15:
|
||||
case 14:
|
||||
if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY;
|
||||
@ -133,14 +123,15 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
} else {
|
||||
return ChatColor.BLUE;
|
||||
}
|
||||
case 16:
|
||||
case 15:
|
||||
return ChatColor.RED;
|
||||
case 17:
|
||||
case 16:
|
||||
return ChatColor.GREEN;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSelectionText(ConversationContext context, int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
@ -178,16 +169,6 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
return ChatColor.YELLOW + Lang.get("stageEditorDelayMessage");
|
||||
}
|
||||
case 12:
|
||||
if (plugin.getDependencies().getDenizenAPI() == null) {
|
||||
return ChatColor.GRAY + Lang.get("stageEditorDenizenScript");
|
||||
} else {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY + Lang.get("stageEditorDenizenScript");
|
||||
} else {
|
||||
return ChatColor.YELLOW + Lang.get("stageEditorDenizenScript");
|
||||
}
|
||||
}
|
||||
case 13:
|
||||
if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY + Lang.get("stageEditorStartMessage");
|
||||
@ -197,7 +178,7 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
} else {
|
||||
return ChatColor.YELLOW + Lang.get("stageEditorStartMessage");
|
||||
}
|
||||
case 14:
|
||||
case 13:
|
||||
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY + Lang.get("stageEditorCompleteMessage");
|
||||
@ -207,7 +188,7 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
} else {
|
||||
return ChatColor.YELLOW + Lang.get("stageEditorCompleteMessage");
|
||||
}
|
||||
case 15:
|
||||
case 14:
|
||||
if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY + Lang.get("stageEditorObjectiveOverride");
|
||||
@ -217,9 +198,9 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
} else {
|
||||
return ChatColor.YELLOW + Lang.get("stageEditorObjectiveOverride");
|
||||
}
|
||||
case 16:
|
||||
case 15:
|
||||
return ChatColor.RED + Lang.get("stageEditorDelete");
|
||||
case 17:
|
||||
case 16:
|
||||
return ChatColor.GREEN + Lang.get("done");
|
||||
default:
|
||||
return null;
|
||||
@ -341,21 +322,6 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
+ context.getSessionData(pref + CK.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")";
|
||||
}
|
||||
case 12:
|
||||
if (plugin.getDependencies().getDenizenAPI() == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
|
||||
} else {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
|
||||
} else {
|
||||
if (context.getSessionData(pref + CK.S_DENIZEN) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(pref + CK.S_DENIZEN)
|
||||
+ ChatColor.GRAY + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
case 13:
|
||||
if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
|
||||
@ -366,7 +332,7 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\""
|
||||
+ context.getSessionData(pref + CK.S_START_MESSAGE) + "\"" + ChatColor.GRAY + ")";
|
||||
}
|
||||
case 14:
|
||||
case 13:
|
||||
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
|
||||
@ -377,7 +343,7 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\""
|
||||
+ context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + ChatColor.GRAY + ")";
|
||||
}
|
||||
case 15:
|
||||
case 14:
|
||||
if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) {
|
||||
if (!hasObjective) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
|
||||
@ -388,8 +354,8 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\""
|
||||
+ context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) + "\"" + ChatColor.GRAY + ")";
|
||||
}
|
||||
case 15:
|
||||
case 16:
|
||||
case 17:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
@ -454,7 +420,7 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
} else {
|
||||
return new DelayMessagePrompt();
|
||||
}
|
||||
case 12:
|
||||
/*case 12:
|
||||
if (plugin.getDependencies().getDenizenAPI() == null) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDenizen"));
|
||||
return new StageMainPrompt(plugin, stageNum, questFactory);
|
||||
@ -465,31 +431,31 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
|
||||
return new StageMainPrompt(plugin, stageNum, questFactory);
|
||||
}
|
||||
}
|
||||
case 13:
|
||||
}*/
|
||||
case 12:
|
||||
if (hasObjective) {
|
||||
return new StartMessagePrompt();
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
|
||||
return new StageMainPrompt(plugin, stageNum, questFactory);
|
||||
}
|
||||
case 14:
|
||||
case 13:
|
||||
if (hasObjective) {
|
||||
return new CompleteMessagePrompt();
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
|
||||
return new StageMainPrompt(plugin, stageNum, questFactory);
|
||||
}
|
||||
case 15:
|
||||
case 14:
|
||||
if (hasObjective) {
|
||||
return new OverrideDisplayPrompt();
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
|
||||
return new StageMainPrompt(plugin, stageNum, questFactory);
|
||||
}
|
||||
case 16:
|
||||
case 15:
|
||||
return new DeletePrompt();
|
||||
case 17:
|
||||
case 16:
|
||||
return new StageMenuPrompt(plugin, questFactory);
|
||||
default:
|
||||
return new StageMainPrompt(plugin, stageNum, questFactory);
|
||||
@ -1500,39 +1466,6 @@ public class StageMainPrompt extends NumericPrompt {
|
||||
}
|
||||
}
|
||||
|
||||
private class DenizenPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = ChatColor.DARK_AQUA + "- " + Lang.get("stageEditorDenizenScript") + " -\n";
|
||||
for (String s : plugin.getDependencies().getDenizenAPI()._getScriptNames()) {
|
||||
text += ChatColor.AQUA + "- " + s + "\n";
|
||||
}
|
||||
return text + ChatColor.YELLOW + Lang.get("stageEditorScriptPrompt");
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (plugin.getDependencies().getDenizenAPI().containsScript(input)) {
|
||||
context.setSessionData(pref + CK.S_DENIZEN, input.toUpperCase());
|
||||
return new StageMainPrompt(plugin, stageNum, questFactory);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + Lang.get("stageEditorInvalidScript"));
|
||||
return new DenizenPrompt();
|
||||
}
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(pref + CK.S_DENIZEN, null);
|
||||
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDenizenCleared"));
|
||||
return new StageMainPrompt(plugin, stageNum, questFactory);
|
||||
} else {
|
||||
return new StageMainPrompt(plugin, stageNum, questFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DeletePrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
|
@ -48,8 +48,8 @@ public class StageTimer implements Runnable {
|
||||
if (quester.getCurrentStage(quest).getScript() != null) {
|
||||
plugin.getDependencies().runDenizenScript(quester.getCurrentStage(quest).getScript(), quester);
|
||||
}
|
||||
if (quester.getCurrentStage(quest).getFinishEvent() != null) {
|
||||
quester.getCurrentStage(quest).getFinishEvent().fire(quester, quest);
|
||||
if (quester.getCurrentStage(quest).getFinishAction() != null) {
|
||||
quester.getCurrentStage(quest).getFinishAction().fire(quester, quest);
|
||||
}
|
||||
quest.completeQuest(quester);
|
||||
} else {
|
||||
@ -59,8 +59,8 @@ public class StageTimer implements Runnable {
|
||||
if (currentStage.getScript() != null) {
|
||||
plugin.getDependencies().runDenizenScript(currentStage.getScript(), quester);
|
||||
}
|
||||
if (currentStage.getFinishEvent() != null) {
|
||||
currentStage.getFinishEvent().fire(quester, quest);
|
||||
if (currentStage.getFinishAction() != null) {
|
||||
currentStage.getFinishAction().fire(quester, quest);
|
||||
}
|
||||
quester.hardStagePut(quest, stageNum);
|
||||
quester.addEmptiesFor(quest, stageNum);
|
||||
@ -68,7 +68,7 @@ public class StageTimer implements Runnable {
|
||||
//quester.getCurrentStage(quest).setDelay(-1);
|
||||
quester.getQuestData(quest).delayStartTime = 0;
|
||||
quester.getQuestData(quest).delayTimeLeft = -1;
|
||||
Action stageStartEvent = quester.getCurrentStage(quest).getStartEvent();
|
||||
Action stageStartEvent = quester.getCurrentStage(quest).getStartAction();
|
||||
if (stageStartEvent != null) {
|
||||
stageStartEvent.fire(quester, quest);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public class CK {
|
||||
public static final String S_DISCONNECT_EVENT = "disconnectEvent";
|
||||
public static final String S_DELAY = "delay";
|
||||
public static final String S_DELAY_MESSAGE = "delayMessage";
|
||||
public static final String S_DENIZEN = "denizen";
|
||||
public static final String S_DENIZEN = "denizen"; // Legacy
|
||||
public static final String S_COMPLETE_MESSAGE = "completeMessage";
|
||||
public static final String S_START_MESSAGE = "startMessage";
|
||||
public static final String S_OVERRIDE_DISPLAY = "overrideDisplay";
|
||||
@ -165,4 +165,5 @@ public class CK {
|
||||
public static final String E_COMMANDS = "evtCommands";
|
||||
public static final String E_TIMER = "evtTimer";
|
||||
public static final String E_CANCEL_TIMER = "evtCancelTimer";
|
||||
public static final String E_DENIZEN = "evtDenizen";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user