1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-07 00:38:42 +01:00

Added sub-command to start or stop the quests for player

This commit is contained in:
montlikadani 2020-04-16 19:47:44 +02:00
parent 3fc2487bfd
commit 97ee33e46e
4 changed files with 105 additions and 62 deletions

View File

@ -26,11 +26,11 @@ public class quests implements Cmd {
public boolean perform(Jobs plugin, final CommandSender sender, String[] args) {
JobsPlayer jPlayer = null;
if (args.length >= 1 && args[0].equals("next")) {
if (args.length >= 1 && args[0].equals("next") && (!(args[0].equalsIgnoreCase("stop") || args[0].equalsIgnoreCase("start")))) {
jPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
jPlayer.resetQuests();
} else {
if (args.length >= 1) {
if (args.length >= 1 && (!(args[0].equalsIgnoreCase("stop") || args[0].equalsIgnoreCase("start")))) {
if (!Jobs.hasPermission(sender, "jobs.command.admin.quests", true))
return true;
@ -52,8 +52,35 @@ public class quests implements Cmd {
return true;
}
if (args.length >= 1) {
Boolean stopped = null;
String cmd = args.length == 1 ? args[0] : args[1];
if (cmd.equalsIgnoreCase("stop")) {
stopped = true;
} else if (cmd.equalsIgnoreCase("start")) {
stopped = false;
}
if (stopped != null) {
for (JobProgression jobProg : jPlayer.getJobProgression()) {
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
for (QuestProgression q : list) {
q.getQuest().setStopped(stopped);
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.status.changed", "%status%",
stopped ? Jobs.getLanguage().getMessage("command.quests.status.stopped") :
Jobs.getLanguage().getMessage("command.quests.status.started")));
return true;
}
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests()));
if (sender instanceof Player) {
if (!(sender instanceof Player)) {
return true;
}
for (JobProgression jobProg : jPlayer.getJobProgression()) {
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
@ -96,6 +123,7 @@ public class quests implements Cmd {
for (String one : hoverList) {
if (!hover.isEmpty())
hover += "\n";
hover += one;
}
@ -110,10 +138,8 @@ public class quests implements Cmd {
rm.show(sender);
}
}
} else
return true;
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
return true;
}
}

View File

@ -474,6 +474,9 @@ public class LanguageManager {
Jobs.getGCManager().getCommandArgs().put("quests", Arrays.asList("[playername]"));
c.get("command.quests.error.noquests", "&cThere are no quests");
c.get("command.quests.toplineseparator", "&7*********************** &6[playerName] &2(&f[questsDone]&2) &7***********************");
c.get("command.quests.status.changed", "&2The quests status has been changed to&r %status%");
c.get("command.quests.status.started", "&aStarted");
c.get("command.quests.status.stopped", "&cStopped");
c.get("command.quests.output.completed", "&2 !Completed!&r ");
c.get("command.quests.output.questLine", "[progress] &7[questName] &f[done]&7/&8[required]");
c.get("command.quests.output.skip", "&7Click to skip this quest");

View File

@ -25,6 +25,8 @@ public class Quest {
private List<String> rewards = new ArrayList<>();
private List<String> area = new ArrayList<>();
private boolean stopped = false;
private HashMap<ActionType, HashMap<String, QuestObjective>> objectives = new HashMap<>();
private Set<ActionType> actions = new HashSet<>();
@ -33,6 +35,14 @@ public class Quest {
this.job = job;
}
public boolean isStopped() {
return stopped;
}
public void setStopped(boolean stopped) {
this.stopped = stopped;
}
public List<String> getRewardCmds() {
return rewardCmds;
}

View File

@ -88,6 +88,10 @@ public class QuestProgression {
}
public void processQuest(JobsPlayer jPlayer, ActionInfo action) {
if (quest.isStopped()) {
return;
}
if (!quest.hasAction(action.getType()))
return;