Added mcMMO requirement support

Cleaned up some code
This commit is contained in:
Blackvein 2013-10-24 14:59:44 -07:00
parent 2f73f6f6cc
commit 3b654100f1
16 changed files with 1027 additions and 808 deletions

View File

@ -1,6 +1,7 @@
package me.blackvein.quests; package me.blackvein.quests;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -12,6 +13,7 @@ import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -307,7 +309,9 @@ public class Event {
FileConfiguration data = new YamlConfiguration(); FileConfiguration data = new YamlConfiguration();
try { try {
data.load(new File(plugin.getDataFolder(), "events.yml")); data.load(new File(plugin.getDataFolder(), "events.yml"));
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -1,6 +1,7 @@
package me.blackvein.quests; package me.blackvein.quests;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
@ -22,6 +23,7 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.conversations.ConversationAbandonedEvent; import org.bukkit.conversations.ConversationAbandonedEvent;
import org.bukkit.conversations.ConversationAbandonedListener; import org.bukkit.conversations.ConversationAbandonedListener;
@ -898,7 +900,11 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
try{ try{
eventsFile = new File(quests.getDataFolder(), "events.yml"); eventsFile = new File(quests.getDataFolder(), "events.yml");
data.load(eventsFile); data.load(eventsFile);
}catch(Exception e){ }catch(IOException e){
e.printStackTrace();
((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile"));
return;
} catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile")); ((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile"));
return; return;
@ -910,7 +916,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
try{ try{
data.save(eventsFile); data.save(eventsFile);
}catch (Exception e){ }catch (IOException e){
((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving")); ((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving"));
return; return;
} }
@ -934,7 +940,11 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
try{ try{
eventsFile = new File(quests.getDataFolder(), "events.yml"); eventsFile = new File(quests.getDataFolder(), "events.yml");
data.load(eventsFile); data.load(eventsFile);
}catch(Exception e){ }catch(IOException e){
e.printStackTrace();
((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile"));
return;
} catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile")); ((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile"));
return; return;
@ -1098,7 +1108,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
try{ try{
data.save(eventsFile); data.save(eventsFile);
}catch (Exception e){ }catch (IOException e){
((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving")); ((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving"));
return; return;
} }
@ -1922,10 +1932,10 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
} }
} else { } else {
LinkedList<String> types = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES); LinkedList<String> types = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES);
int inp = -1; int inp;
try { try {
inp = Integer.parseInt(input); inp = Integer.parseInt(input);
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorNotANumber")); context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorNotANumber"));
return new MobPrompt(); return new MobPrompt();
} }
@ -1953,7 +1963,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
private QuestMob questMob; private QuestMob questMob;
private Integer itemIndex = -1; private Integer itemIndex = -1;
private Integer mobIndex; private final Integer mobIndex;
public QuestMobPrompt(int mobIndex, QuestMob questMob) { public QuestMobPrompt(int mobIndex, QuestMob questMob) {
this.questMob = questMob; this.questMob = questMob;
@ -2081,8 +2091,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
private class MobNamePrompt extends StringPrompt { private class MobNamePrompt extends StringPrompt {
private QuestMob questMob; private final QuestMob questMob;
private Integer mobIndex; private final Integer mobIndex;
public MobNamePrompt (int mobIndex, QuestMob questMob) { public MobNamePrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob; this.questMob = questMob;
@ -2113,8 +2123,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
private class MobTypePrompt extends StringPrompt { private class MobTypePrompt extends StringPrompt {
private QuestMob questMob; private final QuestMob questMob;
private Integer mobIndex; private final Integer mobIndex;
public MobTypePrompt (int mobIndex, QuestMob questMob) { public MobTypePrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob; this.questMob = questMob;
@ -2178,8 +2188,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
private class MobAmountPrompt extends StringPrompt { private class MobAmountPrompt extends StringPrompt {
private QuestMob questMob; private final QuestMob questMob;
private Integer mobIndex; private final Integer mobIndex;
public MobAmountPrompt (int mobIndex, QuestMob questMob) { public MobAmountPrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob; this.questMob = questMob;
@ -2211,7 +2221,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
questMob.setSpawnAmounts(i); questMob.setSpawnAmounts(i);
return new QuestMobPrompt(mobIndex, questMob); return new QuestMobPrompt(mobIndex, questMob);
} catch (Exception e) { } catch (NumberFormatException e) {
player.sendMessage(PINK + input + " " + RED + Lang.get("eventEditorNotANumber")); player.sendMessage(PINK + input + " " + RED + Lang.get("eventEditorNotANumber"));
return new MobAmountPrompt(mobIndex, questMob); return new MobAmountPrompt(mobIndex, questMob);
} }
@ -2225,8 +2235,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
private class MobLocationPrompt extends StringPrompt { private class MobLocationPrompt extends StringPrompt {
private QuestMob questMob; private final QuestMob questMob;
private Integer mobIndex; private final Integer mobIndex;
public MobLocationPrompt (int mobIndex, QuestMob questMob) { public MobLocationPrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob; this.questMob = questMob;
@ -2276,9 +2286,9 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
private class MobDropPrompt extends StringPrompt { private class MobDropPrompt extends StringPrompt {
private QuestMob questMob; private final QuestMob questMob;
private Integer mobIndex; private final Integer mobIndex;
private Integer invIndex; private final Integer invIndex;
public MobDropPrompt (int invIndex, int mobIndex ,QuestMob questMob) { public MobDropPrompt (int invIndex, int mobIndex ,QuestMob questMob) {
this.questMob = questMob; this.questMob = questMob;
@ -2294,7 +2304,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
@Override @Override
public Prompt acceptInput(ConversationContext context, String input) { public Prompt acceptInput(ConversationContext context, String input) {
float chance = 0.0F;
float chance;
if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
return new QuestMobPrompt(mobIndex, questMob); return new QuestMobPrompt(mobIndex, questMob);
@ -2302,7 +2313,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
try { try {
chance = Float.parseFloat(input); chance = Float.parseFloat(input);
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorInvalidDropChance")); context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorInvalidDropChance"));
return new MobDropPrompt(invIndex, mobIndex, questMob); return new MobDropPrompt(invIndex, mobIndex, questMob);
} }
@ -2572,7 +2583,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
effDurations.add(l / 50L); effDurations.add(l / 50L);
} catch (Exception e) { } catch (NumberFormatException e) {
player.sendMessage(PINK + s + " " + RED + Lang.get("eventEditorNotANumber")); player.sendMessage(PINK + s + " " + RED + Lang.get("eventEditorNotANumber"));
return new PotionDurationsPrompt(); return new PotionDurationsPrompt();
} }
@ -2619,7 +2630,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
magAmounts.add(i); magAmounts.add(i);
} catch (Exception e) { } catch (NumberFormatException e) {
player.sendMessage(PINK + s + " " + RED + Lang.get("eventEditorNotANumber")); player.sendMessage(PINK + s + " " + RED + Lang.get("eventEditorNotANumber"));
return new PotionMagnitudesPrompt(); return new PotionMagnitudesPrompt();
} }

View File

@ -32,7 +32,7 @@ public class ItemData {
byte mdata = 0; byte mdata = 0;
try { try {
id = Integer.parseInt(str[0]); id = Integer.parseInt(str[0]);
} catch (Exception e) { } catch (NumberFormatException e) {
} }
if (str.length > 1) { if (str.length > 1) {
mdata = Byte.parseByte(str[1]); mdata = Byte.parseByte(str[1]);

View File

@ -44,7 +44,7 @@ public enum ParticleEffect {
ICONCRACK("iconcrack_"), ICONCRACK("iconcrack_"),
TILECRACK("tilecrack_"); TILECRACK("tilecrack_");
private String particleName; private final String particleName;
ParticleEffect(String particleName) { ParticleEffect(String particleName) {
this.particleName = particleName; this.particleName = particleName;

View File

@ -1,7 +1,6 @@
package me.blackvein.quests; package me.blackvein.quests;
import java.io.File; import java.io.File;
import java.util.UUID;
import me.ThaH3lper.com.Mobs.EpicMobs; import me.ThaH3lper.com.Mobs.EpicMobs;
import me.ThaH3lper.com.Mobs.MobCommon; import me.ThaH3lper.com.Mobs.MobCommon;
import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.CitizensAPI;

View File

@ -1,6 +1,7 @@
package me.blackvein.quests; package me.blackvein.quests;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -19,6 +20,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.conversations.*; import org.bukkit.conversations.*;
@ -788,7 +790,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
data.save(new File(quests.getDataFolder(), "quests.yml")); data.save(new File(quests.getDataFolder(), "quests.yml"));
context.getForWhom().sendRawMessage(BOLD + Lang.get("questEditorSaved")); context.getForWhom().sendRawMessage(BOLD + Lang.get("questEditorSaved"));
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -873,13 +877,15 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<String> permReqs = null; LinkedList<String> permReqs = null;
LinkedList<String> questReqs = null; LinkedList<String> questReqs = null;
LinkedList<String> questBlocks = null; LinkedList<String> questBlocks = null;
LinkedList<String> mcMMOSkillReqs = null;
LinkedList<Integer> mcMMOAmountReqs = null;
String failMessage = null; String failMessage = null;
Integer moneyRew = null; Integer moneyRew = null;
Integer questPointsRew = null; Integer questPointsRew = null;
LinkedList<String> itemRews = new LinkedList<String>(); LinkedList<String> itemRews = null;
LinkedList<Integer> RPGItemRews = new LinkedList<Integer>(); LinkedList<Integer> RPGItemRews = null;
LinkedList<Integer> RPGItemAmounts = new LinkedList<Integer>(); LinkedList<Integer> RPGItemAmounts = null;
Integer expRew = null; Integer expRew = null;
LinkedList<String> commandRews = null; LinkedList<String> commandRews = null;
LinkedList<String> permRews = null; LinkedList<String> permRews = null;
@ -926,6 +932,11 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (cc.getSessionData(CK.REQ_QUEST_BLOCK) != null) { if (cc.getSessionData(CK.REQ_QUEST_BLOCK) != null) {
questBlocks = (LinkedList<String>) cc.getSessionData(CK.REQ_QUEST_BLOCK); questBlocks = (LinkedList<String>) cc.getSessionData(CK.REQ_QUEST_BLOCK);
} }
if (cc.getSessionData(CK.REQ_MCMMO_SKILLS) != null) {
mcMMOSkillReqs = (LinkedList<String>) cc.getSessionData(CK.REQ_MCMMO_SKILLS);
mcMMOAmountReqs = (LinkedList<Integer>) cc.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS);
}
if (cc.getSessionData(CK.Q_FAIL_MESSAGE) != null) { if (cc.getSessionData(CK.Q_FAIL_MESSAGE) != null) {
failMessage = (String) cc.getSessionData(CK.Q_FAIL_MESSAGE); failMessage = (String) cc.getSessionData(CK.Q_FAIL_MESSAGE);
@ -944,6 +955,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
} }
if (cc.getSessionData(CK.REW_ITEMS) != null) { if (cc.getSessionData(CK.REW_ITEMS) != null) {
itemRews = new LinkedList<String>();
for (ItemStack is : (LinkedList<ItemStack>) cc.getSessionData(CK.REW_ITEMS)) { for (ItemStack is : (LinkedList<ItemStack>) cc.getSessionData(CK.REW_ITEMS)) {
itemRews.add(ItemUtil.serialize(is)); itemRews.add(ItemUtil.serialize(is));
} }
@ -988,7 +1000,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cs.set(CK.S_FINISH_EVENT, initialEvent); cs.set(CK.S_FINISH_EVENT, initialEvent);
if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || (questReqs != null && questReqs.isEmpty() == false) || (questBlocks != null && questBlocks.isEmpty() == false)) { if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || (questReqs != null && questReqs.isEmpty() == false) || (questBlocks != null && questBlocks.isEmpty() == false) ||(mcMMOSkillReqs != null && mcMMOSkillReqs.isEmpty() == false)) {
ConfigurationSection reqs = cs.createSection("requirements"); ConfigurationSection reqs = cs.createSection("requirements");
List<String> items = new LinkedList<String>(); List<String> items = new LinkedList<String>();
@ -1006,7 +1018,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
reqs.set("quest-points", questPointsReq); reqs.set("quest-points", questPointsReq);
reqs.set("permissions", permReqs); reqs.set("permissions", permReqs);
reqs.set("quests", questReqs); reqs.set("quests", questReqs);
reqs.set("quests-blocks", questBlocks); reqs.set("quest-blocks", questBlocks);
reqs.set("mcmmo-skills", mcMMOSkillReqs);
reqs.set("mcmmo-amounts", mcMMOAmountReqs);
reqs.set("fail-requirement-message", failMessage); reqs.set("fail-requirement-message", failMessage);
} else { } else {
@ -1404,11 +1418,21 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (q.blockQuests.isEmpty() == false) { if (q.blockQuests.isEmpty() == false) {
cc.setSessionData(CK.REQ_QUEST_BLOCK, q.blockQuests); cc.setSessionData(CK.REQ_QUEST_BLOCK, q.blockQuests);
} }
if(q.mcMMOSkillReqs.isEmpty() == false){
cc.setSessionData(CK.REQ_MCMMO_SKILLS, q.mcMMOSkillReqs);
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, q.mcMMOAmountReqs);
}
if (q.permissionReqs.isEmpty() == false) { if (q.permissionReqs.isEmpty() == false) {
cc.setSessionData(CK.REQ_PERMISSION, q.permissionReqs); cc.setSessionData(CK.REQ_PERMISSION, q.permissionReqs);
} }
if(q.mcMMOSkillReqs.isEmpty() == false) {
cc.setSessionData(CK.REQ_MCMMO_SKILLS, q.mcMMOSkillReqs);
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, q.mcMMOAmountReqs);
}
if (q.failRequirements != null) { if (q.failRequirements != null) {
cc.setSessionData(CK.Q_FAIL_MESSAGE, q.failRequirements); cc.setSessionData(CK.Q_FAIL_MESSAGE, q.failRequirements);
} }
@ -1852,7 +1876,11 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
try { try {
data.load(questsFile); data.load(questsFile);
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace();
((Player) context.getForWhom()).sendMessage(ChatColor.RED + "Error reading Quests file.");
return;
} catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
((Player) context.getForWhom()).sendMessage(ChatColor.RED + "Error reading Quests file."); ((Player) context.getForWhom()).sendMessage(ChatColor.RED + "Error reading Quests file.");
return; return;
@ -1872,7 +1900,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
try { try {
data.save(questsFile); data.save(questsFile);
} catch (Exception e) { } catch (IOException e) {
((Player) context.getForWhom()).sendMessage(ChatColor.RED + "An error occurred while saving."); ((Player) context.getForWhom()).sendMessage(ChatColor.RED + "An error occurred while saving.");
return; return;
} }

View File

@ -1,6 +1,7 @@
package me.blackvein.quests; package me.blackvein.quests;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.logging.Level; import java.util.logging.Level;
@ -10,6 +11,7 @@ import org.bukkit.ChatColor;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -519,140 +521,55 @@ public class Quester {
} }
if (s.equalsIgnoreCase("damageBlock")) { if (s.equalsIgnoreCase("damageBlock")) {
return !currentStage.blocksToDamage.isEmpty();
if (currentStage.blocksToDamage.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("breakBlock")) { } else if (s.equalsIgnoreCase("breakBlock")) {
return !currentStage.blocksToBreak.isEmpty();
if (currentStage.blocksToBreak.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("placeBlock")) { } else if (s.equalsIgnoreCase("placeBlock")) {
return !currentStage.blocksToPlace.isEmpty();
if (currentStage.blocksToPlace.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("useBlock")) { } else if (s.equalsIgnoreCase("useBlock")) {
return !currentStage.blocksToUse.isEmpty();
if (currentStage.blocksToUse.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("cutBlock")) { } else if (s.equalsIgnoreCase("cutBlock")) {
return !currentStage.blocksToCut.isEmpty();
if (currentStage.blocksToCut.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("catchFish")) { } else if (s.equalsIgnoreCase("catchFish")) {
return currentStage.fishToCatch != null;
if (currentStage.fishToCatch == null) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("enchantItem")) { } else if (s.equalsIgnoreCase("enchantItem")) {
return !currentStage.itemsToEnchant.isEmpty();
if (currentStage.itemsToEnchant.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("killMob")) { } else if (s.equalsIgnoreCase("killMob")) {
return !currentStage.mobsToKill.isEmpty();
if (currentStage.mobsToKill.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("deliverItem")) { } else if (s.equalsIgnoreCase("deliverItem")) {
return !currentStage.itemsToDeliver.isEmpty();
if (currentStage.itemsToDeliver.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("killPlayer")) { } else if (s.equalsIgnoreCase("killPlayer")) {
return currentStage.playersToKill != null;
if (currentStage.playersToKill == null) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("talkToNPC")) { } else if (s.equalsIgnoreCase("talkToNPC")) {
return !currentStage.citizensToInteract.isEmpty();
if (currentStage.citizensToInteract.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("killNPC")) { } else if (s.equalsIgnoreCase("killNPC")) {
return !currentStage.citizensToKill.isEmpty();
if (currentStage.citizensToKill.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("killBoss")) { } else if (s.equalsIgnoreCase("killBoss")) {
return !currentStage.bossesToKill.isEmpty();
if (currentStage.bossesToKill.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("tameMob")) { } else if (s.equalsIgnoreCase("tameMob")) {
return !currentStage.mobsToTame.isEmpty();
if (currentStage.mobsToTame.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("shearSheep")) { } else if (s.equalsIgnoreCase("shearSheep")) {
return !currentStage.sheepToShear.isEmpty();
if (currentStage.sheepToShear.isEmpty()) {
return false;
} else {
return true;
}
} else if (s.equalsIgnoreCase("craftItem")) { } else if (s.equalsIgnoreCase("craftItem")) {
return !currentStage.itemsToCraft.isEmpty();
if (currentStage.itemsToCraft.isEmpty()) {
return false;
} else {
return true;
}
} else { } else {
return !currentStage.locationsToReach.isEmpty();
if (currentStage.locationsToReach.isEmpty()) {
return false;
} else {
return true;
}
} }
@ -1643,7 +1560,7 @@ public class Quester {
FileConfiguration data = getBaseData(); FileConfiguration data = getBaseData();
try { try {
data.save(new File(plugin.getDataFolder(), "data/" + name + ".yml")); data.save(new File(plugin.getDataFolder(), "data/" + name + ".yml"));
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -2029,7 +1946,9 @@ public class Quester {
FileConfiguration data = new YamlConfiguration(); FileConfiguration data = new YamlConfiguration();
try { try {
data.load(new File(plugin.getDataFolder(), "data/" + name + ".yml")); data.load(new File(plugin.getDataFolder(), "data/" + name + ".yml"));
} catch (Exception e) { } catch (IOException e) {
return false;
} catch (InvalidConfigurationException e) {
return false; return false;
} }
@ -2651,10 +2570,7 @@ public class Quester {
if(questPoints > 1) if(questPoints > 1)
return true; return true;
if(completedQuests.isEmpty() == false) return completedQuests.isEmpty() == false;
return true;
return false;
} }

File diff suppressed because it is too large Load Diff

View File

@ -577,7 +577,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new BreakBlockIdsPrompt(); return new BreakBlockIdsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(RED + Lang.get("stageEditorNotListofNumbers") + "\n" + PINK + s); context.getForWhom().sendRawMessage(RED + Lang.get("stageEditorNotListofNumbers") + "\n" + PINK + s);
return new BreakBlockIdsPrompt(); return new BreakBlockIdsPrompt();
} }
@ -618,7 +618,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new BreakBlockAmountsPrompt(); return new BreakBlockAmountsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new BreakBlockAmountsPrompt(); return new BreakBlockAmountsPrompt();
} }
@ -768,7 +768,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new DamageBlockIdsPrompt(); return new DamageBlockIdsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new DamageBlockIdsPrompt(); return new DamageBlockIdsPrompt();
} }
@ -809,7 +809,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new DamageBlockAmountsPrompt(); return new DamageBlockAmountsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new DamageBlockAmountsPrompt(); return new DamageBlockAmountsPrompt();
} }
@ -959,7 +959,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new PlaceBlockIdsPrompt(); return new PlaceBlockIdsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new PlaceBlockIdsPrompt(); return new PlaceBlockIdsPrompt();
} }
@ -1000,7 +1000,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new PlaceBlockAmountsPrompt(); return new PlaceBlockAmountsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new PlaceBlockAmountsPrompt(); return new PlaceBlockAmountsPrompt();
} }
@ -1150,7 +1150,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new UseBlockIdsPrompt(); return new UseBlockIdsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new UseBlockIdsPrompt(); return new UseBlockIdsPrompt();
} }
@ -1191,7 +1191,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new UseBlockAmountsPrompt(); return new UseBlockAmountsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new UseBlockAmountsPrompt(); return new UseBlockAmountsPrompt();
} }
@ -1341,7 +1341,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new CutBlockIdsPrompt(); return new CutBlockIdsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new CutBlockIdsPrompt(); return new CutBlockIdsPrompt();
} }
@ -1382,7 +1382,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new CutBlockAmountsPrompt(); return new CutBlockAmountsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new CutBlockAmountsPrompt(); return new CutBlockAmountsPrompt();
} }
@ -1681,7 +1681,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new EnchantItemsPrompt(); return new EnchantItemsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new EnchantItemsPrompt(); return new EnchantItemsPrompt();
} }
@ -1722,7 +1722,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new EnchantAmountsPrompt(); return new EnchantAmountsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new EnchantAmountsPrompt(); return new EnchantAmountsPrompt();
} }
@ -1926,7 +1926,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new DeliveryNPCsPrompt(); return new DeliveryNPCsPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new DeliveryNPCsPrompt(); return new DeliveryNPCsPrompt();
@ -1999,7 +1999,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new NPCIDsToTalkToPrompt(); return new NPCIDsToTalkToPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new NPCIDsToTalkToPrompt(); return new NPCIDsToTalkToPrompt();
@ -2151,7 +2151,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new npcIdsToKillPrompt(); return new npcIdsToKillPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new npcIdsToKillPrompt(); return new npcIdsToKillPrompt();
@ -2194,7 +2194,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new npcAmountsToKillPrompt(); return new npcAmountsToKillPrompt();
} }
} catch (Exception e) { } catch (NumberFormatException e) {
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers")); context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
return new npcAmountsToKillPrompt(); return new npcAmountsToKillPrompt();
} }
@ -2534,7 +2534,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
mobAmounts.add(i); mobAmounts.add(i);
} catch (Exception e) { } catch (NumberFormatException e) {
player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber")); player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber"));
return new MobAmountsPrompt(); return new MobAmountsPrompt();
} }
@ -2632,7 +2632,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
radii.add(i); radii.add(i);
} catch (Exception e) { } catch (NumberFormatException e) {
player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidItemID")); player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidItemID"));
return new MobRadiiPrompt(); return new MobRadiiPrompt();
} }
@ -2895,7 +2895,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
radii.add(i); radii.add(i);
} catch (Exception e) { } catch (NumberFormatException e) {
player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber")); player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber"));
return new ReachRadiiPrompt(); return new ReachRadiiPrompt();
} }
@ -3139,7 +3139,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
mobAmounts.add(i); mobAmounts.add(i);
} catch (Exception e) { } catch (NumberFormatException e) {
player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber")); player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber"));
return new TameAmountsPrompt(); return new TameAmountsPrompt();
} }
@ -3345,7 +3345,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
shearAmounts.add(i); shearAmounts.add(i);
} catch (Exception e) { } catch (NumberFormatException e) {
player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber")); player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber"));
return new ShearAmountsPrompt(); return new ShearAmountsPrompt();
} }
@ -3810,7 +3810,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
l = Long.parseLong(input); l = Long.parseLong(input);
} catch (Exception e) { } catch (NumberFormatException e) {
player.sendMessage(YELLOW + Lang.get("stageEditorNoNumber")); player.sendMessage(YELLOW + Lang.get("stageEditorNoNumber"));
return new DelayPrompt(); return new DelayPrompt();
} }
@ -4084,7 +4084,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
amountList.add(i); amountList.add(i);
} catch (Exception e) { } catch (NumberFormatException e) {
cc.getForWhom().sendRawMessage(RED + amount + " " + Lang.get("stageEditorInvalidNumber")); cc.getForWhom().sendRawMessage(RED + amount + " " + Lang.get("stageEditorInvalidNumber"));
return new EpicBossAmountListPrompt(); return new EpicBossAmountListPrompt();
} }

View File

@ -1,5 +1,6 @@
package me.blackvein.quests.prompts; package me.blackvein.quests.prompts;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -236,7 +237,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
return new ItemStackPrompt(oldPrompt); return new ItemStackPrompt(oldPrompt);
} }
}catch(Exception e){ }catch(NumberFormatException e){
try { try {
Data data = ItemData.getInstance().getItem(input); Data data = ItemData.getInstance().getItem(input);
if (data == null) { if (data == null) {
@ -288,7 +289,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
return new ItemStackPrompt(oldPrompt); return new ItemStackPrompt(oldPrompt);
} }
}catch(Exception e){ }catch(NumberFormatException e){
cc.getForWhom().sendRawMessage(RED + "Invalid input!"); cc.getForWhom().sendRawMessage(RED + "Invalid input!");
return new AmountPrompt(); return new AmountPrompt();
} }
@ -324,7 +325,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
return new ItemStackPrompt(oldPrompt); return new ItemStackPrompt(oldPrompt);
} }
}catch(Exception e){ }catch(NumberFormatException e){
cc.getForWhom().sendRawMessage(RED + "Invalid input!"); cc.getForWhom().sendRawMessage(RED + "Invalid input!");
return new DataPrompt(); return new DataPrompt();
} }
@ -421,7 +422,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
return new ItemStackPrompt(oldPrompt); return new ItemStackPrompt(oldPrompt);
} }
}catch (Exception e){ }catch (NumberFormatException e){
cc.getForWhom().sendRawMessage(RED + "Input was not a number!"); cc.getForWhom().sendRawMessage(RED + "Input was not a number!");
e.printStackTrace(); e.printStackTrace();
return new LevelPrompt(enchantment); return new LevelPrompt(enchantment);
@ -476,8 +477,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
input = Quests.parseString(input); input = Quests.parseString(input);
LinkedList<String> lore = new LinkedList<String>(); LinkedList<String> lore = new LinkedList<String>();
for(String line : input.split(";")) lore.addAll(Arrays.asList(input.split(";")));
lore.add(line);
cc.setSessionData("tempLore", lore); cc.setSessionData("tempLore", lore);
}else if(input.equalsIgnoreCase("clear")){ }else if(input.equalsIgnoreCase("clear")){

View File

@ -56,7 +56,7 @@ public class QuestAcceptPrompt extends StringPrompt implements ColorUtil {
int numInput = -1; int numInput = -1;
try { try {
numInput = Integer.parseInt(input); numInput = Integer.parseInt(input);
} catch (Exception e) { } catch (NumberFormatException e) {
//Continue //Continue
} }

View File

@ -13,6 +13,7 @@ import me.blackvein.quests.Quests;
import me.blackvein.quests.util.CK; import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.MiscUtil;
import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.FixedSetPrompt; import org.bukkit.conversations.FixedSetPrompt;
@ -21,91 +22,110 @@ import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt; import org.bukkit.conversations.StringPrompt;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
Quests quests; Quests quests;
final QuestFactory factory; final QuestFactory factory;
public RequirementsPrompt(Quests plugin, QuestFactory qf){ public RequirementsPrompt(Quests plugin, QuestFactory qf) {
super("1", "2", "3", "4", "5", "6", "7", "8"); super("1", "2", "3", "4", "5", "6", "7", "8", "9");
quests = plugin; quests = plugin;
factory = qf; factory = qf;
} }
@Override @Override
public String getPromptText(ConversationContext context){ public String getPromptText(ConversationContext context) {
String text; String text;
text = DARKAQUA + "- " + AQUA + context.getSessionData(CK.Q_NAME) + AQUA + " | Requirements -\n"; text = DARKAQUA + "- " + AQUA + context.getSessionData(CK.Q_NAME) + AQUA + " | Requirements -\n";
if(context.getSessionData(CK.REQ_MONEY) == null) if (context.getSessionData(CK.REQ_MONEY) == null) {
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set money requirement " + GRAY + " (" + Lang.get("noneSet") + ")\n"; text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set money requirement " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{ } else {
int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY); int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY);
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set money requirement (" + moneyReq + " " + (moneyReq > 1 ? Quests.getCurrency(true) : Quests.getCurrency(false)) + ")\n"; text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set money requirement (" + moneyReq + " " + (moneyReq > 1 ? Quests.getCurrency(true) : Quests.getCurrency(false)) + ")\n";
} }
if(context.getSessionData(CK.REQ_QUEST_POINTS) == null) if (context.getSessionData(CK.REQ_QUEST_POINTS) == null) {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points requirement " + GRAY + " (" + Lang.get("noneSet") + ")\n"; text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points requirement " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{ } else {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points requirement " + GRAY + "(" + AQUA + context.getSessionData(CK.REQ_QUEST_POINTS) + " Quest Points" + GRAY + ")\n"; text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set Quest Points requirement " + GRAY + "(" + AQUA + context.getSessionData(CK.REQ_QUEST_POINTS) + " Quest Points" + GRAY + ")\n";
} }
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Set item requirements\n"; text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Set item requirements\n";
if(context.getSessionData(CK.REQ_PERMISSION) == null) if (context.getSessionData(CK.REQ_PERMISSION) == null) {
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set permission requirements " + GRAY + " (" + Lang.get("noneSet") + ")\n"; text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set permission requirements " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{ } else {
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set permission requirements\n"; text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set permission requirements\n";
List<String> perms = (List<String>) context.getSessionData(CK.REQ_PERMISSION); List<String> perms = (List<String>) context.getSessionData(CK.REQ_PERMISSION);
for(String s : perms){ for (String s : perms) {
text += GRAY + " - " + AQUA + s + "\n"; text += GRAY + " - " + AQUA + s + "\n";
} }
} }
if(context.getSessionData(CK.REQ_QUEST) == null) if (context.getSessionData(CK.REQ_QUEST) == null) {
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set Quest requirements " + GRAY + " (" + Lang.get("noneSet") + ")\n"; text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set Quest requirements " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{ } else {
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set Quest requirements\n"; text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set Quest requirements\n";
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST); List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST);
for(String s : qs){ for (String s : qs) {
text += GRAY + " - " + AQUA + s + "\n"; text += GRAY + " - " + AQUA + s + "\n";
} }
} }
if(context.getSessionData(CK.REQ_QUEST_BLOCK) == null) if (context.getSessionData(CK.REQ_QUEST_BLOCK) == null) {
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest that mustn't be done " + GRAY + " (" + Lang.get("noneSet") + ")\n"; text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest blocks " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{ } else {
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest requirements\n"; text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest blocks\n";
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK); List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK);
for(String s : qs){ for (String s : qs) {
text += GRAY + " - " + AQUA + s + "\n"; text += GRAY + " - " + AQUA + 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){ if (Quests.mcmmo != null) {
text += GRAY + "" + BOLD + "7 - " + RESET + GRAY + "Set fail requirements message (No requirements set)\n";
}else if(context.getSessionData(CK.Q_FAIL_MESSAGE) == null){
text += RED + "" + BOLD + "7 - " + RESET + RED + "Set fail requirements message (Required)\n"; if (context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
}else{ text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set mcMMO requirements " + GRAY + " (" + Lang.get("noneSet") + ")\n";
text += BLUE + "" + BOLD + "7 - " + RESET + YELLOW + "Set fail requirements message" + GRAY + "(" + AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + GRAY + ")\n"; } else {
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set mcMMO requirements\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 += GRAY + " - " + DARKGREEN + s + RESET + YELLOW + " level " + GREEN + amounts.get(skills.indexOf(s)) + "\n";
}
}
} else {
text += GRAY + "6 - Set mcMMO requirements (mcMMO not installed)\n";
} }
text += GREEN + "" + BOLD + "8" + RESET + YELLOW + " - Done";
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) {
text += GRAY + "" + BOLD + "8 - " + RESET + GRAY + "Set fail requirements message (No requirements set)\n";
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
text += RED + "" + BOLD + "8 - " + RESET + RED + "Set fail requirements message (Required)\n";
} else {
text += BLUE + "" + BOLD + "8 - " + RESET + YELLOW + "Set fail requirements message" + GRAY + "(" + AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + GRAY + ")\n";
}
text += GREEN + "" + BOLD + "9" + RESET + YELLOW + " - Done";
return text; return text;
@ -113,26 +133,31 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
} }
@Override @Override
protected Prompt acceptValidatedInput(ConversationContext context, String input){ protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if(input.equalsIgnoreCase("1")){ if (input.equalsIgnoreCase("1")) {
return new MoneyPrompt(); return new MoneyPrompt();
}else if(input.equalsIgnoreCase("2")){ } else if (input.equalsIgnoreCase("2")) {
return new QuestPointsPrompt(); return new QuestPointsPrompt();
}else if(input.equalsIgnoreCase("3")){ } else if (input.equalsIgnoreCase("3")) {
return new ItemListPrompt(); return new ItemListPrompt();
}else if(input.equalsIgnoreCase("4")){ } else if (input.equalsIgnoreCase("4")) {
return new PermissionsPrompt(); return new PermissionsPrompt();
}else if(input.equalsIgnoreCase("5")){ } else if (input.equalsIgnoreCase("5")) {
return new QuestListPrompt(true); return new QuestListPrompt(true);
}else if(input.equalsIgnoreCase("6")) { } else if (input.equalsIgnoreCase("6")) {
return new QuestListPrompt(false); return new QuestListPrompt(false);
}else if(input.equalsIgnoreCase("7")){ } else if (input.equalsIgnoreCase("7")) {
if(Quests.mcmmo != null)
return new mcMMOPrompt();
else
return new RequirementsPrompt(quests, factory);
} else if (input.equalsIgnoreCase("8")) {
return new FailMessagePrompt(); return new FailMessagePrompt();
}else if(input.equalsIgnoreCase("8")){ } else if (input.equalsIgnoreCase("9")) {
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){ 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) {
if(context.getSessionData(CK.Q_FAIL_MESSAGE) == null){ if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
context.getForWhom().sendRawMessage(RED + "You must set a fail requirements message!"); context.getForWhom().sendRawMessage(RED + "You must set a fail requirements message!");
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
} }
@ -148,21 +173,21 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
private class MoneyPrompt extends NumericPrompt { private class MoneyPrompt extends NumericPrompt {
@Override @Override
public String getPromptText(ConversationContext context){ public String getPromptText(ConversationContext context) {
return YELLOW + "Enter amount of " + PURPLE + ((Quests.economy.currencyNamePlural().isEmpty() ? "Money" : Quests.economy.currencyNamePlural())) + YELLOW + ", or 0 to clear the money requirement, or -1 to cancel"; return YELLOW + "Enter amount of " + PURPLE + ((Quests.economy.currencyNamePlural().isEmpty() ? "Money" : Quests.economy.currencyNamePlural())) + YELLOW + ", or 0 to clear the money requirement, or -1 to cancel";
} }
@Override @Override
protected Prompt acceptValidatedInput(ConversationContext context, Number input){ protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if(input.intValue() < -1){ if (input.intValue() < -1) {
context.getForWhom().sendRawMessage(RED + "Amount must be greater than 0!"); context.getForWhom().sendRawMessage(RED + "Amount must be greater than 0!");
return new MoneyPrompt(); return new MoneyPrompt();
}else if(input.intValue() == -1){ } else if (input.intValue() == -1) {
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
}else if(input.intValue() == 0){ } else if (input.intValue() == 0) {
context.setSessionData(CK.REQ_MONEY, null); context.setSessionData(CK.REQ_MONEY, null);
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
} }
@ -171,27 +196,26 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
} }
} }
private class QuestPointsPrompt extends NumericPrompt { private class QuestPointsPrompt extends NumericPrompt {
@Override @Override
public String getPromptText(ConversationContext context){ public String getPromptText(ConversationContext context) {
return YELLOW + "Enter amount of Quest Points, or 0 to clear the Quest Point requirement,\nor -1 to cancel"; return YELLOW + "Enter amount of Quest Points, or 0 to clear the Quest Point requirement,\nor -1 to cancel";
} }
@Override @Override
protected Prompt acceptValidatedInput(ConversationContext context, Number input){ protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if(input.intValue() < -1){ if (input.intValue() < -1) {
context.getForWhom().sendRawMessage(RED + "Amount must be greater than 0!"); context.getForWhom().sendRawMessage(RED + "Amount must be greater than 0!");
return new QuestPointsPrompt(); return new QuestPointsPrompt();
}else if(input.intValue() == -1){ } else if (input.intValue() == -1) {
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
}else if(input.intValue() == 0){ } else if (input.intValue() == 0) {
context.setSessionData(CK.REQ_QUEST_POINTS, null); context.setSessionData(CK.REQ_QUEST_POINTS, null);
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
} }
@ -200,37 +224,35 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
} }
} }
private class QuestListPrompt extends StringPrompt { private class QuestListPrompt extends StringPrompt {
private boolean isRequiredQuest; private final boolean isRequiredQuest;
/*public QuestListPrompt() { /*public QuestListPrompt() {
this.isRequiredQuest = true; this.isRequiredQuest = true;
}*/ }*/
public QuestListPrompt(boolean isRequired) {
public QuestListPrompt(boolean isRequired) { this.isRequiredQuest = isRequired;
this.isRequiredQuest = isRequired; }
}
@Override @Override
public String getPromptText(ConversationContext context){ public String getPromptText(ConversationContext context) {
String text = PINK + "- Quests -\n" + PURPLE; String text = PINK + "- Quests -\n" + PURPLE;
boolean none = true; boolean none = true;
for(Quest q : quests.getQuests()){ for (Quest q : quests.getQuests()) {
text += q.getName() + ", "; text += q.getName() + ", ";
none = false; none = false;
} }
if(none) if (none) {
text += "(None)\n"; text += "(None)\n";
else{ } else {
text = text.substring(0, (text.length() - 2)); text = text.substring(0, (text.length() - 2));
text += "\n"; text += "\n";
} }
@ -242,23 +264,23 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
} }
@Override @Override
public Prompt acceptInput(ConversationContext context, String input){ public Prompt acceptInput(ConversationContext context, String input) {
if(input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false){ if (input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false) {
String[] args = input.split(","); String[] args = input.split(",");
LinkedList<String> questNames = new LinkedList<String>(); LinkedList<String> questNames = new LinkedList<String>();
for(String s : args){ for (String s : args) {
if(quests.getQuest(s) == null){ if (quests.getQuest(s) == null) {
context.getForWhom().sendRawMessage(PINK + s + " " + RED + "is not a Quest name!"); context.getForWhom().sendRawMessage(PINK + s + " " + RED + "is not a Quest name!");
return new QuestListPrompt(isRequiredQuest); return new QuestListPrompt(isRequiredQuest);
} }
if(questNames.contains(s)){ if (questNames.contains(s)) {
context.getForWhom().sendRawMessage(RED + "List contains duplicates!"); context.getForWhom().sendRawMessage(RED + "List contains duplicates!");
return new QuestListPrompt(isRequiredQuest); return new QuestListPrompt(isRequiredQuest);
@ -269,29 +291,27 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
} }
Collections.sort(questNames, new Comparator<String>(){ Collections.sort(questNames, new Comparator<String>() {
@Override @Override
public int compare(String one, String two){ public int compare(String one, String two) {
return one.compareTo(two); return one.compareTo(two);
} }
}); });
if (isRequiredQuest) { if (isRequiredQuest) {
context.setSessionData(CK.REQ_QUEST, questNames); context.setSessionData(CK.REQ_QUEST, questNames);
} else { } else {
context.setSessionData(CK.REQ_QUEST_BLOCK, questNames); context.setSessionData(CK.REQ_QUEST_BLOCK, questNames);
} }
}else if(input.equalsIgnoreCase("clear")){ } else if (input.equalsIgnoreCase("clear")) {
if (isRequiredQuest) { if (isRequiredQuest) {
context.setSessionData(CK.REQ_QUEST, null); context.setSessionData(CK.REQ_QUEST, null);
} else { } else {
context.setSessionData(CK.REQ_QUEST_BLOCK, null); context.setSessionData(CK.REQ_QUEST_BLOCK, null);
} }
} }
@ -299,27 +319,26 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
} }
} }
private class ItemListPrompt extends FixedSetPrompt { private class ItemListPrompt extends FixedSetPrompt {
public ItemListPrompt(){ public ItemListPrompt() {
super("1", "2", "3", "4"); super("1", "2", "3", "4");
} }
@Override @Override
public String getPromptText(ConversationContext context){ public String getPromptText(ConversationContext context) {
// Check/add newly made item // Check/add newly made item
if(context.getSessionData("newItem") != null){ if (context.getSessionData("newItem") != null) {
if(context.getSessionData(CK.REQ_ITEMS) != null){ if (context.getSessionData(CK.REQ_ITEMS) != null) {
List<ItemStack> itemRews = getItems(context); List<ItemStack> itemRews = getItems(context);
itemRews.add((ItemStack) context.getSessionData("tempStack")); itemRews.add((ItemStack) context.getSessionData("tempStack"));
context.setSessionData(CK.REQ_ITEMS, itemRews); context.setSessionData(CK.REQ_ITEMS, itemRews);
}else{ } else {
LinkedList<ItemStack> itemRews = new LinkedList<ItemStack>(); LinkedList<ItemStack> itemRews = new LinkedList<ItemStack>();
itemRews.add((ItemStack) context.getSessionData("tempStack")); itemRews.add((ItemStack) context.getSessionData("tempStack"));
context.setSessionData(CK.REQ_ITEMS, itemRews); context.setSessionData(CK.REQ_ITEMS, itemRews);
@ -331,14 +350,14 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
} }
String text = GOLD + "- Item Requirements -\n"; String text = GOLD + "- Item Requirements -\n";
if(context.getSessionData(CK.REQ_ITEMS) == null){ if (context.getSessionData(CK.REQ_ITEMS) == null) {
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Add item\n"; text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Add item\n";
text += GRAY + "2 - Set remove items (No items set)\n"; text += GRAY + "2 - Set remove items (No items set)\n";
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Clear\n"; text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Clear\n";
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Done"; text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Done";
}else{ } else {
for(ItemStack is : getItems(context)){ for (ItemStack is : getItems(context)) {
text += GRAY + " - " + ItemUtil.getDisplayString(is) + "\n"; text += GRAY + " - " + ItemUtil.getDisplayString(is) + "\n";
@ -347,12 +366,12 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Add item\n"; text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Add item\n";
if(context.getSessionData(CK.REQ_ITEMS_REMOVE) == null){ if (context.getSessionData(CK.REQ_ITEMS_REMOVE) == null) {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set remove items (No values set)\n"; text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set remove items (No values set)\n";
}else{ } else {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set remove items\n"; text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set remove items\n";
for(Boolean b : getRemoveItems(context)){ for (Boolean b : getRemoveItems(context)) {
text += GRAY + " - " + AQUA + b.toString().toLowerCase() + "\n"; text += GRAY + " - " + AQUA + b.toString().toLowerCase() + "\n";
@ -370,40 +389,42 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
} }
@Override @Override
protected Prompt acceptValidatedInput(ConversationContext context, String input){ protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if(input.equalsIgnoreCase("1")){ if (input.equalsIgnoreCase("1")) {
return new ItemStackPrompt(ItemListPrompt.this); return new ItemStackPrompt(ItemListPrompt.this);
}else if(input.equalsIgnoreCase("2")){ } else if (input.equalsIgnoreCase("2")) {
if(context.getSessionData(CK.REQ_ITEMS) == null){ if (context.getSessionData(CK.REQ_ITEMS) == null) {
context.getForWhom().sendRawMessage(RED + "You must add at least one item first!"); context.getForWhom().sendRawMessage(RED + "You must add at least one item first!");
return new ItemListPrompt(); return new ItemListPrompt();
}else{ } else {
return new RemoveItemsPrompt(); return new RemoveItemsPrompt();
} }
}else if(input.equalsIgnoreCase("3")){ } else if (input.equalsIgnoreCase("3")) {
context.getForWhom().sendRawMessage(YELLOW + "Item requirements cleared."); context.getForWhom().sendRawMessage(YELLOW + "Item requirements cleared.");
context.setSessionData(CK.REQ_ITEMS, null); context.setSessionData(CK.REQ_ITEMS, null);
context.setSessionData(CK.REQ_ITEMS_REMOVE, null); context.setSessionData(CK.REQ_ITEMS_REMOVE, null);
return new ItemListPrompt(); return new ItemListPrompt();
}else if(input.equalsIgnoreCase("4")){ } else if (input.equalsIgnoreCase("4")) {
int one; int one;
int two; int two;
if(context.getSessionData(CK.REQ_ITEMS) != null) if (context.getSessionData(CK.REQ_ITEMS) != null) {
one = ((List<ItemStack>) context.getSessionData(CK.REQ_ITEMS)).size(); one = ((List<ItemStack>) context.getSessionData(CK.REQ_ITEMS)).size();
else } else {
one = 0; one = 0;
}
if(context.getSessionData(CK.REQ_ITEMS_REMOVE) != null) if (context.getSessionData(CK.REQ_ITEMS_REMOVE) != null) {
two = ((List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE)).size(); two = ((List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE)).size();
else } else {
two = 0; two = 0;
}
if(one == two) if (one == two) {
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
else{ } else {
context.getForWhom().sendRawMessage(RED + "The " + GOLD + "items list " + RED + "and " + GOLD + "remove items list " + RED + "are not the same size!"); context.getForWhom().sendRawMessage(RED + "The " + GOLD + "items list " + RED + "and " + GOLD + "remove items list " + RED + "are not the same size!");
return new ItemListPrompt(); return new ItemListPrompt();
} }
@ -412,38 +433,37 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
} }
private List<ItemStack> getItems(ConversationContext context){ private List<ItemStack> getItems(ConversationContext context) {
return (List<ItemStack>) context.getSessionData(CK.REQ_ITEMS); return (List<ItemStack>) context.getSessionData(CK.REQ_ITEMS);
} }
private List<Boolean> getRemoveItems(ConversationContext context){ private List<Boolean> getRemoveItems(ConversationContext context) {
return (List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE); return (List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE);
} }
} }
private class RemoveItemsPrompt extends StringPrompt { private class RemoveItemsPrompt extends StringPrompt {
@Override @Override
public String getPromptText(ConversationContext context){ public String getPromptText(ConversationContext context) {
return YELLOW + "Enter a list of true/false values, separating each one by a space, or enter \'cancel\' to return."; return YELLOW + "Enter a list of true/false values, separating each one by a space, or enter \'cancel\' to return.";
} }
@Override @Override
public Prompt acceptInput(ConversationContext context, String input){ public Prompt acceptInput(ConversationContext context, String input) {
if(input.equalsIgnoreCase("cancel") == false){ if (input.equalsIgnoreCase("cancel") == false) {
String[] args = input.split(" "); String[] args = input.split(" ");
LinkedList<Boolean> booleans = new LinkedList<Boolean>(); LinkedList<Boolean> booleans = new LinkedList<Boolean>();
for(String s : args){ for (String s : args) {
if(s.equalsIgnoreCase("true") || s.equalsIgnoreCase("yes")) if (s.equalsIgnoreCase("true") || s.equalsIgnoreCase("yes")) {
booleans.add(true); booleans.add(true);
else if(s.equalsIgnoreCase("false") || s.equalsIgnoreCase("no")) } else if (s.equalsIgnoreCase("false") || s.equalsIgnoreCase("no")) {
booleans.add(false); booleans.add(false);
else{ } else {
context.getForWhom().sendRawMessage(PINK + s + RED + " is not a true or false value!\n " + GOLD + "Example: true false true true"); context.getForWhom().sendRawMessage(PINK + s + RED + " is not a true or false value!\n " + GOLD + "Example: true false true true");
return new RemoveItemsPrompt(); return new RemoveItemsPrompt();
} }
@ -457,21 +477,19 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
return new ItemListPrompt(); return new ItemListPrompt();
} }
} }
private class PermissionsPrompt extends StringPrompt { private class PermissionsPrompt extends StringPrompt {
@Override @Override
public String getPromptText(ConversationContext context){ public String getPromptText(ConversationContext context) {
return YELLOW + "Enter permission requirements separating each one by a space, or enter \'clear\' to clear the list, or enter \'cancel\' to return."; return YELLOW + "Enter permission requirements separating each one by a space, or enter \'clear\' to clear the list, or enter \'cancel\' to return.";
} }
@Override @Override
public Prompt acceptInput(ConversationContext context, String input){ public Prompt acceptInput(ConversationContext context, String input) {
if(input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false){ if (input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false) {
String[] args = input.split(" "); String[] args = input.split(" ");
LinkedList<String> permissions = new LinkedList<String>(); LinkedList<String> permissions = new LinkedList<String>();
@ -479,33 +497,195 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
context.setSessionData(CK.REQ_PERMISSION, permissions); context.setSessionData(CK.REQ_PERMISSION, permissions);
}else if(input.equalsIgnoreCase("clear")){ } else if (input.equalsIgnoreCase("clear")) {
context.setSessionData(CK.REQ_PERMISSION, null); context.setSessionData(CK.REQ_PERMISSION, null);
} }
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
} }
}
private class mcMMOPrompt extends FixedSetPrompt {
public mcMMOPrompt(){
super("1", "2", "3");
}
@Override
public String getPromptText(ConversationContext cc) {
String text = DARKGREEN + "- mcMMO Requirements -\n";
if(cc.getSessionData(CK.REQ_MCMMO_SKILLS) == null){
text += BOLD + "" + GREEN + "1" + RESET + GREEN + " - Set skills (None set)\n";
}else{
text += BOLD + "" + GREEN + "1" + RESET + GREEN + " - Set skills\n";
LinkedList<String> skills = (LinkedList<String>) cc.getSessionData(CK.REQ_MCMMO_SKILLS);
for(String skill : skills){
text += GRAY + " - " + AQUA + skill + "\n";
}
}
if(cc.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) == null){
text += BOLD + "" + GREEN + "2" + RESET + GREEN + " - Set skill amounts (None set)\n";
}else{
text += BOLD + "" + GREEN + "2" + RESET + GREEN + " - Set skill amounts\n";
LinkedList<Integer> amounts = (LinkedList<Integer>) cc.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS);
for(int i : amounts){
text += GRAY + " - " + AQUA + i + "\n";
}
}
text += BOLD + "" + GREEN + "3" + RESET + GREEN + " - Done";
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext cc, String input) {
if(input.equalsIgnoreCase("1")){
return new mcMMOSkillsPrompt();
}else if(input.equalsIgnoreCase("2")){
return new mcMMOAmountsPrompt();
}else if(input.equalsIgnoreCase("3")){
return new RequirementsPrompt(quests, factory);
}
return null;
}
}
private class mcMMOSkillsPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
String skillList =
DARKGREEN + "-Skill List-\n" +
GREEN + "Acrobatics\n" +
GREEN + "All\n" +
GREEN + "Archery\n" +
GREEN + "Axes\n" +
GREEN + "Excavation\n" +
GREEN + "Fishing\n" +
GREEN + "Herbalism\n" +
GREEN + "Mining\n" +
GREEN + "Repair\n" +
GREEN + "Smelting\n" +
GREEN + "Swords\n" +
GREEN + "Taming\n" +
GREEN + "Unarmed\n" +
GREEN + "Woodcutting\n\n";
return skillList + YELLOW + "Enter mcMMO skills, separating each one by a space, or enter \'clear\' to clear the list, "
+ "or \'cancel\' to return.\n";
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false) {
LinkedList<String> skills = new LinkedList<String>();
for(String s : input.split(" ")){
String formatted = MiscUtil.getCapitalized(s);
if(Quests.getMcMMOSkill(formatted) != null){
skills.add(formatted);
}else if(skills.contains(formatted)){
cc.getForWhom().sendRawMessage(YELLOW + "Error: List contains duplicates!");
return new mcMMOSkillsPrompt();
}else{
cc.getForWhom().sendRawMessage(YELLOW + "Error: " + RED + s + YELLOW + " is not an mcMMO skill name!");
return new mcMMOSkillsPrompt();
}
}
cc.setSessionData(CK.REQ_MCMMO_SKILLS, skills);
return new mcMMOPrompt();
}else if(input.equalsIgnoreCase("clear")){
cc.getForWhom().sendRawMessage(YELLOW + "mcMMO skill requirements cleared.");
cc.setSessionData(CK.REQ_MCMMO_SKILLS, null);
return new mcMMOPrompt();
}else if(input.equalsIgnoreCase("cancel")){
return new mcMMOPrompt();
}
return new mcMMOSkillsPrompt();
}
}
private class mcMMOAmountsPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
return YELLOW + "Enter mcMMO skill amounts, separating each one by a space, or enter \'clear\' to clear the list, "
+ "or \'cancel\' to return.\n";
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false) {
LinkedList<Integer> amounts = new LinkedList<Integer>();
for(String s : input.split(" ")){
try{
int i = Integer.parseInt(s);
amounts.add(i);
}catch(NumberFormatException nfe){
cc.getForWhom().sendRawMessage(YELLOW + "Error: " + RED + s + YELLOW + " is not a number!");
return new mcMMOAmountsPrompt();
}
}
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, amounts);
return new mcMMOPrompt();
}else if(input.equalsIgnoreCase("clear")){
cc.getForWhom().sendRawMessage(YELLOW + "mcMMO skill amount requirements cleared.");
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, null);
return new mcMMOPrompt();
}else if(input.equalsIgnoreCase("cancel")){
return new mcMMOPrompt();
}
return new mcMMOAmountsPrompt();
}
} }
private class FailMessagePrompt extends StringPrompt { private class FailMessagePrompt extends StringPrompt {
@Override @Override
public String getPromptText(ConversationContext context){ public String getPromptText(ConversationContext context) {
return YELLOW + "Enter fail requirements message, or enter \'cancel\' to return."; return YELLOW + "Enter fail requirements message, or enter \'cancel\' to return.";
} }
@Override @Override
public Prompt acceptInput(ConversationContext context, String input){ public Prompt acceptInput(ConversationContext context, String input) {
if(input.equalsIgnoreCase("cancel") == false) if (input.equalsIgnoreCase("cancel") == false) {
context.setSessionData(CK.Q_FAIL_MESSAGE, input); context.setSessionData(CK.Q_FAIL_MESSAGE, input);
}
return new RequirementsPrompt(quests, factory); return new RequirementsPrompt(quests, factory);
} }
} }
} }

View File

@ -437,7 +437,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
return new RPGItemIdsPrompt(); return new RPGItemIdsPrompt();
} }
}catch (Exception e){ }catch (NumberFormatException e){
RPGItem item = ItemManager.getItemByName(s); RPGItem item = ItemManager.getItemByName(s);
@ -491,7 +491,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
return new RPGItemAmountsPrompt(); return new RPGItemAmountsPrompt();
} }
}catch (Exception e){ }catch (NumberFormatException e){
context.getForWhom().sendRawMessage(RED + "Invalid entry " + PINK + s + RED + ". Input was not a list of numbers!"); context.getForWhom().sendRawMessage(RED + "Invalid entry " + PINK + s + RED + ". Input was not a list of numbers!");
return new RPGItemAmountsPrompt(); return new RPGItemAmountsPrompt();
} }
@ -700,6 +700,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
AQUA + "Herbalism\n" + AQUA + "Herbalism\n" +
AQUA + "Mining\n" + AQUA + "Mining\n" +
AQUA + "Repair\n" + AQUA + "Repair\n" +
AQUA + "Smelting\n" +
AQUA + "Swords\n" + AQUA + "Swords\n" +
AQUA + "Taming\n" + AQUA + "Taming\n" +
AQUA + "Unarmed\n" + AQUA + "Unarmed\n" +
@ -769,7 +770,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
return new mcMMOAmountsPrompt(); return new mcMMOAmountsPrompt();
} }
}catch (Exception e){ }catch (NumberFormatException e){
context.getForWhom().sendRawMessage(RED + "Invalid entry " + PINK + s + RED + ". Input was not a list of numbers!"); context.getForWhom().sendRawMessage(RED + "Invalid entry " + PINK + s + RED + ". Input was not a list of numbers!");
return new mcMMOAmountsPrompt(); return new mcMMOAmountsPrompt();
} }

View File

@ -49,7 +49,7 @@ public class StagesPrompt extends StringPrompt implements ColorUtil{
i = Integer.parseInt(string); i = Integer.parseInt(string);
}catch(Exception e){ }catch(NumberFormatException e){
return new StagesPrompt(questFactory); return new StagesPrompt(questFactory);
} }

View File

@ -22,6 +22,8 @@ public class CK {
public static final String REQ_ITEMS = "itemReqs"; public static final String REQ_ITEMS = "itemReqs";
public static final String REQ_ITEMS_REMOVE = "removeItemReqs"; public static final String REQ_ITEMS_REMOVE = "removeItemReqs";
public static final String REQ_PERMISSION = "permissionReqs"; public static final String REQ_PERMISSION = "permissionReqs";
public static final String REQ_MCMMO_SKILLS = "mcMMOSkillReqs";
public static final String REQ_MCMMO_SKILL_AMOUNTS = "mcMMOSkillAmountReqs";
public static final String REQ_QUEST = "questReqs"; public static final String REQ_QUEST = "questReqs";
public static final String REQ_QUEST_BLOCK= "questBlocks"; public static final String REQ_QUEST_BLOCK= "questBlocks";

View File

@ -0,0 +1,20 @@
package me.blackvein.quests.util;
public class MiscUtil {
public static String getCapitalized(String s){
if(s.isEmpty())
return s;
s = s.toLowerCase();
String s2 = s.substring(0, 1);
s2 = s2.toUpperCase();
s = s.substring(1, s.length());
return s2 + s;
}
}