Deprecate passing of factory objects to prompts

This commit is contained in:
PikaMug 2020-03-16 17:12:04 -04:00
parent 1c20d05cbe
commit 1090b7dbea
29 changed files with 506 additions and 453 deletions

View File

@ -80,7 +80,7 @@ public class QuestFactory implements ConversationAbandonedListener {
questsFile = new File(plugin.getDataFolder(), "quests.yml");
// Ensure to initialize convoCreator last so that 'this' is fully initialized before it is passed
this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
.withFirstPrompt(new QuestMenuPrompt(plugin, null, this)).withTimeout(3600)
.withFirstPrompt(new QuestMenuPrompt(plugin, null)).withTimeout(3600)
.thatExcludesNonPlayersWithMessage("Console may not perform this operation!")
.addConversationAbandonedListener(this);
}
@ -141,8 +141,8 @@ public class QuestFactory implements ConversationAbandonedListener {
}
public class QuestMenuPrompt extends QuestsEditorNumericPrompt {
public QuestMenuPrompt(Quests plugin, ConversationContext context, QuestFactory factory) {
super(context, factory);
public QuestMenuPrompt(Quests plugin, ConversationContext context) {
super(context);
}
private final int size = 4;
@ -189,9 +189,9 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenNumericPromptEvent event
/*QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, QuestFactory.this, this);
plugin.getServer().getPluginManager().callEvent(event);
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 + " - "
@ -206,24 +206,24 @@ public class QuestFactory implements ConversationAbandonedListener {
switch (input.intValue()) {
case 1:
if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.create")) {
return new QuestSelectCreatePrompt(plugin, context, QuestFactory.this);
return new QuestSelectCreatePrompt(plugin, context);
} else {
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new QuestMenuPrompt(plugin, context, QuestFactory.this);
return new QuestMenuPrompt(plugin, context);
}
case 2:
if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.edit")) {
return new QuestSelectEditPrompt();
} else {
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new QuestMenuPrompt(plugin, context, QuestFactory.this);
return new QuestMenuPrompt(plugin, context);
}
case 3:
if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.delete")) {
return new QuestSelectDeletePrompt();
} else {
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new QuestMenuPrompt(plugin, context, QuestFactory.this);
return new QuestMenuPrompt(plugin, context);
}
case 4:
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("exited"));
@ -235,12 +235,12 @@ public class QuestFactory implements ConversationAbandonedListener {
}
public Prompt returnToMenu(ConversationContext context) {
return new QuestMainPrompt(plugin, context, this);
return new QuestMainPrompt(plugin, context);
}
public class QuestMainPrompt extends QuestsEditorNumericPrompt {
public QuestMainPrompt(Quests plugin, ConversationContext context, QuestFactory factory) {
super(context, factory);
public QuestMainPrompt(Quests plugin, ConversationContext context) {
super(context);
}
private final int size = 15;
@ -439,8 +439,7 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, QuestFactory.this, this);
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": " + ChatColor.AQUA)
@ -465,7 +464,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (plugin.getDependencies().getCitizens() != null) {
return new NPCStartPrompt();
} else {
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
case 5:
selectedBlockStarts.put(((Player) context.getForWhom()).getUniqueId(), null);
@ -474,30 +473,30 @@ public class QuestFactory implements ConversationAbandonedListener {
if (plugin.getDependencies().getWorldGuardApi() != null) {
return new RegionPrompt();
} else {
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
case 7:
return new InitialActionPrompt();
case 8:
if (plugin.getDependencies().getCitizens() != null) {
return new GUIDisplayPrompt(plugin, context, QuestFactory.this);
return new GUIDisplayPrompt(plugin, context);
} else {
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
case 9:
return new RequirementsPrompt(plugin, context, QuestFactory.this);
return new RequirementsPrompt(plugin, context);
case 10:
return new PlannerPrompt(plugin, context, QuestFactory.this);
return new PlannerPrompt(plugin, context);
case 11:
return new StageMenuPrompt(plugin, context, QuestFactory.this);
return new StageMenuPrompt(plugin, context);
case 12:
return new RewardsPrompt(plugin, context, QuestFactory.this);
return new RewardsPrompt(plugin, context);
case 13:
return new OptionsPrompt(plugin, context, QuestFactory.this);
return new OptionsPrompt(plugin, context);
case 14:
return new SavePrompt(plugin, context, QuestFactory.this);
return new SavePrompt(plugin, context);
case 15:
return new ExitPrompt(plugin, context, QuestFactory.this);
return new ExitPrompt(plugin, context);
default:
return null;
}
@ -505,8 +504,8 @@ public class QuestFactory implements ConversationAbandonedListener {
}
public class QuestSelectCreatePrompt extends QuestsEditorStringPrompt {
public QuestSelectCreatePrompt(Quests plugin, ConversationContext context, QuestFactory factory) {
super(context, factory);
public QuestSelectCreatePrompt(Quests plugin, ConversationContext context) {
super(context);
}
public String getTitle(ConversationContext context) {
@ -519,8 +518,7 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, QuestFactory.this, this);
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context)+ "\n" + ChatColor.YELLOW + getQueryText(context);
@ -531,33 +529,33 @@ public class QuestFactory implements ConversationAbandonedListener {
public Prompt acceptInput(ConversationContext context, String input) {
if (input == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new QuestSelectCreatePrompt(plugin, context, QuestFactory.this);
return new QuestSelectCreatePrompt(plugin, context);
}
input = input.trim();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (Quest q : plugin.getQuests()) {
if (q.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNameExists"));
return new QuestSelectCreatePrompt(plugin, context, QuestFactory.this);
return new QuestSelectCreatePrompt(plugin, context);
}
}
if (names.contains(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorBeingEdited"));
return new QuestSelectCreatePrompt(plugin, context, QuestFactory.this);
return new QuestSelectCreatePrompt(plugin, context);
}
if (input.contains(".") || input.contains(",")) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
return new QuestSelectCreatePrompt(plugin, context, QuestFactory.this);
return new QuestSelectCreatePrompt(plugin, context);
}
if (input.equals("")) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new QuestSelectCreatePrompt(plugin, context, QuestFactory.this);
return new QuestSelectCreatePrompt(plugin, context);
}
context.setSessionData(CK.Q_NAME, input);
names.add(input);
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
} else {
return new QuestMenuPrompt(plugin, context, QuestFactory.this);
return new QuestMenuPrompt(plugin, context);
}
}
}
@ -579,11 +577,11 @@ public class QuestFactory implements ConversationAbandonedListener {
Quest q = plugin.getQuest(input);
if (q != null) {
loadQuest(context, q);
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
return new QuestSelectEditPrompt();
} else {
return new QuestMenuPrompt(plugin, context, QuestFactory.this);
return new QuestMenuPrompt(plugin, context);
}
}
}
@ -1018,7 +1016,7 @@ public class QuestFactory implements ConversationAbandonedListener {
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("questEditorQuestNotFound"));
return new QuestSelectDeletePrompt();
} else {
return new QuestMenuPrompt(plugin, context, QuestFactory.this);
return new QuestMenuPrompt(plugin, context);
}
}
}
@ -1041,7 +1039,7 @@ public class QuestFactory implements ConversationAbandonedListener {
deleteQuest(context);
return Prompt.END_OF_CONVERSATION;
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
return new QuestMenuPrompt(plugin, context, QuestFactory.this);
return new QuestMenuPrompt(plugin, context);
} else {
return new QuestConfirmDeletePrompt();
}
@ -1107,13 +1105,13 @@ public class QuestFactory implements ConversationAbandonedListener {
}
if (input.contains(",")) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
return new QuestSelectCreatePrompt(plugin, context, QuestFactory.this);
return new QuestSelectCreatePrompt(plugin, context);
}
names.remove((String) context.getSessionData(CK.Q_NAME));
context.setSessionData(CK.Q_NAME, input);
names.add(input);
}
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
}
@ -1131,12 +1129,12 @@ public class QuestFactory implements ConversationAbandonedListener {
if (context.getSessionData(CK.Q_ASK_MESSAGE) != null) {
context.setSessionData(CK.Q_ASK_MESSAGE, context.getSessionData(CK.Q_ASK_MESSAGE) + " "
+ input.substring(2));
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
}
context.setSessionData(CK.Q_ASK_MESSAGE, input);
}
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
}
@ -1154,12 +1152,12 @@ public class QuestFactory implements ConversationAbandonedListener {
if (context.getSessionData(CK.Q_FINISH_MESSAGE) != null) {
context.setSessionData(CK.Q_FINISH_MESSAGE, context.getSessionData(CK.Q_FINISH_MESSAGE) + " "
+ input.substring(2));
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
}
context.setSessionData(CK.Q_FINISH_MESSAGE, input);
}
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
}
@ -1185,7 +1183,7 @@ public class QuestFactory implements ConversationAbandonedListener {
}
context.setSessionData(CK.Q_START_NPC, i);
selectingNpcs.remove((Player) context.getForWhom());
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
} catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED
@ -1196,7 +1194,7 @@ public class QuestFactory implements ConversationAbandonedListener {
context.setSessionData(CK.Q_START_NPC, null);
}
selectingNpcs.remove((Player) context.getForWhom());
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
}
@ -1224,11 +1222,11 @@ public class QuestFactory implements ConversationAbandonedListener {
} else {
selectedBlockStarts.remove(player.getUniqueId());
}
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
selectedBlockStarts.remove(player.getUniqueId());
context.setSessionData(CK.Q_START_BLOCK, null);
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
return new BlockStartPrompt();
}
@ -1285,14 +1283,14 @@ public class QuestFactory implements ConversationAbandonedListener {
return new RegionPrompt();
} else {
context.setSessionData(CK.Q_REGION, found);
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.Q_REGION, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("questWGRegionCleared"));
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
} else {
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
}
}
@ -1320,7 +1318,7 @@ public class QuestFactory implements ConversationAbandonedListener {
Action a = plugin.getAction(input);
if (a != null) {
context.setSessionData(CK.Q_INITIAL_EVENT, a.getName());
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
player.sendMessage(ChatColor.RED + input + ChatColor.YELLOW + " "
+ Lang.get("questEditorInvalidEventName"));
@ -1328,16 +1326,16 @@ public class QuestFactory implements ConversationAbandonedListener {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.Q_INITIAL_EVENT, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("questEditorEventCleared"));
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
} else {
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
}
}
public class SavePrompt extends QuestsEditorStringPrompt {
public SavePrompt(Quests plugin, ConversationContext context, QuestFactory factory) {
super(context, factory);
public SavePrompt(Quests plugin, ConversationContext context) {
super(context);
}
private final int size = 2;
@ -1379,8 +1377,7 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, QuestFactory.this, this);
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = getQueryText(context) + "\n";
@ -1396,13 +1393,13 @@ public class QuestFactory implements ConversationAbandonedListener {
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedAskMessage"));
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
} else if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedFinishMessage"));
return new QuestMainPrompt(plugin, context, QuestFactory.this);
} else if (new StageMenuPrompt(plugin, context, QuestFactory.this).getStages(context) == 0) {
return new QuestMainPrompt(plugin, context);
} else if (new StageMenuPrompt(plugin, context).getStages(context) == 0) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedStages"));
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
}
FileConfiguration data = new YamlConfiguration();
try {
@ -1439,16 +1436,16 @@ public class QuestFactory implements ConversationAbandonedListener {
}
return Prompt.END_OF_CONVERSATION;
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
} else {
return new SavePrompt(plugin, context, QuestFactory.this);
return new SavePrompt(plugin, context);
}
}
}
public class ExitPrompt extends QuestsEditorStringPrompt {
public ExitPrompt(Quests plugin, ConversationContext context, QuestFactory factory) {
super(context, factory);
public ExitPrompt(Quests plugin, ConversationContext context) {
super(context);
}
private final int size = 2;
@ -1489,8 +1486,7 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, QuestFactory.this, this);
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = getQueryText(context) + "\n";
@ -1507,9 +1503,9 @@ public class QuestFactory implements ConversationAbandonedListener {
context.getForWhom().sendRawMessage(ChatColor.BOLD + "" + ChatColor.YELLOW + Lang.get("exited"));
return Prompt.END_OF_CONVERSATION;
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
return new QuestMainPrompt(plugin, context, QuestFactory.this);
return new QuestMainPrompt(plugin, context);
} else {
return new ExitPrompt(plugin, context, QuestFactory.this);
return new ExitPrompt(plugin, context);
}
}
}
@ -1603,7 +1599,7 @@ public class QuestFactory implements ConversationAbandonedListener {
ConfigurationSection stages = section.createSection("stages");
ConfigurationSection ordered = stages.createSection("ordered");
String pref;
for (int i = 1; i <= new StageMenuPrompt(plugin, context, this).getStages(context); i++) {
for (int i = 1; i <= new StageMenuPrompt(plugin, context).getStages(context); i++) {
pref = "stage" + i;
ConfigurationSection stage = ordered.createSection("" + i);
stage.set("break-block-names", context.getSessionData(pref + CK.S_BREAK_NAMES) != null

View File

@ -120,7 +120,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
private DungeonsListener dungeonsListener;
private PartiesListener partiesListener;
private DenizenTrigger trigger;
private Lang lang;
private LocaleQuery localeQuery;
@Override
@ -141,7 +140,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
questFactory = new QuestFactory(this);
eventFactory = new ActionFactory(this);
depends = new Dependencies(this);
lang = new Lang(this);
trigger = new DenizenTrigger(this);
// 2 - Load main config
@ -307,6 +305,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return questFactory;
}
public ActionFactory getActionFactory() {
return eventFactory;
}
@Deprecated
public ActionFactory getEventFactory() {
return eventFactory;
}
@ -319,10 +322,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return trigger;
}
public Lang getLang() {
return lang;
}
public LocaleQuery getLocaleQuery() {
return localeQuery;
}
@ -411,7 +410,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
jar.close();
}
try {
lang.loadLang();
Lang.loadLang(this);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
@ -1155,7 +1154,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
settings.init();
Lang.clear();
try {
lang.loadLang();
Lang.loadLang(this);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
} catch (IOException e) {

View File

@ -17,6 +17,8 @@ import java.io.IOException;
import org.bukkit.configuration.file.FileConfiguration;
import me.blackvein.quests.util.Lang;
public class Settings {
private Quests plugin;
@ -156,9 +158,9 @@ public class Settings {
killDelay = config.getInt("kill-delay", 600);
if (config.getString("language").equalsIgnoreCase("en")) {
//Legacy
plugin.getLang().setISO("en-US");
Lang.setISO("en-US");
} else {
plugin.getLang().setISO(config.getString("language", "en-US"));
Lang.setISO(config.getString("language", "en-US"));
}
maxQuests = config.getInt("max-quests", maxQuests);
npcEffects = config.getBoolean("npc-effects.enabled", true);

View File

@ -80,7 +80,7 @@ public class ActionFactory implements ConversationAbandonedListener {
actionsFile = new File(plugin.getDataFolder(), "actions.yml");
// Ensure to initialize convoCreator last so that 'this' is fully initialized before it is passed
this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
.withPrefix(new QuestCreatorPrefix()).withFirstPrompt(new ActionMenuPrompt(null, this))
.withPrefix(new QuestCreatorPrefix()).withFirstPrompt(new ActionMenuPrompt(plugin, null))
.withTimeout(3600).thatExcludesNonPlayersWithMessage("Console may not perform this operation!")
.addConversationAbandonedListener(this);
}
@ -151,8 +151,8 @@ public class ActionFactory implements ConversationAbandonedListener {
}
public class ActionMenuPrompt extends ActionsEditorNumericPrompt {
public ActionMenuPrompt(ConversationContext context, ActionFactory factory) {
super(context, factory);
public ActionMenuPrompt(Quests plugin, ConversationContext context) {
super(context);
}
private final int size = 4;
@ -199,9 +199,9 @@ public class ActionFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
ActionsEditorPostOpenNumericPromptEvent event
/*ActionsEditorPostOpenNumericPromptEvent event
= new ActionsEditorPostOpenNumericPromptEvent(context, ActionFactory.this, this);
plugin.getServer().getPluginManager().callEvent(event);
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 + " - "
@ -218,10 +218,10 @@ public class ActionFactory implements ConversationAbandonedListener {
if (player.hasPermission("quests.editor.actions.create")
|| player.hasPermission("quests.editor.events.create")) {
context.setSessionData(CK.E_OLD_EVENT, "");
return new ActionSelectCreatePrompt(context, ActionFactory.this);
return new ActionSelectCreatePrompt(context);
} else {
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
}
case 2:
if (player.hasPermission("quests.editor.actions.edit")
@ -229,13 +229,13 @@ public class ActionFactory implements ConversationAbandonedListener {
if (plugin.getActions().isEmpty()) {
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW
+ Lang.get("eventEditorNoneToEdit"));
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
} else {
return new ActionSelectEditPrompt();
}
} else {
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
}
case 3:
if (player.hasPermission("quests.editor.actions.delete")
@ -243,13 +243,13 @@ public class ActionFactory implements ConversationAbandonedListener {
if (plugin.getActions().isEmpty()) {
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW
+ Lang.get("eventEditorNoneToDelete"));
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
} else {
return new ActionSelectDeletePrompt();
}
} else {
player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
}
case 4:
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("exited"));
@ -261,12 +261,12 @@ public class ActionFactory implements ConversationAbandonedListener {
}
public Prompt returnToMenu(ConversationContext context) {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
public class ActionMainPrompt extends ActionsEditorNumericPrompt {
public ActionMainPrompt(ConversationContext context, ActionFactory factory) {
super(context, factory);
public ActionMainPrompt(ConversationContext context) {
super(context);
}
private final int size = 10;
@ -385,8 +385,7 @@ public class ActionFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
ActionsEditorPostOpenNumericPromptEvent event
= new ActionsEditorPostOpenNumericPromptEvent(context, ActionFactory.this, this);
ActionsEditorPostOpenNumericPromptEvent event = new ActionsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + "- " + getTitle(context).replaceFirst(": ", ": " + ChatColor.AQUA)
@ -422,7 +421,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} else {
context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord"));
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
case 9:
if (context.getSessionData(CK.E_OLD_EVENT) != null) {
return new SavePrompt((String) context.getSessionData(CK.E_OLD_EVENT));
@ -438,8 +437,8 @@ public class ActionFactory implements ConversationAbandonedListener {
}
public class ActionSelectCreatePrompt extends ActionsEditorStringPrompt {
public ActionSelectCreatePrompt(ConversationContext context, ActionFactory factory) {
super(context, factory);
public ActionSelectCreatePrompt(ConversationContext context) {
super(context);
}
public String getTitle(ConversationContext context) {
@ -452,8 +451,7 @@ public class ActionFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
ActionsEditorPostOpenStringPromptEvent event
= new ActionsEditorPostOpenStringPromptEvent(context, ActionFactory.this, this);
ActionsEditorPostOpenStringPromptEvent event = new ActionsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n" + ChatColor.YELLOW + getQueryText(context);
@ -464,33 +462,33 @@ public class ActionFactory implements ConversationAbandonedListener {
public Prompt acceptInput(ConversationContext context, String input) {
if (input == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new ActionSelectCreatePrompt(context, ActionFactory.this);
return new ActionSelectCreatePrompt(context);
}
input = input.trim();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (Action e : plugin.getActions()) {
if (e.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
return new ActionSelectCreatePrompt(context, ActionFactory.this);
return new ActionSelectCreatePrompt(context);
}
}
if (names.contains(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone"));
return new ActionSelectCreatePrompt(context, ActionFactory.this);
return new ActionSelectCreatePrompt(context);
}
if (StringUtils.isAlphanumeric(input) == false) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAlpha"));
return new ActionSelectCreatePrompt(context, ActionFactory.this);
return new ActionSelectCreatePrompt(context);
}
if (input.equals("")) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new ActionSelectCreatePrompt(context, ActionFactory.this);
return new ActionSelectCreatePrompt(context);
}
context.setSessionData(CK.E_NAME, input);
names.add(input);
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else {
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
}
}
}
@ -516,12 +514,12 @@ public class ActionFactory implements ConversationAbandonedListener {
context.setSessionData(CK.E_OLD_EVENT, a.getName());
context.setSessionData(CK.E_NAME, a.getName());
loadData(a, context);
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorNotFound"));
return new ActionSelectEditPrompt();
} else {
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
}
}
}
@ -665,7 +663,7 @@ public class ActionFactory implements ConversationAbandonedListener {
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorNotFound"));
return new ActionSelectDeletePrompt();
} else {
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
}
}
}
@ -686,9 +684,9 @@ public class ActionFactory implements ConversationAbandonedListener {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
deleteAction(context);
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
} else {
return new ActionConfirmDeletePrompt();
}
@ -807,7 +805,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} else {
context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord"));
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else if (input.equalsIgnoreCase("3")) {
return new ItemListPrompt();
} else if (input.equalsIgnoreCase("4")) {
@ -824,7 +822,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} else if (input.equalsIgnoreCase("9")) {
return new CommandsPrompt();
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
@ -867,9 +865,9 @@ public class ActionFactory implements ConversationAbandonedListener {
} else {
context.setSessionData(CK.E_CANCEL_TIMER, Lang.get("yesWord"));
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
@ -920,7 +918,7 @@ public class ActionFactory implements ConversationAbandonedListener {
selectedExplosionLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
return new ExplosionPrompt();
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
@ -981,7 +979,7 @@ public class ActionFactory implements ConversationAbandonedListener {
selectedLightningLocations.put(((Player) context.getForWhom()).getUniqueId(), null);
return new LightningPrompt();
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
@ -990,7 +988,7 @@ public class ActionFactory implements ConversationAbandonedListener {
@Override
protected Prompt acceptValidatedInput(final ConversationContext context, final Number number) {
context.setSessionData(CK.E_TIMER, number);
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
@Override
@ -1038,9 +1036,9 @@ public class ActionFactory implements ConversationAbandonedListener {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yesWord"))) {
saveAction(context);
return new ActionMenuPrompt(context, ActionFactory.this);
return new ActionMenuPrompt(plugin, context);
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else {
return new SavePrompt(modName);
}
@ -1064,7 +1062,7 @@ public class ActionFactory implements ConversationAbandonedListener {
clearData(context);
return Prompt.END_OF_CONVERSATION;
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("noWord"))) {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else {
return new ExitPrompt();
}
@ -1364,14 +1362,14 @@ public class ActionFactory implements ConversationAbandonedListener {
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
return new ExplosionPrompt();
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.E_EXPLOSIONS, null);
selectedExplosionLocations.remove(player.getUniqueId());
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
selectedExplosionLocations.remove(player.getUniqueId());
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else {
return new ExplosionPrompt();
}
@ -1406,7 +1404,7 @@ public class ActionFactory implements ConversationAbandonedListener {
context.setSessionData(CK.E_NAME, input);
names.add(input);
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
@ -1425,7 +1423,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.E_MESSAGE, null);
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
@ -1482,7 +1480,7 @@ public class ActionFactory implements ConversationAbandonedListener {
context.setSessionData(CK.E_ITEMS, null);
return new ItemListPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
return null;
}
@ -1566,7 +1564,7 @@ public class ActionFactory implements ConversationAbandonedListener {
two = 0;
}
if (one == two) {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new SoundEffectListPrompt();
@ -1731,7 +1729,7 @@ public class ActionFactory implements ConversationAbandonedListener {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetStormDuration"));
return new StormPrompt();
} else {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
return null;
@ -1847,7 +1845,7 @@ public class ActionFactory implements ConversationAbandonedListener {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetThunderDuration"));
return new ThunderPrompt();
} else {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
return null;
@ -1945,7 +1943,7 @@ public class ActionFactory implements ConversationAbandonedListener {
context.setSessionData(CK.E_MOB_TYPES, null);
return new MobPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
} else {
@SuppressWarnings("unchecked")
@ -1965,7 +1963,7 @@ public class ActionFactory implements ConversationAbandonedListener {
context.setSessionData(CK.E_MOB_TYPES, null);
return new MobPrompt();
} else if (inp == types.size() + 3) {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else if (inp > types.size()) {
return new MobPrompt();
} else {
@ -2356,14 +2354,14 @@ public class ActionFactory implements ConversationAbandonedListener {
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
return new LightningPrompt();
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.E_LIGHTNING, null);
selectedLightningLocations.remove(player.getUniqueId());
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
selectedLightningLocations.remove(player.getUniqueId());
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else {
return new LightningPrompt();
}
@ -2477,7 +2475,7 @@ public class ActionFactory implements ConversationAbandonedListener {
three = 0;
}
if (one == two && two == three) {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorListSizeMismatch"));
return new PotionEffectPrompt();
@ -2608,7 +2606,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} else {
context.setSessionData(CK.E_HUNGER, null);
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
@ -2639,7 +2637,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} else {
context.setSessionData(CK.E_SATURATION, null);
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
@ -2670,7 +2668,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} else {
context.setSessionData(CK.E_HEALTH, null);
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
@ -2694,14 +2692,14 @@ public class ActionFactory implements ConversationAbandonedListener {
player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst"));
return new TeleportPrompt();
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.E_TELEPORT, null);
selectedTeleportLocations.remove(player.getUniqueId());
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
selectedTeleportLocations.remove(player.getUniqueId());
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else {
return new TeleportPrompt();
}
@ -2727,7 +2725,7 @@ public class ActionFactory implements ConversationAbandonedListener {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.E_COMMANDS, null);
}
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
@ -2759,7 +2757,7 @@ public class ActionFactory implements ConversationAbandonedListener {
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
if (plugin.getDependencies().getDenizenAPI().containsScript(input)) {
context.setSessionData(CK.E_DENIZEN, input.toUpperCase());
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else {
player.sendMessage(ChatColor.RED + Lang.get("stageEditorInvalidScript"));
return new DenizenPrompt();
@ -2767,9 +2765,9 @@ public class ActionFactory implements ConversationAbandonedListener {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.E_DENIZEN, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDenizenCleared"));
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
} else {
return new ActionMainPrompt(context, ActionFactory.this);
return new ActionMainPrompt(context);
}
}
}

View File

@ -15,6 +15,7 @@ package me.blackvein.quests.convo.actions;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.convo.QuestsNumericPrompt;
@ -22,6 +23,12 @@ public abstract class ActionsEditorNumericPrompt extends QuestsNumericPrompt {
private ConversationContext context;
private ActionFactory factory;
public ActionsEditorNumericPrompt(final ConversationContext context) {
this.context = context;
this.factory = ((Quests)context.getPlugin()).getActionFactory();
}
@Deprecated
public ActionsEditorNumericPrompt(final ConversationContext context, final ActionFactory factory) {
this.context = context;
this.factory = factory;

View File

@ -14,6 +14,7 @@ package me.blackvein.quests.convo.actions;
import org.bukkit.conversations.ConversationContext;
import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.convo.QuestsStringPrompt;
@ -21,6 +22,12 @@ public abstract class ActionsEditorStringPrompt extends QuestsStringPrompt {
private ConversationContext context;
private ActionFactory factory;
public ActionsEditorStringPrompt(final ConversationContext context) {
this.context = context;
this.factory = ((Quests)context.getPlugin()).getActionFactory();
}
@Deprecated
public ActionsEditorStringPrompt(final ConversationContext context, final ActionFactory factory) {
this.context = context;
this.factory = factory;

View File

@ -16,12 +16,19 @@ import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.QuestsNumericPrompt;
public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt {
private ConversationContext context;
private QuestFactory factory;
public QuestsEditorNumericPrompt(final ConversationContext context) {
this.context = context;
factory = ((Quests)context.getPlugin()).getQuestFactory();
}
@Deprecated
public QuestsEditorNumericPrompt(final ConversationContext context, final QuestFactory factory) {
this.context = context;
this.factory = factory;

View File

@ -15,13 +15,19 @@ package me.blackvein.quests.convo.quests;
import org.bukkit.conversations.ConversationContext;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.QuestsStringPrompt;
public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt {
private ConversationContext context;
private QuestFactory factory;
//TODO - passing factory may be unnecessary
public QuestsEditorStringPrompt(final ConversationContext context) {
this.context = context;
factory = ((Quests)context.getPlugin()).getQuestFactory();
}
@Deprecated
public QuestsEditorStringPrompt(final ConversationContext context, final QuestFactory factory) {
this.context = context;
this.factory = factory;

View File

@ -15,7 +15,6 @@ package me.blackvein.quests.convo.quests.prompts;
import java.util.LinkedList;
import java.util.List;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
@ -34,14 +33,12 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin;
private final int stageNum;
private final String pref;
private final QuestFactory factory;
public BlocksPrompt(Quests plugin, int stageNum, ConversationContext context, QuestFactory qf) {
super(context, qf);
public BlocksPrompt(Quests plugin, int stageNum, ConversationContext context) {
super(context);
this.plugin = plugin;
this.stageNum = stageNum;
this.pref = "stage" + stageNum;
this.factory = qf;
}
private final int size = 6;
@ -168,8 +165,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
context.setSessionData(pref, Boolean.TRUE);
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
plugin.getServer().getPluginManager().callEvent(event);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.AQUA + "- " + getTitle(context) + " -\n";
for (int i = 1; i <= size; i++) {
@ -194,7 +191,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
return new CutBlockListPrompt();
case 6:
try {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;
@ -310,7 +307,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_BREAK_DURABILITY, elements);
return new BlocksPrompt(plugin, stageNum, context, factory);
return new BlocksPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new BreakBlockListPrompt();
@ -547,7 +544,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, elements);
return new BlocksPrompt(plugin, stageNum, context, factory);
return new BlocksPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new DamageBlockListPrompt();
@ -784,7 +781,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_PLACE_DURABILITY, elements);
return new BlocksPrompt(plugin, stageNum, context, factory);
return new BlocksPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new PlaceBlockListPrompt();
@ -1021,7 +1018,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_USE_DURABILITY, elements);
return new BlocksPrompt(plugin, stageNum, context, factory);
return new BlocksPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new UseBlockListPrompt();
@ -1258,7 +1255,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_CUT_DURABILITY, elements);
return new BlocksPrompt(plugin, stageNum, context, factory);
return new BlocksPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new CutBlockListPrompt();

View File

@ -18,7 +18,6 @@ import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
import me.blackvein.quests.Quests;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.Lang;
@ -30,13 +29,11 @@ import org.bukkit.conversations.StringPrompt;
public class DateTimePrompt extends FixedSetPrompt {
private Quests plugin;
private final Prompt oldPrompt;
private String source = "";
public DateTimePrompt(Quests plugin, Prompt old, String origin) {
public DateTimePrompt(Prompt old, String origin) {
super("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
this.plugin = plugin;
oldPrompt = old;
source = origin;
}
@ -78,7 +75,7 @@ public class DateTimePrompt extends FixedSetPrompt {
}
TimeZone tz = TimeZone.getTimeZone((String) cc.getSessionData("tempZone"));
cal.setTimeZone(tz);
String[] iso = plugin.getLang().getISO().split("-");
String[] iso = Lang.getISO().split("-");
Locale loc = new Locale(iso[0], iso[1]);
Double hour = (double) (cal.getTimeZone().getRawOffset() / 60 / 60 / 1000);
String[] sep = String.valueOf(hour).replace("-", "").split("\\.");
@ -145,10 +142,12 @@ public class DateTimePrompt extends FixedSetPrompt {
String zone = (String) cc.getSessionData("tempZone");
String date = day + ":" + month + ":" + year + ":"
+ hour + ":" + minute + ":" + second + ":" + zone;
if (source.equals("start")) {
cc.setSessionData(CK.PLN_START_DATE, date);
} else if (source.equals("end")) {
cc.setSessionData(CK.PLN_END_DATE, date);
if (source != null) {
if (source.equals("start")) {
cc.setSessionData(CK.PLN_START_DATE, date);
} else if (source.equals("end")) {
cc.setSessionData(CK.PLN_END_DATE, date);
}
}
}
try {
@ -177,14 +176,14 @@ public class DateTimePrompt extends FixedSetPrompt {
return new DayPrompt();
} else {
cc.setSessionData("tempDay", Integer.parseInt(input));
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
} catch (NumberFormatException e) {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new DayPrompt();
}
} else {
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
}
}
@ -207,14 +206,14 @@ public class DateTimePrompt extends FixedSetPrompt {
return new MonthPrompt();
} else {
cc.setSessionData("tempMonth", Integer.parseInt(input) - 1);
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
} catch (NumberFormatException e) {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new MonthPrompt();
}
} else {
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
}
}
@ -237,14 +236,14 @@ public class DateTimePrompt extends FixedSetPrompt {
return new YearPrompt();
} else {
cc.setSessionData("tempYear", Integer.parseInt(input));
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
} catch (NumberFormatException e) {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new YearPrompt();
}
} else {
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
}
}
@ -267,14 +266,14 @@ public class DateTimePrompt extends FixedSetPrompt {
return new HourPrompt();
} else {
cc.setSessionData("tempHour", Integer.parseInt(input));
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
} catch (NumberFormatException e) {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new HourPrompt();
}
} else {
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
}
}
@ -297,14 +296,14 @@ public class DateTimePrompt extends FixedSetPrompt {
return new MinutePrompt();
} else {
cc.setSessionData("tempMinute", Integer.parseInt(input));
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
} catch (NumberFormatException e) {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new MinutePrompt();
}
} else {
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
}
}
@ -327,14 +326,14 @@ public class DateTimePrompt extends FixedSetPrompt {
return new SecondPrompt();
} else {
cc.setSessionData("tempSecond", Integer.parseInt(input));
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
} catch (NumberFormatException e) {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new SecondPrompt();
}
} else {
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
}
}
@ -363,16 +362,15 @@ public class DateTimePrompt extends FixedSetPrompt {
cc.setSessionData("tempZone", t[0]);
} else {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
plugin.getLogger().severe("Unable to get time zone for converted offset " + input);
}
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
} catch (NumberFormatException e) {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new OffsetPrompt();
}
} else {
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
}
}
@ -401,13 +399,13 @@ public class DateTimePrompt extends FixedSetPrompt {
for (String z : zones) {
if (z.toLowerCase().startsWith(input.toLowerCase())) {
cc.setSessionData("tempZone", z);
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
}
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new ZonePrompt(zones);
} else {
return new DateTimePrompt(plugin, oldPrompt, source);
return new DateTimePrompt(oldPrompt, source);
}
}
}

View File

@ -6,7 +6,6 @@ import org.bukkit.conversations.Prompt;
import org.bukkit.inventory.ItemStack;
import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
@ -16,12 +15,10 @@ import me.blackvein.quests.util.Lang;
public class GUIDisplayPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin;
private final QuestFactory factory;
public GUIDisplayPrompt(Quests plugin, ConversationContext context, QuestFactory qf) {
super(context, qf);
public GUIDisplayPrompt(Quests plugin, ConversationContext context) {
super(context);
this.plugin = plugin;
this.factory = qf;
}
private final int size = 3;
@ -67,7 +64,7 @@ public class GUIDisplayPrompt extends QuestsEditorNumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
if (context.getSessionData("tempStack") != null) {
@ -111,9 +108,9 @@ public class GUIDisplayPrompt extends QuestsEditorNumericPrompt {
case 2:
context.setSessionData(CK.Q_GUIDISPLAY, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("questGUICleared"));
return new GUIDisplayPrompt(plugin, context, factory);
return new GUIDisplayPrompt(plugin, context);
case 3:
return factory.returnToMenu(context);
return plugin.getQuestFactory().returnToMenu(context);
default:
return null;
}

View File

@ -15,7 +15,6 @@ package me.blackvein.quests.convo.quests.prompts;
import java.util.LinkedList;
import java.util.List;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
@ -35,14 +34,12 @@ public class ItemsPrompt extends FixedSetPrompt {
private final Quests plugin;
private final int stageNum;
private final String pref;
private final QuestFactory factory;
public ItemsPrompt(Quests plugin, int stageNum, QuestFactory qf) {
public ItemsPrompt(Quests plugin, int stageNum) {
super("1", "2", "3", "4", "5");
this.plugin = plugin;
this.stageNum = stageNum;
this.pref = "stage" + stageNum;
this.factory = qf;
}
@SuppressWarnings("unchecked")
@ -133,7 +130,7 @@ public class ItemsPrompt extends FixedSetPrompt {
return new BrewListPrompt();
}
try {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;
@ -190,7 +187,7 @@ public class ItemsPrompt extends FixedSetPrompt {
context.setSessionData(pref + CK.S_CRAFT_ITEMS, null);
return new CraftListPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new ItemsPrompt(plugin, stageNum, factory);
return new ItemsPrompt(plugin, stageNum);
}
return null;
}
@ -251,7 +248,7 @@ public class ItemsPrompt extends FixedSetPrompt {
context.setSessionData(pref + CK.S_SMELT_ITEMS, null);
return new SmeltListPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new ItemsPrompt(plugin, stageNum, factory);
return new ItemsPrompt(plugin, stageNum);
}
return null;
}
@ -361,7 +358,7 @@ public class ItemsPrompt extends FixedSetPrompt {
three = 0;
}
if (one == two && two == three) {
return new ItemsPrompt(plugin, stageNum, factory);
return new ItemsPrompt(plugin, stageNum);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new EnchantmentListPrompt();
@ -549,7 +546,7 @@ public class ItemsPrompt extends FixedSetPrompt {
context.setSessionData(pref + CK.S_BREW_ITEMS, null);
return new BrewListPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new ItemsPrompt(plugin, stageNum, factory);
return new ItemsPrompt(plugin, stageNum);
}
return null;
}

View File

@ -30,7 +30,6 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ConfigUtil;
@ -41,14 +40,12 @@ public class MobsPrompt extends FixedSetPrompt {
private final Quests plugin;
private final int stageNum;
private final String pref;
private final QuestFactory factory;
public MobsPrompt(Quests plugin, int stageNum, QuestFactory qf) {
public MobsPrompt(Quests plugin, int stageNum) {
super("1", "2", "3", "4", "5", "6");
this.plugin = plugin;
this.stageNum = stageNum;
this.pref = "stage" + stageNum;
this.factory = qf;
}
@SuppressWarnings("unchecked")
@ -149,7 +146,7 @@ public class MobsPrompt extends FixedSetPrompt {
return new ShearListPrompt();
}
try {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;
@ -252,9 +249,9 @@ public class MobsPrompt extends FixedSetPrompt {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoMobTypes"));
return new MobListPrompt();
} else {
Map<UUID, Block> temp = factory.getSelectedKillLocations();
Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedKillLocations();
temp.put(((Player) context.getForWhom()).getUniqueId(), null);
factory.setSelectedKillLocations(temp);
plugin.getQuestFactory().setSelectedKillLocations(temp);
return new MobLocationPrompt();
}
} else if (input.equalsIgnoreCase("4")) {
@ -313,13 +310,13 @@ public class MobsPrompt extends FixedSetPrompt {
if (one == two) {
if (three != 0 || four != 0 || five != 0) {
if (two == three && three == four && four == five) {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new MobListPrompt();
}
} else {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
@ -443,7 +440,7 @@ public class MobsPrompt extends FixedSetPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) {
Block block = factory.getSelectedKillLocations().get(player.getUniqueId());
Block block = plugin.getQuestFactory().getSelectedKillLocations().get(player.getUniqueId());
if (block != null) {
Location loc = block.getLocation();
LinkedList<String> locs;
@ -454,18 +451,18 @@ public class MobsPrompt extends FixedSetPrompt {
}
locs.add(ConfigUtil.getLocationInfo(loc));
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, locs);
Map<UUID, Block> temp = factory.getSelectedKillLocations();
Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedKillLocations();
temp.remove(player.getUniqueId());
factory.setSelectedKillLocations(temp);
plugin.getQuestFactory().setSelectedKillLocations(temp);
} else {
player.sendMessage(ChatColor.RED + Lang.get("stageEditorNoBlock"));
return new MobLocationPrompt();
}
return new MobListPrompt();
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
Map<UUID, Block> temp = factory.getSelectedKillLocations();
Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedKillLocations();
temp.remove(player.getUniqueId());
factory.setSelectedKillLocations(temp);
plugin.getQuestFactory().setSelectedKillLocations(temp);
return new MobListPrompt();
} else {
return new MobLocationPrompt();
@ -551,7 +548,7 @@ public class MobsPrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_FISH, null);
}
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
@ -582,7 +579,7 @@ public class MobsPrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_COW_MILK, null);
}
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
@ -659,7 +656,7 @@ public class MobsPrompt extends FixedSetPrompt {
two = 0;
}
if (one == two) {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new TameListPrompt();
@ -829,7 +826,7 @@ public class MobsPrompt extends FixedSetPrompt {
two = 0;
}
if (one == two) {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new ShearListPrompt();

View File

@ -25,7 +25,6 @@ import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
@ -35,14 +34,12 @@ public class NPCsPrompt extends FixedSetPrompt {
private final Quests plugin;
private final int stageNum;
private final String pref;
private final QuestFactory factory;
public NPCsPrompt(Quests plugin, int stageNum, QuestFactory qf) {
public NPCsPrompt(Quests plugin, int stageNum) {
super("1", "2", "3", "4");
this.plugin = plugin;
this.stageNum = stageNum;
this.pref = "stage" + stageNum;
this.factory = qf;
}
@SuppressWarnings("unchecked")
@ -127,25 +124,25 @@ public class NPCsPrompt extends FixedSetPrompt {
return new DeliveryListPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
} else if (input.equalsIgnoreCase("2")) {
if (plugin.getDependencies().getCitizens() != null) {
return new NPCIDsToTalkToPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
} else if (input.equalsIgnoreCase("3")) {
if (plugin.getDependencies().getCitizens() != null) {
return new NPCKillListPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
try {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;
@ -264,7 +261,7 @@ public class NPCsPrompt extends FixedSetPrompt {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDeliveryMessage"));
return new DeliveryListPrompt();
} else {
return new NPCsPrompt(plugin, stageNum, factory);
return new NPCsPrompt(plugin, stageNum);
}
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
@ -294,9 +291,9 @@ public class NPCsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
HashSet<Player> temp = factory.getSelectingNpcs();
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
temp.add((Player) context.getForWhom());
factory.setSelectingNpcs(temp);
plugin.getQuestFactory().setSelectingNpcs(temp);
return ChatColor.YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint");
}
@ -323,9 +320,9 @@ public class NPCsPrompt extends FixedSetPrompt {
}
context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
}
HashSet<Player> temp = factory.getSelectingNpcs();
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
temp.remove((Player) context.getForWhom());
factory.setSelectingNpcs(temp);
plugin.getQuestFactory().setSelectingNpcs(temp);
return new DeliveryListPrompt();
}
}
@ -354,9 +351,9 @@ public class NPCsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
HashSet<Player> temp = factory.getSelectingNpcs();
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
temp.add((Player) context.getForWhom());
factory.setSelectingNpcs(temp);
plugin.getQuestFactory().setSelectingNpcs(temp);
return ChatColor.YELLOW + Lang.get("stageEditorNPCToTalkToPrompt") + "\n" + ChatColor.GOLD
+ Lang.get("npcHint");
}
@ -383,14 +380,14 @@ public class NPCsPrompt extends FixedSetPrompt {
return new NPCIDsToTalkToPrompt();
}
}
HashSet<Player> temp = factory.getSelectingNpcs();
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
temp.remove((Player) context.getForWhom());
factory.setSelectingNpcs(temp);
plugin.getQuestFactory().setSelectingNpcs(temp);
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, npcs);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null);
}
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
@ -469,7 +466,7 @@ public class NPCsPrompt extends FixedSetPrompt {
two = 0;
}
if (one == two) {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new NPCKillListPrompt();
@ -493,9 +490,9 @@ public class NPCsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
HashSet<Player> temp = factory.getSelectingNpcs();
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
temp.add((Player) context.getForWhom());
factory.setSelectingNpcs(temp);
plugin.getQuestFactory().setSelectingNpcs(temp);
return ChatColor.YELLOW + Lang.get("stageEditorNPCPrompt") + "\n" + ChatColor.GOLD + Lang.get("npcHint");
}
@ -522,9 +519,9 @@ public class NPCsPrompt extends FixedSetPrompt {
}
context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
}
HashSet<Player> temp = factory.getSelectingNpcs();
HashSet<Player> temp = plugin.getQuestFactory().getSelectingNpcs();
temp.remove((Player) context.getForWhom());
factory.setSelectingNpcs(temp);
plugin.getQuestFactory().setSelectingNpcs(temp);
return new NPCKillListPrompt();
}
}

View File

@ -17,7 +17,6 @@ import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import me.blackvein.quests.Options;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
@ -27,16 +26,14 @@ import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.Lang;
public class OptionsPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin;
private final QuestFactory factory;
private String tempKey;
private Prompt tempPrompt;
public OptionsPrompt(Quests plugin, ConversationContext context, QuestFactory qf) {
super(context, qf);
public OptionsPrompt(Quests plugin, ConversationContext context) {
super(context);
this.plugin = plugin;
factory = qf;
}
private final int size = 3;
@ -87,7 +84,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.DARK_GREEN + getTitle(context)
@ -104,19 +101,19 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch (input.intValue()) {
case 1:
return new GeneralPrompt(plugin, context, factory);
return new GeneralPrompt(plugin, context);
case 2:
return new MultiplayerPrompt(plugin, context, factory);
return new MultiplayerPrompt(plugin, context);
case 3:
return factory.returnToMenu(context);
return plugin.getQuestFactory().returnToMenu(context);
default:
return null;
}
}
public class TrueFalsePrompt extends QuestsEditorStringPrompt {
public TrueFalsePrompt(Quests plugin, ConversationContext context, QuestFactory factory) {
super(context, factory);
public TrueFalsePrompt(Quests plugin, ConversationContext context) {
super(context);
}
private final int size = 4;
@ -156,7 +153,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, factory, this);
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = Lang.get("optBooleanPrompt");
@ -177,7 +174,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
context.setSessionData(tempKey, false);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
return new TrueFalsePrompt(plugin, context, factory);
return new TrueFalsePrompt(plugin, context);
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(tempKey, null);
@ -188,8 +185,8 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
}
public class LevelPrompt extends QuestsEditorStringPrompt {
public LevelPrompt(Quests plugin, ConversationContext context, QuestFactory factory) {
super(context, factory);
public LevelPrompt(Quests plugin, ConversationContext context) {
super(context);
}
private final int size = 6;
@ -249,7 +246,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, factory, this);
= new QuestsEditorPostOpenStringPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = Lang.get("optNumberPrompt");
@ -284,8 +281,8 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
}
public class GeneralPrompt extends QuestsEditorNumericPrompt {
public GeneralPrompt(Quests plugin, ConversationContext context, QuestFactory factory) {
super(context, factory);
public GeneralPrompt(Quests plugin, ConversationContext context) {
super(context);
}
private final int size = 3;
@ -365,7 +362,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.DARK_GREEN + "- " + getTitle(context) + " -\n";
@ -381,17 +378,17 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
switch (input.intValue()) {
case 1:
tempKey = CK.OPT_ALLOW_COMMANDS;
tempPrompt = new GeneralPrompt(plugin, context, factory);
return new TrueFalsePrompt(plugin, context, factory);
tempPrompt = new GeneralPrompt(plugin, context);
return new TrueFalsePrompt(plugin, context);
case 2:
tempKey = CK.OPT_ALLOW_QUITTING;
tempPrompt = new GeneralPrompt(plugin, context, factory);
return new TrueFalsePrompt(plugin, context, factory);
tempPrompt = new GeneralPrompt(plugin, context);
return new TrueFalsePrompt(plugin, context);
case 3:
tempKey = null;
tempPrompt = null;
try {
return new OptionsPrompt(plugin, context, factory);
return new OptionsPrompt(plugin, context);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;
@ -403,8 +400,8 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
}
public class MultiplayerPrompt extends QuestsEditorNumericPrompt {
public MultiplayerPrompt(Quests plugin, ConversationContext context, QuestFactory factory) {
super(context, factory);
public MultiplayerPrompt(Quests plugin, ConversationContext context) {
super(context);
}
private final int size = 5;
@ -512,7 +509,7 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.DARK_GREEN + "- " + getTitle(context) + " -\n";
@ -528,25 +525,25 @@ public class OptionsPrompt extends QuestsEditorNumericPrompt {
switch (input.intValue()) {
case 1:
tempKey = CK.OPT_USE_DUNGEONSXL_PLUGIN;
tempPrompt = new MultiplayerPrompt(plugin, context, factory);
return new TrueFalsePrompt(plugin, context, factory);
tempPrompt = new MultiplayerPrompt(plugin, context);
return new TrueFalsePrompt(plugin, context);
case 2:
tempKey = CK.OPT_USE_PARTIES_PLUGIN;
tempPrompt = new MultiplayerPrompt(plugin, context, factory);
return new TrueFalsePrompt(plugin, context, factory);
tempPrompt = new MultiplayerPrompt(plugin, context);
return new TrueFalsePrompt(plugin, context);
case 3:
tempKey = CK.OPT_SHARE_PROGRESS_LEVEL;
tempPrompt = new MultiplayerPrompt(plugin, context, factory);
return new LevelPrompt(plugin, context, factory);
tempPrompt = new MultiplayerPrompt(plugin, context);
return new LevelPrompt(plugin, context);
case 4:
tempKey = CK.OPT_REQUIRE_SAME_QUEST;
tempPrompt = new MultiplayerPrompt(plugin, context, factory);
return new TrueFalsePrompt(plugin, context, factory);
tempPrompt = new MultiplayerPrompt(plugin, context);
return new TrueFalsePrompt(plugin, context);
case 5:
tempKey = null;
tempPrompt = null;
try {
return new OptionsPrompt(plugin, context, factory);
return new OptionsPrompt(plugin, context);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;

View File

@ -14,7 +14,7 @@ public class OverridePrompt extends QuestsEditorStringPrompt {
private String classPrefix;
public OverridePrompt(ConversationContext context, Prompt old, String promptText) {
super(context, null);
super(context);
oldPrompt = old;
classPrefix = old.getClass().getSimpleName();
this.promptText = promptText;
@ -38,8 +38,7 @@ public class OverridePrompt extends QuestsEditorStringPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenStringPromptEvent event
= new QuestsEditorPostOpenStringPromptEvent(context, null, this);
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.YELLOW + promptText + "\n";;

View File

@ -18,7 +18,6 @@ import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
@ -34,12 +33,10 @@ import org.bukkit.conversations.StringPrompt;
public class PlannerPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin;
private final QuestFactory factory;
public PlannerPrompt(Quests plugin, ConversationContext context, QuestFactory qf) {
super(context, qf);
public PlannerPrompt(Quests plugin, ConversationContext context) {
super(context);
this.plugin = plugin;
factory = qf;
}
private final int size = 5;
@ -138,7 +135,7 @@ public class PlannerPrompt extends QuestsEditorNumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.DARK_AQUA + getTitle(context).replace((String) context
@ -155,20 +152,20 @@ public class PlannerPrompt extends QuestsEditorNumericPrompt {
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch (input.intValue()) {
case 1:
return new DateTimePrompt(plugin, PlannerPrompt.this, "start");
return new DateTimePrompt(PlannerPrompt.this, "start");
case 2:
return new DateTimePrompt(plugin, PlannerPrompt.this, "end");
return new DateTimePrompt(PlannerPrompt.this, "end");
case 3:
if (context.getSessionData(CK.PLN_START_DATE) != null && context.getSessionData(CK.PLN_END_DATE) != null) {
return new RepeatPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new PlannerPrompt(plugin, context, factory);
return new PlannerPrompt(plugin, context);
}
case 4:
return new CooldownPrompt();
case 5:
return factory.returnToMenu(context);
return plugin.getQuestFactory().returnToMenu(context);
default:
return null;
}
@ -184,11 +181,11 @@ public class PlannerPrompt extends QuestsEditorNumericPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
return new PlannerPrompt(plugin, context, factory);
return new PlannerPrompt(plugin, context);
}
if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.PLN_REPEAT_CYCLE, null);
return new PlannerPrompt(plugin, context, factory);
return new PlannerPrompt(plugin, context);
}
long delay;
try {
@ -204,7 +201,7 @@ public class PlannerPrompt extends QuestsEditorNumericPrompt {
.replace("<input>", input));
return new RepeatPrompt();
}
return new PlannerPrompt(plugin, context, factory);
return new PlannerPrompt(plugin, context);
}
}
@ -218,11 +215,11 @@ public class PlannerPrompt extends QuestsEditorNumericPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
return new PlannerPrompt(plugin, context, factory);
return new PlannerPrompt(plugin, context);
}
if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.PLN_COOLDOWN, null);
return new PlannerPrompt(plugin, context, factory);
return new PlannerPrompt(plugin, context);
}
long delay;
try {
@ -238,7 +235,7 @@ public class PlannerPrompt extends QuestsEditorNumericPrompt {
.replace("<input>", input));
return new CooldownPrompt();
}
return new PlannerPrompt(plugin, context, factory);
return new PlannerPrompt(plugin, context);
}
}
@ -260,7 +257,7 @@ public class PlannerPrompt extends QuestsEditorNumericPrompt {
TimeZone tz = TimeZone.getTimeZone(date[6]);
cal.setTimeZone(tz);
String[] iso = plugin.getLang().getISO().split("-");
String[] iso = Lang.getISO().split("-");
Locale loc = new Locale(iso[0], iso[1]);
Double zhour = (double) (cal.getTimeZone().getRawOffset() / 60 / 60 / 1000);
String[] sep = String.valueOf(zhour).replace("-", "").split("\\.");

View File

@ -31,7 +31,6 @@ import com.herocraftonline.heroes.characters.classes.HeroClass;
import me.blackvein.quests.CustomRequirement;
import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
@ -44,15 +43,13 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin;
private final String classPrefix;
private final QuestFactory factory;
private boolean hasRequirement = false;
private final int size = 11;
public RequirementsPrompt(Quests plugin, ConversationContext context, QuestFactory qf) {
super(context, qf);
public RequirementsPrompt(Quests plugin, ConversationContext context) {
super(context);
this.plugin = plugin;
this.classPrefix = getClass().getSimpleName();
this.factory = qf;
}
public int getSize() {
@ -294,7 +291,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
checkRequirement(context);
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.DARK_AQUA + getTitle(context).replace((String) context
@ -315,7 +312,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
case 2:
return new QuestPointsPrompt();
case 3:
return new ItemListPrompt(plugin, context, factory);
return new ItemListPrompt(plugin, context);
case 4:
return new PermissionsPrompt();
case 5:
@ -326,28 +323,29 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
if (plugin.getDependencies().getMcmmoClassic() != null) {
return new mcMMOPrompt();
} else {
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
case 8:
if (plugin.getDependencies().getHeroes() != null) {
return new HeroesPrompt();
} else {
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
case 9:
return new CustomRequirementsPrompt();
case 10:
if (hasRequirement) {
return new OverridePrompt.Builder()
.context(context)
.source(this)
.promptText(Lang.get("overrideCreateEnter"))
.build();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
case 11:
return factory.returnToMenu(context);
return plugin.getQuestFactory().returnToMenu(context);
default:
return null;
}
@ -404,9 +402,9 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REQ_MONEY, null);
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
}
@ -436,9 +434,9 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REQ_QUEST_POINTS, null);
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
}
@ -506,13 +504,13 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
context.setSessionData(CK.REQ_QUEST_BLOCK, null);
}
}
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
}
public class ItemListPrompt extends QuestsEditorNumericPrompt {
public ItemListPrompt(Quests plugin, ConversationContext context, QuestFactory factory) {
super(context, factory);
public ItemListPrompt(Quests plugin, ConversationContext context) {
super(context);
}
private final int size = 4;
@ -615,7 +613,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
}
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n";
@ -635,7 +633,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
case 2:
if (context.getSessionData(CK.REQ_ITEMS) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqMustAddItem"));
return new ItemListPrompt(plugin, context, factory);
return new ItemListPrompt(plugin, context);
} else {
return new RemoveItemsPrompt();
}
@ -643,7 +641,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("reqItemCleared"));
context.setSessionData(CK.REQ_ITEMS, null);
context.setSessionData(CK.REQ_ITEMS_REMOVE, null);
return new ItemListPrompt(plugin, context, factory);
return new ItemListPrompt(plugin, context);
case 4:
int one;
int two;
@ -658,10 +656,10 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
two = 0;
}
if (one == two) {
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new ItemListPrompt(plugin, context, factory);
return new ItemListPrompt(plugin, context);
}
default:
return null;
@ -705,7 +703,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
}
context.setSessionData(CK.REQ_ITEMS_REMOVE, booleans);
}
return new ItemListPrompt(plugin, context, factory);
return new ItemListPrompt(plugin, context);
}
}
@ -727,7 +725,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REQ_PERMISSION, null);
}
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
}
@ -809,7 +807,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
context.setSessionData(CK.REQ_CUSTOM_DATA_TEMP, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("reqCustomCleared"));
}
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
}
@ -874,7 +872,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
return new RequirementCustomDataListPrompt();
} else {
context.setSessionData(CK.REQ_CUSTOM_DATA_DESCRIPTIONS, null);
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
}
}
@ -955,7 +953,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
} else if (input.equalsIgnoreCase("2")) {
return new mcMMOAmountsPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
return null;
}
@ -1082,7 +1080,7 @@ public class RequirementsPrompt extends QuestsEditorNumericPrompt {
} else if (input.equalsIgnoreCase("2")) {
return new HeroesSecondaryPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new RequirementsPrompt(plugin, context, factory);
return new RequirementsPrompt(plugin, context);
}
return null;
}

View File

@ -31,7 +31,6 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.herocraftonline.heroes.characters.classes.HeroClass;
import me.blackvein.quests.CustomReward;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
@ -44,15 +43,13 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin;
private final String classPrefix;
private final QuestFactory factory;
private boolean hasReward = false;
private final int size = 12;
public RewardsPrompt(Quests plugin, ConversationContext context, QuestFactory qf) {
super(context, qf);
public RewardsPrompt(Quests plugin, ConversationContext context) {
super(context);
this.plugin = plugin;
this.classPrefix = getClass().getSimpleName();
factory = qf;
}
public int getSize() {
@ -335,7 +332,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
checkReward(context);
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.LIGHT_PURPLE + getTitle(context).replace((String) context
@ -355,7 +352,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
if (plugin.getDependencies().getVaultEconomy() != null) {
return new MoneyPrompt();
} else {
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
case 2:
return new QuestPointsPrompt();
@ -366,24 +363,24 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
case 5:
return new CommandsPrompt();
case 6:
return new PermissionsListPrompt(context, factory);
return new PermissionsListPrompt(context);
case 7:
if (plugin.getDependencies().getMcmmoClassic() != null) {
return new mcMMOListPrompt();
} else {
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
case 8:
if (plugin.getDependencies().getHeroes() != null) {
return new HeroesListPrompt();
} else {
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
case 9:
if (plugin.getDependencies().getPhatLoots() != null) {
return new PhatLootsPrompt();
} else {
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
case 10:
return new CustomRewardsPrompt();
@ -395,10 +392,10 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
.build();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
case 12:
return factory.returnToMenu(context);
return plugin.getQuestFactory().returnToMenu(context);
default:
return null;
}
@ -455,9 +452,9 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_MONEY, null);
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
}
@ -487,9 +484,9 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_EXP, null);
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
}
@ -519,9 +516,9 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_QUEST_POINTS, null);
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
}
@ -579,7 +576,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
context.setSessionData(CK.REW_ITEMS, null);
return new ItemListPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
return null;
}
@ -617,14 +614,14 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_COMMAND, null);
}
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
}
private class PermissionsListPrompt extends QuestsEditorNumericPrompt {
public PermissionsListPrompt(ConversationContext context, QuestFactory factory) {
super(context, factory);
public PermissionsListPrompt(ConversationContext context) {
super(context);
}
private final int size = 4;
@ -718,7 +715,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle(context) + "\n";
@ -740,9 +737,9 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("rewPermissionsCleared"));
context.setSessionData(CK.REW_PERMISSION, null);
context.setSessionData(CK.REW_PERMISSION_WORLDS, null);
return new PermissionsListPrompt(context, factory);
return new PermissionsListPrompt(context);
case 4:
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
default:
return null;
}
@ -768,7 +765,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_PERMISSION, null);
}
return new PermissionsListPrompt(context, factory);
return new PermissionsListPrompt(context);
}
}
@ -797,7 +794,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_PERMISSION_WORLDS, null);
}
return new PermissionsListPrompt(context, factory);
return new PermissionsListPrompt(context);
}
}
@ -874,7 +871,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
two = 0;
}
if (one == two) {
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("rewMcMMOListsNotSameSize"));
return new mcMMOListPrompt();
@ -1037,7 +1034,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
two = 0;
}
if (one == two) {
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("rewHeroesListsNotSameSize"));
return new HeroesListPrompt();
@ -1164,13 +1161,13 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
}
loots.addAll(Arrays.asList(arr));
context.setSessionData(CK.REW_PHAT_LOOTS, loots);
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_PHAT_LOOTS, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("rewPhatLootsCleared"));
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
} else {
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
}
}
@ -1253,7 +1250,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
context.setSessionData(CK.REW_CUSTOM_DATA_TEMP, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("rewCustomCleared"));
}
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
}
@ -1318,7 +1315,7 @@ public class RewardsPrompt extends QuestsEditorNumericPrompt {
return new RewardCustomDataListPrompt();
} else {
context.setSessionData(CK.REW_CUSTOM_DATA_DESCRIPTIONS, null);
return new RewardsPrompt(plugin, context, factory);
return new RewardsPrompt(plugin, context);
}
}
}

View File

@ -30,7 +30,6 @@ import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player;
import me.blackvein.quests.CustomObjective;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.Action;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
@ -41,22 +40,19 @@ import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
public class StageMainPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin;
private final int stageNum;
private final String stagePrefix;
private final String classPrefix;
private final QuestFactory factory;
private boolean hasObjective = false;
private final int size = 16;
public StageMainPrompt(Quests plugin, int stageNum, ConversationContext context, QuestFactory qf) {
super(context, qf);
public StageMainPrompt(Quests plugin, int stageNum, ConversationContext context) {
super(context);
this.plugin = plugin;
this.stageNum = stageNum;
this.stagePrefix = "stage" + stageNum;
this.classPrefix = getClass().getSimpleName();
this.factory = qf;
}
public int getStageNumber() {
@ -389,8 +385,8 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
checkObjective(context);
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
plugin.getServer().getPluginManager().callEvent(event);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
context.getPlugin().getServer().getPluginManager().callEvent(event);
String text = ChatColor.LIGHT_PURPLE + "- " + ChatColor.AQUA
+ getTitle(context).replaceFirst(" \\| ", ChatColor.LIGHT_PURPLE + " | ") + " -\n";
@ -405,13 +401,13 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch (input.intValue()) {
case 1:
return new BlocksPrompt(plugin, stageNum, context, factory);
return new BlocksPrompt(plugin, stageNum, context);
case 2:
return new ItemsPrompt(plugin, stageNum, factory);
return new ItemsPrompt(plugin, stageNum);
case 3:
return new NPCsPrompt(plugin, stageNum, factory);
return new NPCsPrompt(plugin, stageNum);
case 4:
return new MobsPrompt(plugin, stageNum, factory);
return new MobsPrompt(plugin, stageNum);
case 5:
return new KillPlayerPrompt();
case 6:
@ -425,19 +421,19 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
return new EventListPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
case 10:
if (hasObjective) {
return new DelayPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
case 11:
if (context.getSessionData(stagePrefix + CK.S_DELAY) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDelaySet"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
return new DelayMessagePrompt();
}
@ -446,14 +442,14 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
return new StartMessagePrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
case 13:
if (hasObjective) {
return new CompleteMessagePrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
case 14:
if (hasObjective) {
@ -463,14 +459,14 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
.build();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
case 15:
return new DeletePrompt();
case 16:
return new StageMenuPrompt(plugin, context, factory);
return new StageMenuPrompt(plugin, context);
default:
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
@ -582,7 +578,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
two = 0;
}
if (one == two) {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new PasswordListPrompt();
@ -684,7 +680,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(stagePrefix + CK.S_PLAYER_KILL, null);
}
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
@ -746,9 +742,9 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
Map<UUID, Block> temp = factory.getSelectedReachLocations();
Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedReachLocations();
temp.put(((Player) context.getForWhom()).getUniqueId(), null);
factory.setSelectedReachLocations(temp);
plugin.getQuestFactory().setSelectedReachLocations(temp);
return new ReachLocationPrompt();
} else if (input.equalsIgnoreCase("2")) {
if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS) == null) {
@ -790,7 +786,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
three = 0;
}
if (one == two && two == three) {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
return new ReachListPrompt();
@ -828,7 +824,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) {
Block block = factory.getSelectedReachLocations().get(player.getUniqueId());
Block block = plugin.getQuestFactory().getSelectedReachLocations().get(player.getUniqueId());
if (block != null) {
Location loc = block.getLocation();
LinkedList<String> locs;
@ -839,18 +835,18 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
}
locs.add(ConfigUtil.getLocationInfo(loc));
context.setSessionData(stagePrefix + CK.S_REACH_LOCATIONS, locs);
Map<UUID, Block> temp = factory.getSelectedReachLocations();
Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedReachLocations();
temp.remove(player.getUniqueId());
factory.setSelectedReachLocations(temp);
plugin.getQuestFactory().setSelectedReachLocations(temp);
} else {
player.sendMessage(ChatColor.RED + Lang.get("stageEditorNoBlockSelected"));
return new ReachLocationPrompt();
}
return new ReachListPrompt();
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
Map<UUID, Block> temp = factory.getSelectedReachLocations();
Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedReachLocations();
temp.remove(player.getUniqueId());
factory.setSelectedReachLocations(temp);
plugin.getQuestFactory().setSelectedReachLocations(temp);
return new ReachListPrompt();
} else {
return new ReachLocationPrompt();
@ -1001,7 +997,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
} else if (input.equalsIgnoreCase("6")) {
return new CommandEventPrompt();
} else if (input.equalsIgnoreCase("7")) {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
return new EventListPrompt();
}
@ -1393,12 +1389,12 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(stagePrefix + CK.S_DELAY, null);
player.sendMessage(ChatColor.GREEN + Lang.get("stageEditorDelayCleared"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
long stageDelay;
try {
@ -1413,7 +1409,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
return new DelayPrompt();
} else {
context.setSessionData(stagePrefix + CK.S_DELAY, stageDelay);
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
}
@ -1431,11 +1427,11 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
context.setSessionData(stagePrefix + CK.S_DELAY_MESSAGE, input);
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(stagePrefix + CK.S_DELAY_MESSAGE, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorMessageCleared"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
return new DelayMessagePrompt();
}
@ -1459,11 +1455,11 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("Yes")) {
new StageMenuPrompt(plugin, context, factory).deleteStage(context, stageNum);
new StageMenuPrompt(plugin, context).deleteStage(context, stageNum);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDeleteSucces"));
return new StageMenuPrompt(plugin, context, factory);
return new StageMenuPrompt(plugin, context);
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("No")) {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
player.sendMessage(ChatColor.RED + Lang.get("invalidOption"));
return new DeletePrompt();
@ -1484,13 +1480,13 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
context.setSessionData(stagePrefix + CK.S_START_MESSAGE, input);
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(stagePrefix + CK.S_START_MESSAGE, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorMessageCleared"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
}
@ -1508,13 +1504,13 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false
&& input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
context.setSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE, input);
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(stagePrefix + CK.S_COMPLETE_MESSAGE, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorMessageCleared"));
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
} else {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
}
@ -1609,7 +1605,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorCustomCleared"));
}
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
@ -1656,7 +1652,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, found.getDescriptions());
return new ObjectiveCustomDataListPrompt();
} else {
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
} catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
@ -1750,7 +1746,7 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
}
}
context.setSessionData(stagePrefix + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null);
return new StageMainPrompt(plugin, stageNum, context, factory);
return new StageMainPrompt(plugin, stageNum, context);
}
}
}

View File

@ -16,7 +16,6 @@ import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenNumericPromptEvent;
@ -26,13 +25,11 @@ import me.blackvein.quests.util.Lang;
public class StageMenuPrompt extends QuestsEditorNumericPrompt {
private final Quests plugin;
private final QuestFactory factory;
private int size = 2;
public StageMenuPrompt(Quests plugin, ConversationContext context, QuestFactory qf) {
super(context, qf);
public StageMenuPrompt(Quests plugin, ConversationContext context) {
super(context);
this.plugin = plugin;
factory = qf;
}
public int getSize() {
@ -78,7 +75,7 @@ public class StageMenuPrompt extends QuestsEditorNumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenNumericPromptEvent event
= new QuestsEditorPostOpenNumericPromptEvent(context, factory, this);
= new QuestsEditorPostOpenNumericPromptEvent(context, this);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.LIGHT_PURPLE + "- " + getTitle(context) + " -\n";
@ -95,14 +92,14 @@ public class StageMenuPrompt extends QuestsEditorNumericPrompt {
int stages = getStages(context);
if (i > 0) {
if (i < (stages + 1) && i > 0) {
return new StageMainPrompt(plugin, (i), context, factory);
return new StageMainPrompt(plugin, (i), context);
} else if (i == (stages + 1)) {
return new StageMainPrompt(plugin, (stages + 1), context, factory);
return new StageMainPrompt(plugin, (stages + 1), context);
} else if (i == (stages + 2)) {
return factory.returnToMenu(context);
return plugin.getQuestFactory().returnToMenu(context);
}
}
return new StageMenuPrompt(plugin, context, factory);
return new StageMenuPrompt(plugin, context);
}
public int getStages(ConversationContext context) {

View File

@ -16,6 +16,7 @@ import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.events.QuestsEvent;
@ -28,12 +29,27 @@ public abstract class ActionsEditorEvent extends QuestsEvent {
protected ActionFactory factory;
protected Prompt prompt;
public ActionsEditorEvent(final ConversationContext context, final Prompt prompt) {
this.context = context;
this.factory = ((Quests)context.getPlugin()).getActionFactory();
this.prompt = prompt;
}
public ActionsEditorEvent(final ConversationContext context, final Prompt prompt, boolean async) {
super(async);
this.context = context;
this.factory = ((Quests)context.getPlugin()).getActionFactory();
this.prompt = prompt;
}
@Deprecated
public ActionsEditorEvent(final ConversationContext context, ActionFactory factory, final Prompt prompt) {
this.context = context;
this.factory = factory;
this.prompt = prompt;
}
@Deprecated
public ActionsEditorEvent(final ConversationContext context, ActionFactory factory, final Prompt prompt,
boolean async) {
super(async);

View File

@ -15,6 +15,7 @@ package me.blackvein.quests.events.editor.actions;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.convo.actions.ActionsEditorNumericPrompt;
@ -22,7 +23,15 @@ public class ActionsEditorPostOpenNumericPromptEvent extends ActionsEditorEvent
private static final HandlerList HANDLERS = new HandlerList();
private ActionFactory factory;
private ActionsEditorNumericPrompt prompt;
public ActionsEditorPostOpenNumericPromptEvent(ConversationContext context, ActionsEditorNumericPrompt prompt) {
super(context, prompt);
this.context = context;
this.factory = ((Quests)context.getPlugin()).getActionFactory();
this.prompt = prompt;
}
@Deprecated
public ActionsEditorPostOpenNumericPromptEvent(ConversationContext context, ActionFactory factory,
ActionsEditorNumericPrompt prompt) {
super(context, factory, prompt);

View File

@ -15,6 +15,7 @@ package me.blackvein.quests.events.editor.actions;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.Quests;
import me.blackvein.quests.actions.ActionFactory;
import me.blackvein.quests.convo.actions.ActionsEditorStringPrompt;
@ -23,6 +24,14 @@ public class ActionsEditorPostOpenStringPromptEvent extends ActionsEditorEvent {
private ActionFactory factory;
private ActionsEditorStringPrompt prompt;
public ActionsEditorPostOpenStringPromptEvent(ConversationContext context, ActionsEditorStringPrompt prompt) {
super(context, prompt);
this.context = context;
this.factory = ((Quests)context.getPlugin()).getActionFactory();
this.prompt = prompt;
}
@Deprecated
public ActionsEditorPostOpenStringPromptEvent(ConversationContext context, ActionFactory factory,
ActionsEditorStringPrompt prompt) {
super(context, factory, prompt);

View File

@ -17,6 +17,7 @@ import org.bukkit.conversations.Prompt;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.events.QuestsEvent;
/**
@ -28,12 +29,27 @@ public abstract class QuestsEditorEvent extends QuestsEvent {
protected QuestFactory factory;
protected Prompt prompt;
public QuestsEditorEvent(final ConversationContext context, final Prompt prompt) {
this.context = context;
this.factory = ((Quests)context.getPlugin()).getQuestFactory();
this.prompt = prompt;
}
public QuestsEditorEvent(final ConversationContext context, final Prompt prompt, boolean async) {
super(async);
this.context = context;
this.factory = ((Quests)context.getPlugin()).getQuestFactory();
this.prompt = prompt;
}
@Deprecated
public QuestsEditorEvent(final ConversationContext context, QuestFactory factory, final Prompt prompt) {
this.context = context;
this.factory = factory;
this.prompt = prompt;
}
@Deprecated
public QuestsEditorEvent(final ConversationContext context, QuestFactory factory, final Prompt prompt,
boolean async) {
super(async);

View File

@ -16,13 +16,22 @@ import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorNumericPrompt;
public class QuestsEditorPostOpenNumericPromptEvent extends QuestsEditorEvent {
private static final HandlerList HANDLERS = new HandlerList();
private QuestFactory factory;
private QuestsEditorNumericPrompt prompt;
public QuestsEditorPostOpenNumericPromptEvent(ConversationContext context, QuestsEditorNumericPrompt prompt) {
super(context, prompt);
this.context = context;
this.factory = ((Quests)context.getPlugin()).getQuestFactory();
this.prompt = prompt;
}
@Deprecated
public QuestsEditorPostOpenNumericPromptEvent(ConversationContext context, QuestFactory factory,
QuestsEditorNumericPrompt prompt) {
super(context, factory, prompt);

View File

@ -16,13 +16,22 @@ import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.convo.quests.QuestsEditorStringPrompt;
public class QuestsEditorPostOpenStringPromptEvent extends QuestsEditorEvent {
private static final HandlerList HANDLERS = new HandlerList();
private QuestFactory factory;
private QuestsEditorStringPrompt prompt;
public QuestsEditorPostOpenStringPromptEvent(ConversationContext context, QuestsEditorStringPrompt prompt) {
super(context, prompt);
this.context = context;
this.factory = ((Quests)context.getPlugin()).getQuestFactory();
this.prompt = prompt;
}
@Deprecated
public QuestsEditorPostOpenStringPromptEvent(ConversationContext context, QuestFactory factory,
QuestsEditorStringPrompt prompt) {
super(context, factory, prompt);

View File

@ -484,7 +484,7 @@ public class CmdExecutor implements CommandExecutor {
|| cs.hasPermission("quests.actions.editor") || cs.hasPermission("quests.events.editor")) {
Conversable c = (Conversable) cs;
if (!c.isConversing()) {
plugin.getEventFactory().getConversationFactory().buildConversation(c).begin();
plugin.getActionFactory().getConversationFactory().buildConversation(c).begin();
} else {
cs.sendMessage(ChatColor.RED + Lang.get("duplicateEditor"));
}

View File

@ -22,6 +22,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
@ -30,31 +31,21 @@ import org.bukkit.entity.Player;
import me.blackvein.quests.Quests;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
public class Lang {
private String iso = "en-US";
private static final LangToken tokens = new LangToken();
private static String iso = "en-US";
private static final LinkedHashMap<String, String> langMap = new LinkedHashMap<String, String>();
private final Quests plugin;
private static PlaceholderAPIPlugin placeholder;
public Lang(Quests plugin) {
tokens.initTokens();
this.plugin = plugin;
Lang.placeholder = plugin.getDependencies().getPlaceholderApi();
}
public String getISO() {
public static String getISO() {
return iso;
}
public void setISO(String iso) {
this.iso = iso;
public static void setISO(String iso) {
Lang.iso = iso;
}
public Collection<String> values() {
public static Collection<String> values() {
return langMap.values();
}
@ -66,7 +57,7 @@ public class Lang {
* @return formatted string, plus processing through PlaceholderAPI by clip
*/
public static String get(Player p, String key) {
return langMap.containsKey(key) ? tokens.convertString(p, langMap.get(key)) : "NULL";
return langMap.containsKey(key) ? LangToken.convertString(p, langMap.get(key)) : "NULL";
}
/**
@ -76,7 +67,7 @@ public class Lang {
* @return formatted string
*/
public static String get(String key) {
return langMap.containsKey(key) ? tokens.convertString(langMap.get(key)) : "NULL";
return langMap.containsKey(key) ? LangToken.convertString(langMap.get(key)) : "NULL";
}
/**
@ -124,7 +115,7 @@ public class Lang {
return orig;
}
public void loadLang() throws InvalidConfigurationException, IOException {
public static void loadLang(Quests plugin) throws InvalidConfigurationException, IOException {
File langFile = new File(plugin.getDataFolder(), File.separator + "lang" + File.separator + iso + File.separator
+ "strings.yml");
File langFile_new = new File(plugin.getDataFolder(), File.separator + "lang" + File.separator + iso
@ -215,9 +206,9 @@ public class Lang {
private static class LangToken {
Map<String, String> tokenMap = new HashMap<String, String>();
static Map<String, String> tokenMap = new HashMap<String, String>();
public void initTokens() {
public static void init() {
tokenMap.put("%br%", "\n");
tokenMap.put("%tab%", "\t");
tokenMap.put("%rtr%", "\r");
@ -245,7 +236,10 @@ public class Lang {
tokenMap.put("%yellow%", ChatColor.YELLOW.toString());
}
public String convertString(String s) {
public static String convertString(String s) {
if (tokenMap.isEmpty()) {
LangToken.init();
}
for (String token : tokenMap.keySet()) {
s = s.replace(token, tokenMap.get(token));
s = s.replace(token.toUpperCase(), tokenMap.get(token));
@ -253,12 +247,17 @@ public class Lang {
return s;
}
public String convertString(Player p, String s) {
public static String convertString(Player p, String s) {
if (tokenMap.isEmpty()) {
LangToken.init();
}
for (String token : tokenMap.keySet()) {
s = s.replace(token, tokenMap.get(token));
s = s.replace(token.toUpperCase(), tokenMap.get(token));
if (placeholder != null) {
s = PlaceholderAPI.setPlaceholders(p, s);
if (Bukkit.getServer().getPluginManager().getPlugin("PlaceholderAPI") != null ) {
if (!Bukkit.getServer().getPluginManager().getPlugin("PlaceholderAPI").isEnabled()) {
s = PlaceholderAPI.setPlaceholders(p, s);
}
}
}
return s;