mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 12:05:16 +01:00
EditQuests sub-command should work now
This commit is contained in:
parent
0057bd3aba
commit
865ad64c18
@ -21,3 +21,4 @@
|
||||
- Jobs toggles will not be saved from now instantly when get income
|
||||
- Added option to leave from job in jobs GUI.
|
||||
- Quest objective amount is now optional (default 1)
|
||||
- Fixed issue when used 1.12 and lower versions then some materials not work correctly.
|
||||
|
@ -73,11 +73,13 @@ public class editquests implements Cmd {
|
||||
|
||||
RawMessage rm = new RawMessage();
|
||||
for (Quest one : job.getQuests()) {
|
||||
if (one.getJob().isSame(job)) {
|
||||
rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.actions", "%actionname%", oneI.getName()),
|
||||
oneI.getName(), "jobs editquests list " + job.getName() + " " + oneI.getName() + " " + one.getConfigName() + " 1");
|
||||
}
|
||||
rm.show(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Util.getQuestsEditorMap().remove(player.getUniqueId());
|
||||
return true;
|
||||
@ -122,6 +124,10 @@ public class editquests implements Cmd {
|
||||
continue;
|
||||
|
||||
o = one.getValue();
|
||||
|
||||
if (o != null && !o.getAction().equals(actionT))
|
||||
continue;
|
||||
|
||||
String target = o == null ? "STONE" : o.getTargetName();
|
||||
|
||||
String objName = target.toLowerCase().replace('_', ' ');
|
||||
@ -197,25 +203,55 @@ public class editquests implements Cmd {
|
||||
if (action == null || action.isEmpty())
|
||||
return false;
|
||||
|
||||
List<Quest> quests = job.getQuests();
|
||||
if (quests == null || quests.isEmpty())
|
||||
return false;
|
||||
|
||||
Quest q = job.getQuest(args[3]);
|
||||
if (q == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HashMap<String, QuestObjective> obj = q.getObjectives();
|
||||
if (obj == null || obj.isEmpty())
|
||||
return false;
|
||||
|
||||
String target = args[4];
|
||||
if (target == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
quests.remove(q);
|
||||
org.bukkit.configuration.file.YamlConfiguration file = Jobs.getConfigManager().getJobConfig();
|
||||
String j = "Jobs." + job.getJobKeyName() + ".Quests." + q.getConfigName() + ".";
|
||||
|
||||
Jobs.getConfigManager().changeJobsSettings(q.getCurrentPath(), null);
|
||||
if (file.isString(j + "Target")) {
|
||||
Jobs.getConfigManager().changeJobsSettings(file.getString(j + "Target"), target);
|
||||
Jobs.getConfigManager().changeJobsSettings(file.getString(j + "Action"), actionT.getName());
|
||||
} else if (file.isList(j + "Objectives")) {
|
||||
List<String> list = file.getStringList(j + "Objectives");
|
||||
for (String s : list) {
|
||||
String[] split = s.split(";");
|
||||
if (split[1].contains(target.toLowerCase())) {
|
||||
list.remove(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
player.performCommand("jobs editquests list " + job.getName() + " " + q.getConfigName() + " 1");
|
||||
File f = Jobs.getConfigManager().getJobFile();
|
||||
file.set(j + "Objectives", list);
|
||||
|
||||
try {
|
||||
file.save(f);
|
||||
} catch (java.io.IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
for (Entry<String, QuestObjective> one : obj.entrySet()) {
|
||||
if (one.getKey().equalsIgnoreCase(target)) {
|
||||
obj.remove(one.getKey());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
player.performCommand("jobs editquests list " + job.getName() + " " + actionT.getName()
|
||||
+ " " + q.getConfigName() + " 1");
|
||||
|
||||
Util.getQuestsEditorMap().remove(player.getUniqueId());
|
||||
|
||||
@ -516,25 +552,19 @@ public class editquests implements Cmd {
|
||||
|
||||
q.addObjective(new QuestObjective(actionT, id, meta, (type + subType), amount));
|
||||
|
||||
player.performCommand("jobs editquests list " + job.getName() + " " + q.getConfigName() + " 1");
|
||||
|
||||
String path = q.getCurrentPath();
|
||||
path = path.replace("/", ".");
|
||||
player.performCommand("jobs editquests list " + job.getName() + " " + actionT.getName() + " " + q.getConfigName() + " 1");
|
||||
|
||||
org.bukkit.configuration.file.YamlConfiguration file = Jobs.getConfigManager().getJobConfig();
|
||||
String j = "Jobs." + job.getJobKeyName() + ".Quests." + q.getConfigName() + ".";
|
||||
|
||||
String j = "Jobs." + job.getJobKeyName() + ".";
|
||||
|
||||
if (path.equals("Target")) {
|
||||
if (file.isString(j + "Target")) {
|
||||
Jobs.getConfigManager().changeJobsSettings(file.getString(j + "Target"), (type + subType).toLowerCase());
|
||||
Jobs.getConfigManager().changeJobsSettings(file.getString(j + "Action"), actionT.getName());
|
||||
} else if (path.equals("Objectives")) {
|
||||
for (String l : file.getConfigurationSection(j + "Quests").getKeys(false)) {
|
||||
List<String> list = file.getStringList(j + "Quests." + l + ".Objectives");
|
||||
} else if (file.isList(j + "Objectives")) {
|
||||
List<String> list = file.getStringList(j + "Objectives");
|
||||
list.add(actionT.getName() + ";" + (type + subType).toLowerCase() + ";" + amount);
|
||||
|
||||
file.set(j + "Quests." + l + ".Objectives", list);
|
||||
}
|
||||
file.set(j + "Objectives", list);
|
||||
|
||||
try {
|
||||
file.save(Jobs.getConfigManager().getJobFile());
|
||||
|
@ -927,7 +927,6 @@ public class ConfigManager {
|
||||
quest.setRewardCmds(commands);
|
||||
quest.setDescription(desc);
|
||||
quest.setRestrictedArea(areas);
|
||||
quest.setCurrentPath(sqsection.getCurrentPath());
|
||||
quests.add(quest);
|
||||
|
||||
} catch (Throwable e) {
|
||||
|
@ -12,7 +12,6 @@ import com.gamingmesh.jobs.Jobs;
|
||||
|
||||
public class Quest {
|
||||
|
||||
private String path;
|
||||
private String configName;
|
||||
private String questName;
|
||||
private Job job;
|
||||
@ -117,14 +116,6 @@ public class Quest {
|
||||
this.configName = configName;
|
||||
}
|
||||
|
||||
public void setCurrentPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getCurrentPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public Integer getMinLvl() {
|
||||
return minLvl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user