mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-28 21:56:28 +01:00
Finished Custom Requirement API
This commit is contained in:
parent
360c0c6291
commit
4685a169b9
Binary file not shown.
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<groupId>me.blackvein.quests</groupId>
|
<groupId>me.blackvein.quests</groupId>
|
||||||
<artifactId>quests</artifactId>
|
<artifactId>quests</artifactId>
|
||||||
<version>1.7.2-SNAPSHOT</version>
|
<version>1.7.3-SNAPSHOT</version>
|
||||||
<name>quests</name>
|
<name>quests</name>
|
||||||
<url>http://dev.bukkit.org/server-mods/quests/</url>
|
<url>http://dev.bukkit.org/server-mods/quests/</url>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
package me.blackvein.quests;
|
package me.blackvein.quests;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public abstract class CustomRequirement {
|
public abstract class CustomRequirement {
|
||||||
|
|
||||||
private String name = null;
|
private String name = null;
|
||||||
private String author = null;
|
private String author = null;
|
||||||
|
public final Map<String,Object> datamap = new HashMap<String, Object>();
|
||||||
|
public final Map<String, String> descriptions = new HashMap<String, String>();
|
||||||
|
|
||||||
public abstract boolean testRequirement(Player p);
|
public abstract boolean testRequirement(Player p, Map<String, Object> m);
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@ -25,4 +29,12 @@ public abstract class CustomRequirement {
|
|||||||
this.author = author;
|
this.author = author;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setData(String key, Object val) {
|
||||||
|
datamap.put(key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String key, String description){
|
||||||
|
descriptions.put(key, description);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,12 @@ import com.gmail.nossr50.util.player.UserManager;
|
|||||||
import com.herocraftonline.heroes.characters.Hero;
|
import com.herocraftonline.heroes.characters.Hero;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import me.blackvein.quests.exceptions.InvalidStageException;
|
import me.blackvein.quests.exceptions.InvalidStageException;
|
||||||
import me.blackvein.quests.util.ItemUtil;
|
import me.blackvein.quests.util.ItemUtil;
|
||||||
@ -52,7 +54,7 @@ public class Quest {
|
|||||||
List<Integer> mcMMOAmountReqs = new LinkedList<Integer>();
|
List<Integer> mcMMOAmountReqs = new LinkedList<Integer>();
|
||||||
String heroesPrimaryClassReq = null;
|
String heroesPrimaryClassReq = null;
|
||||||
String heroesSecondaryClassReq = null;
|
String heroesSecondaryClassReq = null;
|
||||||
List<String> customRequirements = new LinkedList<String>();
|
Map<String, Map<String, Object>> customRequirements = new HashMap<String, Map<String, Object>>();
|
||||||
public String failRequirements = null;
|
public String failRequirements = null;
|
||||||
//
|
//
|
||||||
//Rewards
|
//Rewards
|
||||||
@ -226,7 +228,7 @@ public class Quest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String s : customRequirements){
|
for (String s : customRequirements.keySet()){
|
||||||
|
|
||||||
CustomRequirement found = null;
|
CustomRequirement found = null;
|
||||||
for(CustomRequirement cr : plugin.customRequirements){
|
for(CustomRequirement cr : plugin.customRequirements){
|
||||||
@ -237,7 +239,7 @@ public class Quest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(found != null){
|
if(found != null){
|
||||||
if(found.testRequirement(player) == false)
|
if(found.testRequirement(player, customRequirements.get(s)) == false)
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
Quests.printWarning("[Quests] Quester \"" + player.getName() + "\" attempted to take Quest \"" + name + "\", but the Custom Requirement \"" + s + "\" could not be found. Does it still exist?");
|
Quests.printWarning("[Quests] Quester \"" + player.getName() + "\" attempted to take Quest \"" + name + "\", but the Custom Requirement \"" + s + "\" could not be found. Does it still exist?");
|
||||||
|
@ -1021,6 +1021,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
|||||||
String heroesPrimaryReq = null;
|
String heroesPrimaryReq = null;
|
||||||
String heroesSecondaryReq = null;
|
String heroesSecondaryReq = null;
|
||||||
LinkedList<String> customReqs = null;
|
LinkedList<String> customReqs = null;
|
||||||
|
LinkedList<Map<String, Object>> customReqsData = null;
|
||||||
String failMessage = null;
|
String failMessage = null;
|
||||||
|
|
||||||
Integer moneyRew = null;
|
Integer moneyRew = null;
|
||||||
@ -1090,6 +1091,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
|||||||
|
|
||||||
if (cc.getSessionData(CK.REQ_CUSTOM) != null) {
|
if (cc.getSessionData(CK.REQ_CUSTOM) != null) {
|
||||||
customReqs = (LinkedList<String>) cc.getSessionData(CK.REQ_CUSTOM);
|
customReqs = (LinkedList<String>) cc.getSessionData(CK.REQ_CUSTOM);
|
||||||
|
customReqsData = (LinkedList<Map<String, Object>>) cc.getSessionData(CK.REQ_CUSTOM_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cc.getSessionData(CK.Q_FAIL_MESSAGE) != null) {
|
if (cc.getSessionData(CK.Q_FAIL_MESSAGE) != null) {
|
||||||
@ -1188,7 +1190,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
|||||||
reqs.set("mcmmo-amounts", mcMMOAmountReqs);
|
reqs.set("mcmmo-amounts", mcMMOAmountReqs);
|
||||||
reqs.set("heroes-primary-class", heroesPrimaryReq);
|
reqs.set("heroes-primary-class", heroesPrimaryReq);
|
||||||
reqs.set("heroes-secondary-class", heroesSecondaryReq);
|
reqs.set("heroes-secondary-class", heroesSecondaryReq);
|
||||||
reqs.set("custom-requirements", customReqs);
|
if(customReqs != null){
|
||||||
|
ConfigurationSection customReqsSec = reqs.createSection("custom-requirements");
|
||||||
|
for(int i = 0; i < customReqs.size(); i++){
|
||||||
|
ConfigurationSection customReqSec = customReqsSec.createSection("req" + (i + 1));
|
||||||
|
customReqSec.set("name", customReqs.get(i));
|
||||||
|
customReqSec.set("data", customReqsData.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
reqs.set("fail-requirement-message", failMessage);
|
reqs.set("fail-requirement-message", failMessage);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -1604,6 +1613,23 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
|||||||
if (q.failRequirements != null) {
|
if (q.failRequirements != null) {
|
||||||
cc.setSessionData(CK.Q_FAIL_MESSAGE, q.failRequirements);
|
cc.setSessionData(CK.Q_FAIL_MESSAGE, q.failRequirements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (q.customRequirements.isEmpty() == false) {
|
||||||
|
|
||||||
|
LinkedList<String> list = new LinkedList<String>();
|
||||||
|
LinkedList<Map<String, Object>> datamapList = new LinkedList<Map<String, Object>>();
|
||||||
|
|
||||||
|
for(Entry<String, Map<String, Object>> entry : q.customRequirements.entrySet()){
|
||||||
|
|
||||||
|
list.add(entry.getKey());
|
||||||
|
datamapList.add(entry.getValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cc.setSessionData(CK.REQ_CUSTOM, list);
|
||||||
|
cc.setSessionData(CK.REQ_CUSTOM_DATA, datamapList);
|
||||||
|
|
||||||
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
//Rewards
|
//Rewards
|
||||||
|
@ -455,7 +455,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
try{
|
try{
|
||||||
|
|
||||||
JarFile jarFile = new JarFile(jar);
|
JarFile jarFile = new JarFile(jar);
|
||||||
Enumeration<JarEntry> e = jarFile.entries();
|
Enumeration e = jarFile.entries();
|
||||||
|
|
||||||
URL[] urls = { new URL("jar:file:" + jar.getPath() + "!/") };
|
URL[] urls = { new URL("jar:file:" + jar.getPath() + "!/") };
|
||||||
|
|
||||||
@ -463,39 +463,24 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
|
|
||||||
while (e.hasMoreElements()) {
|
while (e.hasMoreElements()) {
|
||||||
|
|
||||||
JarEntry je = e.nextElement();
|
JarEntry je = (JarEntry) e.nextElement();
|
||||||
if(je.isDirectory() || !je.getName().endsWith(".class")){
|
if(je.isDirectory() || !je.getName().endsWith(".class")){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String className = je.getName().replaceAll("\\.class$", "");
|
String className = je.getName().substring(0,je.getName().length()-6);
|
||||||
className = className.replace('/', '.');
|
className = className.replace('/', '.');
|
||||||
|
Class<?> c = Class.forName(className, true, cl);
|
||||||
try {
|
Class<? extends CustomRequirement> requirementClass = c.asSubclass(CustomRequirement.class);
|
||||||
Class<?> c = Class.forName(className, true, cl);
|
Constructor<? extends CustomRequirement> cstrctr = requirementClass.getConstructor();
|
||||||
//If CustomRequirement.class is not the super class of 'c', continue.
|
CustomRequirement requirement = cstrctr.newInstance();
|
||||||
if (!CustomRequirement.class.isAssignableFrom(c)) {
|
customRequirements.add(requirement);
|
||||||
continue;
|
String name = requirement.getName() == null ? "[" + jar.getName() + "]" : requirement.getName();
|
||||||
}
|
String author = requirement.getAuthor() == null ? "[Unknown]" : requirement.getAuthor();
|
||||||
|
printInfo("[Quests] Loaded Module: " + name + " by " + author);
|
||||||
Class<? extends CustomRequirement> requirementClass = c.asSubclass(CustomRequirement.class);
|
|
||||||
CustomRequirement requirement = requirementClass.newInstance();
|
|
||||||
|
|
||||||
customRequirements.add(requirement);
|
|
||||||
|
|
||||||
String name = requirement.getName() == null ? "[" + jar.getName() + "]" : requirement.getName();
|
|
||||||
String author = requirement.getAuthor() == null ? "[Unknown]" : requirement.getAuthor();
|
|
||||||
printInfo("[Quests] Loaded Module: " + name + " by " + author);
|
|
||||||
|
|
||||||
} catch (Exception exception) {
|
|
||||||
//If this class fails to load, go to next class instead of failing the whole module.
|
|
||||||
printSevere("[Quests] Error: Unable to load module: " + className + " from file: " + jar.getName());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jarFile.close();
|
}catch (Exception e){
|
||||||
} catch (Exception e) {
|
|
||||||
printSevere("[Quests] Error: Unable to load module from file: " + jar.getName());
|
printSevere("[Quests] Error: Unable to load module from file: " + jar.getName());
|
||||||
if(debug){
|
if(debug){
|
||||||
printSevere("[Quests] Error log:");
|
printSevere("[Quests] Error log:");
|
||||||
@ -505,16 +490,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add custom requirements to Quests,
|
|
||||||
* @param requirement, the requirement that is to be added.
|
|
||||||
* @param plugin, the plugin that adds this requirement.
|
|
||||||
*/
|
|
||||||
public void addCustomRequirement(CustomRequirement requirement, Plugin plugin) {
|
|
||||||
customRequirements.add(requirement);
|
|
||||||
printInfo("[Quests] Loaded custom requirement from: " + plugin.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void printHelp(Player player) {
|
public void printHelp(Player player) {
|
||||||
|
|
||||||
player.sendMessage(GOLD + "- Quests -");
|
player.sendMessage(GOLD + "- Quests -");
|
||||||
@ -2303,24 +2278,37 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains("quests." + s + ".requirements.custom-requirements")) {
|
if (config.contains("quests." + s + ".requirements.custom-requirements")) {
|
||||||
quest.customRequirements = config.getStringList("quests." + s + ".requirements.custom-requirements");
|
|
||||||
|
|
||||||
for(String req : quest.customRequirements){
|
ConfigurationSection sec = config.getConfigurationSection("quests." + s + ".requirements.custom-requirements");
|
||||||
|
for(String path : sec.getKeys(false)){
|
||||||
|
|
||||||
|
String name = sec.getString(path + ".name");
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|
||||||
for(CustomRequirement cr : customRequirements){
|
for(CustomRequirement cr : customRequirements){
|
||||||
if(cr.getName().equalsIgnoreCase(req)){
|
if(cr.getName().equalsIgnoreCase(name)){
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!found){
|
if(!found){
|
||||||
printWarning("[Quests] Custom requirement \"" + req + "\" for Quest \"" + quest.name + "\" could not be found!");
|
printWarning("[Quests] Custom requirement \"" + name + "\" for Quest \"" + quest.name + "\" could not be found!");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, Object> data = new HashMap<String, Object>();
|
||||||
|
ConfigurationSection sec2 = sec.getConfigurationSection(path + ".data");
|
||||||
|
if(sec2 != null){
|
||||||
|
for(String dataPath : sec2.getKeys(false)){
|
||||||
|
data.put(dataPath, sec2.get(dataPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
quest.customRequirements.put(name, data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -4854,9 +4842,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
+ "&arg5=" + quests.size()
|
+ "&arg5=" + quests.size()
|
||||||
+ "&arg6=" + (citizens != null ? "true" : "false")
|
+ "&arg6=" + (citizens != null ? "true" : "false")
|
||||||
+ "&arg7=" + URLEncoder.encode(stamp.toString(), "UTF-8");
|
+ "&arg7=" + URLEncoder.encode(stamp.toString(), "UTF-8");
|
||||||
System.out.println("Arguments");
|
URL url = new URL("http://www.blackvein.net/php/quests.php?" + arguments);
|
||||||
System.out.println(arguments);
|
|
||||||
URL url = new URL("http://www.bcitdnd.net/php/quests.php?" + arguments);
|
|
||||||
URLConnection yc = url.openConnection();
|
URLConnection yc = url.openConnection();
|
||||||
BufferedReader in = new BufferedReader(
|
BufferedReader in = new BufferedReader(
|
||||||
new InputStreamReader(
|
new InputStreamReader(
|
||||||
@ -4880,9 +4866,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
String arguments = "arg1=" + getServer().getIp() + "&arg2=" + ((Integer) getServer().getPort()).toString();
|
String arguments = "arg1=" + getServer().getIp() + "&arg2=" + ((Integer) getServer().getPort()).toString();
|
||||||
URL url = new URL("http://www.bcitdnd.net/php/quests_del.php?" + arguments);
|
URL url = new URL("http://www.blackvein.net/php/quests_del.php?" + arguments);
|
||||||
System.out.println("Delete arguments");
|
|
||||||
System.out.println(arguments);
|
|
||||||
URLConnection yc = url.openConnection();
|
URLConnection yc = url.openConnection();
|
||||||
BufferedReader in = new BufferedReader(
|
BufferedReader in = new BufferedReader(
|
||||||
new InputStreamReader(
|
new InputStreamReader(
|
||||||
|
@ -6,6 +6,7 @@ import java.util.Collections;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import me.blackvein.quests.CustomRequirement;
|
import me.blackvein.quests.CustomRequirement;
|
||||||
|
|
||||||
import me.blackvein.quests.util.ColorUtil;
|
import me.blackvein.quests.util.ColorUtil;
|
||||||
@ -585,18 +586,32 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
|
|||||||
|
|
||||||
if(context.getSessionData(CK.REQ_CUSTOM) != null){
|
if(context.getSessionData(CK.REQ_CUSTOM) != null){
|
||||||
LinkedList<String> list = (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM);
|
LinkedList<String> list = (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM);
|
||||||
|
LinkedList<Map<String, Object>> datamapList = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA);
|
||||||
if(list.contains(found.getName()) == false){
|
if(list.contains(found.getName()) == false){
|
||||||
list.add(found.getName());
|
list.add(found.getName());
|
||||||
|
datamapList.add(found.datamap);
|
||||||
}else{
|
}else{
|
||||||
context.getForWhom().sendRawMessage(YELLOW + "That custom requirement has already been added!");
|
context.getForWhom().sendRawMessage(YELLOW + "That custom requirement has already been added!");
|
||||||
return new CustomRequirementsPrompt();
|
return new CustomRequirementsPrompt();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
LinkedList<Map<String, Object>> datamapList = new LinkedList<Map<String, Object>>();
|
||||||
|
datamapList.add(found.datamap);
|
||||||
LinkedList<String> list = new LinkedList<String>();
|
LinkedList<String> list = new LinkedList<String>();
|
||||||
list.add(found.getName());
|
list.add(found.getName());
|
||||||
context.setSessionData(CK.REQ_CUSTOM, list);
|
context.setSessionData(CK.REQ_CUSTOM, list);
|
||||||
|
context.setSessionData(CK.REQ_CUSTOM_DATA, datamapList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Send user to the custom data prompt if there is any needed
|
||||||
|
if(found.datamap.isEmpty() == false){
|
||||||
|
|
||||||
|
context.setSessionData(CK.REQ_CUSTOM_DATA_DESCRIPTIONS, found.descriptions);
|
||||||
|
return new RequirementCustomDataListPrompt();
|
||||||
|
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
context.getForWhom().sendRawMessage(YELLOW + "Custom requirement module not found.");
|
context.getForWhom().sendRawMessage(YELLOW + "Custom requirement module not found.");
|
||||||
return new CustomRequirementsPrompt();
|
return new CustomRequirementsPrompt();
|
||||||
@ -604,6 +619,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
|
|||||||
|
|
||||||
} else if (input.equalsIgnoreCase("clear")) {
|
} else if (input.equalsIgnoreCase("clear")) {
|
||||||
context.setSessionData(CK.REQ_CUSTOM, null);
|
context.setSessionData(CK.REQ_CUSTOM, null);
|
||||||
|
context.setSessionData(CK.REQ_CUSTOM_DATA, null);
|
||||||
context.getForWhom().sendRawMessage(YELLOW + "Custom requirements cleared.");
|
context.getForWhom().sendRawMessage(YELLOW + "Custom requirements cleared.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,6 +628,113 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RequirementCustomDataListPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
|
||||||
|
String text = BOLD + "" + AQUA + "- ";
|
||||||
|
|
||||||
|
LinkedList<String> list = (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM);
|
||||||
|
LinkedList<Map<String, Object>> datamapList = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA);
|
||||||
|
|
||||||
|
String reqName = list.getLast();
|
||||||
|
Map<String, Object> datamap = datamapList.getLast();
|
||||||
|
|
||||||
|
text += reqName + " -\n";
|
||||||
|
int index = 1;
|
||||||
|
|
||||||
|
LinkedList<String> datamapKeys = new LinkedList<String>();
|
||||||
|
for(String key : datamap.keySet())
|
||||||
|
datamapKeys.add(key);
|
||||||
|
Collections.sort(datamapKeys);
|
||||||
|
|
||||||
|
for(String dataKey : datamapKeys){
|
||||||
|
|
||||||
|
text += BOLD + "" + DARKBLUE + index + " - " + RESET + BLUE + dataKey;
|
||||||
|
if(datamap.get(dataKey) != null)
|
||||||
|
text += GREEN + " (" + (String) datamap.get(dataKey) + ")\n";
|
||||||
|
else
|
||||||
|
text += RED + " (Value required)\n";
|
||||||
|
|
||||||
|
index++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
text += BOLD + "" + DARKBLUE + index + " - " + AQUA + "Finish";
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
|
||||||
|
LinkedList<Map<String, Object>> datamapList = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA);
|
||||||
|
Map<String, Object> datamap = datamapList.getLast();
|
||||||
|
|
||||||
|
int numInput;
|
||||||
|
|
||||||
|
try{
|
||||||
|
numInput = Integer.parseInt(input);
|
||||||
|
}catch(NumberFormatException nfe){
|
||||||
|
return new RequirementCustomDataListPrompt();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(numInput < 1 || numInput > datamap.size() + 1)
|
||||||
|
return new RequirementCustomDataListPrompt();
|
||||||
|
|
||||||
|
if(numInput < datamap.size() + 1){
|
||||||
|
|
||||||
|
LinkedList<String> datamapKeys = new LinkedList<String>();
|
||||||
|
for(String key : datamap.keySet())
|
||||||
|
datamapKeys.add(key);
|
||||||
|
Collections.sort(datamapKeys);
|
||||||
|
|
||||||
|
String selectedKey = datamapKeys.get(numInput - 1);
|
||||||
|
context.setSessionData(CK.REQ_CUSTOM_DATA_TEMP, selectedKey);
|
||||||
|
return new RequirementCustomDataPrompt();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
if(datamap.containsValue(null)){
|
||||||
|
return new RequirementCustomDataListPrompt();
|
||||||
|
}else{
|
||||||
|
context.setSessionData(CK.REQ_CUSTOM_DATA_DESCRIPTIONS, null);
|
||||||
|
return new RequirementsPrompt(quests, factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RequirementCustomDataPrompt extends StringPrompt {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPromptText(ConversationContext context) {
|
||||||
|
String text = "";
|
||||||
|
String temp = (String)context.getSessionData(CK.REQ_CUSTOM_DATA_TEMP);
|
||||||
|
Map<String, String> descriptions = (Map<String, String>) context.getSessionData(CK.REQ_CUSTOM_DATA_DESCRIPTIONS);
|
||||||
|
if(descriptions.get(temp) != null)
|
||||||
|
text += GOLD + descriptions.get(temp) + "\n";
|
||||||
|
|
||||||
|
text += YELLOW + "Enter value for ";
|
||||||
|
text += BOLD + temp + RESET + YELLOW + ":";
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Prompt acceptInput(ConversationContext context, String input) {
|
||||||
|
LinkedList<Map<String, Object>> datamapList = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA);
|
||||||
|
Map<String, Object> datamap = datamapList.getLast();
|
||||||
|
datamap.put((String)context.getSessionData(CK.REQ_CUSTOM_DATA_TEMP), input);
|
||||||
|
context.setSessionData(CK.REQ_CUSTOM_DATA_TEMP, null);
|
||||||
|
return new RequirementCustomDataListPrompt();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private class mcMMOPrompt extends FixedSetPrompt {
|
private class mcMMOPrompt extends FixedSetPrompt {
|
||||||
|
|
||||||
public mcMMOPrompt() {
|
public mcMMOPrompt() {
|
||||||
|
@ -30,6 +30,9 @@ public class CK {
|
|||||||
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";
|
||||||
public static final String REQ_CUSTOM = "customReqs";
|
public static final String REQ_CUSTOM = "customReqs";
|
||||||
|
public static final String REQ_CUSTOM_DATA = "customReqData";
|
||||||
|
public static final String REQ_CUSTOM_DATA_DESCRIPTIONS = "customReqDataDesc";
|
||||||
|
public static final String REQ_CUSTOM_DATA_TEMP = "customReqDataTemp";
|
||||||
|
|
||||||
//Rewards
|
//Rewards
|
||||||
public static final String REW_MONEY = "moneyRew";
|
public static final String REW_MONEY = "moneyRew";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: Quests
|
name: Quests
|
||||||
main: me.blackvein.quests.Quests
|
main: me.blackvein.quests.Quests
|
||||||
version: 1.7.2
|
version: 1.7.3
|
||||||
description: Player questing system
|
description: Player questing system
|
||||||
website: http://dev.bukkit.org/server-mods/quests/
|
website: http://dev.bukkit.org/server-mods/quests/
|
||||||
dev-url: https://github.com/Blackvein/Quests/
|
dev-url: https://github.com/Blackvein/Quests/
|
||||||
|
Loading…
Reference in New Issue
Block a user