mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-01 13:01:29 +01:00
Fixing daily quest resets
This commit is contained in:
parent
0ece576f58
commit
c598b45fc7
@ -14,6 +14,7 @@ import com.gamingmesh.jobs.container.JobProgression;
|
|||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.container.QuestObjective;
|
import com.gamingmesh.jobs.container.QuestObjective;
|
||||||
import com.gamingmesh.jobs.container.QuestProgression;
|
import com.gamingmesh.jobs.container.QuestProgression;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
import com.gamingmesh.jobs.CMILib.RawMessage;
|
import com.gamingmesh.jobs.CMILib.RawMessage;
|
||||||
|
|
||||||
public class quests implements Cmd {
|
public class quests implements Cmd {
|
||||||
@ -59,6 +60,7 @@ public class quests implements Cmd {
|
|||||||
|
|
||||||
if (q.isCompleted())
|
if (q.isCompleted())
|
||||||
progressLine = Jobs.getLanguage().getMessage("command.quests.output.completed");
|
progressLine = Jobs.getLanguage().getMessage("command.quests.output.completed");
|
||||||
|
|
||||||
RawMessage rm = new RawMessage();
|
RawMessage rm = new RawMessage();
|
||||||
String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]",
|
String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]",
|
||||||
progressLine, "[questName]", q.getQuest().getQuestName(), "[done]", q.getTotalAmountDone(), "[required]", q.getTotalAmountNeeded());
|
progressLine, "[questName]", q.getQuest().getQuestName(), "[done]", q.getTotalAmountDone(), "[required]", q.getTotalAmountNeeded());
|
||||||
|
@ -60,8 +60,7 @@ public class resetquest implements Cmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jPlayer.setDoneQuests(0);
|
jPlayer.resetQuests();
|
||||||
jPlayer.getQuestProgressions(job).clear();
|
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.reseted", "%playername%", jPlayer.getUserName()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.reseted", "%playername%", jPlayer.getUserName()));
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import com.gamingmesh.jobs.dao.JobsDAO;
|
|||||||
import com.gamingmesh.jobs.economy.PaymentData;
|
import com.gamingmesh.jobs.economy.PaymentData;
|
||||||
import com.gamingmesh.jobs.resources.jfep.Parser;
|
import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
|
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
|
||||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||||
|
|
||||||
@ -878,13 +879,10 @@ public class JobsPlayer {
|
|||||||
|
|
||||||
public void resetQuests(Job job) {
|
public void resetQuests(Job job) {
|
||||||
for (QuestProgression oneQ : getQuestProgressions(job)) {
|
for (QuestProgression oneQ : getQuestProgressions(job)) {
|
||||||
oneQ.setValidUntil(0l);
|
oneQ.setValidUntil(oneQ.getQuest().getValidUntil());
|
||||||
for (Entry<String, QuestObjective> obj : oneQ.getQuest().getObjectives().entrySet()) {
|
for (Entry<String, QuestObjective> obj : oneQ.getQuest().getObjectives().entrySet()) {
|
||||||
oneQ.setAmountDone(obj.getValue(), 0);
|
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() {
|
public List<QuestProgression> getQuestProgressions() {
|
||||||
List<QuestProgression> g = new ArrayList<>();
|
List<QuestProgression> g = new ArrayList<>();
|
||||||
for (JobProgression one : getJobProgression()) {
|
for (JobProgression one : getJobProgression()) {
|
||||||
@ -918,22 +926,8 @@ public class JobsPlayer {
|
|||||||
for (Entry<String, QuestProgression> one : (new HashMap<String, QuestProgression>(g)).entrySet()) {
|
for (Entry<String, QuestProgression> one : (new HashMap<String, QuestProgression>(g)).entrySet()) {
|
||||||
QuestProgression qp = one.getValue();
|
QuestProgression qp = one.getValue();
|
||||||
|
|
||||||
if (qp == null || !qp.isValid()) {
|
if (qp.isEnded()) {
|
||||||
Quest q = job.getNextQuest(getQuestNameList(job, type), getJobProgression(job).getLevel());
|
g.remove(one.getKey().toLowerCase());
|
||||||
|
|
||||||
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());
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -946,21 +940,32 @@ public class JobsPlayer {
|
|||||||
if (q == null)
|
if (q == null)
|
||||||
continue;
|
continue;
|
||||||
QuestProgression qp = new QuestProgression(q);
|
QuestProgression qp = new QuestProgression(q);
|
||||||
g.put(qp.getQuest().getConfigName(), qp);
|
g.put(qp.getQuest().getConfigName().toLowerCase(), qp);
|
||||||
if (g.size() >= job.getMaxDailyQuests())
|
if (g.size() >= job.getMaxDailyQuests())
|
||||||
break;
|
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);
|
qProgression.put(job.getName(), g);
|
||||||
|
|
||||||
for (Entry<String, QuestProgression> oneJ : g.entrySet()) {
|
for (Entry<String, QuestProgression> oneJ : g.entrySet()) {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
tmp.put(oneJ.getValue().getQuest().getConfigName(), oneJ.getValue());
|
tmp.put(oneJ.getValue().getQuest().getConfigName().toLowerCase(), oneJ.getValue());
|
||||||
} else
|
} else
|
||||||
for (Entry<String, QuestObjective> one : oneJ.getValue().getQuest().getObjectives().entrySet()) {
|
for (Entry<String, QuestObjective> one : oneJ.getValue().getQuest().getObjectives().entrySet()) {
|
||||||
if (type.name().equals(one.getValue().getAction().name())) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,12 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.event.server.ServerCommandEvent;
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
|
|
||||||
public class QuestProgression {
|
public class QuestProgression {
|
||||||
|
|
||||||
private Quest quest;
|
private Quest quest;
|
||||||
private Long validUntil;
|
private long validUntil;
|
||||||
private boolean givenReward = false;
|
private boolean givenReward = false;
|
||||||
private HashMap<QuestObjective, Integer> done = new HashMap<>();
|
private HashMap<QuestObjective, Integer> done = new HashMap<>();
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ public class QuestProgression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long getValidUntil() {
|
public Long getValidUntil() {
|
||||||
return quest.getValidUntil();
|
return this.validUntil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValidUntil(Long validUntil) {
|
public void setValidUntil(Long validUntil) {
|
||||||
@ -64,7 +65,7 @@ public class QuestProgression {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return validUntil.equals(getValidUntil());
|
return validUntil == getValidUntil();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnded() {
|
public boolean isEnded() {
|
||||||
|
Loading…
Reference in New Issue
Block a user