Refactoring for getter/setter methods, part 5

This commit is contained in:
BuildTools 2019-01-07 02:23:21 -05:00
parent 2f325a1e1e
commit 9facf6dafc
12 changed files with 2020 additions and 1937 deletions

View File

@ -51,22 +51,22 @@ import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
import me.blackvein.quests.util.RomanNumeral;
public class EventFactory implements ConversationAbandonedListener {
Quests quests;
Map<UUID, Quest> editSessions = new HashMap<UUID, Quest>();
private Quests plugin;
public Map<UUID, Block> selectedExplosionLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedEffectLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedMobLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedLightningLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedTeleportLocations = new HashMap<UUID, Block>();
List<String> names = new LinkedList<String>();
ConversationFactory convoCreator;
private ConversationFactory convoCreator;
File eventsFile;
public EventFactory(Quests plugin) {
quests = plugin;
this.plugin = plugin;
// Ensure to initialize convoCreator last, to ensure that 'this' is fully initialized before it is passed
this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false).withPrefix(new QuestCreatorPrefix()).withFirstPrompt(new MenuPrompt()).withTimeout(3600).thatExcludesNonPlayersWithMessage("Console may not perform this operation!").addConversationAbandonedListener(this);
}
@ -81,6 +81,10 @@ public class EventFactory implements ConversationAbandonedListener {
selectedTeleportLocations.remove(player.getUniqueId());
}
public ConversationFactory getConversationFactory() {
return convoCreator;
}
private class QuestCreatorPrefix implements ConversationPrefix {
@Override
@ -114,7 +118,7 @@ public class EventFactory implements ConversationAbandonedListener {
}
} else if (input.equalsIgnoreCase("2")) {
if (player.hasPermission("quests.editor.events.edit")) {
if (quests.events.isEmpty()) {
if (plugin.getEvents().isEmpty()) {
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorNoneToEdit"));
return new MenuPrompt();
} else {
@ -126,7 +130,7 @@ public class EventFactory implements ConversationAbandonedListener {
}
} else if (input.equalsIgnoreCase("3")) {
if (player.hasPermission("quests.editor.events.delete")) {
if (quests.events.isEmpty()) {
if (plugin.getEvents().isEmpty()) {
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorNoneToDelete"));
return new MenuPrompt();
} else {
@ -276,7 +280,7 @@ public class EventFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorEdit") + " -\n";
for (Event evt : quests.events) {
for (Event evt : plugin.getEvents()) {
text += ChatColor.AQUA + evt.getName() + ChatColor.YELLOW + ", ";
}
text = text.substring(0, text.length() - 2) + "\n";
@ -287,7 +291,7 @@ public class EventFactory implements ConversationAbandonedListener {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (Event evt : quests.events) {
for (Event evt : plugin.getEvents()) {
if (evt.getName().toLowerCase().startsWith(input.toLowerCase())) {
context.setSessionData(CK.E_OLD_EVENT, evt.getName());
context.setSessionData(CK.E_NAME, evt.getName());
@ -308,7 +312,7 @@ public class EventFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.GOLD + "- " + Lang.get("eventEditorDelete") + " -\n";
for (Event evt : quests.events) {
for (Event evt : plugin.getEvents()) {
text += ChatColor.AQUA + evt.getName() + ChatColor.YELLOW + ",";
}
text = text.substring(0, text.length() - 1) + "\n";
@ -320,9 +324,9 @@ public class EventFactory implements ConversationAbandonedListener {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
LinkedList<String> used = new LinkedList<String>();
for (Event evt : quests.events) {
for (Event evt : plugin.getEvents()) {
if (evt.getName().equalsIgnoreCase(input)) {
for (Quest quest : quests.getQuests()) {
for (Quest quest : plugin.getQuests()) {
for (Stage stage : quest.getStages()) {
if (stage.finishEvent != null && stage.finishEvent.getName().equalsIgnoreCase(evt.getName())) {
used.add(quest.getName());
@ -466,7 +470,7 @@ public class EventFactory implements ConversationAbandonedListener {
int index = -1;
for (String type : types) {
index++;
text += ChatColor.GRAY + " - " + ChatColor.AQUA + type + ChatColor.DARK_PURPLE + " " + Quests.getNumeral(mags.get(index)) + ChatColor.GRAY + " -> " + ChatColor.DARK_AQUA + Quests.getTime(durations.get(index) * 50L) + "\n";
text += ChatColor.GRAY + " - " + ChatColor.AQUA + type + ChatColor.DARK_PURPLE + " " + RomanNumeral.getNumeral(mags.get(index)) + ChatColor.GRAY + " -> " + ChatColor.DARK_AQUA + Quests.getTime(durations.get(index) * 50L) + "\n";
}
}
if (context.getSessionData(CK.E_HUNGER) == null) {
@ -630,7 +634,7 @@ public class EventFactory implements ConversationAbandonedListener {
public FinishPrompt(String modifiedName) {
if (modifiedName != null) {
modName = modifiedName;
for (Quest q : quests.getQuests()) {
for (Quest q : plugin.getQuests()) {
for (Stage s : q.getStages()) {
if (s.finishEvent != null && s.finishEvent.getName() != null) {
if (s.finishEvent.getName().equalsIgnoreCase(modifiedName)) {
@ -714,7 +718,7 @@ public class EventFactory implements ConversationAbandonedListener {
private void deleteEvent(ConversationContext context) {
YamlConfiguration data = new YamlConfiguration();
try {
eventsFile = new File(quests.getDataFolder(), "events.yml");
eventsFile = new File(plugin.getDataFolder(), "events.yml");
data.load(eventsFile);
} catch (IOException e) {
e.printStackTrace();
@ -734,9 +738,9 @@ public class EventFactory implements ConversationAbandonedListener {
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving"));
return;
}
quests.reloadQuests();
plugin.reloadQuests();
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorDeleted"));
for (Quester q : quests.questers.values()) {
for (Quester q : plugin.getQuesters()) {
for (Quest quest : q.currentQuests.keySet()) {
q.checkQuest(quest);
}
@ -747,7 +751,7 @@ public class EventFactory implements ConversationAbandonedListener {
private void saveEvent(ConversationContext context) {
YamlConfiguration data = new YamlConfiguration();
try {
eventsFile = new File(quests.getDataFolder(), "events.yml");
eventsFile = new File(plugin.getDataFolder(), "events.yml");
data.load(eventsFile);
} catch (IOException e) {
e.printStackTrace();
@ -760,7 +764,9 @@ public class EventFactory implements ConversationAbandonedListener {
}
if (((String) context.getSessionData(CK.E_OLD_EVENT)).isEmpty() == false) {
data.set("events." + (String) context.getSessionData(CK.E_OLD_EVENT), null);
quests.events.remove(quests.getEvent((String) context.getSessionData(CK.E_OLD_EVENT)));
LinkedList<Event> temp = plugin.getEvents();
temp.remove(plugin.getEvent((String) context.getSessionData(CK.E_OLD_EVENT)));
plugin.setEvents(temp);
}
ConfigurationSection section = data.createSection("events." + (String) context.getSessionData(CK.E_NAME));
names.remove((String) context.getSessionData(CK.E_NAME));
@ -890,9 +896,9 @@ public class EventFactory implements ConversationAbandonedListener {
((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving"));
return;
}
quests.reloadQuests();
plugin.reloadQuests();
((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorSaved"));
for (Quester q : quests.questers.values()) {
for (Quester q : plugin.getQuesters()) {
for (Quest quest : q.currentQuests.keySet()) {
q.checkQuest(quest);
}
@ -912,7 +918,7 @@ public class EventFactory implements ConversationAbandonedListener {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (Event e : quests.events) {
for (Event e : plugin.getEvents()) {
if (e.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
return new EventNamePrompt();
@ -987,7 +993,7 @@ public class EventFactory implements ConversationAbandonedListener {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (Event e : quests.events) {
for (Event e : plugin.getEvents()) {
if (e.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists"));
return new SetNamePrompt();
@ -1313,7 +1319,7 @@ public class EventFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE;
for (World w : quests.getServer().getWorlds()) {
for (World w : plugin.getServer().getWorlds()) {
effects += w.getName() + ", ";
}
effects = effects.substring(0, effects.length());
@ -1324,8 +1330,8 @@ public class EventFactory implements ConversationAbandonedListener {
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
if (quests.getServer().getWorld(input) != null) {
context.setSessionData(CK.E_WORLD_STORM, quests.getServer().getWorld(input).getName());
if (plugin.getServer().getWorld(input) != null) {
context.setSessionData(CK.E_WORLD_STORM, plugin.getServer().getWorld(input).getName());
} else {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorInvalidWorld"));
return new StormWorldPrompt();
@ -1414,7 +1420,7 @@ public class EventFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE;
for (World w : quests.getServer().getWorlds()) {
for (World w : plugin.getServer().getWorlds()) {
effects += w.getName() + ", ";
}
effects = effects.substring(0, effects.length());
@ -1425,8 +1431,8 @@ public class EventFactory implements ConversationAbandonedListener {
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
if (quests.getServer().getWorld(input) != null) {
context.setSessionData(CK.E_WORLD_THUNDER, quests.getServer().getWorld(input).getName());
if (plugin.getServer().getWorld(input) != null) {
context.setSessionData(CK.E_WORLD_THUNDER, plugin.getServer().getWorld(input).getName());
} else {
player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorInvalidWorld"));
return new ThunderWorldPrompt();

View File

@ -58,8 +58,7 @@ import net.citizensnpcs.api.CitizensAPI;
public class QuestFactory implements ConversationAbandonedListener {
public final Quests plugin;
Map<UUID, Quest> editSessions = new HashMap<UUID, Quest>();
private final Quests plugin;
public Map<UUID, Block> selectedBlockStarts = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedKillLocations = new HashMap<UUID, Block>();
public Map<UUID, Block> selectedReachLocations = new HashMap<UUID, Block>();
@ -86,6 +85,10 @@ public class QuestFactory implements ConversationAbandonedListener {
selectedReachLocations.remove(player.getUniqueId());
}
public ConversationFactory getConversationFactory() {
return convoCreator;
}
private class MenuPrompt extends FixedSetPrompt {
public MenuPrompt() {
@ -236,7 +239,7 @@ public class QuestFactory implements ConversationAbandonedListener {
} else if (input.equalsIgnoreCase("10")) {
return new PlannerPrompt(plugin, QuestFactory.this);
} else if (input.equalsIgnoreCase("11")) {
return new StagesPrompt(QuestFactory.this);
return new StagesPrompt(plugin, QuestFactory.this);
} else if (input.equalsIgnoreCase("12")) {
return new RewardsPrompt(plugin, QuestFactory.this);
} else if (input.equalsIgnoreCase("13")) {
@ -300,7 +303,7 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (Quest q : plugin.quests) {
for (Quest q : plugin.getQuests()) {
if (q.getName().equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorNameExists"));
return new QuestNamePrompt();
@ -402,7 +405,7 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (Quest q : plugin.quests) {
for (Quest q : plugin.getQuests()) {
if (q.getName().equalsIgnoreCase(input)) {
String s = null;
if (context.getSessionData(CK.ED_QUEST_EDIT) != null) {
@ -479,10 +482,10 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.DARK_GREEN + Lang.get("eventTitle") + "\n";
if (plugin.events.isEmpty()) {
if (plugin.getEvents().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
for (Event e : plugin.events) {
for (Event e : plugin.getEvents()) {
text += ChatColor.GREEN + "- " + e.getName() + "\n";
}
}
@ -494,7 +497,7 @@ public class QuestFactory implements ConversationAbandonedListener {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Event found = null;
for (Event e : plugin.events) {
for (Event e : plugin.getEvents()) {
if (e.getName().equalsIgnoreCase(input)) {
found = e;
break;
@ -528,7 +531,7 @@ public class QuestFactory implements ConversationAbandonedListener {
if (context.getSessionData("tempStack") != null) {
ItemStack stack = (ItemStack) context.getSessionData("tempStack");
boolean failed = false;
for (Quest quest : plugin.quests) {
for (Quest quest : plugin.getQuests()) {
if (quest.guiDisplay != null) {
if (ItemUtil.compareItems(stack, quest.guiDisplay, false) == 0) {
String error = Lang.get("questGUIError");
@ -669,8 +672,10 @@ public class QuestFactory implements ConversationAbandonedListener {
data.save(new File(plugin.getDataFolder(), "quests.yml"));
if (context.getSessionData(CK.Q_START_NPC) != null && context.getSessionData(CK.Q_GUIDISPLAY) != null) {
int i = (Integer) context.getSessionData(CK.Q_START_NPC);
if (!plugin.questNPCGUIs.contains(i)) {
plugin.questNPCGUIs.add(i);
if (!plugin.getQuestNpcGuis().contains(i)) {
LinkedList<Integer> temp = plugin.getQuestNpcGuis();
temp.add(i);
plugin.setQuestNpcGuis(temp);
}
plugin.updateData();
}
@ -1643,7 +1648,7 @@ public class QuestFactory implements ConversationAbandonedListener {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.GOLD + Lang.get("questDeleteTitle") + "\n";
for (Quest quest : plugin.quests) {
for (Quest quest : plugin.getQuests()) {
text += ChatColor.AQUA + quest.getName() + ChatColor.YELLOW + ",";
}
text = text.substring(0, text.length() - 1) + "\n";
@ -1655,9 +1660,9 @@ public class QuestFactory implements ConversationAbandonedListener {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
LinkedList<String> used = new LinkedList<String>();
Quest found = plugin.findQuest(input);
Quest found = plugin.getQuest(input);
if (found != null) {
for (Quest q : plugin.quests) {
for (Quest q : plugin.getQuests()) {
if (q.getRequirements().getNeededQuests().contains(q.getName()) || q.getRequirements().getBlockQuests().contains(q.getName())) {
used.add(q.getName());
}

View File

@ -2171,7 +2171,7 @@ public class Quester {
List<String> redoNames = data.getStringList("completedRedoableQuests");
List<Long> redoTimes = data.getLongList("completedQuestTimes");
for (String s : redoNames) {
for (Quest q : plugin.quests) {
for (Quest q : plugin.getQuests()) {
if (q.getName().equalsIgnoreCase(s)) {
completedTimes.put(q.getName(), redoTimes.get(redoNames.indexOf(s)));
break;
@ -2190,7 +2190,7 @@ public class Quester {
hasJournal = data.getBoolean("hasJournal");
if (data.isList("completed-Quests")) {
for (String s : data.getStringList("completed-Quests")) {
for (Quest q : plugin.quests) {
for (Quest q : plugin.getQuests()) {
if (q.getName().equalsIgnoreCase(s)) {
if (!completedQuests.contains(q.getName())) {
completedQuests.add(q.getName());
@ -2648,7 +2648,7 @@ public class Quester {
public void checkQuest(Quest quest) {
if (quest != null) {
boolean exists = false;
for (Quest q : plugin.quests) {
for (Quest q : plugin.getQuests()) {
if (q.getName().equalsIgnoreCase(quest.getName())) {
Stage stage = getCurrentStage(quest);
quest.updateCompass(this, stage);
@ -2879,4 +2879,17 @@ public class Quester {
break;
}
}
public boolean hasItem(ItemStack is) {
Inventory inv = getPlayer().getInventory();
int playerAmount = 0;
for (ItemStack stack : inv.getContents()) {
if (stack != null) {
if (ItemUtil.compareItems(is, stack, false) == 0) {
playerAmount += stack.getAmount();
}
}
}
return playerAmount >= is.getAmount();
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -135,7 +135,7 @@ public class NpcListener implements Listener {
// TODO translate enchantment names
for (Entry<Enchantment, Integer> e : esmeta.getStoredEnchants().entrySet()) {
player.sendMessage(ChatColor.GRAY + "\u2515 " + ChatColor.DARK_GREEN
+ Quester.prettyEnchantmentString(e.getKey()) + " " + RomanNumeral.toRoman(e.getValue()) + "\n");
+ Quester.prettyEnchantmentString(e.getKey()) + " " + RomanNumeral.getNumeral(e.getValue()) + "\n");
}
}
}
@ -146,7 +146,7 @@ public class NpcListener implements Listener {
}
}
}
if (plugin.questNPCs.contains(evt.getNPC()) && delivery == false) {
if (plugin.getQuestNpcs().contains(evt.getNPC()) && delivery == false) {
boolean hasObjective = false;
for (Quest quest : quester.getCurrentQuests().keySet()) {
if (quester.containsObjective(quest, "talkToNPC")) {
@ -172,11 +172,11 @@ public class NpcListener implements Listener {
}
}
if (npcQuests.isEmpty() == false && npcQuests.size() >= 1) {
if (plugin.questNPCGUIs.contains(evt.getNPC().getId())) {
if (plugin.getQuestNpcGuis().contains(evt.getNPC().getId())) {
quester.showGUIDisplay(evt.getNPC(), npcQuests);
return;
}
Conversation c = plugin.NPCConversationFactory.buildConversation(player);
Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
c.getContext().setSessionData("quests", npcQuests);
c.getContext().setSessionData("npc", evt.getNPC().getName());
c.begin();
@ -189,7 +189,7 @@ public class NpcListener implements Listener {
for (String msg : s.split("<br>")) {
player.sendMessage(msg);
}
plugin.conversationFactory.buildConversation(player).begin();
plugin.getNpcConversationFactory().buildConversation(player).begin();
} else if (quester.getCurrentQuests().containsKey(q) == false) {
String msg = Lang.get(player, "questMaxAllowed");
msg = msg.replaceAll("<number>", String.valueOf(plugin.maxQuests));
@ -211,7 +211,7 @@ public class NpcListener implements Listener {
for (String msg : s.split("<br>")) {
player.sendMessage(msg);
}
plugin.conversationFactory.buildConversation(player).begin();
plugin.getConversationFactory().buildConversation(player).begin();
}
} else if (quester.getCurrentQuests().containsKey(q) == false) {
String msg = Lang.get(player, "questMaxAllowed");

View File

@ -14,6 +14,7 @@ package me.blackvein.quests.listeners;
import java.io.File;
import java.util.Iterator;
import java.util.LinkedList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -110,7 +111,7 @@ public class PlayerListener implements Listener {
if (evt.getInventory().getTitle().contains(Lang.get(player, "quests"))) {
ItemStack clicked = evt.getCurrentItem();
if (clicked != null) {
for (Quest quest : plugin.quests) {
for (Quest quest : plugin.getQuests()) {
if (quest.getGUIDisplay() != null) {
if (ItemUtil.compareItems(clicked, quest.getGUIDisplay(), false) == 0) {
if (quester.getCurrentQuests().size() >= plugin.maxQuests && plugin.maxQuests > 0) {
@ -255,7 +256,7 @@ public class PlayerListener implements Listener {
plugin.questFactory.selectedReachLocations.put(evt.getPlayer().getUniqueId(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get(player, "questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + ItemUtil.getName(new ItemStack(block.getType())) + ChatColor.GOLD + ")");
} else if (player.isConversing() == false) {
for (final Quest q : plugin.quests) {
for (final Quest q : plugin.getQuests()) {
if (q.getBlockStart() != null) {
if (q.getBlockStart().equals(evt.getClickedBlock().getLocation())) {
if (quester.getCurrentQuests().size() >= plugin.maxQuests && plugin.maxQuests > 0) {
@ -282,7 +283,7 @@ public class PlayerListener implements Listener {
for (String msg : s.split("<br>")) {
player.sendMessage(msg);
}
plugin.conversationFactory.buildConversation(player).begin();
plugin.getConversationFactory().buildConversation(player).begin();
}
break;
}
@ -667,7 +668,9 @@ public class PlayerListener implements Listener {
} else if (plugin.genFilesOnJoin) {
quester.saveData();
}
plugin.questers.put(evt.getPlayer().getUniqueId(), quester);
LinkedList<Quester> temp = plugin.getQuesters();
temp.add(quester);
plugin.setQuesters(temp);
if (plugin.useCompass) {
quester.resetCompass();
}
@ -723,7 +726,13 @@ public class PlayerListener implements Listener {
if (plugin.questFactory.selectingNPCs.contains(evt.getPlayer())) {
plugin.questFactory.selectingNPCs.remove(evt.getPlayer());
}
plugin.questers.remove(quester.getUUID());
LinkedList<Quester> temp = plugin.getQuesters();
for (Quester q : temp) {
if (q.getUUID().equals(quester.getUUID())) {
temp.remove(q);
}
}
plugin.setQuesters(temp);
}
}

View File

@ -47,14 +47,16 @@ import net.citizensnpcs.api.CitizensPlugin;
public class CreateStagePrompt extends FixedSetPrompt {
private final Quests plugin;
private final int stageNum;
private final String pref;
private final CitizensPlugin citizens;
private final QuestFactory questFactory;
private boolean hasObjective = false;
public CreateStagePrompt(int stageNum, QuestFactory qf, CitizensPlugin cit) {
public CreateStagePrompt(Quests plugin, int stageNum, QuestFactory qf, CitizensPlugin cit) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26");
this.plugin = plugin;
this.stageNum = stageNum;
this.pref = "stage" + stageNum;
this.citizens = cit;
@ -364,21 +366,21 @@ public class CreateStagePrompt extends FixedSetPrompt {
return new DeliveryListPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} else if (input.equalsIgnoreCase("10")) {
if (Quests.citizens != null) {
return new NPCIDsToTalkToPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} else if (input.equalsIgnoreCase("11")) {
if (Quests.citizens != null) {
return new NPCKillListPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoCitizens"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} else if (input.equalsIgnoreCase("12")) {
return new MobListPrompt();
@ -393,26 +395,26 @@ public class CreateStagePrompt extends FixedSetPrompt {
return new EventListPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} else if (input.equalsIgnoreCase("17")) {
if (hasObjective) {
return new DelayPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} else if (input.equalsIgnoreCase("18")) {
if (context.getSessionData(pref + CK.S_DELAY) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDelaySet"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
return new DelayMessagePrompt();
}
} else if (input.equalsIgnoreCase("19")) {
if (Quests.denizen == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDenizen"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
return new DenizenPrompt();
}
@ -425,28 +427,28 @@ public class CreateStagePrompt extends FixedSetPrompt {
return new StartMessagePrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} else if (input.equalsIgnoreCase("23")) {
if (hasObjective) {
return new CompleteMessagePrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} else if (input.equalsIgnoreCase("24")) {
if (hasObjective) {
return new OverrideDisplayPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidOption"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} else if (input.equalsIgnoreCase("25")) {
return new DeletePrompt();
} else if (input.equalsIgnoreCase("26")) {
return new StagesPrompt(questFactory);
return new StagesPrompt(plugin, questFactory);
} else {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
@ -521,7 +523,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
two = 0;
}
if (one == two) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorPasswordNotSameSize"));
return new PasswordListPrompt();
@ -616,7 +618,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
context.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveOverrideCleared"));
}
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
@ -714,7 +716,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_BREAK_DURABILITY, elements);
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize"));
return new BreakBlockListPrompt();
@ -931,7 +933,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_DAMAGE_DURABILITY, elements);
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize"));
return new DamageBlockListPrompt();
@ -1148,7 +1150,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_PLACE_DURABILITY, elements);
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize"));
return new PlaceBlockListPrompt();
@ -1365,7 +1367,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_USE_DURABILITY, elements);
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize"));
return new UseBlockListPrompt();
@ -1582,7 +1584,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
elements.add((short) 0);
}
context.setSessionData(pref + CK.S_CUT_DURABILITY, elements);
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorListNotSameSize"));
return new CutBlockListPrompt();
@ -1731,7 +1733,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_FISH, null);
}
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
@ -1761,7 +1763,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_PLAYER_KILL, null);
}
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
@ -1852,7 +1854,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
three = 0;
}
if (one == two && two == three) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorEnchantmentNotSameSize"));
return new EnchantmentListPrompt();
@ -2092,7 +2094,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNoDeliveryMessage"));
return new DeliveryListPrompt();
} else {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorDeliveriesNotSameSize"));
@ -2204,7 +2206,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null);
}
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
@ -2272,7 +2274,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
two = 0;
}
if (one == two) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorNPCKillsNotSameSize"));
return new NPCKillListPrompt();
@ -2497,13 +2499,13 @@ public class CreateStagePrompt extends FixedSetPrompt {
if (one == two) {
if (three != 0 || four != 0 || five != 0) {
if (two == three && three == four && four == five) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorAllListsNotSameSize"));
return new MobListPrompt();
}
} else {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorMobTypesNotSameSize"));
@ -2788,7 +2790,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
three = 0;
}
if (one == two && two == three) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("allListsNotSameSize"));
return new ReachListPrompt();
@ -2965,7 +2967,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
two = 0;
}
if (one == two) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorTameMobsNotSameSize"));
return new TameListPrompt();
@ -3122,7 +3124,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
two = 0;
}
if (one == two) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorShearNotSameSize"));
return new ShearListPrompt();
@ -3277,7 +3279,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase("6")) {
return new CommandEventPrompt();
} else if (input.equalsIgnoreCase("7")) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
return new EventListPrompt();
}
@ -3289,10 +3291,10 @@ public class CreateStagePrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.DARK_GREEN + "- " + Lang.get("stageEditorStartEvent") + " -\n";
if (questFactory.plugin.events.isEmpty()) {
if (plugin.getEvents().isEmpty()) {
text += ChatColor.RED + "- None";
} else {
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
text += ChatColor.GREEN + "- " + e.getName() + "\n";
}
}
@ -3304,7 +3306,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Event found = null;
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
if (e.getName().equalsIgnoreCase(input)) {
found = e;
break;
@ -3334,10 +3336,10 @@ public class CreateStagePrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.DARK_GREEN + "- " + Lang.get("stageEditorFinishEvent") + " -\n";
if (questFactory.plugin.events.isEmpty()) {
if (plugin.getEvents().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
text += ChatColor.GREEN + "- " + e.getName() + "\n";
}
}
@ -3349,7 +3351,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Event found = null;
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
if (e.getName().equalsIgnoreCase(input)) {
found = e;
break;
@ -3379,10 +3381,10 @@ public class CreateStagePrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.DARK_GREEN + "- " + Lang.get("stageEditorDeathEvent") + " -\n";
if (questFactory.plugin.events.isEmpty()) {
if (plugin.getEvents().isEmpty()) {
text += ChatColor.RED + "- None";
} else {
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
text += ChatColor.GREEN + "- " + e.getName() + "\n";
}
}
@ -3394,7 +3396,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Event found = null;
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
if (e.getName().equalsIgnoreCase(input)) {
found = e;
break;
@ -3424,10 +3426,10 @@ public class CreateStagePrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.DARK_GREEN + "- " + Lang.get("stageEditorDisconnectEvent") + " -\n";
if (questFactory.plugin.events.isEmpty()) {
if (plugin.getEvents().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
text += ChatColor.GREEN + "- " + e.getName() + "\n";
}
}
@ -3439,7 +3441,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Event found = null;
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
if (e.getName().equalsIgnoreCase(input)) {
found = e;
break;
@ -3469,10 +3471,10 @@ public class CreateStagePrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.DARK_GREEN + "- " + Lang.get("stageEditorChatEvents") + " -\n";
if (questFactory.plugin.events.isEmpty()) {
if (plugin.getEvents().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
text += ChatColor.GREEN + "- " + e.getName() + "\n";
}
}
@ -3484,7 +3486,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Event found = null;
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
if (e.getName().equalsIgnoreCase(input)) {
found = e;
break;
@ -3556,10 +3558,10 @@ public class CreateStagePrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.DARK_GREEN + "- " + Lang.get("stageEditorCommandEvents") + " -\n";
if (questFactory.plugin.events.isEmpty()) {
if (plugin.getEvents().isEmpty()) {
text += ChatColor.RED + "- " + Lang.get("none");
} else {
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
text += ChatColor.GREEN + "- " + e.getName() + "\n";
}
}
@ -3571,7 +3573,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Event found = null;
for (Event e : questFactory.plugin.events) {
for (Event e : plugin.getEvents()) {
if (e.getName().equalsIgnoreCase(input)) {
found = e;
break;
@ -3649,12 +3651,12 @@ public class CreateStagePrompt extends FixedSetPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_DELAY, null);
player.sendMessage(ChatColor.GREEN + Lang.get("stageEditorDelayCleared"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
long stageDelay;
try {
@ -3669,7 +3671,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
return new DelayPrompt();
} else {
context.setSessionData(pref + CK.S_DELAY, stageDelay);
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
}
@ -3686,11 +3688,11 @@ public class CreateStagePrompt extends FixedSetPrompt {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
context.setSessionData(pref + CK.S_DELAY_MESSAGE, input);
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_DELAY_MESSAGE, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDelayMessageCleared"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
return new DelayMessagePrompt();
}
@ -3714,7 +3716,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
if (ScriptRegistry.containsScript(input)) {
context.setSessionData(pref + CK.S_DENIZEN, ScriptRegistry.getScriptContainer(input).getName());
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
player.sendMessage(ChatColor.RED + Lang.get("stageEditorInvalidScript"));
return new DenizenPrompt();
@ -3722,9 +3724,9 @@ public class CreateStagePrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_DENIZEN, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDenizenCleared"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
}
@ -3744,9 +3746,9 @@ public class CreateStagePrompt extends FixedSetPrompt {
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("Yes")) {
StagesPrompt.deleteStage(context, stageNum);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorDeleteSucces"));
return new StagesPrompt(questFactory);
return new StagesPrompt(plugin, questFactory);
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("No")) {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
player.sendMessage(ChatColor.RED + Lang.get("invalidOption"));
return new DeletePrompt();
@ -3766,13 +3768,13 @@ public class CreateStagePrompt extends FixedSetPrompt {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
context.setSessionData(pref + CK.S_START_MESSAGE, input);
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_START_MESSAGE, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorStartMessageCleared"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
}
@ -3789,13 +3791,13 @@ public class CreateStagePrompt extends FixedSetPrompt {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, input);
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null);
player.sendMessage(ChatColor.YELLOW + Lang.get("stageEditorCompleteMessageCleared"));
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
} else {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
}
@ -3805,10 +3807,10 @@ public class CreateStagePrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.LIGHT_PURPLE + "- " + Lang.get("stageEditorCustom") + " -\n";
if (questFactory.plugin.customObjectives.isEmpty()) {
if (plugin.customObjectives.isEmpty()) {
text += ChatColor.BOLD + "" + ChatColor.DARK_PURPLE + "(" + Lang.get("stageEditorNoModules") + ") ";
} else {
for (CustomObjective co : questFactory.plugin.customObjectives) {
for (CustomObjective co : plugin.customObjectives) {
text += ChatColor.DARK_PURPLE + " - " + co.getName() + "\n";
}
}
@ -3820,14 +3822,14 @@ public class CreateStagePrompt extends FixedSetPrompt {
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
CustomObjective found = null;
for (CustomObjective co : questFactory.plugin.customObjectives) {
for (CustomObjective co : plugin.customObjectives) {
if (co.getName().equalsIgnoreCase(input)) {
found = co;
break;
}
}
if (found == null) {
for (CustomObjective co : questFactory.plugin.customObjectives) {
for (CustomObjective co : plugin.customObjectives) {
if (co.getName().toLowerCase().contains(input.toLowerCase())) {
found = co;
break;
@ -3879,7 +3881,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorCustomCleared"));
}
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
@ -3893,7 +3895,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
String objName = list.getLast();
text += objName + " -\n";
CustomObjective found = null;
for (CustomObjective co : questFactory.plugin.customObjectives) {
for (CustomObjective co : plugin.customObjectives) {
if (co.getName().equals(objName)) {
found = co;
break;
@ -3915,7 +3917,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
LinkedList<String> list = (LinkedList<String>) context.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES);
String objName = list.getLast();
CustomObjective found = null;
for (CustomObjective co : questFactory.plugin.customObjectives) {
for (CustomObjective co : plugin.customObjectives) {
if (co.getName().equals(objName)) {
found = co;
break;
@ -3925,7 +3927,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, found.descriptions);
return new ObjectiveCustomDataListPrompt();
} else {
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
} catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("stageEditorInvalidNumber"));
@ -3992,7 +3994,7 @@ public class CreateStagePrompt extends FixedSetPrompt {
return new ObjectiveCustomDataListPrompt();
} else {
context.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null);
return new CreateStagePrompt(stageNum, questFactory, citizens);
return new CreateStagePrompt(plugin, stageNum, questFactory, citizens);
}
}
}

View File

@ -37,6 +37,7 @@ import me.blackvein.quests.Quests;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
import me.blackvein.quests.util.RomanNumeral;
public class ItemStackPrompt extends FixedSetPrompt {
@ -509,7 +510,7 @@ public class ItemStackPrompt extends FixedSetPrompt {
@SuppressWarnings("unchecked")
Map<Enchantment, Integer> enchantments = (Map<Enchantment, Integer>) cc.getSessionData("tempEnchantments");
for (Entry<Enchantment, Integer> e : enchantments.entrySet()) {
item += ChatColor.GRAY + " - " + ChatColor.RED + Quester.prettyEnchantmentString(e.getKey()) + " " + Quests.getNumeral(e.getValue()) + "\n";
item += ChatColor.GRAY + " - " + ChatColor.RED + Quester.prettyEnchantmentString(e.getKey()) + " " + RomanNumeral.getNumeral(e.getValue()) + "\n";
}
}
if (cc.getSessionData("tempLore") != null) {

View File

@ -111,7 +111,7 @@ public class QuestAcceptPrompt extends StringPrompt {
if (!plugin.askConfirmation) {
plugin.getQuester(player.getUniqueId()).takeQuest(plugin.getQuest(plugin.getQuester(player.getUniqueId()).getQuestToTake()), false);
} else {
plugin.conversationFactory.buildConversation((Conversable) player).begin();
plugin.getConversationFactory().buildConversation((Conversable) player).begin();
}
} else {
player.sendMessage(q.getRequirements().getFailRequirements());
@ -141,7 +141,7 @@ public class QuestAcceptPrompt extends StringPrompt {
if (!plugin.askConfirmation) {
plugin.getQuester(player.getUniqueId()).takeQuest(plugin.getQuest(plugin.getQuester(player.getUniqueId()).getQuestToTake()), false);
} else {
plugin.conversationFactory.buildConversation((Conversable) player).begin();
plugin.getConversationFactory().buildConversation((Conversable) player).begin();
}
}
} else if (quester.getCurrentQuests().containsKey(q) == false) {

View File

@ -24,9 +24,11 @@ import me.blackvein.quests.util.Lang;
public class StagesPrompt extends StringPrompt {
private final Quests plugin;
private final QuestFactory questFactory;
public StagesPrompt(QuestFactory qf) {
public StagesPrompt(Quests plugin, QuestFactory qf) {
this.plugin = plugin;
questFactory = qf;
}
@ -50,19 +52,19 @@ public class StagesPrompt extends StringPrompt {
try {
i = Integer.parseInt(string);
} catch (NumberFormatException e) {
return new StagesPrompt(questFactory);
return new StagesPrompt(plugin, questFactory);
}
int stages = getStages(cc);
if (i < 0) {
return new StagesPrompt(questFactory);
return new StagesPrompt(plugin, questFactory);
} else if (i < (stages + 1) && i > 0) {
return new CreateStagePrompt((i), questFactory, Quests.citizens);
return new CreateStagePrompt(plugin, (i), questFactory, Quests.citizens);
} else if (i == (stages + 1)) {
return new CreateStagePrompt((stages + 1), questFactory, Quests.citizens);
return new CreateStagePrompt(plugin, (stages + 1), questFactory, Quests.citizens);
} else if (i == (stages + 2)) {
return questFactory.returnToMenu();
} else {
return new StagesPrompt(questFactory);
return new StagesPrompt(plugin, questFactory);
}
}

View File

@ -36,12 +36,12 @@ public class RomanNumeral {
}
public final static String toRoman(int number) {
public final static String getNumeral(int number) {
int l = map.floorKey(number);
if ( number == l ) {
return map.get(number);
}
return map.get(l) + toRoman(number-l);
return map.get(l) + getNumeral(number-l);
}
}