1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Improved displaying player's quests in console

This commit is contained in:
montlikadani 2021-05-15 19:36:12 +02:00
parent b5318089d9
commit 8dc1bf80da
10 changed files with 62 additions and 31 deletions

View File

@ -445,8 +445,9 @@ public class Jobs extends JavaPlugin {
}
/**
* Retrieves the list of active jobs
* @return list of jobs
* Returns the list of available jobs.
*
* @return an unmodifiable list of jobs
*/
public static List<Job> getJobs() {
return Collections.unmodifiableList(jobs);

View File

@ -1102,7 +1102,7 @@ public class PlayerManager {
boost.add(BoostOf.Item, getItemBoostNBT(pl, prog));
}
if (!Jobs.getRestrictedAreaManager().getRestrictedAres().isEmpty())
if (!Jobs.getRestrictedAreaManager().getRestrictedAreas().isEmpty())
boost.add(BoostOf.Area, new BoostMultiplier().add(Jobs.getRestrictedAreaManager().getRestrictedMultiplier(pl)));
return boost;

View File

@ -117,7 +117,7 @@ public class area implements Cmd {
if (args.length == 1 && args[0].equalsIgnoreCase("list")) {
java.util.Map<String, RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAres();
java.util.Map<String, RestrictedArea> areas = Jobs.getRestrictedAreaManager().getRestrictedAreas();
if (areas.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreas"));
return true;

View File

@ -11,6 +11,7 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.Quest;
import com.gamingmesh.jobs.container.QuestObjective;
import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.stuff.TimeManage;
@ -75,37 +76,47 @@ public class quests implements Cmd {
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests()));
if (!isPlayer) {
return true;
}
for (JobProgression jobProg : jPlayer.progression) {
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
for (QuestProgression q : list) {
String progressLine = Jobs.getCommandManager().jobProgressMessage(q.getTotalAmountNeeded(), q.getTotalAmountDone());
int totalAmountNeeded = q.getTotalAmountNeeded();
int totalAmountDone = q.getTotalAmountDone();
if (q.isCompleted())
String progressLine = Jobs.getCommandManager().jobProgressMessage(totalAmountNeeded, totalAmountDone);
boolean completed = q.isCompleted();
if (completed)
progressLine = Jobs.getLanguage().getMessage("command.quests.output.completed");
RawMessage rm = new RawMessage();
Quest quest = q.getQuest();
String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]",
progressLine, "[questName]", q.getQuest().getQuestName(), "[done]", q.getTotalAmountDone(), "[required]", q.getTotalAmountNeeded());
progressLine, "[questName]", quest.getQuestName(), "[done]", totalAmountDone, "[required]", totalAmountNeeded);
if (!isPlayer) {
sender.sendMessage(msg);
continue;
}
RawMessage rm = new RawMessage();
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]")) {
hoverList.addAll(q.getQuest().getDescription());
hoverList.addAll(quest.getDescription());
} else {
hoverList.add(current);
}
}
for (java.util.Map<String, QuestObjective> oneAction : q.getQuest().getObjectives().values()) {
for (java.util.Map<String, QuestObjective> oneAction : quest.getObjectives().values()) {
for (Entry<String, QuestObjective> oneObjective : oneAction.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()
@ -123,12 +134,12 @@ public class quests implements Cmd {
hover += one;
}
if (list.size() < jobProg.getJob().getQuests().size() && Jobs.getGCManager().getDailyQuestsSkips() > jPlayer.getSkippedQuests() && !q.isCompleted()) {
if (list.size() < jobProg.getJob().getQuests().size() && Jobs.getGCManager().getDailyQuestsSkips() > jPlayer.getSkippedQuests() && !completed) {
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.addText(msg).addHover(hover).addCommand("jobs skipquest " + jobProg.getJob().getName() + " " + q.getQuest().getConfigName() + " " + jPlayer.getName());
rm.addText(msg).addHover(hover).addCommand("jobs skipquest " + jobProg.getJob().getName() + " " + quest.getConfigName() + " " + jPlayer.getName());
} else
rm.addText(msg).addHover(hover);

View File

@ -66,10 +66,21 @@ public class RestrictedAreaManager {
}
}
/**
* Retrieves the restricted areas map.
*
* @deprecated badly named
* @return the cached map of restricted areas
*/
@Deprecated
public Map<String, RestrictedArea> getRestrictedAres() {
return restrictedAreas;
}
public Map<String, RestrictedArea> getRestrictedAreas() {
return restrictedAreas;
}
private void save() {
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);

View File

@ -52,8 +52,9 @@ public class ExploreChunk {
StringBuilder s = new StringBuilder();
for (Integer one : playerIds) {
if (!s.toString().isEmpty())
if (s.length() != 0)
s.append(';');
s.append(one);
}
return s.toString();
@ -73,11 +74,13 @@ public class ExploreChunk {
try {
int id = Integer.parseInt(one);
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(id);
if (info != null)
playerIds.add(id);
} catch (Exception e) {
} catch (NumberFormatException e) {
updated = true;
JobsPlayer jp = Jobs.getPlayerManager().getJobsPlayer(one);
if (jp != null)
playerIds.add(jp.getUserId());
}
@ -85,6 +88,7 @@ public class ExploreChunk {
if (playerIds.size() >= Jobs.getExplore().getPlayerAmount() && Jobs.getGCManager().ExploreCompact) {
playerIds = null;
if (!names.isEmpty())
updated = true;
}

View File

@ -28,7 +28,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.CMIChatColor;
import com.gamingmesh.jobs.CMILib.CMIMaterial;
@ -65,8 +64,6 @@ public class JobLimitedItems {
return item;
}
Jobs plugin = org.bukkit.plugin.java.JavaPlugin.getPlugin(Jobs.class);
if (name != null)
meta.setDisplayName(CMIChatColor.translate(name));

View File

@ -406,9 +406,9 @@ public class JobsPlayer {
* Reloads limit for this player.
*/
public void reload(CurrencyType type) {
int totalLevel = getTotalLevels();
Parser eq = Jobs.getGCManager().getLimit(type).getMaxEquation();
eq.setVariable("totallevel", totalLevel);
eq.setVariable("totallevel", getTotalLevels());
maxJobsEquation = Jobs.getPlayerManager().getMaxJobs(this);
limits.put(type, (int) eq.getValue());
setSaved(false);

View File

@ -15,7 +15,7 @@ public class Quest {
private String configName = "";
private String questName = "";
private Job job;
private Long validUntil = 0L;
private long validUntil = 0L;
private int chance = 100, minLvl = 0;
private Integer maxLvl;
@ -76,30 +76,35 @@ public class Quest {
}
}
public Long getValidUntil() {
public long getValidUntil() {
if (validUntil < System.currentTimeMillis()) {
int hour = Jobs.getGCManager().getResetTimeHour();
int minute = Jobs.getGCManager().getResetTimeMinute();
Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, 1);
c.set(Calendar.HOUR_OF_DAY, hour);
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
if (c.getTimeInMillis() - System.currentTimeMillis() > 86400000) {
c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, hour);
c.set(Calendar.MINUTE, minute);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
}
validUntil = c.getTimeInMillis();
}
return validUntil;
}
public void setValidUntil(Long validUntil) {
public void setValidUntil(long validUntil) {
this.validUntil = validUntil;
}
@ -184,7 +189,7 @@ public class Quest {
public void setObjectives(Map<ActionType, Map<String, QuestObjective>> objectives) {
if (objectives == null) {
objectives = new HashMap<>();
return;
}
this.objectives = objectives;

View File

@ -65,16 +65,16 @@ public class QuestProgression {
}
}
public Long getValidUntil() {
public long getValidUntil() {
return validUntil;
}
public void setValidUntil(Long validUntil) {
public void setValidUntil(long validUntil) {
this.validUntil = validUntil;
}
public boolean isValid() {
return validUntil == getValidUntil();
return !isEnded();
}
public boolean isEnded() {
@ -103,7 +103,7 @@ public class QuestProgression {
org.bukkit.entity.Player player = jPlayer.getPlayer();
for (String area : quest.getRestrictedAreas()) {
for (Entry<String, RestrictedArea> a : Jobs.getRestrictedAreaManager().getRestrictedAres().entrySet()) {
for (Entry<String, RestrictedArea> a : Jobs.getRestrictedAreaManager().getRestrictedAreas().entrySet()) {
if (a.getKey().equalsIgnoreCase(area) && a.getValue().inRestrictedArea(player.getLocation())) {
return;
}
@ -120,8 +120,10 @@ public class QuestProgression {
if (!isCompleted()) {
QuestObjective objective = null;
if (byAction != null) {
objective = byAction.get(action.getName());
if (objective == null)
objective = byAction.get(action.getNameWithSub());
}