mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-20 07:01:22 +01:00
Trying to fix resetquest
- Fix for quest tabcomplete
This commit is contained in:
parent
4491966934
commit
283525e853
@ -22,25 +22,19 @@ public class browse implements Cmd {
|
||||
|
||||
if (Jobs.getGCManager().BrowseUseNewLook) {
|
||||
List<Job> jobList = new ArrayList<>(Jobs.getJobs());
|
||||
|
||||
if (jobList.isEmpty()) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
|
||||
// Inventory inv = null;
|
||||
try {
|
||||
Jobs.getGUIManager().openJobsBrowseGUI((Player) sender);
|
||||
} catch (Throwable e) {
|
||||
((Player) sender).closeInventory();
|
||||
// Jobs.getGUIManager().GuiList.remove(((Player) sender).getUniqueId());
|
||||
return true;
|
||||
}
|
||||
// if (inv == null)
|
||||
// return true;
|
||||
// if (Jobs.getGUIManager().isInGui((Player) sender))
|
||||
// ((Player) sender).openInventory(inv);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -52,18 +46,15 @@ public class browse implements Cmd {
|
||||
try {
|
||||
page = Integer.parseInt(one.substring("-p:".length()));
|
||||
continue;
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String one : args) {
|
||||
if (one.startsWith("-j:")) {
|
||||
try {
|
||||
j = Jobs.getJob(one.substring("-j:".length()));
|
||||
continue;
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
j = Jobs.getJob(one.substring("-j:".length()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +73,7 @@ public class browse implements Cmd {
|
||||
String hoverMsg = "";
|
||||
|
||||
if (!one.getDescription().isEmpty())
|
||||
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one.getDescription().replace("/n", ""));
|
||||
hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one.getDescription().replaceAll("/n|\n", ""));
|
||||
|
||||
if (one.getMaxLevel(sender) > 0) {
|
||||
if (!hoverMsg.isEmpty())
|
||||
@ -152,11 +143,10 @@ public class browse implements Cmd {
|
||||
if (j == null) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.console.newHeader", "[amount]", jobList.size(), "\\n", "\n"));
|
||||
for (Job one : jobList) {
|
||||
|
||||
String msg = "";
|
||||
|
||||
if (!one.getDescription().isEmpty())
|
||||
msg += Jobs.getLanguage().getMessage("command.browse.output.console.description", "[description]", one.getDescription().replace("/n", ""));
|
||||
msg += Jobs.getLanguage().getMessage("command.browse.output.console.description", "[description]", one.getDescription().replaceAll("/n|\n", ""));
|
||||
|
||||
if (one.getMaxLevel(sender) > 0)
|
||||
msg += Jobs.getLanguage().getMessage("command.browse.output.console.newMax", "[max]", one.getMaxLevel(sender));
|
||||
@ -176,7 +166,6 @@ public class browse implements Cmd {
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
} else {
|
||||
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
|
||||
|
||||
if (j.getMaxLevel(sender) > 0)
|
||||
@ -199,15 +188,14 @@ public class browse implements Cmd {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
for (Job job : Jobs.getJobs()) {
|
||||
if (Jobs.getGCManager().getHideJobsWithoutPermission()) {
|
||||
if (!Jobs.getCommandManager().hasJobPermission(sender, job))
|
||||
continue;
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(" ");
|
||||
builder.append(job.getChatColor().toString());
|
||||
@ -229,7 +217,7 @@ public class browse implements Cmd {
|
||||
|
||||
lines.add(builder.toString());
|
||||
if (!job.getDescription().isEmpty())
|
||||
lines.add(" - " + job.getDescription().replace("/n", ""));
|
||||
lines.add(" - " + job.getDescription().replaceAll("/n|\n", ""));
|
||||
}
|
||||
|
||||
if (lines.isEmpty()) {
|
||||
@ -238,27 +226,19 @@ public class browse implements Cmd {
|
||||
}
|
||||
|
||||
if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) {
|
||||
|
||||
try {
|
||||
Jobs.getGUIManager().openJobsBrowseGUI((Player) sender);
|
||||
} catch (Throwable e) {
|
||||
((Player) sender).closeInventory();
|
||||
// Jobs.getGUIManager().GuiList.remove(((Player) sender).getUniqueId());
|
||||
return true;
|
||||
}
|
||||
// if (inv == null)
|
||||
// return true;
|
||||
|
||||
// if (Jobs.getGUIManager().isInGui((Player) sender))
|
||||
// ((Player) sender).openInventory(inv);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().JobsGUIShowChatBrowse) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header"));
|
||||
for (String line : lines) {
|
||||
sender.sendMessage(line);
|
||||
}
|
||||
lines.forEach(sender::sendMessage);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer"));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.gamingmesh.jobs.commands.list;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -11,7 +10,6 @@ import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.QuestObjective;
|
||||
import com.gamingmesh.jobs.container.QuestProgression;
|
||||
|
||||
public class resetquest implements Cmd {
|
||||
@ -49,21 +47,12 @@ public class resetquest implements Cmd {
|
||||
if (job != null)
|
||||
quests = jPlayer.getQuestProgressions(job);
|
||||
|
||||
if (quests == null || quests.isEmpty()) {
|
||||
if (quests.isEmpty()) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.noQuests"));
|
||||
return true;
|
||||
}
|
||||
|
||||
for (QuestProgression one : quests) {
|
||||
one.setValidUntil(System.currentTimeMillis());
|
||||
for (HashMap<String, QuestObjective> actions : one.getQuest().getObjectives().values()) {
|
||||
for (QuestObjective obj : actions.values()) {
|
||||
one.setAmountDone(obj, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jPlayer.resetQuests();
|
||||
jPlayer.resetQuests(quests);
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.reseted", "%playername%", jPlayer.getName()));
|
||||
return true;
|
||||
}
|
||||
|
@ -914,17 +914,22 @@ public class JobsPlayer {
|
||||
}
|
||||
|
||||
public void resetQuests(Job job) {
|
||||
for (QuestProgression oneQ : getQuestProgressions(job)) {
|
||||
resetQuests(getQuestProgressions(job));
|
||||
}
|
||||
|
||||
public void resetQuests(List<QuestProgression> quests) {
|
||||
for (QuestProgression oneQ : quests) {
|
||||
if (oneQ.getQuest() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
oneQ.setValidUntil(System.currentTimeMillis());
|
||||
for (HashMap<String, QuestObjective> base : oneQ.getQuest().getObjectives().values()) {
|
||||
for (QuestObjective obj : base.values()) {
|
||||
oneQ.setAmountDone(obj, 0);
|
||||
}
|
||||
Job job = oneQ.getQuest().getJob();
|
||||
getNewQuests(job);
|
||||
if (qProgression.containsKey(job.getName())) {
|
||||
qProgression.remove(job.getName());
|
||||
}
|
||||
|
||||
oneQ.getQuest().setObjectives(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,6 +176,10 @@ public class Quest {
|
||||
}
|
||||
|
||||
public void setObjectives(HashMap<ActionType, HashMap<String, QuestObjective>> objectives) {
|
||||
if (objectives == null) {
|
||||
objectives = new HashMap<>();
|
||||
}
|
||||
|
||||
this.objectives = objectives;
|
||||
objectives.keySet().forEach(actions::add);
|
||||
}
|
||||
@ -192,6 +196,6 @@ public class Quest {
|
||||
}
|
||||
|
||||
public boolean hasAction(ActionType action) {
|
||||
return this.actions.contains(action);
|
||||
return actions.contains(action);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import com.gamingmesh.jobs.container.JobItems;
|
||||
import com.gamingmesh.jobs.container.JobLimitedItems;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.QuestProgression;
|
||||
import com.gamingmesh.jobs.container.Quest;
|
||||
|
||||
public class TabComplete implements TabCompleter {
|
||||
|
||||
@ -66,11 +66,10 @@ public class TabComplete implements TabCompleter {
|
||||
switch (ar) {
|
||||
case "[questname]":
|
||||
case "[quest]":
|
||||
JobsPlayer playerJob = Jobs.getPlayerManager().getJobsPlayer(args[i - 1]);
|
||||
if (playerJob != null) {
|
||||
for (QuestProgression prog : playerJob.getQuestProgressions()) {
|
||||
if (prog.getQuest() != null)
|
||||
temp.add(prog.getQuest().getQuestName());
|
||||
Job job = Jobs.getJob(args[i - 1]);
|
||||
if (job != null) {
|
||||
for (Quest q : job.getQuests()) {
|
||||
temp.add(q.getQuestName());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user