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