mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-06 16:27:59 +01:00
Added sub-command to start or stop the quests for player
This commit is contained in:
parent
3fc2487bfd
commit
97ee33e46e
@ -26,11 +26,11 @@ public class quests implements Cmd {
|
|||||||
public boolean perform(Jobs plugin, final CommandSender sender, String[] args) {
|
public boolean perform(Jobs plugin, final CommandSender sender, String[] args) {
|
||||||
JobsPlayer jPlayer = null;
|
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 = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||||
jPlayer.resetQuests();
|
jPlayer.resetQuests();
|
||||||
} else {
|
} 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))
|
if (!Jobs.hasPermission(sender, "jobs.command.admin.quests", true))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -52,68 +52,94 @@ public class quests implements Cmd {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests()));
|
if (args.length >= 1) {
|
||||||
if (sender instanceof Player) {
|
Boolean stopped = null;
|
||||||
for (JobProgression jobProg : jPlayer.getJobProgression()) {
|
String cmd = args.length == 1 ? args[0] : args[1];
|
||||||
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
if (cmd.equalsIgnoreCase("stop")) {
|
||||||
|
stopped = true;
|
||||||
for (QuestProgression q : list) {
|
} else if (cmd.equalsIgnoreCase("start")) {
|
||||||
String progressLine = Jobs.getCommandManager().jobProgressMessage(q.getTotalAmountNeeded(), q.getTotalAmountDone());
|
stopped = false;
|
||||||
|
|
||||||
if (q.isCompleted())
|
|
||||||
progressLine = Jobs.getLanguage().getMessage("command.quests.output.completed");
|
|
||||||
|
|
||||||
RawMessage rm = new RawMessage();
|
|
||||||
String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]",
|
|
||||||
progressLine, "[questName]", q.getQuest().getQuestName(), "[done]", q.getTotalAmountDone(), "[required]", q.getTotalAmountNeeded());
|
|
||||||
|
|
||||||
String hoverMsg = Jobs.getLanguage().getMessage("command.quests.output.hover");
|
|
||||||
List<String> hoverList = new ArrayList<>();
|
|
||||||
for (String current : hoverMsg.split("\n")) {
|
|
||||||
current = current.replace("[jobName]", jobProg.getJob().getName())
|
|
||||||
.replace("[time]", TimeManage.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
|
|
||||||
|
|
||||||
if (current.contains("[desc]")) {
|
|
||||||
for (String one : q.getQuest().getDescription()) {
|
|
||||||
hoverList.add(one);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
hoverList.add(current);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Entry<ActionType, HashMap<String, QuestObjective>> oneAction : q.getQuest().getObjectives().entrySet()) {
|
|
||||||
for (Entry<String, QuestObjective> oneObjective : oneAction.getValue().entrySet()) {
|
|
||||||
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +
|
|
||||||
Jobs.getNameTranslatorManager().Translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue()
|
|
||||||
.getTargetMeta(), oneObjective.getValue().getTargetName())
|
|
||||||
+ " " + q.getAmountDone(oneObjective.getValue()) + "/"
|
|
||||||
+ oneObjective.getValue().getAmount());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String hover = "";
|
|
||||||
for (String one : hoverList) {
|
|
||||||
if (!hover.isEmpty())
|
|
||||||
hover += "\n";
|
|
||||||
hover += one;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list.size() < jobProg.getJob().getQuests().size() && Jobs.getGCManager().getDailyQuestsSkips() > jPlayer.getSkippedQuests()) {
|
|
||||||
if (Jobs.getGCManager().getDailyQuestsSkips() > 0) {
|
|
||||||
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skip");
|
|
||||||
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skips", "[skips]", (Jobs.getGCManager().getDailyQuestsSkips() - jPlayer.getSkippedQuests()));
|
|
||||||
}
|
|
||||||
rm.add(msg, hover, "jobs skipquest " + jobProg.getJob().getName() + " " + q.getQuest().getConfigName() + " " + jPlayer.getName());
|
|
||||||
} else
|
|
||||||
rm.add(msg, hover);
|
|
||||||
rm.show(sender);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
return true;
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
|
||||||
|
|
||||||
|
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)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (JobProgression jobProg : jPlayer.getJobProgression()) {
|
||||||
|
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
||||||
|
|
||||||
|
for (QuestProgression q : list) {
|
||||||
|
String progressLine = Jobs.getCommandManager().jobProgressMessage(q.getTotalAmountNeeded(), q.getTotalAmountDone());
|
||||||
|
|
||||||
|
if (q.isCompleted())
|
||||||
|
progressLine = Jobs.getLanguage().getMessage("command.quests.output.completed");
|
||||||
|
|
||||||
|
RawMessage rm = new RawMessage();
|
||||||
|
String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]",
|
||||||
|
progressLine, "[questName]", q.getQuest().getQuestName(), "[done]", q.getTotalAmountDone(), "[required]", q.getTotalAmountNeeded());
|
||||||
|
|
||||||
|
String hoverMsg = Jobs.getLanguage().getMessage("command.quests.output.hover");
|
||||||
|
List<String> hoverList = new ArrayList<>();
|
||||||
|
for (String current : hoverMsg.split("\n")) {
|
||||||
|
current = current.replace("[jobName]", jobProg.getJob().getName())
|
||||||
|
.replace("[time]", TimeManage.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
|
||||||
|
|
||||||
|
if (current.contains("[desc]")) {
|
||||||
|
for (String one : q.getQuest().getDescription()) {
|
||||||
|
hoverList.add(one);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hoverList.add(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Entry<ActionType, HashMap<String, QuestObjective>> oneAction : q.getQuest().getObjectives().entrySet()) {
|
||||||
|
for (Entry<String, QuestObjective> oneObjective : oneAction.getValue().entrySet()) {
|
||||||
|
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +
|
||||||
|
Jobs.getNameTranslatorManager().Translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue()
|
||||||
|
.getTargetMeta(), oneObjective.getValue().getTargetName())
|
||||||
|
+ " " + q.getAmountDone(oneObjective.getValue()) + "/"
|
||||||
|
+ oneObjective.getValue().getAmount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String hover = "";
|
||||||
|
for (String one : hoverList) {
|
||||||
|
if (!hover.isEmpty())
|
||||||
|
hover += "\n";
|
||||||
|
|
||||||
|
hover += one;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (list.size() < jobProg.getJob().getQuests().size() && Jobs.getGCManager().getDailyQuestsSkips() > jPlayer.getSkippedQuests()) {
|
||||||
|
if (Jobs.getGCManager().getDailyQuestsSkips() > 0) {
|
||||||
|
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skip");
|
||||||
|
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skips", "[skips]", (Jobs.getGCManager().getDailyQuestsSkips() - jPlayer.getSkippedQuests()));
|
||||||
|
}
|
||||||
|
rm.add(msg, hover, "jobs skipquest " + jobProg.getJob().getName() + " " + q.getQuest().getConfigName() + " " + jPlayer.getName());
|
||||||
|
} else
|
||||||
|
rm.add(msg, hover);
|
||||||
|
rm.show(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -474,6 +474,9 @@ public class LanguageManager {
|
|||||||
Jobs.getGCManager().getCommandArgs().put("quests", Arrays.asList("[playername]"));
|
Jobs.getGCManager().getCommandArgs().put("quests", Arrays.asList("[playername]"));
|
||||||
c.get("command.quests.error.noquests", "&cThere are no quests");
|
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.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.completed", "&2 !Completed!&r ");
|
||||||
c.get("command.quests.output.questLine", "[progress] &7[questName] &f[done]&7/&8[required]");
|
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");
|
c.get("command.quests.output.skip", "&7Click to skip this quest");
|
||||||
|
@ -25,6 +25,8 @@ public class Quest {
|
|||||||
private List<String> rewards = new ArrayList<>();
|
private List<String> rewards = new ArrayList<>();
|
||||||
private List<String> area = new ArrayList<>();
|
private List<String> area = new ArrayList<>();
|
||||||
|
|
||||||
|
private boolean stopped = false;
|
||||||
|
|
||||||
private HashMap<ActionType, HashMap<String, QuestObjective>> objectives = new HashMap<>();
|
private HashMap<ActionType, HashMap<String, QuestObjective>> objectives = new HashMap<>();
|
||||||
private Set<ActionType> actions = new HashSet<>();
|
private Set<ActionType> actions = new HashSet<>();
|
||||||
|
|
||||||
@ -33,6 +35,14 @@ public class Quest {
|
|||||||
this.job = job;
|
this.job = job;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isStopped() {
|
||||||
|
return stopped;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStopped(boolean stopped) {
|
||||||
|
this.stopped = stopped;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getRewardCmds() {
|
public List<String> getRewardCmds() {
|
||||||
return rewardCmds;
|
return rewardCmds;
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,10 @@ public class QuestProgression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void processQuest(JobsPlayer jPlayer, ActionInfo action) {
|
public void processQuest(JobsPlayer jPlayer, ActionInfo action) {
|
||||||
|
if (quest.isStopped()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!quest.hasAction(action.getType()))
|
if (!quest.hasAction(action.getType()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user