Merge pull request #1 from PikaMug/master

Sync merge
This commit is contained in:
AlessioDP 2019-09-02 20:21:07 +00:00 committed by GitHub
commit 4a09d352d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 2087 additions and 876 deletions

View File

@ -63,10 +63,19 @@ public class Dependencies {
return worldGuardApi;
}
/**
* Get mcMMO Classic plugin
*
* @deprecated Use {@link #getMcmmoClassic()}
*/
public mcMMO getMcmmo() {
return mcmmo;
}
public mcMMO getMcmmoClassic() {
return mcmmo;
}
public Heroes getHeroes() {
return heroes;
}

View File

@ -624,8 +624,10 @@ public class Quest {
int index = 0;
for (String s : rews.getCommands()) {
if (rews.getCommandsOverrideDisplay().isEmpty() == false && rews.getCommandsOverrideDisplay().size() >= index) {
if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) {
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getCommandsOverrideDisplay().get(index));
if (rews.getCommandsOverrideDisplay().size() > index) {
if (!rews.getCommandsOverrideDisplay().get(index).trim().equals("")) {
player.sendMessage("- " + ChatColor.DARK_GREEN + rews.getCommandsOverrideDisplay().get(index));
}
}
} else {
player.sendMessage("- " + ChatColor.DARK_GREEN + s);

View File

@ -47,8 +47,10 @@ import org.bukkit.inventory.ItemStack;
import com.sk89q.worldguard.protection.managers.RegionManager;
import me.blackvein.quests.actions.Action;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenCreateMenuEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenMainMenuEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenCreatePromptEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenExitPromptEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenMainPromptEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenSavePromptEvent;
import me.blackvein.quests.prompts.GUIDisplayPrompt;
import me.blackvein.quests.prompts.OptionsPrompt;
import me.blackvein.quests.prompts.RequirementsPrompt;
@ -136,10 +138,10 @@ public class QuestFactory implements ConversationAbandonedListener {
}
public class MainMenuPrompt extends NumericPrompt {
private final int maxNumber = 4;
private final int size = 4;
public int getMaxNumber() {
return maxNumber;
public int getSize() {
return size;
}
public String getTitle() {
@ -176,10 +178,10 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenMainMenuEvent event = new QuestsEditorPostOpenMainMenuEvent(context);
QuestsEditorPostOpenMainPromptEvent event = new QuestsEditorPostOpenMainPromptEvent(context);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + getTitle() + "\n";
for (int i = 1; i <= maxNumber; i++) {
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
}
return text;
@ -224,14 +226,14 @@ public class QuestFactory implements ConversationAbandonedListener {
}
public class CreateMenuPrompt extends NumericPrompt {
private final int maxNumber = 15;
private final int size = 15;
public int getMaxNumber() {
return maxNumber;
public int getSize() {
return size;
}
public String getTitle(ConversationContext context) {
return Lang.get("quest") + ": " + ChatColor.AQUA + context.getSessionData(CK.Q_NAME);
return ChatColor.GOLD + Lang.get("quest") + ": " + ChatColor.AQUA + context.getSessionData(CK.Q_NAME);
}
public ChatColor getNumberColor(ConversationContext context, int number) {
@ -410,11 +412,11 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenCreateMenuEvent event = new QuestsEditorPostOpenCreateMenuEvent(context);
QuestsEditorPostOpenCreatePromptEvent event = new QuestsEditorPostOpenCreatePromptEvent(context);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.GOLD + "- " + getTitle(context) + ChatColor.GOLD + " -\n";
for (int i = 1; i <= maxNumber; i++) {
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
}
return text;
@ -782,12 +784,49 @@ public class QuestFactory implements ConversationAbandonedListener {
}
}
private class SavePrompt extends StringPrompt {
public class SavePrompt extends StringPrompt {
private final int size = 2;
public int getSize() {
return size;
}
public ChatColor getNumberColor(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.GREEN;
case 2:
return ChatColor.RED;
default:
return null;
}
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.GREEN + Lang.get("yesWord");
case 2:
return ChatColor.RED + Lang.get("noWord");
default:
return null;
}
}
public String getQueryText(ConversationContext context) {
return ChatColor.YELLOW + Lang.get("questEditorSave") + " \"" + ChatColor.AQUA + context.getSessionData(CK.Q_NAME) + ChatColor.YELLOW + "\"?\n";
}
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.GREEN + "1 - " + Lang.get("yesWord") + "\n" + "2 - " + Lang.get("noWord");
return ChatColor.YELLOW + Lang.get("questEditorSave") + " \"" + ChatColor.AQUA + context.getSessionData(CK.Q_NAME) + ChatColor.YELLOW + "\"?\n" + text;
QuestsEditorPostOpenSavePromptEvent event = new QuestsEditorPostOpenSavePromptEvent(QuestFactory.this, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = getQueryText(context);
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
}
return text;
}
@Override
@ -799,7 +838,7 @@ public class QuestFactory implements ConversationAbandonedListener {
} else if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedFinishMessage"));
return new CreateMenuPrompt();
} else if (StagesPrompt.getStages(context) == 0) {
} else if (new StagesPrompt(plugin, QuestFactory.this).getStages(context) == 0) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNeedStages"));
return new CreateMenuPrompt();
}
@ -837,13 +876,49 @@ public class QuestFactory implements ConversationAbandonedListener {
}
}
private class ExitPrompt extends StringPrompt {
public class ExitPrompt extends StringPrompt {
private final int size = 2;
public int getSize() {
return size;
}
public ChatColor getNumberColor(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.GREEN;
case 2:
return ChatColor.RED;
default:
return null;
}
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.GREEN + Lang.get("yesWord");
case 2:
return ChatColor.RED + Lang.get("noWord");
default:
return null;
}
}
public String getQueryText(ConversationContext context) {
return ChatColor.YELLOW + Lang.get("confirmDelete") + "\n";
}
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("yesWord") + "\n"
+ ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.RED + " - " + Lang.get("noWord");
return ChatColor.YELLOW + Lang.get("questEditorExited") + "\n" + text;
QuestsEditorPostOpenExitPromptEvent event = new QuestsEditorPostOpenExitPromptEvent(QuestFactory.this, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = getQueryText(context);
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
}
return text;
}
@Override
@ -1150,7 +1225,7 @@ public class QuestFactory implements ConversationAbandonedListener {
String delayMessage;
String startMessage;
String completeMessage;
for (int i = 1; i <= StagesPrompt.getStages(cc); i++) {
for (int i = 1; i <= new StagesPrompt(plugin, this).getStages(cc); i++) {
pref = "stage" + i;
ConfigurationSection stage = ordered.createSection("" + i);
breakNames = null;
@ -1945,7 +2020,7 @@ public class QuestFactory implements ConversationAbandonedListener {
public String getPromptText(ConversationContext context) {
String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - " + Lang.get("yesWord") + "\n";
text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - " + Lang.get("noWord");
return ChatColor.RED + Lang.get("questEditorDeleted") + " (" + ChatColor.YELLOW + (String) context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + ")\n" + text;
return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW + (String) context.getSessionData(CK.ED_QUEST_DELETE) + ChatColor.RED + ")\n" + text;
}
@Override

View File

@ -1693,6 +1693,9 @@ public class Quester {
int index = 0;
for (Location location : getQuestData(quest).locationsReached) {
try {
if (getCurrentStage(quest).locationsToReach.size() <= index) {
return;
}
Location locationToReach = getCurrentStage(quest).locationsToReach.get(index);
double radius = getQuestData(quest).radiiToReachWithin.get(index);
if (l.getX() < (locationToReach.getX() + radius) && l.getX() > (locationToReach.getX() - radius)) {
@ -1711,10 +1714,12 @@ public class Quester {
}
}
index++;
} catch (IndexOutOfBoundsException e) {
plugin.getLogger().severe("An error has occurred with Quests. Please report on Github. Include the info below");
plugin.getLogger().warning("index = " + index);
plugin.getLogger().warning("locationsReached = " + getQuestData(quest).locationsReached.toString());
plugin.getLogger().warning("currentLocation = " + location.toString());
plugin.getLogger().warning("locationsReached = " + getQuestData(quest).locationsReached.size());
plugin.getLogger().warning("hasReached = " + getQuestData(quest).hasReached.size());
e.printStackTrace();
}

View File

@ -374,7 +374,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
player.sendMessage(ChatColor.YELLOW + Lang.get("cancelled"));
return Prompt.END_OF_CONVERSATION;
} else {
player.sendMessage(ChatColor.RED + Lang.get("questInvalidChoice"));
String msg = Lang.get("questInvalidChoice");
msg.replace("<yes>", Lang.get(player, "yesWord"));
msg.replace("<no>", Lang.get(player, "noWord"));
player.sendMessage(ChatColor.RED + msg);
return new QuestPrompt();
}
}
@ -1281,6 +1284,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (q.testRequirements(player)) {
available.add(q);
}
} else if (q.getPlanner().hasCooldown() && quester.getCooldownDifference(q) < 0) {
if (q.testRequirements(player)) {
available.add(q);
}
}
}
if ((available.size() + rows) <= ((page * rows)) || available.size() == 0) {
@ -1658,7 +1665,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (config.contains("quests." + questKey + ".rewards.mcmmo-levels")) {
if (Quests.checkList(config.getList("quests." + questKey + ".rewards.mcmmo-levels"), Integer.class)) {
for (String skill : config.getStringList("quests." + questKey + ".rewards.mcmmo-skills")) {
if (depends.getMcmmo() == null) {
if (depends.getMcmmoClassic() == null) {
skipQuestProcess("" + skill + " in mcmmo-skills: Reward in Quest " + quest.getName() + " requires the mcMMO plugin!");
} else if (Quests.getMcMMOSkill(skill) == null) {
skipQuestProcess("" + skill + " in mcmmo-skills: Reward in Quest " + quest.getName() + " is not a valid mcMMO skill name!");

View File

@ -408,7 +408,7 @@ public class ActionFactory implements ConversationAbandonedListener {
public String getPromptText(ConversationContext context) {
String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - " + Lang.get("yesWord") + "\n";
text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - " + Lang.get("noWord");
return ChatColor.RED + Lang.get("eventEditorDeletePrompt") + " (" + ChatColor.YELLOW + (String) context.getSessionData(CK.ED_EVENT_DELETE) + ChatColor.RED + ")\n" + text;
return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW + (String) context.getSessionData(CK.ED_EVENT_DELETE) + ChatColor.RED + ")\n" + text;
}
@Override
@ -799,7 +799,7 @@ public class ActionFactory implements ConversationAbandonedListener {
public String getPromptText(ConversationContext context) {
String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("yesWord") + "\n"
+ ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.RED + " - " + Lang.get("noWord");
return ChatColor.YELLOW + Lang.get("questEditorExited") + "\n" + text;
return ChatColor.YELLOW + Lang.get("confirmDelete") + "\n" + text;
}
@Override

View File

@ -3,10 +3,10 @@ package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
public class QuestsEditorPostOpenMainMenuEvent extends QuestsEditorEvent {
public class QuestsEditorPostOpenCreatePromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
public QuestsEditorPostOpenMainMenuEvent(ConversationContext context) {
public QuestsEditorPostOpenCreatePromptEvent(ConversationContext context) {
super(context);
this.context = context;
}

View File

@ -0,0 +1,36 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenCreateStagePromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
private final int stageNum;
public QuestsEditorPostOpenCreateStagePromptEvent(QuestFactory factory, int stageNum, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
this.stageNum = stageNum;
}
public QuestFactory getQuestFactory() {
return factory;
}
public int getStageNumber() {
return stageNum;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -5,11 +5,11 @@ import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenGUIDisplayMenuEvent extends QuestsEditorEvent {
public class QuestsEditorPostOpenExitPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenGUIDisplayMenuEvent(QuestFactory factory, ConversationContext context) {
public QuestsEditorPostOpenExitPromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenGUIDisplayPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenGUIDisplayPromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -3,10 +3,10 @@ package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
public class QuestsEditorPostOpenCreateMenuEvent extends QuestsEditorEvent {
public class QuestsEditorPostOpenMainPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
public QuestsEditorPostOpenCreateMenuEvent(ConversationContext context) {
public QuestsEditorPostOpenMainPromptEvent(ConversationContext context) {
super(context);
this.context = context;
}

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenOptionsGeneralPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenOptionsGeneralPromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenOptionsLevelPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenOptionsLevelPromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenOptionsMultiplayerPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenOptionsMultiplayerPromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenOptionsPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenOptionsPromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenOptionsTrueFalsePromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenOptionsTrueFalsePromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenPlannerPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenPlannerPromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenRequirementsPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenRequirementsPromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenRewardsPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenRewardsPromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenSavePromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenSavePromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,30 @@
package me.blackvein.quests.events.editor.quests;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.event.HandlerList;
import me.blackvein.quests.QuestFactory;
public class QuestsEditorPostOpenStagesPromptEvent extends QuestsEditorEvent {
private static final HandlerList handlers = new HandlerList();
private final QuestFactory factory;
public QuestsEditorPostOpenStagesPromptEvent(QuestFactory factory, ConversationContext context) {
super(context);
this.context = context;
this.factory = factory;
}
public QuestFactory getQuestFactory() {
return factory;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -7,11 +7,11 @@ import org.bukkit.event.HandlerList;
/**
* Called when the initial Quests Editor menu is opened by a player
*/
public class QuestsEditorPreOpenMainMenuEvent extends QuestsEditorEvent implements Cancellable {
public class QuestsEditorPreOpenMainPromptEvent extends QuestsEditorEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
public QuestsEditorPreOpenMainMenuEvent(ConversationContext context) {
public QuestsEditorPreOpenMainPromptEvent(ConversationContext context) {
super(context);
this.context = context;
}

View File

@ -30,7 +30,7 @@ import me.blackvein.quests.Quester;
import me.blackvein.quests.Quests;
import me.blackvein.quests.Requirements;
import me.blackvein.quests.Stage;
import me.blackvein.quests.events.editor.quests.QuestsEditorPreOpenMainMenuEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPreOpenMainPromptEvent;
import me.blackvein.quests.events.quest.QuestQuitEvent;
import me.blackvein.quests.exceptions.InvalidStageException;
import me.blackvein.quests.util.ItemUtil;
@ -454,7 +454,7 @@ public class CmdExecutor implements CommandExecutor {
Conversable c = (Conversable) cs;
if (!c.isConversing()) {
Conversation cn = plugin.getQuestFactory().getConversationFactory().buildConversation(c);
QuestsEditorPreOpenMainMenuEvent event = new QuestsEditorPreOpenMainMenuEvent(cn.getContext());
QuestsEditorPreOpenMainPromptEvent event = new QuestsEditorPreOpenMainPromptEvent(cn.getContext());
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;

View File

@ -585,7 +585,9 @@ public class PlayerListener implements Listener {
Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() != null) {
Quester quester = plugin.getQuester(wolf.getOwner().getUniqueId());
killPlayer(quester.getPlayer(), evt.getEntity());
if (quester != null) {
killPlayer(quester.getPlayer(), evt.getEntity());
}
}
} else {
killMob(damager, evt.getEntity());
@ -694,6 +696,9 @@ public class PlayerListener implements Listener {
* @since 3.1.4
*/
public void killPlayer(Entity damager, Entity target) {
if (damager == null) {
return;
}
if (!plugin.canUseQuests(damager.getUniqueId())) {
return;
}

View File

@ -25,6 +25,7 @@ import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.FixedSetPrompt;
import org.bukkit.conversations.NumericPrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player;
@ -33,251 +34,463 @@ 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.events.editor.quests.QuestsEditorPostOpenCreateStagePromptEvent;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.Lang;
public class CreateStagePrompt extends FixedSetPrompt {
public class CreateStagePrompt extends NumericPrompt {
private final Quests plugin;
private final int stageNum;
private final String pref;
private final QuestFactory questFactory;
private boolean hasObjective = false;
private final int size = 17;
public CreateStagePrompt(Quests plugin, int stageNum, QuestFactory qf) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17");
this.plugin = plugin;
this.stageNum = stageNum;
this.pref = "stage" + stageNum;
this.questFactory = qf;
}
@SuppressWarnings({ "unchecked" })
@Override
public String getPromptText(ConversationContext context) {
try {
context.setSessionData(pref, Boolean.TRUE);
String text = ChatColor.LIGHT_PURPLE + "- " + ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.LIGHT_PURPLE + " | " + Lang.get("stageEditorStage") + " " + stageNum + " -\n";
if (context.getSessionData(pref + CK.S_BREAK_NAMES) == null && context.getSessionData(pref + CK.S_DAMAGE_NAMES) == null
&& context.getSessionData(pref + CK.S_PLACE_NAMES) == null && context.getSessionData(pref + CK.S_USE_NAMES) == null
&& context.getSessionData(pref + CK.S_CUT_NAMES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorBlocks") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
hasObjective = true;
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorBlocks") + "\n";
}
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null && context.getSessionData(pref + CK.S_SMELT_ITEMS) == null && context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null && context.getSessionData(pref + CK.S_BREW_ITEMS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
hasObjective = true;
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorItems") + "\n";
}
if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null && context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null && context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorNPCs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
hasObjective = true;
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorNPCs") + "\n";
}
if (context.getSessionData(pref + CK.S_MOB_TYPES) == null && context.getSessionData(pref + CK.S_FISH) == null && context.getSessionData(pref + CK.S_TAME_TYPES) == null && context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorMobs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
hasObjective = true;
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("stageEditorMobs") + "\n";
}
if (context.getSessionData(pref + CK.S_PLAYER_KILL) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
hasObjective = true;
Integer players = (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorKillPlayers") + ChatColor.GRAY + " (" + ChatColor.AQUA + players + " " + Lang.get("stageEditorPlayers") + ChatColor.GRAY + ")\n";
}
if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorReachLocs") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
hasObjective = true;
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorReachLocs") + "\n";
LinkedList<String> locations = (LinkedList<String>) context.getSessionData(pref + CK.S_REACH_LOCATIONS);
LinkedList<Integer> radii = (LinkedList<Integer>) context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS);
LinkedList<String> names = (LinkedList<String>) context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES);
for (int i = 0; i < locations.size(); i++) {
text += ChatColor.GRAY + " - " + Lang.get("stageEditorReachRadii1") + " " + ChatColor.BLUE + radii.get(i) + ChatColor.GRAY + " " + Lang.get("stageEditorReachRadii2") + " " + ChatColor.AQUA + names.get(i) + ChatColor.GRAY + " (" + ChatColor.DARK_AQUA + locations.get(i) + ChatColor.GRAY + ")\n";
public int getSize() {
return size;
}
public String getTitle(ConversationContext context) {
return ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.LIGHT_PURPLE + " | " + Lang.get("stageEditorStage") + " " + stageNum;
}
public ChatColor getNumberColor(ConversationContext context, int number) {
switch (number) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
return ChatColor.BLUE;
case 9:
if (!hasObjective) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
}
if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorPassword") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
hasObjective = true;
LinkedList<LinkedList<String>> passPhrases = (LinkedList<LinkedList<String>>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES);
LinkedList<String> passDisplays = (LinkedList<String>) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorPassword") + "\n";
for (int i = 0; i < passPhrases.size(); i++) {
text += ChatColor.AQUA + " - \"" + passDisplays.get(i) + "\"\n";
LinkedList<String> phrases = passPhrases.get(i);
for (String phrase : phrases) {
text += ChatColor.DARK_AQUA + " - " + phrase + "\n";
}
case 10:
if (!hasObjective) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
}
if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.DARK_PURPLE + " - " + Lang.get("stageEditorCustom") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
hasObjective = true;
LinkedList<String> customObjs = (LinkedList<String>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.DARK_PURPLE + " - " + Lang.get("stageEditorCustom") + "\n";
for (String s : customObjs) {
text += ChatColor.LIGHT_PURPLE + " - " + ChatColor.GOLD + s + "\n";
}
}
if (!hasObjective) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorEvents") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.AQUA + " - " + Lang.get("stageEditorEvents") + "\n";
}
if (!hasObjective) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("delay") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n";
} else {
case 11:
if (context.getSessionData(pref + CK.S_DELAY) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("delay") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
return ChatColor.GRAY;
} else {
long time = (Long) context.getSessionData(pref + CK.S_DELAY);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("delay") + ChatColor.GRAY + " (" + ChatColor.AQUA + Quests.getTime(time) + ChatColor.GRAY + ")\n";
return ChatColor.BLUE;
}
}
if (context.getSessionData(pref + CK.S_DELAY) == null) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + Lang.get("noDelaySet") + ")\n";
} else if (context.getSessionData(pref + CK.S_DELAY_MESSAGE) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDelayMessage") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")\n";
}
if (plugin.getDependencies().getDenizenAPI() == null) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + Lang.get("notInstalled") + ")\n";
} else {
if (!hasObjective) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n";
case 12:
if (plugin.getDependencies().getDenizenAPI() == null) {
return ChatColor.GRAY;
} else {
if (context.getSessionData(pref + CK.S_DENIZEN) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
if (!hasObjective) {
return ChatColor.GRAY;
} else {
hasObjective = true;
text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDenizenScript") + ChatColor.GRAY + " (" + ChatColor.AQUA + context.getSessionData(pref + CK.S_DENIZEN) + ChatColor.GRAY + ")\n";
return ChatColor.BLUE;
}
}
}
if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) {
if (!hasObjective) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n";
case 13:
if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
return ChatColor.BLUE;
}
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorStartMessage") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_START_MESSAGE) + "\"" + ChatColor.GRAY + ")\n";
}
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) {
if (!hasObjective) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n";
case 14:
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
return ChatColor.BLUE;
}
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorCompleteMessage") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + ChatColor.GRAY + ")\n";
}
if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) {
if (!hasObjective) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + " (" + Lang.get("stageEditorOptional") + ")\n";
case 15:
if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) {
if (!hasObjective) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
return ChatColor.BLUE;
}
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorObjectiveOverride") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) + "\"" + ChatColor.GRAY + ")\n";
}
text += ChatColor.RED + "" + ChatColor.BOLD + "16" + ChatColor.RESET + ChatColor.RED + " - " + Lang.get("stageEditorDelete") + "\n";
text += ChatColor.GREEN + "" + ChatColor.BOLD + "17" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("done") + "\n";
return text;
} catch (Exception e) {
e.printStackTrace();
return "error";
case 16:
return ChatColor.RED;
case 17:
return ChatColor.GREEN;
default:
return null;
}
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.GOLD + Lang.get("stageEditorBlocks");
case 2:
return ChatColor.GOLD + Lang.get("stageEditorItems");
case 3:
return ChatColor.GOLD + Lang.get("stageEditorNPCs");
case 4:
return ChatColor.GOLD + Lang.get("stageEditorMobs");
case 5:
return ChatColor.YELLOW + Lang.get("stageEditorKillPlayers");
case 6:
return ChatColor.YELLOW + Lang.get("stageEditorReachLocs");
case 7:
return ChatColor.YELLOW + Lang.get("stageEditorPassword");
case 8:
return ChatColor.DARK_PURPLE + Lang.get("stageEditorCustom");
case 9:
if (!hasObjective) {
return ChatColor.GRAY + Lang.get("stageEditorEvents");
} else {
return ChatColor.AQUA + Lang.get("stageEditorEvents");
}
case 10:
if (!hasObjective) {
return ChatColor.GRAY + Lang.get("delay");
} else {
return ChatColor.YELLOW + Lang.get("delay");
}
case 11:
if (context.getSessionData(pref + CK.S_DELAY) == null) {
return ChatColor.GRAY + Lang.get("stageEditorDelayMessage");
} else {
return ChatColor.YELLOW + Lang.get("stageEditorDelayMessage");
}
case 12:
if (plugin.getDependencies().getDenizenAPI() == null) {
return ChatColor.GRAY + Lang.get("stageEditorDenizenScript");
} else {
if (!hasObjective) {
return ChatColor.GRAY + Lang.get("stageEditorDenizenScript");
} else {
return ChatColor.YELLOW + Lang.get("stageEditorDenizenScript");
}
}
case 13:
if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY + Lang.get("stageEditorStartMessage");
} else {
return ChatColor.YELLOW + Lang.get("stageEditorStartMessage");
}
} else {
return ChatColor.YELLOW + Lang.get("stageEditorStartMessage");
}
case 14:
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY + Lang.get("stageEditorCompleteMessage");
} else {
return ChatColor.YELLOW + Lang.get("stageEditorCompleteMessage");
}
} else {
return ChatColor.YELLOW + Lang.get("stageEditorCompleteMessage");
}
case 15:
if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) {
if (!hasObjective) {
return ChatColor.GRAY + Lang.get("stageEditorObjectiveOverride");
} else {
return ChatColor.YELLOW + Lang.get("stageEditorObjectiveOverride");
}
} else {
return ChatColor.YELLOW + Lang.get("stageEditorObjectiveOverride");
}
case 16:
return ChatColor.RED + Lang.get("stageEditorDelete");
case 17:
return ChatColor.GREEN + Lang.get("done");
default:
return null;
}
}
@SuppressWarnings("unchecked")
public String getAdditionalText(ConversationContext context, int number) {
switch (number) {
case 1:
if (context.getSessionData(pref + CK.S_BREAK_NAMES) == null && context.getSessionData(pref + CK.S_DAMAGE_NAMES) == null
&& context.getSessionData(pref + CK.S_PLACE_NAMES) == null && context.getSessionData(pref + CK.S_USE_NAMES) == null
&& context.getSessionData(pref + CK.S_CUT_NAMES) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
}
case 2:
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) == null && context.getSessionData(pref + CK.S_SMELT_ITEMS) == null && context.getSessionData(pref + CK.S_ENCHANT_TYPES) == null && context.getSessionData(pref + CK.S_BREW_ITEMS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
}
case 3:
if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) == null && context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) == null && context.getSessionData(pref + CK.S_NPCS_TO_KILL) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
}
case 4:
if (context.getSessionData(pref + CK.S_MOB_TYPES) == null && context.getSessionData(pref + CK.S_FISH) == null && context.getSessionData(pref + CK.S_TAME_TYPES) == null && context.getSessionData(pref + CK.S_SHEAR_COLORS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
}
case 5:
if (context.getSessionData(pref + CK.S_PLAYER_KILL) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
Integer players = (Integer) context.getSessionData(pref + CK.S_PLAYER_KILL);
return ChatColor.GRAY + "(" + ChatColor.AQUA + players + " " + Lang.get("stageEditorPlayers") + ChatColor.GRAY + ")";
}
case 6:
if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
LinkedList<String> locations = (LinkedList<String>) context.getSessionData(pref + CK.S_REACH_LOCATIONS);
LinkedList<Integer> radii = (LinkedList<Integer>) context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS);
LinkedList<String> names = (LinkedList<String>) context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES);
for (int i = 0; i < locations.size(); i++) {
text += ChatColor.GRAY + " - " + Lang.get("stageEditorReachRadii1") + " " + ChatColor.BLUE + radii.get(i) + ChatColor.GRAY + " " + Lang.get("stageEditorReachRadii2") + " " + ChatColor.AQUA + names.get(i) + ChatColor.GRAY + " (" + ChatColor.DARK_AQUA + locations.get(i) + ChatColor.GRAY + ")\n";
}
return text;
}
case 7:
if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
LinkedList<LinkedList<String>> passPhrases = (LinkedList<LinkedList<String>>) context.getSessionData(pref + CK.S_PASSWORD_PHRASES);
LinkedList<String> passDisplays = (LinkedList<String>) context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS);
for (int i = 0; i < passPhrases.size(); i++) {
text += ChatColor.AQUA + " - \"" + passDisplays.get(i) + "\"\n";
LinkedList<String> phrases = passPhrases.get(i);
for (String phrase : phrases) {
text += ChatColor.DARK_AQUA + " - " + phrase + "\n";
}
}
return text;
}
case 8:
if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
LinkedList<String> customObjs = (LinkedList<String>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.DARK_PURPLE + " - " + Lang.get("stageEditorCustom") + "\n";
for (String s : customObjs) {
text += ChatColor.LIGHT_PURPLE + " - " + ChatColor.GOLD + s + "\n";
}
return text;
}
case 9:
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
}
case 10:
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
} else {
if (context.getSessionData(pref + CK.S_DELAY) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
long time = (Long) context.getSessionData(pref + CK.S_DELAY);
return ChatColor.GRAY + "(" + ChatColor.AQUA + Quests.getTime(time) + ChatColor.GRAY + ")";
}
}
case 11:
if (context.getSessionData(pref + CK.S_DELAY) == null) {
return ChatColor.GRAY + "(" + Lang.get("noDelaySet") + ")";
} else if (context.getSessionData(pref + CK.S_DELAY_MESSAGE) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_DELAY_MESSAGE) + "\"" + ChatColor.GRAY + ")";
}
case 12:
if (plugin.getDependencies().getDenizenAPI() == null) {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
} else {
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
} else {
if (context.getSessionData(pref + CK.S_DENIZEN) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(pref + CK.S_DENIZEN) + ChatColor.GRAY + ")";
}
}
}
case 13:
if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
} else {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
}
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_START_MESSAGE) + "\"" + ChatColor.GRAY + ")";
}
case 14:
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) {
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
} else {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
}
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + ChatColor.GRAY + ")";
}
case 15:
if (context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) == null) {
if (!hasObjective) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
} else {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
}
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY) + "\"" + ChatColor.GRAY + ")";
}
case 16:
case 17:
return "";
default:
return null;
}
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new BlocksPrompt(plugin, stageNum, questFactory);
} else if (input.equalsIgnoreCase("2")) {
return new ItemsPrompt(plugin, stageNum, questFactory);
} else if (input.equalsIgnoreCase("3")) {
return new NPCsPrompt(plugin, stageNum, questFactory);
} else if (input.equalsIgnoreCase("4")) {
return new MobsPrompt(plugin, stageNum, questFactory);
} else if (input.equalsIgnoreCase("5")) {
return new KillPlayerPrompt();
} else if (input.equalsIgnoreCase("6")) {
return new ReachListPrompt();
} else if (input.equalsIgnoreCase("7")) {
return new PasswordListPrompt();
} else if (input.equalsIgnoreCase("8")) {
return new CustomObjectivesPrompt();
} else if (input.equalsIgnoreCase("9")) {
if (hasObjective) {
return new EventListPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
} else if (input.equalsIgnoreCase("10")) {
if (hasObjective) {
return new DelayPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
} else if (input.equalsIgnoreCase("11")) {
if (context.getSessionData(pref + CK.S_DELAY) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDelaySet"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
} else {
return new DelayMessagePrompt();
}
} else if (input.equalsIgnoreCase("12")) {
if (plugin.getDependencies().getDenizenAPI() == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDenizen"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
} else {
public String getPromptText(ConversationContext context) {
context.setSessionData(pref, Boolean.TRUE);
checkObjective(context);
QuestsEditorPostOpenCreateStagePromptEvent event = new QuestsEditorPostOpenCreateStagePromptEvent(questFactory, stageNum, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.LIGHT_PURPLE + "- " + getTitle(context) + " -\n";
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
}
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch (input.intValue()) {
case 1:
return new BlocksPrompt(plugin, stageNum, questFactory);
case 2:
return new ItemsPrompt(plugin, stageNum, questFactory);
case 3:
return new NPCsPrompt(plugin, stageNum, questFactory);
case 4:
return new MobsPrompt(plugin, stageNum, questFactory);
case 5:
return new KillPlayerPrompt();
case 6:
return new ReachListPrompt();
case 7:
return new PasswordListPrompt();
case 8:
return new CustomObjectivesPrompt();
case 9:
if (hasObjective) {
return new DenizenPrompt();
return new EventListPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
}
} else if (input.equalsIgnoreCase("13")) {
if (hasObjective) {
return new StartMessagePrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
case 10:
if (hasObjective) {
return new DelayPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
case 11:
if (context.getSessionData(pref + CK.S_DELAY) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDelaySet"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
} else {
return new DelayMessagePrompt();
}
case 12:
if (plugin.getDependencies().getDenizenAPI() == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDenizen"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
} else {
if (hasObjective) {
return new DenizenPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
}
case 13:
if (hasObjective) {
return new StartMessagePrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
case 14:
if (hasObjective) {
return new CompleteMessagePrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
case 15:
if (hasObjective) {
return new OverrideDisplayPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
case 16:
return new DeletePrompt();
case 17:
return new StagesPrompt(plugin, questFactory);
default:
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
} else if (input.equalsIgnoreCase("14")) {
if (hasObjective) {
return new CompleteMessagePrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
} else if (input.equalsIgnoreCase("15")) {
if (hasObjective) {
return new OverrideDisplayPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
} else if (input.equalsIgnoreCase("16")) {
return new DeletePrompt();
} else if (input.equalsIgnoreCase("17")) {
return new StagesPrompt(plugin, questFactory);
} else {
return new CreateStagePrompt(plugin, stageNum, questFactory);
}
}
public void checkObjective(ConversationContext context) {
if (context.getSessionData(pref + CK.S_BREAK_NAMES) != null || context.getSessionData(pref + CK.S_DAMAGE_NAMES) != null
|| context.getSessionData(pref + CK.S_PLACE_NAMES) != null || context.getSessionData(pref + CK.S_USE_NAMES) != null
|| context.getSessionData(pref + CK.S_CUT_NAMES) != null) {
hasObjective = true;
}
if (context.getSessionData(pref + CK.S_CRAFT_ITEMS) != null || context.getSessionData(pref + CK.S_SMELT_ITEMS) != null || context.getSessionData(pref + CK.S_ENCHANT_TYPES) != null || context.getSessionData(pref + CK.S_BREW_ITEMS) != null) {
hasObjective = true;
}
if (context.getSessionData(pref + CK.S_DELIVERY_NPCS) != null || context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO) != null || context.getSessionData(pref + CK.S_NPCS_TO_KILL) != null) {
hasObjective = true;
}
if (context.getSessionData(pref + CK.S_MOB_TYPES) != null || context.getSessionData(pref + CK.S_FISH) != null || context.getSessionData(pref + CK.S_TAME_TYPES) != null || context.getSessionData(pref + CK.S_SHEAR_COLORS) != null) {
hasObjective = true;
}
if (context.getSessionData(pref + CK.S_PLAYER_KILL) != null) {
hasObjective = true;
}
if (context.getSessionData(pref + CK.S_REACH_LOCATIONS) != null) {
hasObjective = true;
}
if (context.getSessionData(pref + CK.S_PASSWORD_PHRASES) != null) {
hasObjective = true;
}
if (context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES) == null) {
hasObjective = true;
}
}
@ -1214,14 +1427,14 @@ public class CreateStagePrompt extends FixedSetPrompt {
public String getPromptText(ConversationContext context) {
String text = ChatColor.GREEN + "" + ChatColor.BOLD + "1" + ChatColor.RESET + "" + ChatColor.GREEN + " - " + Lang.get("yesWord") + "\n";
text += ChatColor.RED + "" + ChatColor.BOLD + "2" + ChatColor.RESET + "" + ChatColor.RED + " - " + Lang.get("noWord");
return ChatColor.RED + Lang.get("stageEditorConfirmStageDelete") + " (" + ChatColor.YELLOW + Lang.get("stageEditorStage") + " " + stageNum + ChatColor.RED + ")\n" + ChatColor.GOLD + "(" + Lang.get("stageEditorConfirmStageNote") + ")\n" + text;
return ChatColor.RED + Lang.get("confirmDelete") + " (" + ChatColor.YELLOW + Lang.get("stageEditorStage") + " " + stageNum + ChatColor.RED + ")\n" + ChatColor.GOLD + "(" + Lang.get("stageEditorConfirmStageNote") + ")\n" + text;
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("Yes")) {
StagesPrompt.deleteStage(context, stageNum);
new StagesPrompt(plugin, questFactory).deleteStage(context, stageNum);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDeleteSucces"));
return new StagesPrompt(plugin, questFactory);
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("No")) {

View File

@ -9,7 +9,7 @@ import org.bukkit.inventory.ItemStack;
import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenGUIDisplayMenuEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenGUIDisplayPromptEvent;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
@ -23,14 +23,14 @@ public class GUIDisplayPrompt extends NumericPrompt {
this.questFactory = qf;
}
private final int maxNumber = 3;
private final int size = 3;
public int getMaxNumber() {
return maxNumber;
public int getSize() {
return size;
}
public String getTitle() {
return Lang.get("questGUITitle");
return ChatColor.GOLD + Lang.get("questGUITitle");
}
public ChatColor getNumberColor(ConversationContext context, int number) {
@ -61,7 +61,7 @@ public class GUIDisplayPrompt extends NumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenGUIDisplayMenuEvent event = new QuestsEditorPostOpenGUIDisplayMenuEvent(questFactory, context);
QuestsEditorPostOpenGUIDisplayPromptEvent event = new QuestsEditorPostOpenGUIDisplayPromptEvent(questFactory, context);
plugin.getServer().getPluginManager().callEvent(event);
if (context.getSessionData("tempStack") != null) {
@ -83,14 +83,14 @@ public class GUIDisplayPrompt extends NumericPrompt {
}
context.setSessionData("tempStack", null);
}
String text = ChatColor.GOLD + getTitle() + "\n";
String text = getTitle() + "\n";
if (context.getSessionData(CK.Q_GUIDISPLAY) != null) {
ItemStack stack = (ItemStack) context.getSessionData(CK.Q_GUIDISPLAY);
text += " " + ChatColor.RESET + ItemUtil.getDisplayString(stack) + "\n";
} else {
text += " " + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
}
for (int i = 1; i <= maxNumber; i++) {
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
}
return text;

View File

@ -14,57 +14,130 @@ package me.blackvein.quests.prompts;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.FixedSetPrompt;
import org.bukkit.conversations.NumericPrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import me.blackvein.quests.Options;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsGeneralPromptEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsLevelPromptEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsMultiplayerPromptEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsPromptEvent;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenOptionsTrueFalsePromptEvent;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.Lang;
public class OptionsPrompt extends FixedSetPrompt {
public class OptionsPrompt extends NumericPrompt {
private final Quests plugin;
private final QuestFactory factory;
private String tempKey;
private StringPrompt tempPrompt;
private Prompt tempPrompt;
public OptionsPrompt(Quests plugin, QuestFactory qf) {
super("1", "2", "3");
this.plugin = plugin;
factory = qf;
}
private final int size = 3;
public int getSize() {
return size;
}
public String getTitle(ConversationContext context) {
return ChatColor.DARK_GREEN + Lang.get("optionsTitle").replace("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_GREEN);
}
public ChatColor getNumberColor(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.BLUE;
case 2:
return ChatColor.BLUE;
case 3:
return ChatColor.GREEN;
default:
return null;
}
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.GOLD + Lang.get("optGeneral");
case 2:
return ChatColor.GOLD + Lang.get("optMultiplayer");
case 3:
return ChatColor.YELLOW + Lang.get("done");
default:
return null;
}
}
@Override
public String getPromptText(ConversationContext context) {
String text;
String lang = Lang.get("optionsTitle");
lang = lang.replace("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_GREEN);
text = ChatColor.DARK_AQUA + lang + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("optGeneral") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GOLD + " - " + Lang.get("optMultiplayer") + "\n";
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
QuestsEditorPostOpenOptionsPromptEvent event = new QuestsEditorPostOpenOptionsPromptEvent(factory, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = getTitle(context) + "\n";
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
}
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new GeneralPrompt();
} else if (input.equalsIgnoreCase("2")) {
return new MultiplayerPrompt();
} else if (input.equalsIgnoreCase("3")) {
return factory.returnToMenu();
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch (input.intValue()) {
case 1:
return new GeneralPrompt();
case 2:
return new MultiplayerPrompt();
case 3:
return factory.returnToMenu();
default:
return null;
}
return null;
}
private class TrueFalsePrompt extends StringPrompt {
public class TrueFalsePrompt extends StringPrompt {
private final int size = 4;
public int getSize() {
return size;
}
public String getQueryText() {
String text = "Select '<true>' or '<false>'";
text = text.replace("<true>", Lang.get("true"));
text = text.replace("<false>", Lang.get("false"));
return text;
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.YELLOW + Lang.get("true");
case 2:
return ChatColor.YELLOW + Lang.get("false");
case 3:
return ChatColor.RED + Lang.get("cmdClear");
case 4:
return ChatColor.RED + Lang.get("cmdCancel");
default:
return null;
}
}
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenOptionsTrueFalsePromptEvent event = new QuestsEditorPostOpenOptionsTrueFalsePromptEvent(factory, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = Lang.get("optBooleanPrompt");
text = text.replace("<true>", Lang.get("true"));
text = text.replace("<false>", Lang.get("false"));
@ -76,7 +149,7 @@ public class OptionsPrompt extends FixedSetPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
try {
boolean b = Boolean.parseBoolean(input);
if (input.equalsIgnoreCase("t") || input.equalsIgnoreCase(Lang.get("true"))) {
if (input.equalsIgnoreCase("t") || input.equalsIgnoreCase(Lang.get("true")) || input.equalsIgnoreCase(Lang.get("yesWord"))) {
b = true;
}
context.setSessionData(tempKey, b);
@ -92,15 +165,66 @@ public class OptionsPrompt extends FixedSetPrompt {
}
}
private class NumberPrompt extends StringPrompt {
public class LevelPrompt extends StringPrompt {
private final int size = 6;
public int getSize() {
return size;
}
public String getQueryText() {
return "Select level of progress sharing";
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.GOLD + "1";
case 2:
return ChatColor.GOLD + "2";
case 3:
return ChatColor.GOLD + "3";
case 4:
return ChatColor.GOLD + "4";
case 5:
return ChatColor.RED + Lang.get("cmdClear");
case 6:
return ChatColor.RED + Lang.get("cmdCancel");
default:
return null;
}
}
public String getAdditionalText(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.GRAY + Lang.get("everything");
case 2:
return ChatColor.GRAY + Lang.get("objectives");
case 3:
return ChatColor.GRAY + Lang.get("stageEditorStages");
case 4:
return ChatColor.GRAY + Lang.get("quests");
case 5:
return "";
case 6:
return "";
default:
return null;
}
}
@Override
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenOptionsLevelPromptEvent event = new QuestsEditorPostOpenOptionsLevelPromptEvent(factory, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = Lang.get("optNumberPrompt");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "1" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("everything");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "2" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("objectives");;
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "3" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("stageEditorStages");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "4" + ChatColor.RESET + " = " + ChatColor.GOLD + Lang.get("quests");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "1" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("everything");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "2" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("objectives");;
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "3" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("stageEditorStages");
text += "\n" + ChatColor.GRAY + "\u2515 " + ChatColor.GOLD + "4" + ChatColor.RESET + " = " + ChatColor.GRAY + Lang.get("quests");
return ChatColor.YELLOW + text;
}
@ -121,118 +245,203 @@ public class OptionsPrompt extends FixedSetPrompt {
}
}
private class GeneralPrompt extends StringPrompt {
public class GeneralPrompt extends NumericPrompt {
private final int size = 3;
public int getSize() {
return size;
}
public String getTitle() {
return ChatColor.DARK_GREEN + Lang.get("optGeneral");
}
public ChatColor getNumberColor(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.BLUE;
case 2:
return ChatColor.BLUE;
case 3:
return ChatColor.GREEN;
default:
return null;
}
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
if (context.getSessionData(CK.OPT_ALLOW_COMMANDS) == null) {
boolean defaultOpt = new Options().getAllowCommands();
return ChatColor.YELLOW + Lang.get("optAllowCommands") + " ("
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")";
} else {
boolean commandsOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS);
return ChatColor.YELLOW + Lang.get("optAllowCommands") + " ("
+ (commandsOpt ? ChatColor.GREEN + String.valueOf(commandsOpt) : ChatColor.RED + String.valueOf(commandsOpt)) + ChatColor.YELLOW + ")";
}
case 2:
if (context.getSessionData(CK.OPT_ALLOW_QUITTING) == null) {
boolean defaultOpt = new Options().getAllowQuitting();
return ChatColor.YELLOW + Lang.get("optAllowQuitting") + " ("
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")";
} else {
boolean quittingOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING);
return ChatColor.YELLOW + Lang.get("optAllowQuitting") + " ("
+ (quittingOpt ? ChatColor.GREEN + String.valueOf(quittingOpt) : ChatColor.RED + String.valueOf(quittingOpt)) + ChatColor.YELLOW + ")";
}
case 3:
return ChatColor.YELLOW + Lang.get("done");
default:
return null;
}
}
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.DARK_GREEN + "- " + Lang.get("optGeneral") + " -\n";
if (context.getSessionData(CK.OPT_ALLOW_COMMANDS) == null) {
boolean defaultOpt = new Options().getAllowCommands();
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowCommands") + " ("
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n";
} else {
boolean commandsOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_COMMANDS);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowCommands") + " ("
+ (commandsOpt ? ChatColor.GREEN + String.valueOf(commandsOpt) : ChatColor.RED + String.valueOf(commandsOpt)) + ChatColor.YELLOW + ")\n";
}
if (context.getSessionData(CK.OPT_ALLOW_QUITTING) == null) {
boolean defaultOpt = new Options().getAllowQuitting();
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowQuitting") + " ("
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n";
} else {
boolean quittingOpt = (Boolean) context.getSessionData(CK.OPT_ALLOW_QUITTING);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optAllowQuitting") + " ("
+ (quittingOpt ? ChatColor.GREEN + String.valueOf(quittingOpt) : ChatColor.RED + String.valueOf(quittingOpt)) + ChatColor.YELLOW + ")\n";
}
text += ChatColor.GREEN + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
QuestsEditorPostOpenOptionsGeneralPromptEvent event = new QuestsEditorPostOpenOptionsGeneralPromptEvent(factory, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.DARK_GREEN + "- " + getTitle() + " -\n";
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
}
return text;
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
tempKey = CK.OPT_ALLOW_COMMANDS;
tempPrompt = new GeneralPrompt();
return new TrueFalsePrompt();
} else if (input.equalsIgnoreCase("2")) {
tempKey = CK.OPT_ALLOW_QUITTING;
tempPrompt = new GeneralPrompt();
return new TrueFalsePrompt();
} else if (input.equalsIgnoreCase("3")) {
tempKey = null;
tempPrompt = null;
try {
return new OptionsPrompt(plugin, factory);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;
}
public Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch (input.intValue()) {
case 1:
tempKey = CK.OPT_ALLOW_COMMANDS;
tempPrompt = new GeneralPrompt();
return new TrueFalsePrompt();
case 2:
tempKey = CK.OPT_ALLOW_QUITTING;
tempPrompt = new GeneralPrompt();
return new TrueFalsePrompt();
case 3:
tempKey = null;
tempPrompt = null;
try {
return new OptionsPrompt(plugin, factory);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;
}
default:
return null;
}
return null;
}
}
private class MultiplayerPrompt extends StringPrompt {
public class MultiplayerPrompt extends NumericPrompt {
private final int size = 4;
public int getSize() {
return size;
}
public String getTitle() {
return ChatColor.DARK_GREEN + Lang.get("optMultiplayer");
}
public ChatColor getNumberColor(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.BLUE;
case 2:
return ChatColor.BLUE;
case 3:
return ChatColor.BLUE;
case 4:
return ChatColor.GREEN;
default:
return null;
}
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
if (context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) == null) {
boolean defaultOpt = new Options().getUseDungeonsXLPlugin();
return ChatColor.YELLOW + Lang.get("optUseDungeonsXLPlugin") + " ("
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")";
} else {
boolean dungeonsOpt = (Boolean) context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN);
return ChatColor.YELLOW + Lang.get("optUseDungeonsXLPlugin") + " ("
+ (dungeonsOpt ? ChatColor.GREEN + String.valueOf(dungeonsOpt) : ChatColor.RED + String.valueOf(dungeonsOpt)) + ChatColor.YELLOW + ")";
}
case 2:
if (context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) == null) {
boolean defaultOpt = new Options().getUsePartiesPlugin();
return ChatColor.YELLOW + Lang.get("optUsePartiesPlugin") + " ("
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")";
} else {
boolean partiesOpt = (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN);
return ChatColor.YELLOW + Lang.get("optUsePartiesPlugin") + " ("
+ (partiesOpt ? ChatColor.GREEN + String.valueOf(partiesOpt) : ChatColor.RED + String.valueOf(partiesOpt)) + ChatColor.YELLOW + ")";
}
case 3:
if (context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) == null) {
int defaultOpt = new Options().getShareProgressLevel();
return ChatColor.YELLOW + Lang.get("optShareProgressLevel") + " ("
+ ChatColor.AQUA + String.valueOf(defaultOpt) + ChatColor.YELLOW + ")";
} else {
int shareOpt = (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL);
return ChatColor.YELLOW + Lang.get("optShareProgressLevel") + " ("
+ ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")";
}
case 4:
return ChatColor.YELLOW + Lang.get("done");
default:
return null;
}
}
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.DARK_GREEN + "- " + Lang.get("optMultiplayer") + " -\n";
if (context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN) == null) {
boolean defaultOpt = new Options().getUseDungeonsXLPlugin();
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUseDungeonsXLPlugin") + " ("
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n";
} else {
boolean dungeonsOpt = (Boolean) context.getSessionData(CK.OPT_USE_DUNGEONSXL_PLUGIN);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUseDungeonsXLPlugin") + " ("
+ (dungeonsOpt ? ChatColor.GREEN + String.valueOf(dungeonsOpt) : ChatColor.RED + String.valueOf(dungeonsOpt)) + ChatColor.YELLOW + ")\n";
}
if (context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN) == null) {
boolean defaultOpt = new Options().getUsePartiesPlugin();
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUsePartiesPlugin") + " ("
+ (defaultOpt ? ChatColor.GREEN + String.valueOf(defaultOpt) : ChatColor.RED + String.valueOf(defaultOpt)) + ChatColor.YELLOW + ")\n";
} else {
boolean partiesOpt = (Boolean) context.getSessionData(CK.OPT_USE_PARTIES_PLUGIN);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optUsePartiesPlugin") + " ("
+ (partiesOpt ? ChatColor.GREEN + String.valueOf(partiesOpt) : ChatColor.RED + String.valueOf(partiesOpt)) + ChatColor.YELLOW + ")\n";
}
if (context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL) == null) {
int defaultOpt = new Options().getShareProgressLevel();
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optShareProgressLevel") + " ("
+ ChatColor.AQUA + String.valueOf(defaultOpt) + ChatColor.YELLOW + ")\n";
} else {
int shareOpt = (Integer) context.getSessionData(CK.OPT_SHARE_PROGRESS_LEVEL);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("optShareProgressLevel") + " ("
+ ChatColor.AQUA + String.valueOf(shareOpt) + ChatColor.YELLOW + ")\n";
}
text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
QuestsEditorPostOpenOptionsMultiplayerPromptEvent event = new QuestsEditorPostOpenOptionsMultiplayerPromptEvent(factory, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.DARK_GREEN + "- " + getTitle() + " -\n";
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
}
return text;
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
tempKey = CK.OPT_USE_DUNGEONSXL_PLUGIN;
tempPrompt = new MultiplayerPrompt();
return new TrueFalsePrompt();
} else if (input.equalsIgnoreCase("2")) {
tempKey = CK.OPT_USE_PARTIES_PLUGIN;
tempPrompt = new MultiplayerPrompt();
return new TrueFalsePrompt();
} else if (input.equalsIgnoreCase("3")) {
tempKey = CK.OPT_SHARE_PROGRESS_LEVEL;
tempPrompt = new MultiplayerPrompt();
return new NumberPrompt();
} else if (input.equalsIgnoreCase("4")) {
tempKey = null;
tempPrompt = null;
try {
return new OptionsPrompt(plugin, factory);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;
}
public Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch (input.intValue()) {
case 1:
tempKey = CK.OPT_USE_DUNGEONSXL_PLUGIN;
tempPrompt = new MultiplayerPrompt();
return new TrueFalsePrompt();
case 2:
tempKey = CK.OPT_USE_PARTIES_PLUGIN;
tempPrompt = new MultiplayerPrompt();
return new TrueFalsePrompt();
case 3:
tempKey = CK.OPT_SHARE_PROGRESS_LEVEL;
tempPrompt = new MultiplayerPrompt();
return new LevelPrompt();
case 4:
tempKey = null;
tempPrompt = null;
try {
return new OptionsPrompt(plugin, factory);
} catch (Exception e) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
return Prompt.END_OF_CONVERSATION;
}
default:
return null;
}
return null;
}
}
}

View File

@ -20,88 +20,148 @@ import java.util.TimeZone;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenPlannerPromptEvent;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.Lang;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.FixedSetPrompt;
import org.bukkit.conversations.NumericPrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
public class PlannerPrompt extends FixedSetPrompt {
public class PlannerPrompt extends NumericPrompt {
private final Quests plugin;
private final QuestFactory factory;
public PlannerPrompt(Quests plugin, QuestFactory qf) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11");
this.plugin = plugin;
factory = qf;
}
private final int size = 5;
public int getSize() {
return size;
}
public String getTitle(ConversationContext context) {
return ChatColor.DARK_AQUA + Lang.get("plannerTitle").replace("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA);
}
public ChatColor getNumberColor(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.BLUE;
case 2:
return ChatColor.BLUE;
case 3:
if (context.getSessionData(CK.PLN_START_DATE) == null || context.getSessionData(CK.PLN_END_DATE) == null) {
return ChatColor.GRAY;
} else {
return ChatColor.BLUE;
}
case 4:
return ChatColor.BLUE;
case 5:
return ChatColor.GREEN;
default:
return null;
}
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.YELLOW + Lang.get("plnStart");
case 2:
return ChatColor.YELLOW + Lang.get("plnEnd");
case 3:
if (context.getSessionData(CK.PLN_START_DATE) == null || context.getSessionData(CK.PLN_END_DATE) == null) {
return ChatColor.GRAY + Lang.get("plnRepeat");
} else {
return ChatColor.YELLOW + Lang.get("plnRepeat");
}
case 4:
return ChatColor.YELLOW + Lang.get("plnCooldown");
case 5:
return ChatColor.YELLOW + Lang.get("done");
default:
return null;
}
}
public String getAdditionalText(ConversationContext context, int number) {
switch (number) {
case 1:
if (context.getSessionData(CK.PLN_START_DATE) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.YELLOW + " - " + getPrettyDate((String) context.getSessionData(CK.PLN_START_DATE));
}
case 2:
if (context.getSessionData(CK.PLN_END_DATE) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.YELLOW + " - " + getPrettyDate((String) context.getSessionData(CK.PLN_END_DATE));
}
case 3:
if (context.getSessionData(CK.PLN_START_DATE) == null || context.getSessionData(CK.PLN_END_DATE) == null) {
return ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")";
} else {
if (context.getSessionData(CK.PLN_REPEAT_CYCLE) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.YELLOW + "(" + Quests.getTime((Long) context.getSessionData(CK.PLN_REPEAT_CYCLE)) + ChatColor.RESET + ChatColor.YELLOW + ")";
}
}
case 4:
if (context.getSessionData(CK.PLN_COOLDOWN) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.YELLOW + "(" + Quests.getTime((Long) context.getSessionData(CK.PLN_COOLDOWN)) + ChatColor.RESET + ChatColor.YELLOW + ")";
}
case 5:
return "";
default:
return null;
}
}
@Override
public String getPromptText(ConversationContext context) {
String text;
String lang = Lang.get("plannerTitle");
lang = lang.replace("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA);
text = ChatColor.DARK_AQUA + lang + "\n";
if (context.getSessionData(CK.PLN_START_DATE) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnStart") + " "
+ ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnStart") + "\n";
text += " - " + getPrettyDate((String) context.getSessionData(CK.PLN_START_DATE)) + "\n";
}
if (context.getSessionData(CK.PLN_END_DATE) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnEnd") + " "
+ ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnEnd") + "\n";
text += " - " + getPrettyDate((String) context.getSessionData(CK.PLN_END_DATE)) + "\n";
}
if (context.getSessionData(CK.PLN_START_DATE) == null || context.getSessionData(CK.PLN_END_DATE) == null) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("plnRepeat") + " "
+ ChatColor.GRAY + "(" + Lang.get("stageEditorOptional") + ")\n";
} else {
if (context.getSessionData(CK.PLN_REPEAT_CYCLE) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnRepeat") + " "
+ ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnRepeat") + " ("
+ Quests.getTime((Long) context.getSessionData(CK.PLN_REPEAT_CYCLE)) + ChatColor.RESET + ChatColor.YELLOW + ")\n";
}
}
if (context.getSessionData(CK.PLN_COOLDOWN) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnCooldown") + " "
+ ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("plnCooldown") + " ("
+ Quests.getTime((Long) context.getSessionData(CK.PLN_COOLDOWN)) + ChatColor.RESET + ChatColor.YELLOW + ")\n";
}
text += ChatColor.GREEN + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
QuestsEditorPostOpenPlannerPromptEvent event = new QuestsEditorPostOpenPlannerPromptEvent(factory, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = getTitle(context) + "\n";
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
}
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch (input.intValue()) {
case 1:
return new DateTimePrompt(plugin, PlannerPrompt.this, "start");
} else if (input.equalsIgnoreCase("2")) {
case 2:
return new DateTimePrompt(plugin, PlannerPrompt.this, "end");
} else if (input.equalsIgnoreCase("3")) {
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, factory);
}
} else if (input.equalsIgnoreCase("4")) {
case 4:
return new CooldownPrompt();
} else if (input.equalsIgnoreCase("5")) {
case 5:
return factory.returnToMenu();
default:
return null;
}
return null;
}
private class RepeatPrompt extends StringPrompt {

View File

@ -22,6 +22,7 @@ import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.FixedSetPrompt;
import org.bukkit.conversations.NumericPrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.inventory.ItemStack;
@ -33,168 +34,289 @@ import me.blackvein.quests.CustomRequirement;
import me.blackvein.quests.Quest;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenRequirementsPromptEvent;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
public class RequirementsPrompt extends FixedSetPrompt {
public class RequirementsPrompt extends NumericPrompt {
private Quests plugin;
private final Quests plugin;
private final QuestFactory factory;
private final int size = 11;
public RequirementsPrompt(Quests plugin, QuestFactory qf) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11");
this.plugin = plugin;
factory = qf;
}
public int getSize() {
return size;
}
public String getTitle(ConversationContext context) {
return ChatColor.DARK_AQUA + Lang.get("requirementsTitle").replace("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA);
}
public ChatColor getNumberColor(ConversationContext context, int number) {
switch (number) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return ChatColor.BLUE;
case 7:
if (plugin.getDependencies().getMcmmoClassic() != null) {
return ChatColor.BLUE;
} else {
return ChatColor.GRAY;
}
case 8:
if (plugin.getDependencies().getHeroes() != null) {
return ChatColor.BLUE;
} else {
return ChatColor.GRAY;
}
case 9:
case 10:
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null
&& context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null
&& context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null
&& context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null && context.getSessionData(CK.REQ_CUSTOM) == null) {
return ChatColor.GRAY;
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
return ChatColor.RED;
} else {
return ChatColor.BLUE;
}
case 11:
return ChatColor.GREEN;
default:
return null;
}
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.YELLOW + Lang.get("reqSetMoney");
case 2:
return ChatColor.YELLOW + Lang.get("reqSetQuestPoints");
case 3:
return ChatColor.YELLOW + Lang.get("reqSetItem");
case 4:
return ChatColor.YELLOW + Lang.get("reqSetPerms");
case 5:
return ChatColor.YELLOW + Lang.get("reqSetQuest");
case 6:
return ChatColor.YELLOW + Lang.get("reqSetQuestBlocks");
case 7:
return ChatColor.YELLOW + Lang.get("reqSetMcMMO");
case 8:
return ChatColor.YELLOW + Lang.get("reqSetHeroes");
case 9:
return ChatColor.DARK_PURPLE + Lang.get("reqSetCustom");
case 10:
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null
&& context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null
&& context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null
&& context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null && context.getSessionData(CK.REQ_CUSTOM) == null) {
return ChatColor.GRAY + Lang.get("reqSetFail");
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
return ChatColor.RED + Lang.get("reqSetFail");
} else {
return ChatColor.YELLOW + Lang.get("reqSetFail");
}
case 11:
return ChatColor.YELLOW + Lang.get("done");
default:
return null;
}
}
@SuppressWarnings("unchecked")
public String getAdditionalText(ConversationContext context, int number) {
switch (number) {
case 1:
if (context.getSessionData(CK.REQ_MONEY) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY);
return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyReq + " " + (moneyReq > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY + ")";
}
case 2:
if (context.getSessionData(CK.REQ_QUEST_POINTS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.REQ_QUEST_POINTS) + " " + Lang.get("questPoints") + ChatColor.GRAY + ")";
}
case 3:
if (context.getSessionData(CK.REQ_ITEMS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(CK.REQ_ITEMS);
for (int i = 0; i < items.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
}
return text;
}
case 4:
if (context.getSessionData(CK.REQ_PERMISSION) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
List<String> perms = (List<String>) context.getSessionData(CK.REQ_PERMISSION);
for (String s : perms) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
return text;
}
case 5:
if (context.getSessionData(CK.REQ_QUEST) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST);
for (String s : qs) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
return text;
}
case 6:
if (context.getSessionData(CK.REQ_QUEST_BLOCK) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK);
for (String s : qs) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
return text;
}
case 7:
if (plugin.getDependencies().getMcmmoClassic() != null) {
if (context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
List<String> skills = (List<String>) context.getSessionData(CK.REQ_MCMMO_SKILLS);
List<Integer> amounts = (List<Integer>) context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS);
for (String s : skills) {
text += ChatColor.GRAY + " - " + ChatColor.DARK_GREEN + s + ChatColor.RESET + ChatColor.YELLOW + " " + Lang.get("mcMMOLevel") + " " + ChatColor.GREEN + amounts.get(skills.indexOf(s)) + "\n";
}
return text;
}
} else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
}
case 8:
if (plugin.getDependencies().getHeroes() != null) {
if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
} else {
String text = "";
if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null) {
text += ChatColor.AQUA + " " + Lang.get("reqHeroesPrimaryDisplay") + " " + ChatColor.BLUE + (String) context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS);
}
if (context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null) {
text += ChatColor.AQUA + " " + Lang.get("reqHeroesSecondaryDisplay") + " " + ChatColor.BLUE + (String) context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS);
}
return text;
}
} else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
}
case 9:
if (context.getSessionData(CK.REQ_CUSTOM) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
LinkedList<String> customReqs = (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM);
for (String s : customReqs) {
text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\n";
}
return text;
}
case 10:
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null
&& context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null
&& context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null
&& context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null && context.getSessionData(CK.REQ_CUSTOM) == null) {
return ChatColor.GRAY + "(" + Lang.get("reqNone") + ")";
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
return ChatColor.RED + "(" + Lang.get("questRequiredNoneSet") + ")";
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + ChatColor.GRAY + ")";
}
case 11:
case 12:
case 13:
case 14:
case 15:
return "";
default:
return null;
}
}
@Override
public String getPromptText(ConversationContext context) {
String text;
String lang = Lang.get("requirementsTitle");
lang = lang.replaceAll("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA);
text = ChatColor.DARK_AQUA + lang + "\n";
if (context.getSessionData(CK.REQ_MONEY) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMoney") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMoney") + ChatColor.GRAY + " (" + ChatColor.AQUA + moneyReq + " " + (moneyReq > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY + ")\n";
}
if (context.getSessionData(CK.REQ_QUEST_POINTS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestPoints") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestPoints") + ChatColor.GRAY + " (" + ChatColor.AQUA + context.getSessionData(CK.REQ_QUEST_POINTS) + " " + Lang.get("questPoints") + ChatColor.GRAY + ")\n";
}
if (context.getSessionData(CK.REQ_ITEMS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetItem") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetItem") + "\n";
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(CK.REQ_ITEMS);
for (int i = 0; i < items.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
}
}
if (context.getSessionData(CK.REQ_PERMISSION) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetPerms") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetPerms") + "\n";
List<String> perms = (List<String>) context.getSessionData(CK.REQ_PERMISSION);
for (String s : perms) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
if (context.getSessionData(CK.REQ_QUEST) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuest") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuest") + "\n";
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST);
for (String s : qs) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
if (context.getSessionData(CK.REQ_QUEST_BLOCK) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestBlocks") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestBlocks") + "\n";
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK);
for (String s : qs) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
if (plugin.getDependencies().getMcmmo() != null) {
if (context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMcMMO") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMcMMO") + "\n";
List<String> skills = (List<String>) context.getSessionData(CK.REQ_MCMMO_SKILLS);
List<Integer> amounts = (List<Integer>) context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS);
for (String s : skills) {
text += ChatColor.GRAY + " - " + ChatColor.DARK_GREEN + s + ChatColor.RESET + ChatColor.YELLOW + " " + Lang.get("mcMMOLevel") + " " + ChatColor.GREEN + amounts.get(skills.indexOf(s)) + "\n";
}
}
} else {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("reqSetMcMMO") + " (" + Lang.get("notInstalled") + ")\n";
}
if (plugin.getDependencies().getHeroes() != null) {
if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetHeroes") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetHeroes") + "\n";
if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null) {
text += ChatColor.AQUA + " " + Lang.get("reqHeroesPrimaryDisplay") + " " + ChatColor.BLUE + (String) context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) + "\n";
}
if (context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null) {
text += ChatColor.AQUA + " " + Lang.get("reqHeroesSecondaryDisplay") + " " + ChatColor.BLUE + (String) context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) + "\n";
}
}
} else {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("reqSetHeroes") + " (" + Lang.get("notInstalled") + ")\n";
}
if (context.getSessionData(CK.REQ_CUSTOM) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("reqSetCustom") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("reqSetCustom") + "\n";
LinkedList<String> customReqs = (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM);
for (String s : customReqs) {
text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\n";
}
}
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null
&& context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null
&& context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null
&& context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null && context.getSessionData(CK.REQ_CUSTOM) == null) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.GRAY + Lang.get("reqSetFail") + " (" + Lang.get("reqNone") + ")\n";
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
text += ChatColor.RED + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.RED + Lang.get("reqSetFail") + " (" + Lang.get("questRequiredNoneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("reqSetFail") + ChatColor.GRAY + " (" + ChatColor.AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + ChatColor.GRAY + ")\n";
}
text += ChatColor.GREEN + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
QuestsEditorPostOpenRequirementsPromptEvent event = new QuestsEditorPostOpenRequirementsPromptEvent(factory, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = getTitle(context) + "\n";
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
}
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new MoneyPrompt();
} else if (input.equalsIgnoreCase("2")) {
return new QuestPointsPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new ItemListPrompt();
} else if (input.equalsIgnoreCase("4")) {
return new PermissionsPrompt();
} else if (input.equalsIgnoreCase("5")) {
return new QuestListPrompt(true);
} else if (input.equalsIgnoreCase("6")) {
return new QuestListPrompt(false);
} else if (input.equalsIgnoreCase("7")) {
if (plugin.getDependencies().getMcmmo() != null) {
return new mcMMOPrompt();
} else {
return new RequirementsPrompt(plugin, factory);
}
} else if (input.equalsIgnoreCase("8")) {
if (plugin.getDependencies().getHeroes() != null) {
return new HeroesPrompt();
} else {
return new RequirementsPrompt(plugin, factory);
}
} else if (input.equalsIgnoreCase("9")) {
return new CustomRequirementsPrompt();
} else if (input.equalsIgnoreCase("10")) {
return new FailMessagePrompt();
} else if (input.equalsIgnoreCase("11")) {
if (context.getSessionData(CK.REQ_MONEY) != null || context.getSessionData(CK.REQ_QUEST_POINTS) != null || context.getSessionData(CK.REQ_ITEMS) != null || context.getSessionData(CK.REQ_PERMISSION) != null || context.getSessionData(CK.REQ_QUEST) != null || context.getSessionData(CK.REQ_QUEST_BLOCK) != null || context.getSessionData(CK.REQ_MCMMO_SKILLS) != null || context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null || context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null || context.getSessionData(CK.REQ_CUSTOM) != null) {
if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNoMessage"));
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch (input.intValue()) {
case 1:
return new MoneyPrompt();
case 2:
return new QuestPointsPrompt();
case 3:
return new ItemListPrompt();
case 4:
return new PermissionsPrompt();
case 5:
return new QuestListPrompt(true);
case 6:
return new QuestListPrompt(false);
case 7:
if (plugin.getDependencies().getMcmmoClassic() != null) {
return new mcMMOPrompt();
} else {
return new RequirementsPrompt(plugin, factory);
}
}
return factory.returnToMenu();
case 8:
if (plugin.getDependencies().getHeroes() != null) {
return new HeroesPrompt();
} else {
return new RequirementsPrompt(plugin, factory);
}
case 9:
return new CustomRequirementsPrompt();
case 10:
return new FailMessagePrompt();
case 11:
if (context.getSessionData(CK.REQ_MONEY) != null || context.getSessionData(CK.REQ_QUEST_POINTS) != null || context.getSessionData(CK.REQ_ITEMS) != null || context.getSessionData(CK.REQ_PERMISSION) != null || context.getSessionData(CK.REQ_QUEST) != null || context.getSessionData(CK.REQ_QUEST_BLOCK) != null || context.getSessionData(CK.REQ_MCMMO_SKILLS) != null || context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null || context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null || context.getSessionData(CK.REQ_CUSTOM) != null) {
if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNoMessage"));
return new RequirementsPrompt(plugin, factory);
}
}
return factory.returnToMenu();
default:
return null;
}
return null;
}
private class MoneyPrompt extends StringPrompt {
@ -355,9 +477,9 @@ public class RequirementsPrompt extends FixedSetPrompt {
String text = ChatColor.GOLD + Lang.get("itemRequirementsTitle") + "\n";
if (context.getSessionData(CK.REQ_ITEMS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("stageEditorDeliveryAddItem") + "\n";
text += ChatColor.GRAY + "2 - " + Lang.get("reqSetRemoveItems") + " (" + Lang.get("reqNoItemsSet") + ")\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
text += ChatColor.GRAY + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("reqSetRemoveItems") + " (" + Lang.get("reqNoItemsSet") + ")\n";
text += ChatColor.RED + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
} else {
for (ItemStack is : getItems(context)) {
text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n";
@ -371,8 +493,8 @@ public class RequirementsPrompt extends FixedSetPrompt {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + (b.equals(Boolean.TRUE) ? Lang.get("yesWord") : Lang.get("noWord")) + "\n";
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
text += ChatColor.RED + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
}
return text;
}

View File

@ -21,6 +21,7 @@ import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.FixedSetPrompt;
import org.bukkit.conversations.NumericPrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.inventory.ItemStack;
@ -33,167 +34,275 @@ 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.events.editor.quests.QuestsEditorPostOpenRewardsPromptEvent;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
public class RewardsPrompt extends FixedSetPrompt {
public class RewardsPrompt extends NumericPrompt {
private final Quests plugin;
private final QuestFactory factory;
private final int size = 11;
public RewardsPrompt(Quests plugin, QuestFactory qf) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11");
this.plugin = plugin;
factory = qf;
}
public int getSize() {
return size;
}
public String getTitle(ConversationContext context) {
return ChatColor.LIGHT_PURPLE + Lang.get("rewardsTitle").replace("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.LIGHT_PURPLE);
}
public ChatColor getNumberColor(ConversationContext context, int number) {
switch (number) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
return ChatColor.BLUE;
case 7:
if (plugin.getDependencies().getMcmmoClassic() != null) {
return ChatColor.BLUE;
} else {
return ChatColor.GRAY;
}
case 8:
if (plugin.getDependencies().getHeroes() != null) {
return ChatColor.BLUE;
} else {
return ChatColor.GRAY;
}
case 9:
if (plugin.getDependencies().getPhatLoots() != null) {
return ChatColor.BLUE;
} else {
return ChatColor.GRAY;
}
case 10:
return ChatColor.BLUE;
case 11:
return ChatColor.GREEN;
default:
return null;
}
}
public String getSelectionText(ConversationContext context, int number) {
switch (number) {
case 1:
return ChatColor.YELLOW + Lang.get("reqSetMoney");
case 2:
return ChatColor.YELLOW + Lang.get("reqSetQuestPoints");
case 3:
return ChatColor.YELLOW + Lang.get("reqSetItem");
case 4:
return ChatColor.YELLOW + Lang.get("rewSetExperience");
case 5:
return ChatColor.YELLOW + Lang.get("rewSetCommands");
case 6:
return ChatColor.YELLOW + Lang.get("rewSetPermission");
case 7:
return ChatColor.YELLOW + Lang.get("reqSetMcMMO");
case 8:
return ChatColor.YELLOW + Lang.get("reqSetHeroes");
case 9:
return ChatColor.YELLOW + Lang.get("rewSetPhat");
case 10:
return ChatColor.DARK_PURPLE + Lang.get("rewSetCustom");
case 11:
return ChatColor.YELLOW + Lang.get("done");
default:
return null;
}
}
@SuppressWarnings("unchecked")
public String getAdditionalText(ConversationContext context, int number) {
switch (number) {
case 1:
if (context.getSessionData(CK.REW_MONEY) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
int moneyRew = (Integer) context.getSessionData(CK.REW_MONEY);
return ChatColor.GRAY + "(" + ChatColor.AQUA + moneyRew + " " + (moneyRew > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY + ")";
}
case 2:
if (context.getSessionData(CK.REW_QUEST_POINTS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.REW_QUEST_POINTS) + " " + Lang.get("questPoints") + ChatColor.GRAY + ")";
}
case 3:
if (context.getSessionData(CK.REW_ITEMS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(CK.REW_ITEMS);
for (int i = 0; i < items.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
}
return text;
}
case 4:
if (context.getSessionData(CK.REW_EXP) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
return ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.REW_EXP) + " " + Lang.get("points") + ChatColor.DARK_GRAY + ")";
}
case 5:
if (context.getSessionData(CK.REW_COMMAND) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
List<String> commands = (List<String>) context.getSessionData(CK.REW_COMMAND);
List<String> overrides = (List<String>) context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY);
int index = 0;
for (String cmd : commands) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + cmd + (overrides != null ? ChatColor.GRAY + " (\"" + ChatColor.AQUA + overrides.get(index) + ChatColor.GRAY + "\")" : "") + "\n";
index++;
}
return text;
}
case 6:
if (context.getSessionData(CK.REW_PERMISSION) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
List<String> permissions = (List<String>) context.getSessionData(CK.REW_PERMISSION);
for (String perm : permissions) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + perm + "\n";
}
return text;
}
case 7:
if (plugin.getDependencies().getMcmmoClassic() != null) {
if (context.getSessionData(CK.REW_MCMMO_SKILLS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
List<String> skills = (List<String>) context.getSessionData(CK.REW_MCMMO_SKILLS);
List<Integer> amounts = (List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS);
for (String skill : skills) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + skill + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amounts.get(skills.indexOf(skill)) + "\n";
}
return text;
}
} else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
}
case 8:
if (plugin.getDependencies().getHeroes() != null) {
if (context.getSessionData(CK.REW_HEROES_CLASSES) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
List<String> heroClasses = (List<String>) context.getSessionData(CK.REW_HEROES_CLASSES);
List<Double> amounts = (List<Double>) context.getSessionData(CK.REW_HEROES_AMOUNTS);
for (String heroClass : heroClasses) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + amounts.get(heroClasses.indexOf(heroClass)) + " " + ChatColor.DARK_AQUA + heroClass + " " + Lang.get("experience") + "\n";
}
return text;
}
} else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
}
case 9:
if (plugin.getDependencies().getPhatLoots() != null) {
if (context.getSessionData(CK.REW_PHAT_LOOTS) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
List<String> phatLoots = (List<String>) context.getSessionData(CK.REW_PHAT_LOOTS);
for (String phatLoot : phatLoots) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + phatLoot + "\n";
}
return text;
}
} else {
return ChatColor.GRAY + "(" + Lang.get("notInstalled") + ")";
}
case 10:
if (context.getSessionData(CK.REW_CUSTOM) == null) {
return ChatColor.GRAY + "(" + Lang.get("noneSet") + ")";
} else {
String text = "";
LinkedList<String> customRews = (LinkedList<String>) context.getSessionData(CK.REW_CUSTOM);
for (String s : customRews) {
text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\n";
}
return text;
}
case 11:
case 12:
case 13:
case 14:
case 15:
return "";
default:
return null;
}
}
@Override
public String getPromptText(ConversationContext context) {
String text;
String lang = Lang.get("rewardsTitle");
lang = lang.replace("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.LIGHT_PURPLE);
text = ChatColor.LIGHT_PURPLE + lang + "\n";
if (context.getSessionData(CK.REW_MONEY) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMoney") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
int moneyRew = (Integer) context.getSessionData(CK.REW_MONEY);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMoney") + ChatColor.GRAY + " (" + ChatColor.AQUA + moneyRew + " " + (moneyRew > 1 ? plugin.getCurrency(true) : plugin.getCurrency(false)) + ChatColor.GRAY + ")\n";
}
if (context.getSessionData(CK.REW_QUEST_POINTS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetQuestPoints") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetQuestPoints") + ChatColor.GRAY + " (" + ChatColor.AQUA + context.getSessionData(CK.REW_QUEST_POINTS) + " " + Lang.get("questPoints") + ChatColor.GRAY + ")\n";
}
if (context.getSessionData(CK.REW_ITEMS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetItems") + "\n";
LinkedList<ItemStack> items = (LinkedList<ItemStack>) context.getSessionData(CK.REW_ITEMS);
for (int i = 0; i < items.size(); i++) {
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getName(items.get(i)) + ChatColor.GRAY + " x " + ChatColor.AQUA + items.get(i).getAmount() + "\n";
}
}
if (context.getSessionData(CK.REW_EXP) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetExperience") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetExperience") + ChatColor.GRAY + " (" + ChatColor.AQUA + context.getSessionData(CK.REW_EXP) + " " + Lang.get("points") + ChatColor.DARK_GRAY + ")\n";
}
if (context.getSessionData(CK.REW_COMMAND) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommands") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommands") + "\n";
List<String> commands = (List<String>) context.getSessionData(CK.REW_COMMAND);
List<String> overrides = (List<String>) context.getSessionData(CK.REW_COMMAND_OVERRIDE_DISPLAY);
int index = 0;
for (String cmd : commands) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + cmd + (overrides != null ? ChatColor.GRAY + " (\"" + ChatColor.AQUA + overrides.get(index) + ChatColor.GRAY + "\")" : "") + "\n";
index++;
}
}
if (context.getSessionData(CK.REW_PERMISSION) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPermission") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPermission") + "\n";
List<String> permissions = (List<String>) context.getSessionData(CK.REW_PERMISSION);
for (String perm : permissions) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + perm + "\n";
}
}
if (plugin.getDependencies().getMcmmo() != null) {
if (context.getSessionData(CK.REW_MCMMO_SKILLS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMcMMO") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMcMMO") + "\n";
List<String> skills = (List<String>) context.getSessionData(CK.REW_MCMMO_SKILLS);
List<Integer> amounts = (List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS);
for (String skill : skills) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + skill + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amounts.get(skills.indexOf(skill)) + "\n";
}
}
} else {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("rewSetMcMMO") + " (" + Lang.get("notInstalled") + ")\n";
}
if (plugin.getDependencies().getHeroes() != null) {
if (context.getSessionData(CK.REW_HEROES_CLASSES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetHeroes") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetHeroes") + "\n";
List<String> heroClasses = (List<String>) context.getSessionData(CK.REW_HEROES_CLASSES);
List<Double> amounts = (List<Double>) context.getSessionData(CK.REW_HEROES_AMOUNTS);
for (String heroClass : heroClasses) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + amounts.get(heroClasses.indexOf(heroClass)) + " " + ChatColor.DARK_AQUA + heroClass + " " + Lang.get("experience") + "\n";
}
}
} else {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("rewSetHeroes") + " (" + Lang.get("notInstalled") + ")\n";
}
if (plugin.getDependencies().getPhatLoots() != null) {
if (context.getSessionData(CK.REW_PHAT_LOOTS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPhat") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPhat") + "\n";
List<String> phatLoots = (List<String>) context.getSessionData(CK.REW_PHAT_LOOTS);
for (String phatLoot : phatLoots) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + phatLoot + "\n";
}
}
} else {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.GRAY + " - " + Lang.get("rewSetPhat") + " (" + Lang.get("notInstalled") + ")\n";
}
if (context.getSessionData(CK.REW_CUSTOM) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("rewSetCustom") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("rewSetCustom") + "\n";
LinkedList<String> customRews = (LinkedList<String>) context.getSessionData(CK.REW_CUSTOM);
for (String s : customRews) {
text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\n";
}
}
text += ChatColor.GREEN + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
QuestsEditorPostOpenRewardsPromptEvent event = new QuestsEditorPostOpenRewardsPromptEvent(factory, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = getTitle(context) + "\n";
for (int i = 1; i <= size; i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
}
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new MoneyPrompt();
} else if (input.equalsIgnoreCase("2")) {
return new QuestPointsPrompt();
} else if (input.equalsIgnoreCase("3")) {
return new ItemListPrompt();
} else if (input.equalsIgnoreCase("4")) {
return new ExperiencePrompt();
} else if (input.equalsIgnoreCase("5")) {
return new CommandsListPrompt();
} else if (input.equalsIgnoreCase("6")) {
return new PermissionsPrompt();
} else if (input.equalsIgnoreCase("7")) {
if (plugin.getDependencies().getMcmmo() != null) {
return new mcMMOListPrompt();
} else {
return new RewardsPrompt(plugin, factory);
}
} else if (input.equalsIgnoreCase("8")) {
if (plugin.getDependencies().getHeroes() != null) {
return new HeroesListPrompt();
} else {
return new RewardsPrompt(plugin, factory);
}
} else if (input.equalsIgnoreCase("9")) {
if (plugin.getDependencies().getPhatLoots() != null) {
return new PhatLootsPrompt();
} else {
return new RewardsPrompt(plugin, factory);
}
} else if (input.equalsIgnoreCase("10")) {
return new CustomRewardsPrompt();
} else if (input.equalsIgnoreCase("11")) {
return factory.returnToMenu();
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
switch (input.intValue()) {
case 1:
return new MoneyPrompt();
case 2:
return new QuestPointsPrompt();
case 3:
return new ItemListPrompt();
case 4:
return new ExperiencePrompt();
case 5:
return new CommandsListPrompt();
case 6:
return new PermissionsPrompt();
case 7:
if (plugin.getDependencies().getMcmmoClassic() != null) {
return new mcMMOListPrompt();
} else {
return new RewardsPrompt(plugin, factory);
}
case 8:
if (plugin.getDependencies().getHeroes() != null) {
return new HeroesListPrompt();
} else {
return new RewardsPrompt(plugin, factory);
}
case 9:
if (plugin.getDependencies().getPhatLoots() != null) {
return new PhatLootsPrompt();
} else {
return new RewardsPrompt(plugin, factory);
}
case 10:
return new CustomRewardsPrompt();
case 11:
return factory.returnToMenu();
default:
return null;
}
return null;
}
private class MoneyPrompt extends StringPrompt {

View File

@ -14,64 +14,94 @@ package me.blackvein.quests.prompts;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.NumericPrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import me.blackvein.quests.QuestFactory;
import me.blackvein.quests.Quests;
import me.blackvein.quests.events.editor.quests.QuestsEditorPostOpenStagesPromptEvent;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.Lang;
public class StagesPrompt extends StringPrompt {
public class StagesPrompt extends NumericPrompt {
private final Quests plugin;
private final QuestFactory questFactory;
private int size = 2;
public StagesPrompt(Quests plugin, QuestFactory qf) {
this.plugin = plugin;
questFactory = qf;
}
public int getSize(ConversationContext context) {
return size;
}
public String getTitle() {
return ChatColor.LIGHT_PURPLE + Lang.get("stageEditorStages");
}
public ChatColor getNumberColor(ConversationContext context, int number) {
int stages = getStages(context);
if (number > 0) {
if (number < (stages + 1) && number > 0) {
return ChatColor.BLUE;
} else if (number == (stages + 1)) {
return ChatColor.BLUE;
} else if (number == (stages + 2)) {
return ChatColor.GREEN;
}
}
return null;
}
public String getSelectionText(ConversationContext context, int number) {
int stages = getStages(context);
if (number > 0) {
if (number < (stages + 1) && number > 0) {
return ChatColor.GOLD + Lang.get("stageEditorEditStage") + " " + number;
} else if (number == (stages + 1)) {
return ChatColor.YELLOW + Lang.get("stageEditorNewStage");
} else if (number == (stages + 2)) {
return ChatColor.YELLOW + Lang.get("done");
}
}
return null;
}
@Override
public String getPromptText(ConversationContext cc) {
String text = ChatColor.LIGHT_PURPLE + "- " + Lang.get("stageEditorStages") + " -\n";
int stages = getStages(cc);
for (int i = 1; i <= stages; i++) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + i + " - " + ChatColor.RESET + ChatColor.GOLD + Lang.get("stageEditorEditStage") + " " + i + "\n";
}
stages++;
text += "\n" + ChatColor.BLUE + "" + ChatColor.BOLD + stages + " - " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("stageEditorNewStage");
stages++;
text += "\n" + ChatColor.GREEN + "" + ChatColor.BOLD + stages + " - " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("done");
public String getPromptText(ConversationContext context) {
QuestsEditorPostOpenStagesPromptEvent event = new QuestsEditorPostOpenStagesPromptEvent(questFactory, context);
plugin.getServer().getPluginManager().callEvent(event);
String text = ChatColor.LIGHT_PURPLE + "- " + getTitle() + " -\n";
for (int i = 1; i <= (getStages(context) + size); i++) {
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - " + getSelectionText(context, i) + "\n";
}
return text;
}
@Override
public Prompt acceptInput(ConversationContext cc, String string) {
int i;
try {
i = Integer.parseInt(string);
} catch (NumberFormatException e) {
return new StagesPrompt(plugin, questFactory);
}
int stages = getStages(cc);
if (i < 0) {
return new StagesPrompt(plugin, questFactory);
} else if (i < (stages + 1) && i > 0) {
return new CreateStagePrompt(plugin, (i), questFactory);
} else if (i == (stages + 1)) {
return new CreateStagePrompt(plugin, (stages + 1), questFactory);
} else if (i == (stages + 2)) {
return questFactory.returnToMenu();
} else {
return new StagesPrompt(plugin, questFactory);
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
int i = input.intValue();
int stages = getStages(context);
if (i > 0) {
if (i < (stages + 1) && i > 0) {
return new CreateStagePrompt(plugin, (i), questFactory);
} else if (i == (stages + 1)) {
return new CreateStagePrompt(plugin, (stages + 1), questFactory);
} else if (i == (stages + 2)) {
return questFactory.returnToMenu();
}
}
return new StagesPrompt(plugin, questFactory);
}
public static int getStages(ConversationContext cc) {
public int getStages(ConversationContext context) {
int num = 1;
while (true) {
if (cc.getSessionData("stage" + num) != null) {
if (context.getSessionData("stage" + num) != null) {
num++;
} else {
break;
@ -80,8 +110,8 @@ public class StagesPrompt extends StringPrompt {
return (num - 1);
}
public static void deleteStage(ConversationContext cc, int stageNum) {
int stages = getStages(cc);
public void deleteStage(ConversationContext context, int stageNum) {
int stages = getStages(context);
int current = stageNum;
String pref = "stage" + current;
String newPref;
@ -97,135 +127,135 @@ public class StagesPrompt extends StringPrompt {
}
pref = "stage" + current;
newPref = "stage" + (current - 1);
cc.setSessionData(newPref + CK.S_BREAK_NAMES, cc.getSessionData(pref + CK.S_BREAK_NAMES));
cc.setSessionData(newPref + CK.S_BREAK_AMOUNTS, cc.getSessionData(pref + CK.S_BREAK_AMOUNTS));
cc.setSessionData(newPref + CK.S_BREAK_DURABILITY, cc.getSessionData(pref + CK.S_BREAK_DURABILITY));
cc.setSessionData(newPref + CK.S_DAMAGE_NAMES, cc.getSessionData(pref + CK.S_DAMAGE_NAMES));
cc.setSessionData(newPref + CK.S_DAMAGE_AMOUNTS, cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS));
cc.setSessionData(newPref + CK.S_DAMAGE_DURABILITY, cc.getSessionData(pref + CK.S_DAMAGE_DURABILITY));
cc.setSessionData(newPref + CK.S_PLACE_NAMES, cc.getSessionData(pref + CK.S_PLACE_NAMES));
cc.setSessionData(newPref + CK.S_PLACE_NAMES, cc.getSessionData(pref + CK.S_PLACE_AMOUNTS));
cc.setSessionData(newPref + CK.S_PLACE_DURABILITY, cc.getSessionData(pref + CK.S_PLACE_DURABILITY));
cc.setSessionData(newPref + CK.S_USE_NAMES, cc.getSessionData(pref + CK.S_USE_NAMES));
cc.setSessionData(newPref + CK.S_USE_AMOUNTS, cc.getSessionData(pref + CK.S_USE_AMOUNTS));
cc.setSessionData(newPref + CK.S_USE_DURABILITY, cc.getSessionData(pref + CK.S_USE_DURABILITY));
cc.setSessionData(newPref + CK.S_CUT_NAMES, cc.getSessionData(pref + CK.S_CUT_NAMES));
cc.setSessionData(newPref + CK.S_CUT_AMOUNTS, cc.getSessionData(pref + CK.S_CUT_AMOUNTS));
cc.setSessionData(newPref + CK.S_CUT_DURABILITY, cc.getSessionData(pref + CK.S_CUT_DURABILITY));
cc.setSessionData(newPref + CK.S_CRAFT_ITEMS, cc.getSessionData(pref + CK.S_CRAFT_ITEMS));
cc.setSessionData(newPref + CK.S_SMELT_ITEMS, cc.getSessionData(pref + CK.S_SMELT_ITEMS));
cc.setSessionData(newPref + CK.S_ENCHANT_TYPES, cc.getSessionData(pref + CK.S_ENCHANT_TYPES));
cc.setSessionData(newPref + CK.S_ENCHANT_NAMES, cc.getSessionData(pref + CK.S_ENCHANT_NAMES));
cc.setSessionData(newPref + CK.S_ENCHANT_AMOUNTS, cc.getSessionData(pref + CK.S_ENCHANT_AMOUNTS));
cc.setSessionData(newPref + CK.S_BREW_ITEMS, cc.getSessionData(pref + CK.S_BREW_ITEMS));
cc.setSessionData(newPref + CK.S_FISH, cc.getSessionData(pref + CK.S_FISH));
cc.setSessionData(newPref + CK.S_PLAYER_KILL, cc.getSessionData(pref + CK.S_PLAYER_KILL));
cc.setSessionData(newPref + CK.S_DELIVERY_ITEMS, cc.getSessionData(pref + CK.S_DELIVERY_ITEMS));
cc.setSessionData(newPref + CK.S_DELIVERY_NPCS, cc.getSessionData(pref + CK.S_DELIVERY_NPCS));
cc.setSessionData(newPref + CK.S_DELIVERY_MESSAGES, cc.getSessionData(pref + CK.S_DELIVERY_MESSAGES));
cc.setSessionData(newPref + CK.S_NPCS_TO_TALK_TO, cc.getSessionData(pref + CK.S_NPCS_TO_TALK_TO));
cc.setSessionData(newPref + CK.S_NPCS_TO_KILL, cc.getSessionData(pref + CK.S_NPCS_TO_KILL));
cc.setSessionData(newPref + CK.S_NPCS_TO_KILL_AMOUNTS, cc.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS));
cc.setSessionData(newPref + CK.S_MOB_TYPES, cc.getSessionData(pref + CK.S_MOB_TYPES));
cc.setSessionData(newPref + CK.S_MOB_AMOUNTS, cc.getSessionData(pref + CK.S_MOB_AMOUNTS));
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS));
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_RADIUS, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS));
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_NAMES, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES));
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS, cc.getSessionData(pref + CK.S_REACH_LOCATIONS));
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS_RADIUS, cc.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS));
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS_NAMES, cc.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES));
cc.setSessionData(newPref + CK.S_TAME_TYPES, cc.getSessionData(pref + CK.S_TAME_TYPES));
cc.setSessionData(newPref + CK.S_TAME_AMOUNTS, cc.getSessionData(pref + CK.S_TAME_AMOUNTS));
cc.setSessionData(newPref + CK.S_SHEAR_COLORS, cc.getSessionData(pref + CK.S_SHEAR_COLORS));
cc.setSessionData(newPref + CK.S_SHEAR_AMOUNTS, cc.getSessionData(pref + CK.S_SHEAR_AMOUNTS));
cc.setSessionData(newPref + CK.S_START_EVENT, cc.getSessionData(pref + CK.S_START_EVENT));
cc.setSessionData(newPref + CK.S_DISCONNECT_EVENT, cc.getSessionData(pref + CK.S_DISCONNECT_EVENT));
cc.setSessionData(newPref + CK.S_DEATH_EVENT, cc.getSessionData(pref + CK.S_DEATH_EVENT));
cc.setSessionData(newPref + CK.S_CHAT_EVENTS, cc.getSessionData(pref + CK.S_CHAT_EVENTS));
cc.setSessionData(newPref + CK.S_CHAT_EVENT_TRIGGERS, cc.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS));
cc.setSessionData(newPref + CK.S_FINISH_EVENT, cc.getSessionData(pref + CK.S_FINISH_EVENT));
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES));
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA));
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_COUNT, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT));
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS));
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP));
cc.setSessionData(newPref + CK.S_PASSWORD_DISPLAYS, cc.getSessionData(pref + CK.S_PASSWORD_DISPLAYS));
cc.setSessionData(newPref + CK.S_PASSWORD_PHRASES, cc.getSessionData(pref + CK.S_PASSWORD_PHRASES));
cc.setSessionData(newPref + CK.S_OVERRIDE_DISPLAY, cc.getSessionData(pref + CK.S_OVERRIDE_DISPLAY));
cc.setSessionData(newPref + CK.S_DELAY, cc.getSessionData(pref + CK.S_DELAY));
cc.setSessionData(newPref + CK.S_DELAY_MESSAGE, cc.getSessionData(pref + CK.S_DELAY_MESSAGE));
cc.setSessionData(newPref + CK.S_DENIZEN, cc.getSessionData(pref + CK.S_DENIZEN));
cc.setSessionData(newPref + CK.S_COMPLETE_MESSAGE, cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE));
cc.setSessionData(newPref + CK.S_START_MESSAGE, cc.getSessionData(pref + CK.S_START_MESSAGE));
context.setSessionData(newPref + CK.S_BREAK_NAMES, context.getSessionData(pref + CK.S_BREAK_NAMES));
context.setSessionData(newPref + CK.S_BREAK_AMOUNTS, context.getSessionData(pref + CK.S_BREAK_AMOUNTS));
context.setSessionData(newPref + CK.S_BREAK_DURABILITY, context.getSessionData(pref + CK.S_BREAK_DURABILITY));
context.setSessionData(newPref + CK.S_DAMAGE_NAMES, context.getSessionData(pref + CK.S_DAMAGE_NAMES));
context.setSessionData(newPref + CK.S_DAMAGE_AMOUNTS, context.getSessionData(pref + CK.S_DAMAGE_AMOUNTS));
context.setSessionData(newPref + CK.S_DAMAGE_DURABILITY, context.getSessionData(pref + CK.S_DAMAGE_DURABILITY));
context.setSessionData(newPref + CK.S_PLACE_NAMES, context.getSessionData(pref + CK.S_PLACE_NAMES));
context.setSessionData(newPref + CK.S_PLACE_NAMES, context.getSessionData(pref + CK.S_PLACE_AMOUNTS));
context.setSessionData(newPref + CK.S_PLACE_DURABILITY, context.getSessionData(pref + CK.S_PLACE_DURABILITY));
context.setSessionData(newPref + CK.S_USE_NAMES, context.getSessionData(pref + CK.S_USE_NAMES));
context.setSessionData(newPref + CK.S_USE_AMOUNTS, context.getSessionData(pref + CK.S_USE_AMOUNTS));
context.setSessionData(newPref + CK.S_USE_DURABILITY, context.getSessionData(pref + CK.S_USE_DURABILITY));
context.setSessionData(newPref + CK.S_CUT_NAMES, context.getSessionData(pref + CK.S_CUT_NAMES));
context.setSessionData(newPref + CK.S_CUT_AMOUNTS, context.getSessionData(pref + CK.S_CUT_AMOUNTS));
context.setSessionData(newPref + CK.S_CUT_DURABILITY, context.getSessionData(pref + CK.S_CUT_DURABILITY));
context.setSessionData(newPref + CK.S_CRAFT_ITEMS, context.getSessionData(pref + CK.S_CRAFT_ITEMS));
context.setSessionData(newPref + CK.S_SMELT_ITEMS, context.getSessionData(pref + CK.S_SMELT_ITEMS));
context.setSessionData(newPref + CK.S_ENCHANT_TYPES, context.getSessionData(pref + CK.S_ENCHANT_TYPES));
context.setSessionData(newPref + CK.S_ENCHANT_NAMES, context.getSessionData(pref + CK.S_ENCHANT_NAMES));
context.setSessionData(newPref + CK.S_ENCHANT_AMOUNTS, context.getSessionData(pref + CK.S_ENCHANT_AMOUNTS));
context.setSessionData(newPref + CK.S_BREW_ITEMS, context.getSessionData(pref + CK.S_BREW_ITEMS));
context.setSessionData(newPref + CK.S_FISH, context.getSessionData(pref + CK.S_FISH));
context.setSessionData(newPref + CK.S_PLAYER_KILL, context.getSessionData(pref + CK.S_PLAYER_KILL));
context.setSessionData(newPref + CK.S_DELIVERY_ITEMS, context.getSessionData(pref + CK.S_DELIVERY_ITEMS));
context.setSessionData(newPref + CK.S_DELIVERY_NPCS, context.getSessionData(pref + CK.S_DELIVERY_NPCS));
context.setSessionData(newPref + CK.S_DELIVERY_MESSAGES, context.getSessionData(pref + CK.S_DELIVERY_MESSAGES));
context.setSessionData(newPref + CK.S_NPCS_TO_TALK_TO, context.getSessionData(pref + CK.S_NPCS_TO_TALK_TO));
context.setSessionData(newPref + CK.S_NPCS_TO_KILL, context.getSessionData(pref + CK.S_NPCS_TO_KILL));
context.setSessionData(newPref + CK.S_NPCS_TO_KILL_AMOUNTS, context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS));
context.setSessionData(newPref + CK.S_MOB_TYPES, context.getSessionData(pref + CK.S_MOB_TYPES));
context.setSessionData(newPref + CK.S_MOB_AMOUNTS, context.getSessionData(pref + CK.S_MOB_AMOUNTS));
context.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS, context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS));
context.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_RADIUS, context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS));
context.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_NAMES, context.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES));
context.setSessionData(newPref + CK.S_REACH_LOCATIONS, context.getSessionData(pref + CK.S_REACH_LOCATIONS));
context.setSessionData(newPref + CK.S_REACH_LOCATIONS_RADIUS, context.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS));
context.setSessionData(newPref + CK.S_REACH_LOCATIONS_NAMES, context.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES));
context.setSessionData(newPref + CK.S_TAME_TYPES, context.getSessionData(pref + CK.S_TAME_TYPES));
context.setSessionData(newPref + CK.S_TAME_AMOUNTS, context.getSessionData(pref + CK.S_TAME_AMOUNTS));
context.setSessionData(newPref + CK.S_SHEAR_COLORS, context.getSessionData(pref + CK.S_SHEAR_COLORS));
context.setSessionData(newPref + CK.S_SHEAR_AMOUNTS, context.getSessionData(pref + CK.S_SHEAR_AMOUNTS));
context.setSessionData(newPref + CK.S_START_EVENT, context.getSessionData(pref + CK.S_START_EVENT));
context.setSessionData(newPref + CK.S_DISCONNECT_EVENT, context.getSessionData(pref + CK.S_DISCONNECT_EVENT));
context.setSessionData(newPref + CK.S_DEATH_EVENT, context.getSessionData(pref + CK.S_DEATH_EVENT));
context.setSessionData(newPref + CK.S_CHAT_EVENTS, context.getSessionData(pref + CK.S_CHAT_EVENTS));
context.setSessionData(newPref + CK.S_CHAT_EVENT_TRIGGERS, context.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS));
context.setSessionData(newPref + CK.S_FINISH_EVENT, context.getSessionData(pref + CK.S_FINISH_EVENT));
context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES, context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES));
context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA, context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA));
context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_COUNT, context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT));
context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS));
context.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP));
context.setSessionData(newPref + CK.S_PASSWORD_DISPLAYS, context.getSessionData(pref + CK.S_PASSWORD_DISPLAYS));
context.setSessionData(newPref + CK.S_PASSWORD_PHRASES, context.getSessionData(pref + CK.S_PASSWORD_PHRASES));
context.setSessionData(newPref + CK.S_OVERRIDE_DISPLAY, context.getSessionData(pref + CK.S_OVERRIDE_DISPLAY));
context.setSessionData(newPref + CK.S_DELAY, context.getSessionData(pref + CK.S_DELAY));
context.setSessionData(newPref + CK.S_DELAY_MESSAGE, context.getSessionData(pref + CK.S_DELAY_MESSAGE));
context.setSessionData(newPref + CK.S_DENIZEN, context.getSessionData(pref + CK.S_DENIZEN));
context.setSessionData(newPref + CK.S_COMPLETE_MESSAGE, context.getSessionData(pref + CK.S_COMPLETE_MESSAGE));
context.setSessionData(newPref + CK.S_START_MESSAGE, context.getSessionData(pref + CK.S_START_MESSAGE));
}
cc.setSessionData(pref + CK.S_BREAK_NAMES, null);
cc.setSessionData(pref + CK.S_BREAK_AMOUNTS, null);
cc.setSessionData(pref + CK.S_BREAK_DURABILITY, null);
cc.setSessionData(pref + CK.S_DAMAGE_NAMES, null);
cc.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, null);
cc.setSessionData(pref + CK.S_DAMAGE_DURABILITY, null);
cc.setSessionData(pref + CK.S_PLACE_NAMES, null);
cc.setSessionData(pref + CK.S_PLACE_AMOUNTS, null);
cc.setSessionData(pref + CK.S_PLACE_DURABILITY, null);
cc.setSessionData(pref + CK.S_USE_NAMES, null);
cc.setSessionData(pref + CK.S_USE_AMOUNTS, null);
cc.setSessionData(pref + CK.S_USE_DURABILITY, null);
cc.setSessionData(pref + CK.S_CUT_NAMES, null);
cc.setSessionData(pref + CK.S_CUT_AMOUNTS, null);
cc.setSessionData(pref + CK.S_CUT_DURABILITY, null);
cc.setSessionData(pref + CK.S_CRAFT_ITEMS, null);
cc.setSessionData(pref + CK.S_SMELT_ITEMS, null);
cc.setSessionData(pref + CK.S_ENCHANT_TYPES, null);
cc.setSessionData(pref + CK.S_ENCHANT_NAMES, null);
cc.setSessionData(pref + CK.S_BREW_ITEMS, null);
cc.setSessionData(pref + CK.S_FISH, null);
cc.setSessionData(pref + CK.S_PLAYER_KILL, null);
cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, null);
cc.setSessionData(pref + CK.S_DELIVERY_ITEMS, null);
cc.setSessionData(pref + CK.S_DELIVERY_NPCS, null);
cc.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null);
cc.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null);
cc.setSessionData(pref + CK.S_NPCS_TO_KILL, null);
cc.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, null);
cc.setSessionData(pref + CK.S_MOB_TYPES, null);
cc.setSessionData(pref + CK.S_MOB_AMOUNTS, null);
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, null);
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, null);
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, null);
cc.setSessionData(pref + CK.S_REACH_LOCATIONS, null);
cc.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, null);
cc.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, null);
cc.setSessionData(pref + CK.S_TAME_TYPES, null);
cc.setSessionData(pref + CK.S_TAME_AMOUNTS, null);
cc.setSessionData(pref + CK.S_SHEAR_COLORS, null);
cc.setSessionData(pref + CK.S_SHEAR_AMOUNTS, null);
cc.setSessionData(pref + CK.S_FINISH_EVENT, null);
cc.setSessionData(pref + CK.S_START_EVENT, null);
cc.setSessionData(pref + CK.S_DEATH_EVENT, null);
cc.setSessionData(pref + CK.S_CHAT_EVENTS, null);
cc.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, null);
cc.setSessionData(pref + CK.S_DISCONNECT_EVENT, null);
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, null);
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, null);
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, null);
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null);
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null);
cc.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, null);
cc.setSessionData(pref + CK.S_PASSWORD_PHRASES, null);
cc.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, null);
cc.setSessionData(pref + CK.S_DELAY, null);
cc.setSessionData(pref + CK.S_DELAY_MESSAGE, null);
cc.setSessionData(pref + CK.S_DENIZEN, null);
cc.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null);
cc.setSessionData(pref + CK.S_START_MESSAGE, null);
context.setSessionData(pref + CK.S_BREAK_NAMES, null);
context.setSessionData(pref + CK.S_BREAK_AMOUNTS, null);
context.setSessionData(pref + CK.S_BREAK_DURABILITY, null);
context.setSessionData(pref + CK.S_DAMAGE_NAMES, null);
context.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, null);
context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, null);
context.setSessionData(pref + CK.S_PLACE_NAMES, null);
context.setSessionData(pref + CK.S_PLACE_AMOUNTS, null);
context.setSessionData(pref + CK.S_PLACE_DURABILITY, null);
context.setSessionData(pref + CK.S_USE_NAMES, null);
context.setSessionData(pref + CK.S_USE_AMOUNTS, null);
context.setSessionData(pref + CK.S_USE_DURABILITY, null);
context.setSessionData(pref + CK.S_CUT_NAMES, null);
context.setSessionData(pref + CK.S_CUT_AMOUNTS, null);
context.setSessionData(pref + CK.S_CUT_DURABILITY, null);
context.setSessionData(pref + CK.S_CRAFT_ITEMS, null);
context.setSessionData(pref + CK.S_SMELT_ITEMS, null);
context.setSessionData(pref + CK.S_ENCHANT_TYPES, null);
context.setSessionData(pref + CK.S_ENCHANT_NAMES, null);
context.setSessionData(pref + CK.S_BREW_ITEMS, null);
context.setSessionData(pref + CK.S_FISH, null);
context.setSessionData(pref + CK.S_PLAYER_KILL, null);
context.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, null);
context.setSessionData(pref + CK.S_DELIVERY_ITEMS, null);
context.setSessionData(pref + CK.S_DELIVERY_NPCS, null);
context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null);
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null);
context.setSessionData(pref + CK.S_NPCS_TO_KILL, null);
context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, null);
context.setSessionData(pref + CK.S_MOB_TYPES, null);
context.setSessionData(pref + CK.S_MOB_AMOUNTS, null);
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, null);
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, null);
context.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, null);
context.setSessionData(pref + CK.S_REACH_LOCATIONS, null);
context.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, null);
context.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, null);
context.setSessionData(pref + CK.S_TAME_TYPES, null);
context.setSessionData(pref + CK.S_TAME_AMOUNTS, null);
context.setSessionData(pref + CK.S_SHEAR_COLORS, null);
context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, null);
context.setSessionData(pref + CK.S_FINISH_EVENT, null);
context.setSessionData(pref + CK.S_START_EVENT, null);
context.setSessionData(pref + CK.S_DEATH_EVENT, null);
context.setSessionData(pref + CK.S_CHAT_EVENTS, null);
context.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, null);
context.setSessionData(pref + CK.S_DISCONNECT_EVENT, null);
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, null);
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, null);
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, null);
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null);
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null);
context.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, null);
context.setSessionData(pref + CK.S_PASSWORD_PHRASES, null);
context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, null);
context.setSessionData(pref + CK.S_DELAY, null);
context.setSessionData(pref + CK.S_DELAY_MESSAGE, null);
context.setSessionData(pref + CK.S_DENIZEN, null);
context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null);
context.setSessionData(pref + CK.S_START_MESSAGE, null);
if (last) {
break;
}
}
if (!last) {
cc.setSessionData("stage" + (current - 1), null);
context.setSessionData("stage" + (current - 1), null);
} else {
cc.setSessionData("stage" + (current), null);
context.setSessionData("stage" + (current), null);
}
}
}
}

View File

@ -250,7 +250,11 @@ public class LocaleQuery {
key = oldEntities.get(type.name());
}
} else {
key = "entity.minecraft." + type.toString().toLowerCase();
if (type.name().equals("PIG_ZOMBIE")) {
key = "entity.minecraft.zombie_pigman";
} else {
key = "entity.minecraft." + type.toString().toLowerCase();
}
}
String msg = message.replace("<mob>", "\",{\"translate\":\"" + key + "\"},\"");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tellraw " + player.getName() + " [\"" + msg + "\"]");

View File

@ -96,7 +96,7 @@ questEditorNameExists: "A Quest with that name already exists!"
questEditorBeingEdited: "Someone is creating/editing a Quest with that name!"
questEditorInvalidQuestName: "Name may not contain periods or commas!"
questEditorInvalidEventName: "is not a valid action name!"
questEditorInvalidNPC: "No NPC exists with that id!"
questEditorInvalidNPC: "No NPC exists with that ID!"
questEditorNoStartBlockSelected: "You must select a block first."
questEditorPositiveAmount: "Amount must be a positive number."
questEditorQuestAsRequirement1: "The following Quests have"
@ -109,8 +109,6 @@ questEditorNeedAskMessage: "You must set an ask message!"
questEditorNeedFinishMessage: "You must set a finish message!"
questEditorNeedStages: "Your Quest has no Stages!"
questEditorSaved: "%bold%Quest saved! %reset%(You will need to perform %red%<command> %reset% for it to appear in-game)"
questEditorExited: "Are you sure you want to exit without saving?"
questEditorDeleted: "Are you sure you want to delete the Quest?"
stageEditorEditStage: "Edit Stage"
stageEditorNewStage: "Add new Stage"
stageEditorStages: "Stages"
@ -273,7 +271,6 @@ stageEditorDelayCleared: "Delay cleared."
stageEditorDenizenCleared: "Denizen script cleared."
stageEditorObjectiveCleared: "Objective cleared."
stageEditorMessageCleared: "Message cleared."
stageEditorConfirmStageDelete: "Are you sure you want to delete this stage?"
stageEditorConfirmStageNote: "Any Stages after will be shifted back one spot"
stageEditorDeleteSucces: "Stage deleted successfully."
stageEditorEnchantments: "Enchantments"
@ -294,8 +291,6 @@ eventEditorErrorSaving: "An error occurred while saving."
eventEditorDeleted: "Action deleted, Quests and Actions reloaded."
eventEditorSaved: "Action saved, Quests and Actions reloaded."
eventEditorEnterEventName: "Enter Action name, <cancel>"
eventEditorDeletePrompt: "Are you sure you want to delete the Action?"
eventEditorQuitWithoutSaving: "Are you sure you want to quit without saving?"
eventEditorModifiedNote: 'Note: You have modified an Action that the following Quests use:'
eventEditorForcedToQuit: "If you save the Action, anyone who is actively doing any of these Quests will be forced to quit them."
eventEditorEventInUse: "The following Quests use the Action"
@ -667,7 +662,7 @@ inputNum: "Input must be a number."
inputPosNum: "Input must be a positive number."
questModified: "Your active Quest <quest> has been modified. You have been forced to quit the Quest."
questNotExist: "Your active Quest <quest> no longer exists. You have been forced to quit the Quest."
questInvalidChoice: "Invalid choice. Type 'Yes' or 'No'"
questInvalidChoice: "Invalid choice. Type '<yes>' or '<no>'"
questPointsDisplay: "Quest points:"
questNoDrop: "You may not drop Quest items."
questNoBrew: "You may not brew Quest items."
@ -811,7 +806,6 @@ noDelaySet: "No delay set"
noIdsSet: "No IDs set"
noNamesSet: "No names set"
worlds: "Worlds"
mobs: "Mobs"
points: "points"
npcHint: "Note: You can left or right click on NPCs to get their ID."
listsNotSameSize: "All required lists must have the same number of entries!"
@ -844,4 +838,5 @@ questSaveError: "An error occurred while saving."
noPermission: "You do not have permission to do that."
duplicateEditor: "You are already using an editor!"
difference: "The difference is '<data>'."
notInstalled: "Not installed"
notInstalled: "Not installed"
confirmDelete: "Are you sure?"