Supply external conversation hooks, part 33

This commit is contained in:
PikaMug 2020-08-16 03:23:51 -04:00
parent a369642a54
commit 46fe484826
7 changed files with 629 additions and 284 deletions

View File

@ -127,7 +127,7 @@ public class Dependencies {
if (citizens == null && isPluginAvailable("Citizens")) { if (citizens == null && isPluginAvailable("Citizens")) {
try { try {
citizens = (CitizensPlugin) plugin.getServer().getPluginManager().getPlugin("Citizens"); citizens = (CitizensPlugin) plugin.getServer().getPluginManager().getPlugin("Citizens");
plugin.getLogger().info("Sucessfully linked Quests with Citizens " plugin.getLogger().info("Successfully linked Quests with Citizens "
+ citizens.getDescription().getVersion()); + citizens.getDescription().getVersion());
} catch (final Exception e) { } catch (final Exception e) {
plugin.getLogger().warning("Legacy version of Citizens found. Citizens in Quests not enabled."); plugin.getLogger().warning("Legacy version of Citizens found. Citizens in Quests not enabled.");

View File

@ -207,7 +207,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} }
context.setSessionData(CK.E_POTION_TYPES, types); context.setSessionData(CK.E_POTION_TYPES, types);
context.setSessionData(CK.E_POTION_DURATIONS, durations); context.setSessionData(CK.E_POTION_DURATIONS, durations);
context.setSessionData(CK.E_POTION_STRENGHT, mags); context.setSessionData(CK.E_POTION_STRENGTH, mags);
} }
if (event.hunger > -1) { if (event.hunger > -1) {
context.setSessionData(CK.E_HUNGER, event.hunger); context.setSessionData(CK.E_HUNGER, event.hunger);
@ -251,7 +251,7 @@ public class ActionFactory implements ConversationAbandonedListener {
context.setSessionData(CK.E_LIGHTNING, null); context.setSessionData(CK.E_LIGHTNING, null);
context.setSessionData(CK.E_POTION_TYPES, null); context.setSessionData(CK.E_POTION_TYPES, null);
context.setSessionData(CK.E_POTION_DURATIONS, null); context.setSessionData(CK.E_POTION_DURATIONS, null);
context.setSessionData(CK.E_POTION_STRENGHT, null); context.setSessionData(CK.E_POTION_STRENGTH, null);
context.setSessionData(CK.E_HUNGER, null); context.setSessionData(CK.E_HUNGER, null);
context.setSessionData(CK.E_SATURATION, null); context.setSessionData(CK.E_SATURATION, null);
context.setSessionData(CK.E_HEALTH, null); context.setSessionData(CK.E_HEALTH, null);
@ -417,7 +417,7 @@ public class ActionFactory implements ConversationAbandonedListener {
if (context.getSessionData(CK.E_POTION_TYPES) != null) { if (context.getSessionData(CK.E_POTION_TYPES) != null) {
section.set("potion-effect-types", context.getSessionData(CK.E_POTION_TYPES)); section.set("potion-effect-types", context.getSessionData(CK.E_POTION_TYPES));
section.set("potion-effect-durations", context.getSessionData(CK.E_POTION_DURATIONS)); section.set("potion-effect-durations", context.getSessionData(CK.E_POTION_DURATIONS));
section.set("potion-effect-amplifiers", context.getSessionData(CK.E_POTION_STRENGHT)); section.set("potion-effect-amplifiers", context.getSessionData(CK.E_POTION_STRENGTH));
} }
if (context.getSessionData(CK.E_HUNGER) != null) { if (context.getSessionData(CK.E_HUNGER) != null) {
section.set("hunger", context.getSessionData(CK.E_HUNGER)); section.set("hunger", context.getSessionData(CK.E_HUNGER));

View File

@ -23,11 +23,11 @@ import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt; import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import me.blackvein.quests.Quests; import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt; 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.convo.actions.main.ActionMainPrompt;
import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenNumericPromptEvent; import me.blackvein.quests.events.editor.actions.ActionsEditorPostOpenNumericPromptEvent;
import me.blackvein.quests.util.CK; import me.blackvein.quests.util.CK;
@ -136,12 +136,12 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) { protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
switch (input.intValue()) { switch (input.intValue()) {
case 1: case 1:
return new SoundEffectListPrompt(context); return new EffectSoundListPrompt(context);
case 2: case 2:
final Map<UUID, Block> selectedExplosionLocations = plugin.getActionFactory().getSelectedExplosionLocations(); final Map<UUID, Block> selectedExplosionLocations = plugin.getActionFactory().getSelectedExplosionLocations();
selectedExplosionLocations.put(((Player) context.getForWhom()).getUniqueId(), null); selectedExplosionLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
plugin.getActionFactory().setSelectedExplosionLocations(selectedExplosionLocations); plugin.getActionFactory().setSelectedExplosionLocations(selectedExplosionLocations);
return new ExplosionPrompt(); return new EffectExplosionPrompt(context);
case 3: case 3:
return new ActionMainPrompt(context); return new ActionMainPrompt(context);
default: default:
@ -149,11 +149,11 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
} }
} }
public class SoundEffectListPrompt extends ActionsEditorNumericPrompt { public class EffectSoundListPrompt extends ActionsEditorNumericPrompt {
private final Quests plugin; private final Quests plugin;
public SoundEffectListPrompt(final ConversationContext context) { public EffectSoundListPrompt(final ConversationContext context) {
super(context); super(context);
this.plugin = (Quests)context.getPlugin(); this.plugin = (Quests)context.getPlugin();
} }
@ -251,22 +251,22 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) { protected Prompt acceptValidatedInput(final ConversationContext context, final Number input) {
switch (input.intValue()) { switch (input.intValue()) {
case 1: case 1:
return new SoundEffectPrompt(); return new EffectSoundPrompt(context);
case 2: case 2:
if (context.getSessionData(CK.E_EFFECTS) == null) { if (context.getSessionData(CK.E_EFFECTS) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustAddEffects")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustAddEffects"));
return new SoundEffectListPrompt(context); return new EffectSoundListPrompt(context);
} else { } else {
final Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations(); final Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations();
selectedEffectLocations.put(((Player) context.getForWhom()).getUniqueId(), null); selectedEffectLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations); plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations);
return new SoundEffectLocationPrompt(); return new EffectSoundLocationPrompt(context);
} }
case 3: case 3:
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorEffectsCleared")); context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorEffectsCleared"));
context.setSessionData(CK.E_EFFECTS, null); context.setSessionData(CK.E_EFFECTS, null);
context.setSessionData(CK.E_EFFECTS_LOCATIONS, null); context.setSessionData(CK.E_EFFECTS_LOCATIONS, null);
return new SoundEffectListPrompt(context); return new EffectSoundListPrompt(context);
case 4: case 4:
int one; int one;
int two; int two;
@ -284,7 +284,7 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
return new ActionMainPrompt(context); return new ActionMainPrompt(context);
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize")); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new SoundEffectListPrompt(context); return new EffectSoundListPrompt(context);
} }
default: default:
return null; return null;
@ -292,11 +292,25 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
} }
} }
private class SoundEffectPrompt extends StringPrompt { public class EffectSoundPrompt extends ActionsEditorStringPrompt {
public EffectSoundPrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return Lang.get("eventEditorEffectsTitle");
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("effEnterName");
}
@Override @Override
public String getPromptText(final ConversationContext context) { public String getPromptText(final ConversationContext context) {
String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorEffectsTitle") + "\n"; String effects = ChatColor.LIGHT_PURPLE + getTitle(context) + "\n";
final Effect[] vals = Effect.values(); final Effect[] vals = Effect.values();
for (int i = 0; i < vals.length; i++) { for (int i = 0; i < vals.length; i++) {
final Effect eff = vals[i]; final Effect eff = vals[i];
@ -307,7 +321,7 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
} }
} }
return effects + ChatColor.YELLOW + Lang.get("effEnterName"); return effects + ChatColor.YELLOW + getQueryText(context);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -327,26 +341,40 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
final Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations(); final Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations();
selectedEffectLocations.remove(player.getUniqueId()); selectedEffectLocations.remove(player.getUniqueId());
plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations); plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations);
return new SoundEffectListPrompt(context); return new EffectSoundListPrompt(context);
} else { } else {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED
+ Lang.get("eventEditorInvalidEffect")); + Lang.get("eventEditorInvalidEffect"));
return new SoundEffectPrompt(); return new EffectSoundPrompt(context);
} }
} else { } else {
final Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations(); final Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations();
selectedEffectLocations.remove(player.getUniqueId()); selectedEffectLocations.remove(player.getUniqueId());
plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations); plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations);
return new SoundEffectListPrompt(context); return new EffectSoundListPrompt(context);
} }
} }
} }
private class SoundEffectLocationPrompt extends StringPrompt { public class EffectSoundLocationPrompt extends ActionsEditorStringPrompt {
public EffectSoundLocationPrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return null;
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("eventEditorEffectLocationPrompt");
}
@Override @Override
public String getPromptText(final ConversationContext context) { public String getPromptText(final ConversationContext context) {
return ChatColor.YELLOW + Lang.get("eventEditorEffectLocationPrompt"); return ChatColor.YELLOW + getQueryText(context);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -369,25 +397,39 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
selectedEffectLocations.remove(player.getUniqueId()); selectedEffectLocations.remove(player.getUniqueId());
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
return new SoundEffectLocationPrompt(); return new EffectSoundLocationPrompt(context);
} }
return new SoundEffectListPrompt(context); return new EffectSoundListPrompt(context);
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
final Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations(); final Map<UUID, Block> selectedEffectLocations = plugin.getActionFactory().getSelectedEffectLocations();
selectedEffectLocations.remove(player.getUniqueId()); selectedEffectLocations.remove(player.getUniqueId());
plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations); plugin.getActionFactory().setSelectedEffectLocations(selectedEffectLocations);
return new SoundEffectListPrompt(context); return new EffectSoundListPrompt(context);
} else { } else {
return new SoundEffectLocationPrompt(); return new EffectSoundLocationPrompt(context);
} }
} }
} }
public class ExplosionPrompt extends StringPrompt { public class EffectExplosionPrompt extends ActionsEditorStringPrompt {
public EffectExplosionPrompt(final ConversationContext context) {
super(context);
}
@Override
public String getTitle(final ConversationContext context) {
return null;
}
@Override
public String getQueryText(final ConversationContext context) {
return Lang.get("eventEditorExplosionPrompt");
}
@Override @Override
public String getPromptText(final ConversationContext context) { public String getPromptText(final ConversationContext context) {
return ChatColor.YELLOW + Lang.get("eventEditorExplosionPrompt"); return ChatColor.YELLOW + getQueryText(context);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -411,7 +453,7 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
plugin.getActionFactory().setSelectedExplosionLocations(selectedExplosionLocations); plugin.getActionFactory().setSelectedExplosionLocations(selectedExplosionLocations);
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
return new ExplosionPrompt(); return new EffectExplosionPrompt(context);
} }
return new ActionMainPrompt(context); return new ActionMainPrompt(context);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
@ -426,7 +468,7 @@ public class EffectPrompt extends ActionsEditorNumericPrompt {
plugin.getActionFactory().setSelectedExplosionLocations(selectedExplosionLocations); plugin.getActionFactory().setSelectedExplosionLocations(selectedExplosionLocations);
return new ActionMainPrompt(context); return new ActionMainPrompt(context);
} else { } else {
return new ExplosionPrompt(); return new EffectExplosionPrompt(context);
} }
} }
} }

View File

@ -165,7 +165,7 @@ public class CK {
public static final String E_LIGHTNING = "evtLightningStrikes"; public static final String E_LIGHTNING = "evtLightningStrikes";
public static final String E_POTION_TYPES = "evtPotionTypes"; public static final String E_POTION_TYPES = "evtPotionTypes";
public static final String E_POTION_DURATIONS = "evtPotionDurations"; public static final String E_POTION_DURATIONS = "evtPotionDurations";
public static final String E_POTION_STRENGHT = "evtPotionMagnitudes"; public static final String E_POTION_STRENGTH = "evtPotionMagnitudes";
public static final String E_HUNGER = "evtHunger"; public static final String E_HUNGER = "evtHunger";
public static final String E_SATURATION = "evtSaturation"; public static final String E_SATURATION = "evtSaturation";
public static final String E_HEALTH = "evtHealth"; public static final String E_HEALTH = "evtHealth";

View File

@ -391,8 +391,7 @@ eventEditorSetHungerPrompt: "Enter hunger level, <clear>"
eventEditorSetSaturationPrompt: "Enter saturation level, <clear>" eventEditorSetSaturationPrompt: "Enter saturation level, <clear>"
eventEditorSetHealthPrompt: "Enter health level, <clear>" eventEditorSetHealthPrompt: "Enter health level, <clear>"
eventEditorSetTeleportPrompt: "Right-click on a block to teleport the player to, <done>, <clear>, <cancel>" eventEditorSetTeleportPrompt: "Right-click on a block to teleport the player to, <done>, <clear>, <cancel>"
eventEditorCommandsNote: "Note: You may use <player> to refer to the player's name." eventEditorSetCommandsPrompt: "Enter commands (use '<player>' to represent the player), <semicolon>, <clear>, <cancel>"
eventEditorSetCommandsPrompt: "Enter commands, <semicolon>, <clear>, <cancel>"
conditionEditorCreate: "Create new condition" conditionEditorCreate: "Create new condition"
conditionEditorEdit: "Edit a condition" conditionEditorEdit: "Edit a condition"
conditionEditorDelete: "Delete a condition" conditionEditorDelete: "Delete a condition"