mirror of
https://github.com/PikaMug/Quests.git
synced 2025-02-10 17:41:21 +01:00
Supply external conversation hooks, part 34
This commit is contained in:
parent
829da3867d
commit
b635532109
@ -197,7 +197,7 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
|
||||
case 2:
|
||||
return new PlayerPrompt(context);
|
||||
case 3:
|
||||
return new TimerPrompt();
|
||||
return new TimerPrompt(context);
|
||||
case 4:
|
||||
return new EffectPrompt(context);
|
||||
case 5:
|
||||
|
@ -30,6 +30,7 @@ import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
|
||||
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
|
||||
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
||||
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenNumericPromptEvent;
|
||||
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenStringPromptEvent;
|
||||
import me.blackvein.quests.util.CK;
|
||||
import me.blackvein.quests.util.ConfigUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
@ -310,6 +311,10 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String effects = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n";
|
||||
final Effect[] vals = Effect.values();
|
||||
for (int i = 0; i < vals.length; i++) {
|
||||
@ -374,6 +379,10 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@ -429,6 +438,10 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
|
||||
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
||||
import me.blackvein.quests.convo.generic.ItemStackPrompt;
|
||||
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenNumericPromptEvent;
|
||||
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenStringPromptEvent;
|
||||
import me.blackvein.quests.util.CK;
|
||||
import me.blackvein.quests.util.ConfigUtil;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
@ -269,6 +270,10 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@ -587,6 +592,10 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String effs = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n";
|
||||
for (final PotionEffectType pet : PotionEffectType.values()) {
|
||||
effs += (pet != null && pet.getName() != null) ? (ChatColor.DARK_PURPLE + pet.getName() + "\n") : "";
|
||||
@ -632,6 +641,10 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@ -678,6 +691,10 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@ -723,6 +740,10 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@ -768,6 +789,10 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@ -813,6 +838,10 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@ -858,6 +887,10 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@ -912,6 +945,10 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
|
@ -14,47 +14,107 @@ package me.blackvein.quests.convo.actions.tasks;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.FixedSetPrompt;
|
||||
import org.bukkit.conversations.NumericPrompt;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
|
||||
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
|
||||
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
||||
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenNumericPromptEvent;
|
||||
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenStringPromptEvent;
|
||||
import me.blackvein.quests.util.CK;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
|
||||
public class TimerPrompt extends FixedSetPrompt {
|
||||
public class TimerPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
public TimerPrompt() {
|
||||
super("1", "2", "3");
|
||||
private final Quests plugin;
|
||||
|
||||
public TimerPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
this.plugin = (Quests)context.getPlugin();
|
||||
}
|
||||
|
||||
private final int size = 3;
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return Lang.get("eventEditorTimer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
case 2:
|
||||
return ChatColor.BLUE;
|
||||
case 3:
|
||||
return ChatColor.GREEN;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSelectionText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorSetTimer");
|
||||
case 2:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorCancelTimer");
|
||||
case 3:
|
||||
return ChatColor.GREEN + Lang.get("done");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAdditionalText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
if (context.getSessionData(CK.E_TIMER) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.E_TIMER) + ChatColor.GRAY + ")";
|
||||
}
|
||||
case 2:
|
||||
return ChatColor.AQUA + "" + context.getSessionData(CK.E_CANCEL_TIMER);
|
||||
case 3:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorTimer") + " -\n";
|
||||
if (context.getSessionData(CK.E_TIMER) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetTimer") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetTimer") + "(" + ChatColor.AQUA + "\""
|
||||
+ context.getSessionData(CK.E_TIMER) + "\"" + ChatColor.YELLOW + ")\n";
|
||||
}
|
||||
if (context.getSessionData(CK.E_CANCEL_TIMER) == null) {
|
||||
context.setSessionData(CK.E_CANCEL_TIMER, Lang.get("noWord"));
|
||||
}
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorCancelTimer") + ": " + ChatColor.AQUA
|
||||
+ context.getSessionData(CK.E_CANCEL_TIMER) + "\n";
|
||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3 " + ChatColor.RESET + ChatColor.YELLOW + "- "
|
||||
+ Lang.get("done") + "\n";
|
||||
|
||||
final ActionsEditorPostOpenNumericPromptEvent event
|
||||
= new ActionsEditorPostOpenNumericPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.GOLD + "- " + getTitle(context) + " -\n";
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
return new FailTimerPrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
|
||||
switch (input.intValue()) {
|
||||
case 1:
|
||||
return new TimerFailPrompt(context);
|
||||
case 2:
|
||||
final String s = (String) context.getSessionData(CK.E_CANCEL_TIMER);
|
||||
if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
|
||||
context.setSessionData(CK.E_CANCEL_TIMER, Lang.get("noWord"));
|
||||
@ -62,21 +122,49 @@ public class TimerPrompt extends FixedSetPrompt {
|
||||
context.setSessionData(CK.E_CANCEL_TIMER, Lang.get("yesWord"));
|
||||
}
|
||||
return new ActionMainPrompt(context);
|
||||
case 3:
|
||||
return new ActionMainPrompt(context);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return new ActionMainPrompt(context);
|
||||
}
|
||||
|
||||
public class FailTimerPrompt extends NumericPrompt {
|
||||
|
||||
public class TimerFailPrompt extends ActionsEditorStringPrompt {
|
||||
|
||||
public TimerFailPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final Number number) {
|
||||
context.setSessionData(CK.E_TIMER, number);
|
||||
return new ActionMainPrompt(context);
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext conversationContext) {
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorEnterTimerSeconds");
|
||||
public String getQueryText(final ConversationContext context) {
|
||||
return Lang.get("eventEditorEnterTimerSeconds");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
try {
|
||||
final Integer i = Integer.parseInt(input);
|
||||
context.setSessionData(CK.E_TIMER, i);
|
||||
return new TimerFailPrompt(context);
|
||||
} catch (final NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||
+ Lang.get("reqNotANumber").replace("<input>", input));
|
||||
return new ActionMainPrompt(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,162 +21,288 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.FixedSetPrompt;
|
||||
import org.bukkit.conversations.NumericPrompt;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
|
||||
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
|
||||
import me.blackvein.quests.convo.actions.main.ActionMainPrompt;
|
||||
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenNumericPromptEvent;
|
||||
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenStringPromptEvent;
|
||||
import me.blackvein.quests.util.CK;
|
||||
import me.blackvein.quests.util.ConfigUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import me.blackvein.quests.util.MiscUtil;
|
||||
|
||||
public class WeatherPrompt extends FixedSetPrompt {
|
||||
public class WeatherPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
private final Quests plugin;
|
||||
|
||||
public WeatherPrompt(final ConversationContext context) {
|
||||
super("1", "2", "3", "4");
|
||||
super(context);
|
||||
this.plugin = (Quests)context.getPlugin();
|
||||
}
|
||||
|
||||
|
||||
private final int size = 4;
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return Lang.get("eventEditorWeather");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
return ChatColor.BLUE;
|
||||
case 4:
|
||||
return ChatColor.GREEN;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSelectionText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorSetStorm");
|
||||
case 2:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorSetThunder");
|
||||
case 3:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorSetLightning");
|
||||
case 4:
|
||||
return ChatColor.GREEN + Lang.get("done");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorWeather") + " -\n";
|
||||
if (context.getSessionData(CK.E_WORLD_STORM) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetStorm") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetStorm") + " (" + ChatColor.AQUA
|
||||
+ (String) context.getSessionData(CK.E_WORLD_STORM) + ChatColor.YELLOW + " -> "
|
||||
+ ChatColor.DARK_AQUA + MiscUtil.getTime(Long.valueOf((int)context
|
||||
.getSessionData(CK.E_WORLD_STORM_DURATION) * 1000)) + ChatColor.YELLOW + ")\n";
|
||||
}
|
||||
if (context.getSessionData(CK.E_WORLD_THUNDER) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetThunder") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetThunder") + " (" + ChatColor.AQUA
|
||||
+ (String) context.getSessionData(CK.E_WORLD_THUNDER) + ChatColor.YELLOW + " -> "
|
||||
+ ChatColor.DARK_AQUA + MiscUtil.getTime(Long.valueOf((int)context
|
||||
.getSessionData(CK.E_WORLD_THUNDER_DURATION) * 1000)) + ChatColor.YELLOW + ")\n";
|
||||
}
|
||||
|
||||
if (context.getSessionData(CK.E_LIGHTNING) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetLightning") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetLightning") + "\n";
|
||||
final LinkedList<String> locations = (LinkedList<String>) context.getSessionData(CK.E_LIGHTNING);
|
||||
for (final String loc : locations) {
|
||||
text += ChatColor.GRAY + " - " + ChatColor.AQUA + loc + "\n";
|
||||
public String getAdditionalText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
if (context.getSessionData(CK.E_WORLD_STORM) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + (String) context.getSessionData(CK.E_WORLD_STORM)
|
||||
+ ChatColor.GRAY + " -> " + ChatColor.DARK_AQUA + MiscUtil.getTime(Long.valueOf((int)context
|
||||
.getSessionData(CK.E_WORLD_STORM_DURATION) * 1000)) + ChatColor.GRAY + ")";
|
||||
}
|
||||
case 2:
|
||||
if (context.getSessionData(CK.E_WORLD_THUNDER) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + (String) context.getSessionData(CK.E_WORLD_THUNDER)
|
||||
+ ChatColor.GRAY + " -> " + ChatColor.DARK_AQUA + MiscUtil.getTime(Long.valueOf((int)context
|
||||
.getSessionData(CK.E_WORLD_THUNDER_DURATION) * 1000)) + ChatColor.GRAY + ")";
|
||||
}
|
||||
case 3:
|
||||
if (context.getSessionData(CK.E_LIGHTNING) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
String text = "\n";
|
||||
final LinkedList<String> locations = (LinkedList<String>) context.getSessionData(CK.E_LIGHTNING);
|
||||
for (final String loc : locations) {
|
||||
text += ChatColor.GRAY + " - " + ChatColor.AQUA + loc + "\n";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
case 4:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenNumericPromptEvent event
|
||||
= new ActionsEditorPostOpenNumericPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.GOLD + "- " + getTitle(context) + " -\n";
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||
}
|
||||
text += ChatColor.GREEN + "" + ChatColor.BOLD + "4 " + ChatColor.RESET + ChatColor.GREEN + "- "
|
||||
+ Lang.get("done") + "\n";
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
return new StormPrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
return new ThunderPrompt();
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
final Map<UUID, Block> selectedLightningLocations = plugin.getActionFactory().getSelectedLightningLocations();
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
|
||||
switch (input.intValue()) {
|
||||
case 1:
|
||||
return new StormPrompt(context);
|
||||
case 2:
|
||||
return new ThunderPrompt(context);
|
||||
case 3:
|
||||
final Map<UUID, Block> selectedLightningLocations
|
||||
= plugin.getActionFactory().getSelectedLightningLocations();
|
||||
selectedLightningLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
|
||||
plugin.getActionFactory().setSelectedLightningLocations(selectedLightningLocations);
|
||||
return new LightningPrompt();
|
||||
return new LightningPrompt(context);
|
||||
case 4:
|
||||
return new ActionMainPrompt(context);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return new ActionMainPrompt(context);
|
||||
}
|
||||
|
||||
private class StormPrompt extends FixedSetPrompt {
|
||||
public class StormPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
public StormPrompt() {
|
||||
super("1", "2", "3", "4");
|
||||
public StormPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
private final int size = 4;
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
String text = ChatColor.GOLD + Lang.get("eventEditorStormTitle") + "\n";
|
||||
if (context.getSessionData(CK.E_WORLD_STORM) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetWorld") + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - "
|
||||
+ Lang.get("eventEditorSetDuration") + " " + Lang.get("eventEditorNoWorld") + "\n";
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("clear") + "\n";
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("done");
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetWorld") + " (" + ChatColor.AQUA
|
||||
+ ((String) context.getSessionData(CK.E_WORLD_STORM)) + ChatColor.YELLOW + ")\n";
|
||||
if (context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetDuration") + " (" + Lang.get("noneSet") + ")\n";
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return Lang.get("eventEditorStormTitle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
case 2:
|
||||
return ChatColor.BLUE;
|
||||
case 3:
|
||||
return ChatColor.RED;
|
||||
case 4:
|
||||
return ChatColor.GREEN;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSelectionText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorSetWorld");
|
||||
case 2:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorSetDuration");
|
||||
case 3:
|
||||
return ChatColor.YELLOW + Lang.get("clear");
|
||||
case 4:
|
||||
return ChatColor.GREEN + Lang.get("done");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAdditionalText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
if (context.getSessionData(CK.E_WORLD_STORM) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
final int dur = (int) context.getSessionData(CK.E_WORLD_STORM_DURATION);
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetDuration") + " (" + ChatColor.AQUA + MiscUtil.getTime(dur * 1000)
|
||||
+ ChatColor.YELLOW + ")\n";
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + ((String) context.getSessionData(CK.E_WORLD_STORM))
|
||||
+ ChatColor.GRAY + ")";
|
||||
}
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("clear") + "\n";
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("done");
|
||||
case 2:
|
||||
if (context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA
|
||||
+ MiscUtil.getTime((int)context.getSessionData(CK.E_WORLD_STORM_DURATION) * 1000)
|
||||
+ ChatColor.GRAY + ")";
|
||||
}
|
||||
case 3:
|
||||
case 4:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenNumericPromptEvent event
|
||||
= new ActionsEditorPostOpenNumericPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.GOLD + getTitle(context) + "\n";
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
return new StormWorldPrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
|
||||
switch (input.intValue()) {
|
||||
case 1:
|
||||
return new StormWorldPrompt(context);
|
||||
case 2:
|
||||
if (context.getSessionData(CK.E_WORLD_STORM) == null) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSetWorldFirst"));
|
||||
return new StormPrompt();
|
||||
return new StormPrompt(context);
|
||||
} else {
|
||||
return new StormDurationPrompt();
|
||||
return new StormDurationPrompt(context);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorStormCleared"));
|
||||
context.setSessionData(CK.E_WORLD_STORM, null);
|
||||
context.setSessionData(CK.E_WORLD_STORM_DURATION, null);
|
||||
return new StormPrompt();
|
||||
} else if (input.equalsIgnoreCase("4")) {
|
||||
case 3:
|
||||
if (context.getSessionData(CK.E_WORLD_STORM) != null
|
||||
&& context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetStormDuration"));
|
||||
return new StormPrompt();
|
||||
return new StormPrompt(context);
|
||||
} else {
|
||||
return new ActionMainPrompt(context);
|
||||
}
|
||||
case 4:
|
||||
return new ActionMainPrompt(context);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class StormWorldPrompt extends StringPrompt {
|
||||
public class StormWorldPrompt extends ActionsEditorStringPrompt {
|
||||
|
||||
public StormWorldPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return Lang.get("eventEditorWorldsTitle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryText(final ConversationContext context) {
|
||||
return Lang.get("eventEditorEnterStormWorld");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE;
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String effects = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n" + ChatColor.DARK_PURPLE;
|
||||
for (final World w : plugin.getServer().getWorlds()) {
|
||||
effects += w.getName() + ", ";
|
||||
}
|
||||
effects = effects.substring(0, effects.length());
|
||||
return ChatColor.YELLOW + effects + Lang.get("eventEditorEnterStormWorld");
|
||||
return ChatColor.YELLOW + effects + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -188,111 +314,205 @@ public class WeatherPrompt extends FixedSetPrompt {
|
||||
} else {
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
|
||||
+ Lang.get("eventEditorInvalidWorld"));
|
||||
return new StormWorldPrompt();
|
||||
return new StormWorldPrompt(context);
|
||||
}
|
||||
}
|
||||
return new StormPrompt();
|
||||
return new StormPrompt(context);
|
||||
}
|
||||
}
|
||||
|
||||
private class StormDurationPrompt extends NumericPrompt {
|
||||
public class StormDurationPrompt extends ActionsEditorStringPrompt {
|
||||
|
||||
public StormDurationPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorEnterDuration");
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
|
||||
if (input.intValue() < 1) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||
+ Lang.get("invalidMinimum").replace("<number>", "1"));
|
||||
return new StormDurationPrompt();
|
||||
} else {
|
||||
context.setSessionData(CK.E_WORLD_STORM_DURATION, input.intValue());
|
||||
}
|
||||
return new StormPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
private class ThunderPrompt extends FixedSetPrompt {
|
||||
|
||||
public ThunderPrompt() {
|
||||
super("1", "2", "3", "4");
|
||||
public String getQueryText(final ConversationContext context) {
|
||||
return Lang.get("eventEditorEnterDuration");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
String text = ChatColor.GOLD + Lang.get("eventEditorThunderTitle") + "\n";
|
||||
if (context.getSessionData(CK.E_WORLD_THUNDER) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetWorld") + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - "
|
||||
+ Lang.get("eventEditorSetDuration") + " " + Lang.get("eventEditorNoWorld") + "\n";
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("clear") + "\n";
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("done");
|
||||
} else {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetWorld") + " (" + ChatColor.AQUA
|
||||
+ ((String) context.getSessionData(CK.E_WORLD_THUNDER)) + ChatColor.YELLOW + ")\n";
|
||||
if (context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) {
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetDuration") + " (" + Lang.get("noneSet") + ")\n";
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
try {
|
||||
final Integer i = Integer.parseInt(input);
|
||||
if (i < 1) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||
+ Lang.get("invalidMinimum").replace("<number>", "1"));
|
||||
return new StormDurationPrompt(context);
|
||||
} else {
|
||||
final int dur = (int) context.getSessionData(CK.E_WORLD_THUNDER_DURATION);
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("eventEditorSetDuration") + " (" + ChatColor.AQUA + MiscUtil.getTime(dur * 1000)
|
||||
+ ChatColor.YELLOW + ")\n";
|
||||
context.setSessionData(CK.E_WORLD_STORM_DURATION, i);
|
||||
}
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("clear") + "\n";
|
||||
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - "
|
||||
+ Lang.get("done");
|
||||
} catch (final NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||
+ Lang.get("reqNotANumber").replace("<input>", input));
|
||||
}
|
||||
return new StormPrompt(context);
|
||||
}
|
||||
}
|
||||
|
||||
public class ThunderPrompt extends ActionsEditorNumericPrompt {
|
||||
|
||||
public ThunderPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
private final int size = 4;
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return Lang.get("eventEditorThunderTitle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor getNumberColor(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
case 2:
|
||||
return ChatColor.BLUE;
|
||||
case 3:
|
||||
return ChatColor.RED;
|
||||
case 4:
|
||||
return ChatColor.GREEN;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSelectionText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorSetWorld");
|
||||
case 2:
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorSetDuration");
|
||||
case 3:
|
||||
return ChatColor.YELLOW + Lang.get("clear");
|
||||
case 4:
|
||||
return ChatColor.GREEN + Lang.get("done");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAdditionalText(final ConversationContext context, final int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
if (context.getSessionData(CK.E_WORLD_THUNDER) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA + ((String) context.getSessionData(CK.E_WORLD_THUNDER))
|
||||
+ ChatColor.GRAY + ")";
|
||||
}
|
||||
case 2:
|
||||
if (context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) {
|
||||
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
|
||||
} else {
|
||||
return ChatColor.GRAY + "(" + ChatColor.AQUA
|
||||
+ MiscUtil.getTime((int)context.getSessionData(CK.E_WORLD_THUNDER_DURATION) * 1000)
|
||||
+ ChatColor.GRAY + ")";
|
||||
}
|
||||
case 3:
|
||||
case 4:
|
||||
return "";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenNumericPromptEvent event
|
||||
= new ActionsEditorPostOpenNumericPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String text = ChatColor.GOLD + getTitle(context) + "\n";
|
||||
for (int i = 1; i <= size; i++) {
|
||||
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
||||
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final String input) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
return new ThunderWorldPrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
|
||||
switch (input.intValue()) {
|
||||
case 1:
|
||||
return new ThunderWorldPrompt(context);
|
||||
case 2:
|
||||
if (context.getSessionData(CK.E_WORLD_THUNDER) == null) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSetWorldFirst"));
|
||||
return new ThunderPrompt();
|
||||
return new ThunderPrompt(context);
|
||||
} else {
|
||||
return new ThunderDurationPrompt();
|
||||
return new ThunderDurationPrompt(context);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
case 3:
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorThunderCleared"));
|
||||
context.setSessionData(CK.E_WORLD_THUNDER, null);
|
||||
context.setSessionData(CK.E_WORLD_THUNDER_DURATION, null);
|
||||
return new ThunderPrompt();
|
||||
} else if (input.equalsIgnoreCase("4")) {
|
||||
return new ThunderPrompt(context);
|
||||
case 4:
|
||||
if (context.getSessionData(CK.E_WORLD_THUNDER) != null
|
||||
&& context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetThunderDuration"));
|
||||
return new ThunderPrompt();
|
||||
return new ThunderPrompt(context);
|
||||
} else {
|
||||
return new ActionMainPrompt(context);
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private class ThunderWorldPrompt extends StringPrompt {
|
||||
public class ThunderWorldPrompt extends ActionsEditorStringPrompt {
|
||||
|
||||
public ThunderWorldPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return Lang.get("eventEditorWorldsTitle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryText(final ConversationContext context) {
|
||||
return Lang.get("eventEditorEnterThunderWorld");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE;
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
String effects = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n" + ChatColor.DARK_PURPLE;
|
||||
for (final World w : plugin.getServer().getWorlds()) {
|
||||
effects += w.getName() + ", ";
|
||||
}
|
||||
effects = effects.substring(0, effects.length());
|
||||
return ChatColor.YELLOW + effects + Lang.get("eventEditorEnterThunderWorld");
|
||||
return ChatColor.YELLOW + effects + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -304,38 +524,80 @@ public class WeatherPrompt extends FixedSetPrompt {
|
||||
} else {
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
|
||||
+ Lang.get("eventEditorInvalidWorld"));
|
||||
return new ThunderWorldPrompt();
|
||||
return new ThunderWorldPrompt(context);
|
||||
}
|
||||
}
|
||||
return new ThunderPrompt();
|
||||
return new ThunderPrompt(context);
|
||||
}
|
||||
}
|
||||
|
||||
private class ThunderDurationPrompt extends NumericPrompt {
|
||||
public class ThunderDurationPrompt extends ActionsEditorStringPrompt {
|
||||
|
||||
public ThunderDurationPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorEnterDuration");
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
|
||||
if (input.intValue() < 1) {
|
||||
public String getQueryText(final ConversationContext context) {
|
||||
return Lang.get("eventEditorEnterDuration");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
try {
|
||||
final Integer i = Integer.parseInt(input);
|
||||
if (i < 1) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||
+ Lang.get("invalidMinimum").replace("<number>", "1"));
|
||||
return new ThunderDurationPrompt(context);
|
||||
} else {
|
||||
context.setSessionData(CK.E_WORLD_THUNDER_DURATION, i);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED
|
||||
+ Lang.get("invalidMinimum").replace("<number>", "1"));
|
||||
return new ThunderDurationPrompt();
|
||||
} else {
|
||||
context.setSessionData(CK.E_WORLD_THUNDER_DURATION, input.intValue());
|
||||
+ Lang.get("reqNotANumber").replace("<input>", input));
|
||||
}
|
||||
return new ThunderPrompt();
|
||||
return new ThunderPrompt(context);
|
||||
}
|
||||
}
|
||||
|
||||
public class LightningPrompt extends StringPrompt {
|
||||
public class LightningPrompt extends ActionsEditorStringPrompt {
|
||||
|
||||
public LightningPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryText(final ConversationContext context) {
|
||||
return Lang.get("eventEditorLightningPrompt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(final ConversationContext context) {
|
||||
return ChatColor.YELLOW + Lang.get("eventEditorLightningPrompt");
|
||||
final ActionsEditorPostOpenStringPromptEvent event
|
||||
= new ActionsEditorPostOpenStringPromptEvent(context, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -343,7 +605,8 @@ public class WeatherPrompt extends FixedSetPrompt {
|
||||
public Prompt acceptInput(final ConversationContext context, final String input) {
|
||||
final Player player = (Player) context.getForWhom();
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) {
|
||||
final Map<UUID, Block> selectedLightningLocations = plugin.getActionFactory().getSelectedLightningLocations();
|
||||
final Map<UUID, Block> selectedLightningLocations
|
||||
= plugin.getActionFactory().getSelectedLightningLocations();
|
||||
final Block block = selectedLightningLocations.get(player.getUniqueId());
|
||||
if (block != null) {
|
||||
final Location loc = block.getLocation();
|
||||
@ -359,22 +622,24 @@ public class WeatherPrompt extends FixedSetPrompt {
|
||||
plugin.getActionFactory().setSelectedLightningLocations(selectedLightningLocations);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
|
||||
return new LightningPrompt();
|
||||
return new LightningPrompt(context);
|
||||
}
|
||||
return new ActionMainPrompt(context);
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(CK.E_LIGHTNING, null);
|
||||
final Map<UUID, Block> selectedLightningLocations = plugin.getActionFactory().getSelectedLightningLocations();
|
||||
final Map<UUID, Block> selectedLightningLocations
|
||||
= plugin.getActionFactory().getSelectedLightningLocations();
|
||||
selectedLightningLocations.remove(player.getUniqueId());
|
||||
plugin.getActionFactory().setSelectedLightningLocations(selectedLightningLocations);
|
||||
return new ActionMainPrompt(context);
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
final Map<UUID, Block> selectedLightningLocations = plugin.getActionFactory().getSelectedLightningLocations();
|
||||
final Map<UUID, Block> selectedLightningLocations
|
||||
= plugin.getActionFactory().getSelectedLightningLocations();
|
||||
selectedLightningLocations.remove(player.getUniqueId());
|
||||
plugin.getActionFactory().setSelectedLightningLocations(selectedLightningLocations);
|
||||
return new ActionMainPrompt(context);
|
||||
} else {
|
||||
return new LightningPrompt();
|
||||
return new LightningPrompt(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -326,7 +326,6 @@ eventEditorInvalidName: "is not a valid item name!"
|
||||
eventEditorStorm: "Action Storm"
|
||||
eventEditorSetWorld: "Set world"
|
||||
eventEditorSetDuration: "Set duration"
|
||||
eventEditorNoWorld: "(No world set)"
|
||||
eventEditorSetWorldFirst: "You must set a world first!"
|
||||
eventEditorInvalidWorld: "is not a valid world name!"
|
||||
eventEditorMustSetStormDuration: "You must set a storm duration!"
|
||||
|
Loading…
Reference in New Issue
Block a user