Improve use of Actions Editor through console

This commit is contained in:
PikaMug 2021-03-09 04:39:22 -05:00
parent 25350ed2a2
commit c1b8161630
3 changed files with 40 additions and 32 deletions

View File

@ -562,10 +562,15 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
case 2:
return new ActionMobTypePrompt(context, mobIndex, questMob);
case 3:
final Map<UUID, Block> selectedMobLocations = plugin.getActionFactory().getSelectedMobLocations();
selectedMobLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
plugin.getActionFactory().setSelectedMobLocations(selectedMobLocations);
return new ActionMobLocationPrompt(context, mobIndex, questMob);
if (context.getForWhom() instanceof Player) {
final Map<UUID, Block> selectedMobLocations = plugin.getActionFactory().getSelectedMobLocations();
selectedMobLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
plugin.getActionFactory().setSelectedMobLocations(selectedMobLocations);
return new ActionMobLocationPrompt(context, mobIndex, questMob);
} else {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("consoleError"));
return new ActionMainPrompt(context);
}
case 4:
return new ActionMobAmountPrompt(context, mobIndex, questMob);
case 5:
@ -715,12 +720,11 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
if (MiscUtil.getProperMobType(input) != null) {
questMob.setType(MiscUtil.getProperMobType(input));
} else {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
+ Lang.get("stageEditorInvalidMob"));
return new ActionMobTypePrompt(context, mobIndex, questMob);
}
@ -760,18 +764,19 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
try {
final int i = Integer.parseInt(input);
if (i < 1) {
player.sendMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "1"));
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum")
.replace("<number>", "1"));
return new ActionMobAmountPrompt(context, mobIndex, questMob);
}
questMob.setSpawnAmounts(i);
return new ActionMobPrompt(context, mobIndex, questMob);
} catch (final NumberFormatException e) {
player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", input));
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
.replace("<input>", input));
return new ActionMobAmountPrompt(context, mobIndex, questMob);
}
}
@ -921,19 +926,18 @@ public class ActionMainPrompt extends ActionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
final 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(context);
} else {
player.sendMessage(ChatColor.RED + Lang.get("stageEditorInvalidScript"));
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorInvalidScript"));
return new ActionDenizenPrompt(context);
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.E_DENIZEN, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDenizenCleared"));
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorDenizenCleared"));
return new ActionMainPrompt(context);
} else {
return new ActionMainPrompt(context);

View File

@ -610,7 +610,6 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
final LinkedList<String> effTypes = new LinkedList<String>();
for (final String s : input.split(" ")) {
@ -618,7 +617,7 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
effTypes.add(PotionEffectType.getByName(s.toUpperCase()).getName());
context.setSessionData(CK.E_POTION_TYPES, effTypes);
} else {
player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
+ Lang.get("eventEditorInvalidPotionType"));
return new PlayerPotionTypesPrompt(context);
}
@ -655,7 +654,6 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
final LinkedList<Long> effDurations = new LinkedList<Long>();
for (final String s : input.split(" ")) {
@ -663,12 +661,14 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
final int i = Integer.parseInt(s);
final long l = i * 1000;
if (l < 1000) {
player.sendMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "1"));
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum")
.replace("<number>", "1"));
return new PlayerPotionDurationsPrompt(context);
}
effDurations.add(l / 50L);
} catch (final NumberFormatException e) {
player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", s));
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
.replace("<input>", s));
return new PlayerPotionDurationsPrompt(context);
}
}
@ -705,19 +705,20 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
final LinkedList<Integer> magAmounts = new LinkedList<Integer>();
for (final String s : input.split(" ")) {
try {
final int i = Integer.parseInt(s);
if (i < 1) {
player.sendMessage(ChatColor.RED + Lang.get("invalidMinimum").replace("<number>", "1"));
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidMinimum")
.replace("<number>", "1"));
return new PlayerPotionMagnitudesPrompt(context);
}
magAmounts.add(i);
} catch (final NumberFormatException e) {
player.sendMessage(ChatColor.RED + Lang.get("reqNotANumber").replace("<input>", s));
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
.replace("<input>", s));
return new PlayerPotionMagnitudesPrompt(context);
}
}
@ -758,7 +759,7 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
try {
final int i = Integer.parseInt(input);
if (i < 0) {
((Player) context.getForWhom()).sendMessage(ChatColor.RED
context.getForWhom().sendRawMessage(ChatColor.RED
+ Lang.get("invalidMinimum").replace("<number>", "0"));
return new PlayerHungerPrompt(context);
} else {
@ -807,7 +808,7 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
try {
final int i = Integer.parseInt(input);
if (i < 0) {
((Player) context.getForWhom()).sendMessage(ChatColor.RED
context.getForWhom().sendRawMessage(ChatColor.RED
+ Lang.get("invalidMinimum").replace("<number>", "0"));
return new PlayerSaturationPrompt(context);
} else {
@ -856,7 +857,7 @@ public class PlayerPrompt extends ActionsEditorNumericPrompt {
try {
final int i = Integer.parseInt(input);
if (i < 0) {
((Player) context.getForWhom()).sendMessage(ChatColor.RED
context.getForWhom().sendRawMessage(ChatColor.RED
+ Lang.get("invalidMinimum").replace("<number>", "0"));
return new PlayerHealthPrompt(context);
} else {

View File

@ -146,11 +146,16 @@ public class WeatherPrompt extends ActionsEditorNumericPrompt {
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(context);
if (context.getForWhom() instanceof Player) {
final Map<UUID, Block> selectedLightningLocations
= plugin.getActionFactory().getSelectedLightningLocations();
selectedLightningLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
plugin.getActionFactory().setSelectedLightningLocations(selectedLightningLocations);
return new LightningPrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("consoleError"));
return new WeatherPrompt(context);
}
case 4:
return new ActionMainPrompt(context);
default:
@ -307,12 +312,11 @@ public class WeatherPrompt extends ActionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
if (plugin.getServer().getWorld(input) != null) {
context.setSessionData(CK.E_WORLD_STORM, plugin.getServer().getWorld(input).getName());
} else {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
+ Lang.get("eventEditorInvalidWorld"));
return new StormWorldPrompt(context);
}
@ -517,12 +521,11 @@ public class WeatherPrompt extends ActionsEditorNumericPrompt {
@Override
public Prompt acceptInput(final ConversationContext context, final String input) {
final Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
if (plugin.getServer().getWorld(input) != null) {
context.setSessionData(CK.E_WORLD_THUNDER, plugin.getServer().getWorld(input).getName());
} else {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
+ Lang.get("eventEditorInvalidWorld"));
return new ThunderWorldPrompt(context);
}