mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
Fix when the completed quests can be skipped
Fixes #863 - Added tab complete for skipquest
This commit is contained in:
parent
176eb70dd3
commit
958329778a
@ -522,7 +522,7 @@ public class Placeholder {
|
||||
|
||||
case maxjobs:
|
||||
Double max = Jobs.getPermissionManager().getMaxPermission(user, "jobs.max");
|
||||
max = max == null ? Jobs.getGCManager().getMaxJobs() : max;
|
||||
max = max == 0D ? Jobs.getGCManager().getMaxJobs() : max;
|
||||
return Double.toString(max);
|
||||
default:
|
||||
break;
|
||||
|
@ -126,7 +126,7 @@ public class quests implements Cmd {
|
||||
hover += one;
|
||||
}
|
||||
|
||||
if (list.size() < jobProg.getJob().getQuests().size() && Jobs.getGCManager().getDailyQuestsSkips() > jPlayer.getSkippedQuests()) {
|
||||
if (list.size() < jobProg.getJob().getQuests().size() && Jobs.getGCManager().getDailyQuestsSkips() > jPlayer.getSkippedQuests() && !q.isCompleted()) {
|
||||
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()));
|
||||
|
@ -75,6 +75,13 @@ public class skipquest implements Cmd {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do not skip the completed quests
|
||||
for (QuestProgression q : quests) {
|
||||
if (q.getQuest().getQuestName().equals(old.getQuestName()) && q.isCompleted()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().getDailyQuestsSkips() <= jPlayer.getSkippedQuests())
|
||||
return false;
|
||||
|
||||
|
@ -464,6 +464,7 @@ public class LanguageManager {
|
||||
c.get("command.skipquest.help.info", "Skip defined quest and get new one");
|
||||
c.get("command.skipquest.help.args", "[jobname] [questname] (playerName)");
|
||||
c.get("command.skipquest.output.questSkipForCost", "&2You skipped the quest and paid:&e %amount%$");
|
||||
Jobs.getGCManager().getCommandArgs().put("skipquest", Arrays.asList("[jobname]", "[questname]", "[playername]"));
|
||||
|
||||
c.get("command.quests.help.info", "List available quests");
|
||||
c.get("command.quests.help.args", "[playername]");
|
||||
|
@ -879,8 +879,8 @@ public class JobsPlayer {
|
||||
if (qpl == null)
|
||||
return false;
|
||||
|
||||
for (Entry<String, QuestProgression> one : qpl.entrySet()) {
|
||||
if (one.getValue().getQuest() != null && one.getValue().getQuest().getConfigName().equalsIgnoreCase(questName))
|
||||
for (QuestProgression one : qpl.values()) {
|
||||
if (one.getQuest() != null && one.getQuest().getConfigName().equalsIgnoreCase(questName))
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -896,14 +896,13 @@ public class JobsPlayer {
|
||||
if (qpl == null)
|
||||
return ls;
|
||||
|
||||
for (Entry<String, QuestProgression> one : qpl.entrySet()) {
|
||||
QuestProgression prog = one.getValue();
|
||||
for (QuestProgression prog : qpl.values()) {
|
||||
if (prog.isEnded() || prog.getQuest() == null)
|
||||
continue;
|
||||
|
||||
for (Entry<ActionType, HashMap<String, QuestObjective>> oneAction : prog.getQuest().getObjectives().entrySet()) {
|
||||
for (Entry<String, QuestObjective> oneObjective : oneAction.getValue().entrySet()) {
|
||||
if (type == null || type.name().equals(oneObjective.getValue().getAction().name())) {
|
||||
for (HashMap<String, QuestObjective> oneAction : prog.getQuest().getObjectives().values()) {
|
||||
for (QuestObjective oneObjective : oneAction.values()) {
|
||||
if (type == null || type.name().equals(oneObjective.getAction().name())) {
|
||||
ls.add(prog.getQuest().getConfigName().toLowerCase());
|
||||
break;
|
||||
}
|
||||
@ -921,9 +920,9 @@ public class JobsPlayer {
|
||||
}
|
||||
|
||||
oneQ.setValidUntil(System.currentTimeMillis());
|
||||
for (Entry<ActionType, HashMap<String, QuestObjective>> base : oneQ.getQuest().getObjectives().entrySet()) {
|
||||
for (Entry<String, QuestObjective> obj : base.getValue().entrySet()) {
|
||||
oneQ.setAmountDone(obj.getValue(), 0);
|
||||
for (HashMap<String, QuestObjective> base : oneQ.getQuest().getObjectives().values()) {
|
||||
for (QuestObjective obj : base.values()) {
|
||||
oneQ.setAmountDone(obj, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1038,7 +1037,7 @@ public class JobsPlayer {
|
||||
while (i > 0) {
|
||||
--i;
|
||||
|
||||
g.remove(g.entrySet().iterator().next().getKey());
|
||||
g.remove(g.keySet().iterator().next());
|
||||
|
||||
if (g.size() <= job.getMaxDailyQuests())
|
||||
break;
|
||||
@ -1047,31 +1046,29 @@ public class JobsPlayer {
|
||||
|
||||
qProgression.put(job.getName(), g);
|
||||
|
||||
for (Entry<String, QuestProgression> oneJ : g.entrySet()) {
|
||||
Quest q = oneJ.getValue().getQuest();
|
||||
for (QuestProgression oneJ : g.values()) {
|
||||
Quest q = oneJ.getQuest();
|
||||
if (q == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
tmp.put(q.getConfigName().toLowerCase(), oneJ.getValue());
|
||||
tmp.put(q.getConfigName().toLowerCase(), oneJ);
|
||||
continue;
|
||||
}
|
||||
|
||||
HashMap<String, QuestObjective> old = q.getObjectives().get(type);
|
||||
if (old != null)
|
||||
for (Entry<String, QuestObjective> one : old.entrySet()) {
|
||||
if (type.name().equals(one.getValue().getAction().name())) {
|
||||
tmp.put(q.getConfigName().toLowerCase(), oneJ.getValue());
|
||||
for (QuestObjective one : old.values()) {
|
||||
if (type.name().equals(one.getAction().name())) {
|
||||
tmp.put(q.getConfigName().toLowerCase(), oneJ);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<QuestProgression> pr = new ArrayList<>();
|
||||
for (Entry<String, QuestProgression> one : tmp.entrySet()) {
|
||||
pr.add(one.getValue());
|
||||
}
|
||||
tmp.values().forEach(pr::add);
|
||||
|
||||
return pr;
|
||||
}
|
||||
@ -1089,8 +1086,8 @@ public class JobsPlayer {
|
||||
|
||||
prog += q.getJob().getName() + ":" + q.getConfigName() + ":" + one.getValidUntil() + ":";
|
||||
|
||||
for (Entry<ActionType, HashMap<String, QuestObjective>> oneA : q.getObjectives().entrySet()) {
|
||||
for (Entry<String, QuestObjective> oneO : oneA.getValue().entrySet()) {
|
||||
for (HashMap<String, QuestObjective> oneA : q.getObjectives().values()) {
|
||||
for (Entry<String, QuestObjective> oneO : oneA.entrySet()) {
|
||||
prog += oneO.getValue().getAction().toString() + ";" + oneO.getKey() + ";" + one.getAmountDone(oneO.getValue()) + ":;:";
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
public class BufferedEconomy {
|
||||
private Jobs plugin;
|
||||
private Economy economy;
|
||||
private LinkedBlockingQueue<BufferedPayment> payments = new LinkedBlockingQueue<>();
|
||||
private final LinkedBlockingQueue<BufferedPayment> payments = new LinkedBlockingQueue<>();
|
||||
private final Map<UUID, BufferedPayment> paymentCache = Collections.synchronizedMap(new HashMap<UUID, BufferedPayment>());
|
||||
|
||||
private OfflinePlayer ServerTaxesAccount = null;
|
||||
|
@ -19,7 +19,6 @@
|
||||
package com.gamingmesh.jobs.economy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
@ -27,7 +26,7 @@ import com.gamingmesh.jobs.container.CurrencyType;
|
||||
|
||||
public class BufferedPayment {
|
||||
private OfflinePlayer offlinePlayer;
|
||||
private HashMap<CurrencyType, Double> payments = new HashMap<CurrencyType, Double>();
|
||||
private final HashMap<CurrencyType, Double> payments = new HashMap<>();
|
||||
|
||||
@Deprecated
|
||||
public BufferedPayment(OfflinePlayer offlinePlayer, double amount, double points, double exp) {
|
||||
@ -89,8 +88,8 @@ public class BufferedPayment {
|
||||
}
|
||||
|
||||
public boolean containsPayment() {
|
||||
for (Entry<CurrencyType, Double> one : payments.entrySet()) {
|
||||
if (one.getValue() != 0D)
|
||||
for (Double one : payments.values()) {
|
||||
if (one != 0D)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -20,6 +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;
|
||||
|
||||
public class TabComplete implements TabCompleter {
|
||||
|
||||
@ -63,6 +64,16 @@ public class TabComplete implements TabCompleter {
|
||||
List<String> temp = new ArrayList<>();
|
||||
for (String ar : t2) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "[jobname]":
|
||||
case "[newjob]":
|
||||
for (Job one : Jobs.getJobs()) {
|
||||
|
Loading…
Reference in New Issue
Block a user