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;
@ -927,6 +933,11 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
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 {
@ -1405,10 +1419,20 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
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;
} }

View File

@ -1,11 +1,15 @@
package me.blackvein.quests; package me.blackvein.quests;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.herocraftonline.heroes.Heroes; import com.herocraftonline.heroes.Heroes;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Calendar; import java.util.Calendar;
@ -13,7 +17,6 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -23,9 +26,12 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import me.ThaH3lper.com.EpicBoss; import me.ThaH3lper.com.EpicBoss;
import me.ThaH3lper.com.Mobs.EpicMobs; import me.ThaH3lper.com.Mobs.EpicMobs;
import static me.blackvein.quests.ColorUtil.GREEN;
import static me.blackvein.quests.ColorUtil.RED;
import me.blackvein.quests.prompts.QuestAcceptPrompt; import me.blackvein.quests.prompts.QuestAcceptPrompt;
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 net.aufdemrand.denizen.Denizen; import net.aufdemrand.denizen.Denizen;
import net.aufdemrand.denizen.scripts.ScriptRegistry; import net.aufdemrand.denizen.scripts.ScriptRegistry;
import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.CitizensAPI;
@ -43,6 +49,7 @@ import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
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.Conversable; import org.bukkit.conversations.Conversable;
@ -189,7 +196,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
try { try {
config.load(this.getResource("config.yml")); config.load(this.getResource("config.yml"));
config.save(new File(this.getDataFolder(), "config.yml")); config.save(new File(this.getDataFolder(), "config.yml"));
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -207,7 +216,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
data.load(this.getResource("quests.yml")); data.load(this.getResource("quests.yml"));
data.set("events", null); data.set("events", null);
data.save(new File(this.getDataFolder(), "quests.yml")); data.save(new File(this.getDataFolder(), "quests.yml"));
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -221,7 +232,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
try { try {
data.load(this.getResource("events.yml")); data.load(this.getResource("events.yml"));
data.save(new File(this.getDataFolder(), "events.yml")); data.save(new File(this.getDataFolder(), "events.yml"));
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -320,7 +333,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} }
} }
@ -386,7 +398,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
try { try {
config.save(new File(this.getDataFolder(), "config.yml")); config.save(new File(this.getDataFolder(), "config.yml"));
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -551,6 +563,24 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
if (quest.mcMMOSkillReqs.isEmpty() == false) {
for (String skill : quest.mcMMOSkillReqs) {
int level = Quests.getMCMMOSkillLevel(Quests.getMcMMOSkill(skill), player.getName());
int req = quest.mcMMOAmountReqs.get(quest.mcMMOSkillReqs.indexOf(skill));
String skillName = MiscUtil.getCapitalized(skill);
if (level >= req) {
cs.sendMessage(GREEN + skillName + " level " + req);
} else {
cs.sendMessage(RED + skillName + " level " + req);
}
}
}
if (quest.questPointsReq != 0) { if (quest.questPointsReq != 0) {
if (quester.questPoints >= quest.questPointsReq) { if (quester.questPoints >= quest.questPointsReq) {
@ -695,7 +725,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} catch (Exception e) { } catch (NumberFormatException e) {
cs.sendMessage(YELLOW + "Page selection must be a number."); cs.sendMessage(YELLOW + "Page selection must be a number.");
return true; return true;
@ -808,8 +838,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
quester.questToTake = quest.name; quester.questToTake = quest.name;
String s = String s
GOLD + "- " + PURPLE + quester.questToTake + GOLD + " -\n" = GOLD + "- " + PURPLE + quester.questToTake + GOLD + " -\n"
+ "\n" + "\n"
+ RESET + getQuest(quester.questToTake).description + "\n"; + RESET + getQuest(quester.questToTake).description + "\n";
@ -939,7 +969,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
topNumber = Integer.parseInt(args[1]); topNumber = Integer.parseInt(args[1]);
} catch (Exception e) { } catch (NumberFormatException e) {
cs.sendMessage(YELLOW + "Input must be a number."); cs.sendMessage(YELLOW + "Input must be a number.");
return true; return true;
@ -965,10 +995,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
data.load(f); data.load(f);
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace();
} }
String name = f.getName().substring(0, (f.getName().indexOf("."))); String name = f.getName().substring(0, (f.getName().indexOf(".")));
@ -981,10 +1013,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
int numPrinted = 0; int numPrinted = 0;
cs.sendMessage(GOLD + "- Top " + PURPLE + topNumber + GOLD + " Questers -"); cs.sendMessage(GOLD + "- Top " + PURPLE + topNumber + GOLD + " Questers -");
for (Object o : sortedMap.keySet()) { for (String s : sortedMap.keySet()) {
String s = (String) o; int i = (Integer) sortedMap.get(s);
int i = (Integer) sortedMap.get(o);
numPrinted++; numPrinted++;
cs.sendMessage(YELLOW + String.valueOf(numPrinted) + ". " + s + " - " + PURPLE + i + YELLOW + " Quest points"); cs.sendMessage(YELLOW + String.valueOf(numPrinted) + ". " + s + " - " + PURPLE + i + YELLOW + " Quest points");
@ -992,10 +1023,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
break; break;
} }
} }
} }
return true; return true;
@ -1221,7 +1250,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
return true; return true;
} }
} catch (Exception e) { } catch (NumberFormatException e) {
cs.sendMessage(RED + "Error: Input was not a number!"); cs.sendMessage(RED + "Error: Input was not a number!");
return true; return true;
} }
@ -1245,7 +1274,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
data.set("quest-points", amount); data.set("quest-points", amount);
data.save(f); data.save(f);
} catch (Exception e) { } catch (IOException e) {
if (failCount < 4) { if (failCount < 4) {
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", skipping.."); cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", skipping..");
@ -1254,6 +1283,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
suppressed = true; suppressed = true;
} }
} catch (InvalidConfigurationException e) {
if (failCount < 4) {
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", skipping..");
} else if (suppressed == false) {
cs.sendMessage(RED + "Error reading " + DARKAQUA + f.getName() + RED + ", suppressing further errors.");
suppressed = true;
}
} }
} }
@ -1418,7 +1454,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
points = Integer.parseInt(args[2]); points = Integer.parseInt(args[2]);
} catch (Exception e) { } catch (NumberFormatException e) {
cs.sendMessage(YELLOW + "Amount must be a number."); cs.sendMessage(YELLOW + "Amount must be a number.");
return true; return true;
@ -1467,7 +1503,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
points = Integer.parseInt(args[2]); points = Integer.parseInt(args[2]);
} catch (Exception e) { } catch (NumberFormatException e) {
cs.sendMessage(YELLOW + "Amount must be a number."); cs.sendMessage(YELLOW + "Amount must be a number.");
return true; return true;
@ -1523,14 +1559,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
return true; return true;
} catch (Exception e) { } catch (NumberFormatException e) {
cs.sendMessage(YELLOW + "Amount must be a number."); cs.sendMessage(YELLOW + "Amount must be a number.");
} }
} }
} else { } else {
@ -1550,7 +1584,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
return false; return false;
} }
@ -1711,7 +1744,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
config.load(file); config.load(file);
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -1834,7 +1869,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
continue; continue;
} }
if (config.contains("quests." + s + ".requirements.remove-items")) { if (config.contains("quests." + s + ".requirements.remove-items")) {
if (Quests.checkList(config.getList("quests." + s + ".requirements.remove-items"), Boolean.class)) { if (Quests.checkList(config.getList("quests." + s + ".requirements.remove-items"), Boolean.class)) {
@ -1873,11 +1907,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
if (config.contains("quests." + s + ".requirements.noQuests")) { if (config.contains("quests." + s + ".requirements.quest-blocks")) {
if (Quests.checkList(config.getList("quests." + s + ".requirements.noQuests"), String.class)) { if (Quests.checkList(config.getList("quests." + s + ".requirements.quest-blocks"), String.class)) {
List<String> names = config.getStringList("quests." + s + ".requirements.noQuests"); List<String> names = config.getStringList("quests." + s + ".requirements.quest-blocks");
boolean failed = false; boolean failed = false;
String failedQuest = "NULL"; String failedQuest = "NULL";
@ -1910,7 +1944,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} else { } else {
printSevere("[Quests] quests: Requirement for Quest " + quest.name + " is not a list of Quest names!"); printSevere("[Quests] quest-blocks: Requirement for Quest " + quest.name + " is not a list of Quest names!");
continue; continue;
} }
@ -1959,7 +1993,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
if (config.contains("quests." + s + ".requirements.permissions")) { if (config.contains("quests." + s + ".requirements.permissions")) {
if (Quests.checkList(config.getList("quests." + s + ".requirements.permissions"), String.class)) { if (Quests.checkList(config.getList("quests." + s + ".requirements.permissions"), String.class)) {
@ -1972,6 +2005,42 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
if (config.contains("quests." + s + ".requirements.mcmmo-skills")) {
if (Quests.checkList(config.getList("quests." + s + ".requirements.mcmmo-skills"), String.class)) {
if (config.contains("quests." + s + ".requirements.mcmmo-amounts")) {
if (Quests.checkList(config.getList("quests." + s + ".requirements.mcmmo-amounts"), Integer.class)) {
List<String> skills = config.getStringList("quests." + s + ".requirements.mcmmo-skills");
List<Integer> amounts = config.getIntegerList("quests." + s + ".requirements.mcmmo-amounts");
if (skills.size() != amounts.size()) {
printSevere("[Quests] mcmmo-skills: and mcmmo-amounts: in requirements: for Quest " + quest.name + " are not the same size!");
continue;
}
quest.mcMMOSkillReqs.addAll(skills);
quest.mcMMOAmountReqs.addAll(amounts);
} else {
printSevere("[Quests] mcmmo-amounts: Requirement for Quest " + quest.name + " is not a list of numbers!");
continue;
}
} else {
printSevere("[Quests] Requirements for Quest " + quest.name + " is missing mcmmo-amounts:");
continue;
}
} else {
printSevere("[Quests] mcmmo-skills: Requirement for Quest " + quest.name + " is not a list of skills!");
continue;
}
}
} }
quest.plugin = this; quest.plugin = this;
@ -2010,7 +2079,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
List<Integer> cutamounts = new LinkedList<Integer>(); List<Integer> cutamounts = new LinkedList<Integer>();
//Denizen script load //Denizen script load
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".script-to-run")) { if (config.contains("quests." + s + ".stages.ordered." + s2 + ".script-to-run")) {
if (ScriptRegistry.containsScript(config.getString("quests." + s + ".stages.ordered." + s2 + ".script-to-run"))) { if (ScriptRegistry.containsScript(config.getString("quests." + s + ".stages.ordered." + s2 + ".script-to-run"))) {
@ -2025,7 +2093,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
// //
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".break-block-ids")) { if (config.contains("quests." + s + ".stages.ordered." + s2 + ".break-block-ids")) {
if (checkList(config.getList("quests." + s + ".stages.ordered." + s2 + ".break-block-ids"), Integer.class)) { if (checkList(config.getList("quests." + s + ".stages.ordered." + s2 + ".break-block-ids"), Integer.class)) {
@ -2296,7 +2363,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
break; break;
} }
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".enchantment-amounts")) { if (config.contains("quests." + s + ".stages.ordered." + s2 + ".enchantment-amounts")) {
if (Quests.checkList(config.getList("quests." + s + ".stages.ordered." + s2 + ".enchantment-amounts"), Integer.class)) { if (Quests.checkList(config.getList("quests." + s + ".stages.ordered." + s2 + ".enchantment-amounts"), Integer.class)) {
@ -2317,7 +2383,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
break; break;
} }
} }
List<Integer> npcIdsToTalkTo = null; List<Integer> npcIdsToTalkTo = null;
@ -2603,7 +2668,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
x = Double.parseDouble(info[1]); x = Double.parseDouble(info[1]);
y = Double.parseDouble(info[2]); y = Double.parseDouble(info[2]);
z = Double.parseDouble(info[3]); z = Double.parseDouble(info[3]);
} catch (Exception e) { } catch (NumberFormatException e) {
printSevere("[Quests] " + loc + " inside mobs-to-kill: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!"); printSevere("[Quests] " + loc + " inside mobs-to-kill: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!");
printSevere("[Quests] Proper location format is: \"WorldName x y z\""); printSevere("[Quests] Proper location format is: \"WorldName x y z\"");
stageFailed = true; stageFailed = true;
@ -2680,7 +2745,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
break; break;
} }
} }
stage.mobsToKill = mobsToKill; stage.mobsToKill = mobsToKill;
@ -2732,7 +2796,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
x = Double.parseDouble(info[1]); x = Double.parseDouble(info[1]);
y = Double.parseDouble(info[2]); y = Double.parseDouble(info[2]);
z = Double.parseDouble(info[3]); z = Double.parseDouble(info[3]);
} catch (Exception e) { } catch (NumberFormatException e) {
printSevere("[Quests] " + loc + " inside locations-to-reach: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!"); printSevere("[Quests] " + loc + " inside locations-to-reach: inside Stage " + s2 + " of Quest " + quest.name + " is not in proper location format!");
printSevere("[Quests] Proper location format is: \"WorldName x y z\""); printSevere("[Quests] Proper location format is: \"WorldName x y z\"");
stageFailed = true; stageFailed = true;
@ -3178,9 +3242,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (Quests.checkList(config.getList("quests." + s + ".rewards.rpgitem-ids"), Integer.class)) { if (Quests.checkList(config.getList("quests." + s + ".rewards.rpgitem-ids"), Integer.class)) {
if(config.contains("quests." + s + ".rewards.rpgitem-amounts")){ if (config.contains("quests." + s + ".rewards.rpgitem-amounts")) {
if(Quests.checkList(config.getList("quests." + s + ".rewards.rpgitem-amounts"), Integer.class)){ if (Quests.checkList(config.getList("quests." + s + ".rewards.rpgitem-amounts"), Integer.class)) {
boolean failed = false; boolean failed = false;
for (Integer id : config.getIntegerList("quests." + s + ".rewards.rpgitem-ids")) { for (Integer id : config.getIntegerList("quests." + s + ".rewards.rpgitem-ids")) {
@ -3202,7 +3266,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
for(Integer amount : config.getIntegerList("quests." + s + ".rewards.rpgitem-amounts")) { for (Integer amount : config.getIntegerList("quests." + s + ".rewards.rpgitem-amounts")) {
quest.rpgItemRewardAmounts.add(amount); quest.rpgItemRewardAmounts.add(amount);
@ -3212,12 +3276,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
continue; continue;
} }
}else{ } else {
printSevere("[Quests] rpgitem-amounts: Reward in Quest " + quest.name + " is not a list of numbers!"); printSevere("[Quests] rpgitem-amounts: Reward in Quest " + quest.name + " is not a list of numbers!");
break; break;
} }
}else { } else {
printSevere("[Quests] Rewards for Quest " + quest.name + " is missing rpgitem-amounts"); printSevere("[Quests] Rewards for Quest " + quest.name + " is missing rpgitem-amounts");
continue; continue;
} }
@ -3331,7 +3395,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
config.save(file); config.save(file);
} }
} catch (Exception e) { } catch (IOException e) {
if (debug == false) { if (debug == false) {
log.log(Level.SEVERE, "[Quests] Failed to load Quest \"" + s + "\". Skipping."); log.log(Level.SEVERE, "[Quests] Failed to load Quest \"" + s + "\". Skipping.");
@ -3357,7 +3421,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
try { try {
config.load(eventsFile); config.load(eventsFile);
} catch (Exception e) { } catch (IOException e) {
e.printStackTrace();
} catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -3485,7 +3551,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
return parsed; return parsed;
} }
private boolean setupEconomy() { private boolean setupEconomy() {
@ -3531,8 +3596,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}); });
Map<String, Integer> sortedMap = new LinkedHashMap<String, Integer>(); Map<String, Integer> sortedMap = new LinkedHashMap<String, Integer>();
for (Iterator<Entry<String, Integer>> it = list.iterator(); it.hasNext();) { for (Entry<String, Integer> entry : list) {
Entry<String, Integer> entry = it.next();
sortedMap.put(entry.getKey(), entry.getValue()); sortedMap.put(entry.getKey(), entry.getValue());
} }
return sortedMap; return sortedMap;
@ -3575,12 +3639,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} }
return playerAmount >= is.getAmount();
if (playerAmount >= is.getAmount()) {
return true;
} else {
return false;
}
} }
@ -3599,7 +3658,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
x = Double.parseDouble(info[1]); x = Double.parseDouble(info[1]);
y = Double.parseDouble(info[2]); y = Double.parseDouble(info[2]);
z = Double.parseDouble(info[3]); z = Double.parseDouble(info[3]);
} catch (Exception e) { } catch (NumberFormatException e) {
return null; return null;
} }
@ -3782,7 +3841,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
public static String getTime(long milliseconds) { public static String getTime(long milliseconds) {
String message = ""; String message = "";
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
@ -3912,7 +3970,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
return null; return null;
} }
return new PotionEffect(potionType, duration, amplifier); return new PotionEffect(potionType, duration, amplifier);
} }
@ -3935,6 +3992,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
return SkillType.MINING; return SkillType.MINING;
} else if (s.equalsIgnoreCase("Repair")) { } else if (s.equalsIgnoreCase("Repair")) {
return SkillType.REPAIR; return SkillType.REPAIR;
} else if (s.equalsIgnoreCase("Smelting")) {
return SkillType.SMELTING;
} else if (s.equalsIgnoreCase("Swords")) { } else if (s.equalsIgnoreCase("Swords")) {
return SkillType.SWORDS; return SkillType.SWORDS;
} else if (s.equalsIgnoreCase("Taming")) { } else if (s.equalsIgnoreCase("Taming")) {
@ -4053,37 +4112,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (check.endsWith("*") && check.startsWith("*") == false) { if (check.endsWith("*") && check.startsWith("*") == false) {
check = check.substring(0, check.length()); check = check.substring(0, check.length());
if (name.endsWith(check)) { return name.endsWith(check);
return true;
} else {
return false;
}
} else if (check.endsWith("*") == false && check.startsWith("*")) { } else if (check.endsWith("*") == false && check.startsWith("*")) {
check = check.substring(1); check = check.substring(1);
if (name.startsWith(check)) { return name.startsWith(check);
return true;
} else {
return false;
}
} else if (check.endsWith("*") && check.startsWith("*")) { } else if (check.endsWith("*") && check.startsWith("*")) {
check = check.substring(1, check.length()); check = check.substring(1, check.length());
if (name.contains(check)) { return name.contains(check);
return true;
} else {
return false;
}
} else { } else {
return name.equalsIgnoreCase(check);
if (name.equalsIgnoreCase(check)) {
return true;
} else {
return false;
}
} }
@ -4478,12 +4520,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
String name = getServer().getServerName().replaceAll("'", "''").replaceAll("\"", "''"); String name = getServer().getServerName().replaceAll("'", "''").replaceAll("\"", "''");
String motd = getServer().getMotd().replaceAll("'", "''").replaceAll("\"", "''"); String motd = getServer().getMotd().replaceAll("'", "''").replaceAll("\"", "''");
String ip = getServer().getIp().trim(); String ip = getServer().getIp().trim();
if(ip.isEmpty()) if (ip.isEmpty()) {
ip = "localhost"; ip = "localhost";
}
String port = ((Integer) getServer().getPort()).toString(); String port = ((Integer) getServer().getPort()).toString();
statement.executeUpdate("INSERT INTO entries VALUES ('" + ip + ":" + port + "', '" + name + "', '" + motd + "', " + quests.size() + ", '" + cit + "', '" + stamp.toString() + "')"); statement.executeUpdate("INSERT INTO entries VALUES ('" + ip + ":" + port + "', '" + name + "', '" + motd + "', " + quests.size() + ", '" + cit + "', '" + stamp.toString() + "')");
} catch (Exception e) { } catch (ClassNotFoundException e) {
} catch (IllegalAccessException e) {
} catch (InstantiationException e) {
} catch (SQLException e) {
} }
} }
@ -4516,4 +4562,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
return null; return null;
} }
public static int getMCMMOSkillLevel(SkillType st, String player) {
McMMOPlayer mPlayer = UserManager.getPlayer(player);
if (mPlayer == null) {
return -1;
}
return mPlayer.getProfile().getSkillLevel(st);
}
} }

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";
}
} }
text += GREEN + "" + BOLD + "8" + RESET + YELLOW + " - Done"; } else {
text += GRAY + "6 - Set mcMMO requirements (mcMMO not installed)\n";
}
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
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,15 +291,13 @@ 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) {
@ -286,7 +306,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
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);
@ -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;
}
}