mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-22 00:58:55 +01:00
Added mcMMO requirement support
Cleaned up some code
This commit is contained in:
parent
2f73f6f6cc
commit
3b654100f1
@ -1,6 +1,7 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -12,6 +13,7 @@ import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -307,7 +309,9 @@ public class Event {
|
||||
FileConfiguration data = new YamlConfiguration();
|
||||
try {
|
||||
data.load(new File(plugin.getDataFolder(), "events.yml"));
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
@ -22,6 +23,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.conversations.ConversationAbandonedListener;
|
||||
@ -898,7 +900,11 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
try{
|
||||
eventsFile = new File(quests.getDataFolder(), "events.yml");
|
||||
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();
|
||||
((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile"));
|
||||
return;
|
||||
@ -910,7 +916,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
try{
|
||||
data.save(eventsFile);
|
||||
}catch (Exception e){
|
||||
}catch (IOException e){
|
||||
((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving"));
|
||||
return;
|
||||
}
|
||||
@ -934,7 +940,11 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
try{
|
||||
eventsFile = new File(quests.getDataFolder(), "events.yml");
|
||||
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();
|
||||
((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile"));
|
||||
return;
|
||||
@ -1098,7 +1108,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
try{
|
||||
data.save(eventsFile);
|
||||
}catch (Exception e){
|
||||
}catch (IOException e){
|
||||
((Player)context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving"));
|
||||
return;
|
||||
}
|
||||
@ -1922,10 +1932,10 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
}
|
||||
} else {
|
||||
LinkedList<String> types = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES);
|
||||
int inp = -1;
|
||||
int inp;
|
||||
try {
|
||||
inp = Integer.parseInt(input);
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorNotANumber"));
|
||||
return new MobPrompt();
|
||||
}
|
||||
@ -1953,7 +1963,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
private QuestMob questMob;
|
||||
private Integer itemIndex = -1;
|
||||
private Integer mobIndex;
|
||||
private final Integer mobIndex;
|
||||
|
||||
public QuestMobPrompt(int mobIndex, QuestMob questMob) {
|
||||
this.questMob = questMob;
|
||||
@ -2081,8 +2091,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
private class MobNamePrompt extends StringPrompt {
|
||||
|
||||
private QuestMob questMob;
|
||||
private Integer mobIndex;
|
||||
private final QuestMob questMob;
|
||||
private final Integer mobIndex;
|
||||
|
||||
public MobNamePrompt (int mobIndex, QuestMob questMob) {
|
||||
this.questMob = questMob;
|
||||
@ -2113,8 +2123,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
private class MobTypePrompt extends StringPrompt {
|
||||
|
||||
private QuestMob questMob;
|
||||
private Integer mobIndex;
|
||||
private final QuestMob questMob;
|
||||
private final Integer mobIndex;
|
||||
|
||||
public MobTypePrompt (int mobIndex, QuestMob questMob) {
|
||||
this.questMob = questMob;
|
||||
@ -2178,8 +2188,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
private class MobAmountPrompt extends StringPrompt {
|
||||
|
||||
private QuestMob questMob;
|
||||
private Integer mobIndex;
|
||||
private final QuestMob questMob;
|
||||
private final Integer mobIndex;
|
||||
|
||||
public MobAmountPrompt (int mobIndex, QuestMob questMob) {
|
||||
this.questMob = questMob;
|
||||
@ -2211,7 +2221,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
questMob.setSpawnAmounts(i);
|
||||
return new QuestMobPrompt(mobIndex, questMob);
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(PINK + input + " " + RED + Lang.get("eventEditorNotANumber"));
|
||||
return new MobAmountPrompt(mobIndex, questMob);
|
||||
}
|
||||
@ -2225,8 +2235,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
private class MobLocationPrompt extends StringPrompt {
|
||||
|
||||
private QuestMob questMob;
|
||||
private Integer mobIndex;
|
||||
private final QuestMob questMob;
|
||||
private final Integer mobIndex;
|
||||
|
||||
public MobLocationPrompt (int mobIndex, QuestMob questMob) {
|
||||
this.questMob = questMob;
|
||||
@ -2276,9 +2286,9 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
private class MobDropPrompt extends StringPrompt {
|
||||
|
||||
private QuestMob questMob;
|
||||
private Integer mobIndex;
|
||||
private Integer invIndex;
|
||||
private final QuestMob questMob;
|
||||
private final Integer mobIndex;
|
||||
private final Integer invIndex;
|
||||
|
||||
public MobDropPrompt (int invIndex, int mobIndex ,QuestMob questMob) {
|
||||
this.questMob = questMob;
|
||||
@ -2294,7 +2304,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
float chance = 0.0F;
|
||||
|
||||
float chance;
|
||||
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
return new QuestMobPrompt(mobIndex, questMob);
|
||||
@ -2302,7 +2313,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
|
||||
try {
|
||||
chance = Float.parseFloat(input);
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorInvalidDropChance"));
|
||||
return new MobDropPrompt(invIndex, mobIndex, questMob);
|
||||
}
|
||||
@ -2572,7 +2583,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
effDurations.add(l / 50L);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(PINK + s + " " + RED + Lang.get("eventEditorNotANumber"));
|
||||
return new PotionDurationsPrompt();
|
||||
}
|
||||
@ -2619,7 +2630,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
|
||||
magAmounts.add(i);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(PINK + s + " " + RED + Lang.get("eventEditorNotANumber"));
|
||||
return new PotionMagnitudesPrompt();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class ItemData {
|
||||
byte mdata = 0;
|
||||
try {
|
||||
id = Integer.parseInt(str[0]);
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
if (str.length > 1) {
|
||||
mdata = Byte.parseByte(str[1]);
|
||||
|
@ -44,7 +44,7 @@ public enum ParticleEffect {
|
||||
ICONCRACK("iconcrack_"),
|
||||
TILECRACK("tilecrack_");
|
||||
|
||||
private String particleName;
|
||||
private final String particleName;
|
||||
|
||||
ParticleEffect(String particleName) {
|
||||
this.particleName = particleName;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import me.ThaH3lper.com.Mobs.EpicMobs;
|
||||
import me.ThaH3lper.com.Mobs.MobCommon;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -19,6 +20,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.conversations.*;
|
||||
@ -788,7 +790,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
data.save(new File(quests.getDataFolder(), "quests.yml"));
|
||||
context.getForWhom().sendRawMessage(BOLD + Lang.get("questEditorSaved"));
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -873,13 +877,15 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
LinkedList<String> permReqs = null;
|
||||
LinkedList<String> questReqs = null;
|
||||
LinkedList<String> questBlocks = null;
|
||||
LinkedList<String> mcMMOSkillReqs = null;
|
||||
LinkedList<Integer> mcMMOAmountReqs = null;
|
||||
String failMessage = null;
|
||||
|
||||
Integer moneyRew = null;
|
||||
Integer questPointsRew = null;
|
||||
LinkedList<String> itemRews = new LinkedList<String>();
|
||||
LinkedList<Integer> RPGItemRews = new LinkedList<Integer>();
|
||||
LinkedList<Integer> RPGItemAmounts = new LinkedList<Integer>();
|
||||
LinkedList<String> itemRews = null;
|
||||
LinkedList<Integer> RPGItemRews = null;
|
||||
LinkedList<Integer> RPGItemAmounts = null;
|
||||
Integer expRew = null;
|
||||
LinkedList<String> commandRews = null;
|
||||
LinkedList<String> permRews = null;
|
||||
@ -926,6 +932,11 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
if (cc.getSessionData(CK.REQ_QUEST_BLOCK) != null) {
|
||||
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) {
|
||||
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) {
|
||||
itemRews = new LinkedList<String>();
|
||||
for (ItemStack is : (LinkedList<ItemStack>) cc.getSessionData(CK.REW_ITEMS)) {
|
||||
itemRews.add(ItemUtil.serialize(is));
|
||||
}
|
||||
@ -988,7 +1000,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
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");
|
||||
List<String> items = new LinkedList<String>();
|
||||
@ -1006,7 +1018,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
reqs.set("quest-points", questPointsReq);
|
||||
reqs.set("permissions", permReqs);
|
||||
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);
|
||||
|
||||
} else {
|
||||
@ -1404,11 +1418,21 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
if (q.blockQuests.isEmpty() == false) {
|
||||
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) {
|
||||
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) {
|
||||
cc.setSessionData(CK.Q_FAIL_MESSAGE, q.failRequirements);
|
||||
}
|
||||
@ -1852,7 +1876,11 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
|
||||
try {
|
||||
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();
|
||||
((Player) context.getForWhom()).sendMessage(ChatColor.RED + "Error reading Quests file.");
|
||||
return;
|
||||
@ -1872,7 +1900,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
|
||||
try {
|
||||
data.save(questsFile);
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
((Player) context.getForWhom()).sendMessage(ChatColor.RED + "An error occurred while saving.");
|
||||
return;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
@ -10,6 +11,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -519,140 +521,55 @@ public class Quester {
|
||||
}
|
||||
|
||||
if (s.equalsIgnoreCase("damageBlock")) {
|
||||
|
||||
if (currentStage.blocksToDamage.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.blocksToDamage.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("breakBlock")) {
|
||||
|
||||
if (currentStage.blocksToBreak.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.blocksToBreak.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("placeBlock")) {
|
||||
|
||||
if (currentStage.blocksToPlace.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.blocksToPlace.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("useBlock")) {
|
||||
|
||||
if (currentStage.blocksToUse.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.blocksToUse.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("cutBlock")) {
|
||||
|
||||
if (currentStage.blocksToCut.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.blocksToCut.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("catchFish")) {
|
||||
|
||||
if (currentStage.fishToCatch == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return currentStage.fishToCatch != null;
|
||||
|
||||
} else if (s.equalsIgnoreCase("enchantItem")) {
|
||||
|
||||
if (currentStage.itemsToEnchant.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.itemsToEnchant.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("killMob")) {
|
||||
|
||||
if (currentStage.mobsToKill.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.mobsToKill.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("deliverItem")) {
|
||||
|
||||
if (currentStage.itemsToDeliver.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.itemsToDeliver.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("killPlayer")) {
|
||||
|
||||
if (currentStage.playersToKill == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return currentStage.playersToKill != null;
|
||||
|
||||
} else if (s.equalsIgnoreCase("talkToNPC")) {
|
||||
|
||||
if (currentStage.citizensToInteract.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.citizensToInteract.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("killNPC")) {
|
||||
|
||||
if (currentStage.citizensToKill.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.citizensToKill.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("killBoss")) {
|
||||
|
||||
if (currentStage.bossesToKill.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.bossesToKill.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("tameMob")) {
|
||||
|
||||
if (currentStage.mobsToTame.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.mobsToTame.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("shearSheep")) {
|
||||
|
||||
if (currentStage.sheepToShear.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.sheepToShear.isEmpty();
|
||||
|
||||
} else if (s.equalsIgnoreCase("craftItem")) {
|
||||
|
||||
if (currentStage.itemsToCraft.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.itemsToCraft.isEmpty();
|
||||
|
||||
} else {
|
||||
|
||||
if (currentStage.locationsToReach.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return !currentStage.locationsToReach.isEmpty();
|
||||
|
||||
}
|
||||
|
||||
@ -1643,7 +1560,7 @@ public class Quester {
|
||||
FileConfiguration data = getBaseData();
|
||||
try {
|
||||
data.save(new File(plugin.getDataFolder(), "data/" + name + ".yml"));
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -2029,7 +1946,9 @@ public class Quester {
|
||||
FileConfiguration data = new YamlConfiguration();
|
||||
try {
|
||||
data.load(new File(plugin.getDataFolder(), "data/" + name + ".yml"));
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
} catch (InvalidConfigurationException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2651,10 +2570,7 @@ public class Quester {
|
||||
if(questPoints > 1)
|
||||
return true;
|
||||
|
||||
if(completedQuests.isEmpty() == false)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return completedQuests.isEmpty() == false;
|
||||
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -577,7 +577,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new BreakBlockIdsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(RED + Lang.get("stageEditorNotListofNumbers") + "\n" + PINK + s);
|
||||
return new BreakBlockIdsPrompt();
|
||||
}
|
||||
@ -618,7 +618,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new BreakBlockAmountsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new BreakBlockAmountsPrompt();
|
||||
}
|
||||
@ -768,7 +768,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new DamageBlockIdsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new DamageBlockIdsPrompt();
|
||||
}
|
||||
@ -809,7 +809,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new DamageBlockAmountsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new DamageBlockAmountsPrompt();
|
||||
}
|
||||
@ -959,7 +959,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new PlaceBlockIdsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new PlaceBlockIdsPrompt();
|
||||
}
|
||||
@ -1000,7 +1000,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new PlaceBlockAmountsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new PlaceBlockAmountsPrompt();
|
||||
}
|
||||
@ -1150,7 +1150,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new UseBlockIdsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new UseBlockIdsPrompt();
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new UseBlockAmountsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new UseBlockAmountsPrompt();
|
||||
}
|
||||
@ -1341,7 +1341,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new CutBlockIdsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new CutBlockIdsPrompt();
|
||||
}
|
||||
@ -1382,7 +1382,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new CutBlockAmountsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new CutBlockAmountsPrompt();
|
||||
}
|
||||
@ -1681,7 +1681,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new EnchantItemsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new EnchantItemsPrompt();
|
||||
}
|
||||
@ -1722,7 +1722,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new EnchantAmountsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new EnchantAmountsPrompt();
|
||||
}
|
||||
@ -1926,7 +1926,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new DeliveryNPCsPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new DeliveryNPCsPrompt();
|
||||
@ -1999,7 +1999,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new NPCIDsToTalkToPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new NPCIDsToTalkToPrompt();
|
||||
@ -2151,7 +2151,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new npcIdsToKillPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new npcIdsToKillPrompt();
|
||||
@ -2194,7 +2194,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
return new npcAmountsToKillPrompt();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage( PINK + s + RED + Lang.get("stageEditorNotListofNumbers"));
|
||||
return new npcAmountsToKillPrompt();
|
||||
}
|
||||
@ -2534,7 +2534,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
mobAmounts.add(i);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber"));
|
||||
return new MobAmountsPrompt();
|
||||
}
|
||||
@ -2632,7 +2632,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
radii.add(i);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidItemID"));
|
||||
return new MobRadiiPrompt();
|
||||
}
|
||||
@ -2895,7 +2895,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
radii.add(i);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber"));
|
||||
return new ReachRadiiPrompt();
|
||||
}
|
||||
@ -3139,7 +3139,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
mobAmounts.add(i);
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber"));
|
||||
return new TameAmountsPrompt();
|
||||
}
|
||||
@ -3345,7 +3345,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
shearAmounts.add(i);
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(PINK + input + " " + RED + Lang.get("stageEditorInvalidNumber"));
|
||||
return new ShearAmountsPrompt();
|
||||
}
|
||||
@ -3810,7 +3810,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
l = Long.parseLong(input);
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(YELLOW + Lang.get("stageEditorNoNumber"));
|
||||
return new DelayPrompt();
|
||||
}
|
||||
@ -4084,7 +4084,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
amountList.add(i);
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(RED + amount + " " + Lang.get("stageEditorInvalidNumber"));
|
||||
return new EpicBossAmountListPrompt();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.blackvein.quests.prompts;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -236,7 +237,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
}catch(NumberFormatException e){
|
||||
try {
|
||||
Data data = ItemData.getInstance().getItem(input);
|
||||
if (data == null) {
|
||||
@ -288,7 +289,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
}catch(NumberFormatException e){
|
||||
cc.getForWhom().sendRawMessage(RED + "Invalid input!");
|
||||
return new AmountPrompt();
|
||||
}
|
||||
@ -324,7 +325,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
}catch(NumberFormatException e){
|
||||
cc.getForWhom().sendRawMessage(RED + "Invalid input!");
|
||||
return new DataPrompt();
|
||||
}
|
||||
@ -421,7 +422,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
}catch (NumberFormatException e){
|
||||
cc.getForWhom().sendRawMessage(RED + "Input was not a number!");
|
||||
e.printStackTrace();
|
||||
return new LevelPrompt(enchantment);
|
||||
@ -476,8 +477,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
input = Quests.parseString(input);
|
||||
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
for(String line : input.split(";"))
|
||||
lore.add(line);
|
||||
lore.addAll(Arrays.asList(input.split(";")));
|
||||
cc.setSessionData("tempLore", lore);
|
||||
|
||||
}else if(input.equalsIgnoreCase("clear")){
|
||||
|
@ -56,7 +56,7 @@ public class QuestAcceptPrompt extends StringPrompt implements ColorUtil {
|
||||
int numInput = -1;
|
||||
try {
|
||||
numInput = Integer.parseInt(input);
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException e) {
|
||||
//Continue
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.util.CK;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import me.blackvein.quests.util.MiscUtil;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.FixedSetPrompt;
|
||||
@ -21,91 +22,110 @@ import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
Quests quests;
|
||||
|
||||
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;
|
||||
factory = qf;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context){
|
||||
public String getPromptText(ConversationContext context) {
|
||||
|
||||
String text;
|
||||
|
||||
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";
|
||||
else{
|
||||
} else {
|
||||
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";
|
||||
}
|
||||
|
||||
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";
|
||||
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 + "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";
|
||||
else{
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set permission requirements\n";
|
||||
List<String> perms = (List<String>) context.getSessionData(CK.REQ_PERMISSION);
|
||||
|
||||
for(String s : perms){
|
||||
for (String s : perms) {
|
||||
|
||||
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";
|
||||
else{
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set Quest requirements\n";
|
||||
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST);
|
||||
|
||||
for(String s : qs){
|
||||
for (String s : qs) {
|
||||
|
||||
text += GRAY + " - " + AQUA + s + "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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";
|
||||
else{
|
||||
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest requirements\n";
|
||||
if (context.getSessionData(CK.REQ_QUEST_BLOCK) == null) {
|
||||
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest blocks " + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest blocks\n";
|
||||
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK);
|
||||
|
||||
for(String s : qs){
|
||||
for (String s : qs) {
|
||||
|
||||
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){
|
||||
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";
|
||||
}else{
|
||||
text += BLUE + "" + BOLD + "7 - " + RESET + YELLOW + "Set fail requirements message" + GRAY + "(" + AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + GRAY + ")\n";
|
||||
if (Quests.mcmmo != null) {
|
||||
|
||||
|
||||
if (context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
|
||||
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set mcMMO requirements " + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set mcMMO requirements\n";
|
||||
List<String> skills = (List<String>) context.getSessionData(CK.REQ_MCMMO_SKILLS);
|
||||
List<Integer> amounts = (List<Integer>) context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS);
|
||||
|
||||
for (String s : skills) {
|
||||
text += GRAY + " - " + DARKGREEN + s + RESET + YELLOW + " level " + GREEN + amounts.get(skills.indexOf(s)) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
text += GRAY + "6 - Set mcMMO requirements (mcMMO not installed)\n";
|
||||
}
|
||||
|
||||
text += GREEN + "" + BOLD + "8" + RESET + YELLOW + " - Done";
|
||||
|
||||
|
||||
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
|
||||
text += GRAY + "" + BOLD + "8 - " + RESET + GRAY + "Set fail requirements message (No requirements set)\n";
|
||||
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
|
||||
text += RED + "" + BOLD + "8 - " + RESET + RED + "Set fail requirements message (Required)\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "8 - " + RESET + YELLOW + "Set fail requirements message" + GRAY + "(" + AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + GRAY + ")\n";
|
||||
}
|
||||
|
||||
text += GREEN + "" + BOLD + "9" + RESET + YELLOW + " - Done";
|
||||
|
||||
|
||||
return text;
|
||||
@ -113,26 +133,31 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
}
|
||||
|
||||
@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();
|
||||
}else if(input.equalsIgnoreCase("2")){
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
return new QuestPointsPrompt();
|
||||
}else if(input.equalsIgnoreCase("3")){
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
return new ItemListPrompt();
|
||||
}else if(input.equalsIgnoreCase("4")){
|
||||
} else if (input.equalsIgnoreCase("4")) {
|
||||
return new PermissionsPrompt();
|
||||
}else if(input.equalsIgnoreCase("5")){
|
||||
} else if (input.equalsIgnoreCase("5")) {
|
||||
return new QuestListPrompt(true);
|
||||
}else if(input.equalsIgnoreCase("6")) {
|
||||
return new QuestListPrompt(false);
|
||||
}else if(input.equalsIgnoreCase("7")){
|
||||
} else if (input.equalsIgnoreCase("6")) {
|
||||
return new QuestListPrompt(false);
|
||||
} 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();
|
||||
}else if(input.equalsIgnoreCase("8")){
|
||||
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){
|
||||
} 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 || 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!");
|
||||
return new RequirementsPrompt(quests, factory);
|
||||
}
|
||||
@ -148,21 +173,21 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
private class MoneyPrompt extends NumericPrompt {
|
||||
|
||||
@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";
|
||||
|
||||
}
|
||||
|
||||
@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!");
|
||||
return new MoneyPrompt();
|
||||
}else if(input.intValue() == -1){
|
||||
} else if (input.intValue() == -1) {
|
||||
return new RequirementsPrompt(quests, factory);
|
||||
}else if(input.intValue() == 0){
|
||||
} else if (input.intValue() == 0) {
|
||||
context.setSessionData(CK.REQ_MONEY, null);
|
||||
return new RequirementsPrompt(quests, factory);
|
||||
}
|
||||
@ -171,27 +196,26 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
return new RequirementsPrompt(quests, factory);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class QuestPointsPrompt extends NumericPrompt {
|
||||
|
||||
@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";
|
||||
|
||||
}
|
||||
|
||||
@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!");
|
||||
return new QuestPointsPrompt();
|
||||
}else if(input.intValue() == -1){
|
||||
} else if (input.intValue() == -1) {
|
||||
return new RequirementsPrompt(quests, factory);
|
||||
}else if(input.intValue() == 0){
|
||||
} else if (input.intValue() == 0) {
|
||||
context.setSessionData(CK.REQ_QUEST_POINTS, null);
|
||||
return new RequirementsPrompt(quests, factory);
|
||||
}
|
||||
@ -200,37 +224,35 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
return new RequirementsPrompt(quests, factory);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class QuestListPrompt extends StringPrompt {
|
||||
|
||||
private boolean isRequiredQuest;
|
||||
private final boolean isRequiredQuest;
|
||||
|
||||
/*public QuestListPrompt() {
|
||||
this.isRequiredQuest = true;
|
||||
}*/
|
||||
|
||||
public QuestListPrompt(boolean isRequired) {
|
||||
this.isRequiredQuest = isRequired;
|
||||
}
|
||||
/*public QuestListPrompt() {
|
||||
this.isRequiredQuest = true;
|
||||
}*/
|
||||
public QuestListPrompt(boolean isRequired) {
|
||||
this.isRequiredQuest = isRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context){
|
||||
public String getPromptText(ConversationContext context) {
|
||||
|
||||
String text = PINK + "- Quests -\n" + PURPLE;
|
||||
|
||||
boolean none = true;
|
||||
for(Quest q : quests.getQuests()){
|
||||
for (Quest q : quests.getQuests()) {
|
||||
|
||||
text += q.getName() + ", ";
|
||||
none = false;
|
||||
|
||||
}
|
||||
|
||||
if(none)
|
||||
if (none) {
|
||||
text += "(None)\n";
|
||||
else{
|
||||
} else {
|
||||
text = text.substring(0, (text.length() - 2));
|
||||
text += "\n";
|
||||
}
|
||||
@ -242,23 +264,23 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
}
|
||||
|
||||
@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(",");
|
||||
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!");
|
||||
return new QuestListPrompt(isRequiredQuest);
|
||||
|
||||
}
|
||||
|
||||
if(questNames.contains(s)){
|
||||
if (questNames.contains(s)) {
|
||||
|
||||
context.getForWhom().sendRawMessage(RED + "List contains duplicates!");
|
||||
return new QuestListPrompt(isRequiredQuest);
|
||||
@ -269,29 +291,27 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
|
||||
}
|
||||
|
||||
Collections.sort(questNames, new Comparator<String>(){
|
||||
|
||||
Collections.sort(questNames, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String one, String two){
|
||||
public int compare(String one, String two) {
|
||||
|
||||
return one.compareTo(two);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (isRequiredQuest) {
|
||||
context.setSessionData(CK.REQ_QUEST, questNames);
|
||||
context.setSessionData(CK.REQ_QUEST, questNames);
|
||||
} else {
|
||||
context.setSessionData(CK.REQ_QUEST_BLOCK, questNames);
|
||||
context.setSessionData(CK.REQ_QUEST_BLOCK, questNames);
|
||||
}
|
||||
|
||||
}else if(input.equalsIgnoreCase("clear")){
|
||||
} else if (input.equalsIgnoreCase("clear")) {
|
||||
|
||||
if (isRequiredQuest) {
|
||||
context.setSessionData(CK.REQ_QUEST, null);
|
||||
if (isRequiredQuest) {
|
||||
context.setSessionData(CK.REQ_QUEST, null);
|
||||
} else {
|
||||
context.setSessionData(CK.REQ_QUEST_BLOCK, null);
|
||||
context.setSessionData(CK.REQ_QUEST_BLOCK, null);
|
||||
}
|
||||
|
||||
}
|
||||
@ -299,27 +319,26 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
return new RequirementsPrompt(quests, factory);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ItemListPrompt extends FixedSetPrompt {
|
||||
|
||||
public ItemListPrompt(){
|
||||
public ItemListPrompt() {
|
||||
|
||||
super("1", "2", "3", "4");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context){
|
||||
public String getPromptText(ConversationContext context) {
|
||||
|
||||
// Check/add newly made item
|
||||
if(context.getSessionData("newItem") != null){
|
||||
if(context.getSessionData(CK.REQ_ITEMS) != null){
|
||||
if (context.getSessionData("newItem") != null) {
|
||||
if (context.getSessionData(CK.REQ_ITEMS) != null) {
|
||||
List<ItemStack> itemRews = getItems(context);
|
||||
itemRews.add((ItemStack) context.getSessionData("tempStack"));
|
||||
context.setSessionData(CK.REQ_ITEMS, itemRews);
|
||||
}else{
|
||||
} else {
|
||||
LinkedList<ItemStack> itemRews = new LinkedList<ItemStack>();
|
||||
itemRews.add((ItemStack) context.getSessionData("tempStack"));
|
||||
context.setSessionData(CK.REQ_ITEMS, itemRews);
|
||||
@ -331,14 +350,14 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
}
|
||||
|
||||
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 += GRAY + "2 - Set remove items (No items set)\n";
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Clear\n";
|
||||
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";
|
||||
|
||||
@ -347,12 +366,12 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
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";
|
||||
}else{
|
||||
} else {
|
||||
|
||||
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";
|
||||
|
||||
@ -370,40 +389,42 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
}
|
||||
|
||||
@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);
|
||||
}else if(input.equalsIgnoreCase("2")){
|
||||
if(context.getSessionData(CK.REQ_ITEMS) == null){
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
if (context.getSessionData(CK.REQ_ITEMS) == null) {
|
||||
context.getForWhom().sendRawMessage(RED + "You must add at least one item first!");
|
||||
return new ItemListPrompt();
|
||||
}else{
|
||||
} else {
|
||||
return new RemoveItemsPrompt();
|
||||
}
|
||||
}else if(input.equalsIgnoreCase("3")){
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
context.getForWhom().sendRawMessage(YELLOW + "Item requirements cleared.");
|
||||
context.setSessionData(CK.REQ_ITEMS, null);
|
||||
context.setSessionData(CK.REQ_ITEMS_REMOVE, null);
|
||||
return new ItemListPrompt();
|
||||
}else if(input.equalsIgnoreCase("4")){
|
||||
} else if (input.equalsIgnoreCase("4")) {
|
||||
|
||||
int one;
|
||||
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();
|
||||
else
|
||||
} else {
|
||||
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();
|
||||
else
|
||||
} else {
|
||||
two = 0;
|
||||
}
|
||||
|
||||
if(one == two)
|
||||
if (one == two) {
|
||||
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!");
|
||||
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);
|
||||
}
|
||||
|
||||
private List<Boolean> getRemoveItems(ConversationContext context){
|
||||
private List<Boolean> getRemoveItems(ConversationContext context) {
|
||||
return (List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class RemoveItemsPrompt extends StringPrompt {
|
||||
|
||||
@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.";
|
||||
}
|
||||
|
||||
@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(" ");
|
||||
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);
|
||||
else if(s.equalsIgnoreCase("false") || s.equalsIgnoreCase("no"))
|
||||
} else if (s.equalsIgnoreCase("false") || s.equalsIgnoreCase("no")) {
|
||||
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");
|
||||
return new RemoveItemsPrompt();
|
||||
}
|
||||
@ -457,21 +477,19 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
return new ItemListPrompt();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private class PermissionsPrompt extends StringPrompt {
|
||||
|
||||
@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.";
|
||||
}
|
||||
|
||||
@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(" ");
|
||||
LinkedList<String> permissions = new LinkedList<String>();
|
||||
@ -479,33 +497,195 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
|
||||
context.setSessionData(CK.REQ_PERMISSION, permissions);
|
||||
|
||||
}else if(input.equalsIgnoreCase("clear")){
|
||||
} else if (input.equalsIgnoreCase("clear")) {
|
||||
context.setSessionData(CK.REQ_PERMISSION, null);
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context){
|
||||
public String getPromptText(ConversationContext context) {
|
||||
return YELLOW + "Enter fail requirements message, or enter \'cancel\' to return.";
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
return new RequirementsPrompt(quests, factory);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
return new RPGItemIdsPrompt();
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
}catch (NumberFormatException e){
|
||||
|
||||
RPGItem item = ItemManager.getItemByName(s);
|
||||
|
||||
@ -491,7 +491,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
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!");
|
||||
return new RPGItemAmountsPrompt();
|
||||
}
|
||||
@ -700,6 +700,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
AQUA + "Herbalism\n" +
|
||||
AQUA + "Mining\n" +
|
||||
AQUA + "Repair\n" +
|
||||
AQUA + "Smelting\n" +
|
||||
AQUA + "Swords\n" +
|
||||
AQUA + "Taming\n" +
|
||||
AQUA + "Unarmed\n" +
|
||||
@ -769,7 +770,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
|
||||
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!");
|
||||
return new mcMMOAmountsPrompt();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class StagesPrompt extends StringPrompt implements ColorUtil{
|
||||
|
||||
i = Integer.parseInt(string);
|
||||
|
||||
}catch(Exception e){
|
||||
}catch(NumberFormatException e){
|
||||
return new StagesPrompt(questFactory);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ public class CK {
|
||||
public static final String REQ_ITEMS = "itemReqs";
|
||||
public static final String REQ_ITEMS_REMOVE = "removeItemReqs";
|
||||
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_BLOCK= "questBlocks";
|
||||
|
||||
|
20
src/main/java/me/blackvein/quests/util/MiscUtil.java
Normal file
20
src/main/java/me/blackvein/quests/util/MiscUtil.java
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user