1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-20 23:21:19 +01:00

Fixing daily quest resets

This commit is contained in:
Zrips 2019-11-04 14:54:00 +02:00
parent 0ece576f58
commit c598b45fc7
4 changed files with 37 additions and 30 deletions

View File

@ -14,6 +14,7 @@ import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.QuestObjective;
import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.CMILib.RawMessage;
public class quests implements Cmd {
@ -59,6 +60,7 @@ public class quests implements Cmd {
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());

View File

@ -60,8 +60,7 @@ public class resetquest implements Cmd {
}
}
jPlayer.setDoneQuests(0);
jPlayer.getQuestProgressions(job).clear();
jPlayer.resetQuests();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.reseted", "%playername%", jPlayer.getUserName()));

View File

@ -34,6 +34,7 @@ import com.gamingmesh.jobs.dao.JobsDAO;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
import com.gamingmesh.jobs.stuff.TimeManage;
@ -381,7 +382,7 @@ public class JobsPlayer {
public void setPlayerUUID(UUID playerUUID) {
setUniqueId(playerUUID);
}
public void setUniqueId(UUID playerUUID) {
this.playerUUID = playerUUID;
}
@ -878,13 +879,10 @@ public class JobsPlayer {
public void resetQuests(Job job) {
for (QuestProgression oneQ : getQuestProgressions(job)) {
oneQ.setValidUntil(0l);
oneQ.setValidUntil(oneQ.getQuest().getValidUntil());
for (Entry<String, QuestObjective> obj : oneQ.getQuest().getObjectives().entrySet()) {
oneQ.setAmountDone(obj.getValue(), 0);
}
setDoneQuests(0);
getQuestProgressions(job).clear();
}
}
@ -894,6 +892,16 @@ public class JobsPlayer {
}
}
public void getNewQuests() {
qProgression.clear();
}
public void getNewQuests(Job job) {
HashMap<String, QuestProgression> prog = qProgression.get(job.getName());
if (prog != null)
prog.clear();
}
public List<QuestProgression> getQuestProgressions() {
List<QuestProgression> g = new ArrayList<>();
for (JobProgression one : getJobProgression()) {
@ -918,22 +926,8 @@ public class JobsPlayer {
for (Entry<String, QuestProgression> one : (new HashMap<String, QuestProgression>(g)).entrySet()) {
QuestProgression qp = one.getValue();
if (qp == null || !qp.isValid()) {
Quest q = job.getNextQuest(getQuestNameList(job, type), getJobProgression(job).getLevel());
if (q == null)
continue;
qp = new QuestProgression(q);
if (g.size() >= job.getMaxDailyQuests())
continue;
g.put(qp.getQuest().getConfigName(), qp);
}
if (qp.getQuest() == null) {
g.remove(one.getKey());
if (qp.isEnded()) {
g.remove(one.getKey().toLowerCase());
continue;
}
}
@ -946,21 +940,32 @@ public class JobsPlayer {
if (q == null)
continue;
QuestProgression qp = new QuestProgression(q);
g.put(qp.getQuest().getConfigName(), qp);
g.put(qp.getQuest().getConfigName().toLowerCase(), qp);
if (g.size() >= job.getMaxDailyQuests())
break;
}
}
if (g.size() > job.getMaxDailyQuests()) {
int i = g.size();
while (i > 0) {
--i;
g.remove(g.entrySet().iterator().next().getKey());
if (g.size() <= job.getMaxDailyQuests())
break;
}
}
qProgression.put(job.getName(), g);
for (Entry<String, QuestProgression> oneJ : g.entrySet()) {
if (type == null) {
tmp.put(oneJ.getValue().getQuest().getConfigName(), oneJ.getValue());
tmp.put(oneJ.getValue().getQuest().getConfigName().toLowerCase(), oneJ.getValue());
} else
for (Entry<String, QuestObjective> one : oneJ.getValue().getQuest().getObjectives().entrySet()) {
if (type.name().equals(one.getValue().getAction().name())) {
tmp.put(oneJ.getValue().getQuest().getConfigName(), oneJ.getValue());
tmp.put(oneJ.getValue().getQuest().getConfigName().toLowerCase(), oneJ.getValue());
break;
}
}

View File

@ -7,11 +7,12 @@ import org.bukkit.Bukkit;
import org.bukkit.event.server.ServerCommandEvent;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.stuff.Debug;
public class QuestProgression {
private Quest quest;
private Long validUntil;
private long validUntil;
private boolean givenReward = false;
private HashMap<QuestObjective, Integer> done = new HashMap<>();
@ -56,7 +57,7 @@ public class QuestProgression {
}
public Long getValidUntil() {
return quest.getValidUntil();
return this.validUntil;
}
public void setValidUntil(Long validUntil) {
@ -64,7 +65,7 @@ public class QuestProgression {
}
public boolean isValid() {
return validUntil.equals(getValidUntil());
return validUntil == getValidUntil();
}
public boolean isEnded() {
@ -91,7 +92,7 @@ public class QuestProgression {
for (String area : quest.getRestrictedAreas()) {
for (Entry<String, RestrictedArea> a : Jobs.getRestrictedAreaManager().getRestrictedAres().entrySet()) {
if (quest.getRestrictedAreas().contains(a.getKey()) && a.getKey().equalsIgnoreCase(area)
&& a.getValue().inRestrictedArea(jPlayer.getPlayer().getLocation())) {
&& a.getValue().inRestrictedArea(jPlayer.getPlayer().getLocation())) {
return;
}
}