mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-07 00:38:42 +01:00
Improved displaying player's quests in console
This commit is contained in:
parent
b5318089d9
commit
8dc1bf80da
@ -445,8 +445,9 @@ public class Jobs extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the list of active jobs
|
* Returns the list of available jobs.
|
||||||
* @return list of jobs
|
*
|
||||||
|
* @return an unmodifiable list of jobs
|
||||||
*/
|
*/
|
||||||
public static List<Job> getJobs() {
|
public static List<Job> getJobs() {
|
||||||
return Collections.unmodifiableList(jobs);
|
return Collections.unmodifiableList(jobs);
|
||||||
|
@ -1102,7 +1102,7 @@ public class PlayerManager {
|
|||||||
boost.add(BoostOf.Item, getItemBoostNBT(pl, prog));
|
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)));
|
boost.add(BoostOf.Area, new BoostMultiplier().add(Jobs.getRestrictedAreaManager().getRestrictedMultiplier(pl)));
|
||||||
|
|
||||||
return boost;
|
return boost;
|
||||||
|
@ -117,7 +117,7 @@ public class area implements Cmd {
|
|||||||
|
|
||||||
if (args.length == 1 && args[0].equalsIgnoreCase("list")) {
|
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()) {
|
if (areas.isEmpty()) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreas"));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.noAreas"));
|
||||||
return true;
|
return true;
|
||||||
|
@ -11,6 +11,7 @@ import com.gamingmesh.jobs.Jobs;
|
|||||||
import com.gamingmesh.jobs.commands.Cmd;
|
import com.gamingmesh.jobs.commands.Cmd;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
import com.gamingmesh.jobs.container.Quest;
|
||||||
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.TimeManage;
|
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()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests()));
|
||||||
|
|
||||||
if (!isPlayer) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (JobProgression jobProg : jPlayer.progression) {
|
for (JobProgression jobProg : jPlayer.progression) {
|
||||||
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
|
||||||
|
|
||||||
for (QuestProgression q : list) {
|
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");
|
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]",
|
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");
|
String hoverMsg = Jobs.getLanguage().getMessage("command.quests.output.hover");
|
||||||
List<String> hoverList = new ArrayList<>();
|
List<String> hoverList = new ArrayList<>();
|
||||||
|
|
||||||
for (String current : hoverMsg.split("\n")) {
|
for (String current : hoverMsg.split("\n")) {
|
||||||
current = current.replace("[jobName]", jobProg.getJob().getName())
|
current = current.replace("[jobName]", jobProg.getJob().getName())
|
||||||
.replace("[time]", TimeManage.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
|
.replace("[time]", TimeManage.to24hourShort(q.getValidUntil() - System.currentTimeMillis()));
|
||||||
|
|
||||||
if (current.contains("[desc]")) {
|
if (current.contains("[desc]")) {
|
||||||
hoverList.addAll(q.getQuest().getDescription());
|
hoverList.addAll(quest.getDescription());
|
||||||
} else {
|
} else {
|
||||||
hoverList.add(current);
|
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()) {
|
for (Entry<String, QuestObjective> oneObjective : oneAction.entrySet()) {
|
||||||
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +
|
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()
|
Jobs.getNameTranslatorManager().translate(oneObjective.getKey(), oneObjective.getValue().getAction(), oneObjective.getValue().getTargetId(), oneObjective.getValue()
|
||||||
@ -123,12 +134,12 @@ public class quests implements Cmd {
|
|||||||
hover += one;
|
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) {
|
if (Jobs.getGCManager().getDailyQuestsSkips() > 0) {
|
||||||
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skip");
|
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skip");
|
||||||
hover += "\n" + Jobs.getLanguage().getMessage("command.quests.output.skips", "[skips]", (Jobs.getGCManager().getDailyQuestsSkips() - jPlayer.getSkippedQuests()));
|
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
|
} else
|
||||||
rm.addText(msg).addHover(hover);
|
rm.addText(msg).addHover(hover);
|
||||||
|
|
||||||
|
@ -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() {
|
public Map<String, RestrictedArea> getRestrictedAres() {
|
||||||
return restrictedAreas;
|
return restrictedAreas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, RestrictedArea> getRestrictedAreas() {
|
||||||
|
return restrictedAreas;
|
||||||
|
}
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
|
File f = new File(Jobs.getFolder(), "restrictedAreas.yml");
|
||||||
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
YamlConfiguration conf = YamlConfiguration.loadConfiguration(f);
|
||||||
|
@ -52,8 +52,9 @@ public class ExploreChunk {
|
|||||||
|
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
for (Integer one : playerIds) {
|
for (Integer one : playerIds) {
|
||||||
if (!s.toString().isEmpty())
|
if (s.length() != 0)
|
||||||
s.append(';');
|
s.append(';');
|
||||||
|
|
||||||
s.append(one);
|
s.append(one);
|
||||||
}
|
}
|
||||||
return s.toString();
|
return s.toString();
|
||||||
@ -73,11 +74,13 @@ public class ExploreChunk {
|
|||||||
try {
|
try {
|
||||||
int id = Integer.parseInt(one);
|
int id = Integer.parseInt(one);
|
||||||
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(id);
|
PlayerInfo info = Jobs.getPlayerManager().getPlayerInfo(id);
|
||||||
|
|
||||||
if (info != null)
|
if (info != null)
|
||||||
playerIds.add(id);
|
playerIds.add(id);
|
||||||
} catch (Exception e) {
|
} catch (NumberFormatException e) {
|
||||||
updated = true;
|
updated = true;
|
||||||
JobsPlayer jp = Jobs.getPlayerManager().getJobsPlayer(one);
|
JobsPlayer jp = Jobs.getPlayerManager().getJobsPlayer(one);
|
||||||
|
|
||||||
if (jp != null)
|
if (jp != null)
|
||||||
playerIds.add(jp.getUserId());
|
playerIds.add(jp.getUserId());
|
||||||
}
|
}
|
||||||
@ -85,6 +88,7 @@ public class ExploreChunk {
|
|||||||
|
|
||||||
if (playerIds.size() >= Jobs.getExplore().getPlayerAmount() && Jobs.getGCManager().ExploreCompact) {
|
if (playerIds.size() >= Jobs.getExplore().getPlayerAmount() && Jobs.getGCManager().ExploreCompact) {
|
||||||
playerIds = null;
|
playerIds = null;
|
||||||
|
|
||||||
if (!names.isEmpty())
|
if (!names.isEmpty())
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
|
||||||
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
import com.gamingmesh.jobs.CMILib.CMIChatColor;
|
||||||
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
import com.gamingmesh.jobs.CMILib.CMIMaterial;
|
||||||
|
|
||||||
@ -65,8 +64,6 @@ public class JobLimitedItems {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
Jobs plugin = org.bukkit.plugin.java.JavaPlugin.getPlugin(Jobs.class);
|
|
||||||
|
|
||||||
if (name != null)
|
if (name != null)
|
||||||
meta.setDisplayName(CMIChatColor.translate(name));
|
meta.setDisplayName(CMIChatColor.translate(name));
|
||||||
|
|
||||||
|
@ -406,9 +406,9 @@ public class JobsPlayer {
|
|||||||
* Reloads limit for this player.
|
* Reloads limit for this player.
|
||||||
*/
|
*/
|
||||||
public void reload(CurrencyType type) {
|
public void reload(CurrencyType type) {
|
||||||
int totalLevel = getTotalLevels();
|
|
||||||
Parser eq = Jobs.getGCManager().getLimit(type).getMaxEquation();
|
Parser eq = Jobs.getGCManager().getLimit(type).getMaxEquation();
|
||||||
eq.setVariable("totallevel", totalLevel);
|
eq.setVariable("totallevel", getTotalLevels());
|
||||||
|
|
||||||
maxJobsEquation = Jobs.getPlayerManager().getMaxJobs(this);
|
maxJobsEquation = Jobs.getPlayerManager().getMaxJobs(this);
|
||||||
limits.put(type, (int) eq.getValue());
|
limits.put(type, (int) eq.getValue());
|
||||||
setSaved(false);
|
setSaved(false);
|
||||||
|
@ -15,7 +15,7 @@ public class Quest {
|
|||||||
private String configName = "";
|
private String configName = "";
|
||||||
private String questName = "";
|
private String questName = "";
|
||||||
private Job job;
|
private Job job;
|
||||||
private Long validUntil = 0L;
|
private long validUntil = 0L;
|
||||||
|
|
||||||
private int chance = 100, minLvl = 0;
|
private int chance = 100, minLvl = 0;
|
||||||
private Integer maxLvl;
|
private Integer maxLvl;
|
||||||
@ -76,30 +76,35 @@ public class Quest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getValidUntil() {
|
public long getValidUntil() {
|
||||||
if (validUntil < System.currentTimeMillis()) {
|
if (validUntil < System.currentTimeMillis()) {
|
||||||
int hour = Jobs.getGCManager().getResetTimeHour();
|
int hour = Jobs.getGCManager().getResetTimeHour();
|
||||||
int minute = Jobs.getGCManager().getResetTimeMinute();
|
int minute = Jobs.getGCManager().getResetTimeMinute();
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
|
|
||||||
c.add(Calendar.DAY_OF_MONTH, 1);
|
c.add(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
|
||||||
c.set(Calendar.HOUR_OF_DAY, hour);
|
c.set(Calendar.HOUR_OF_DAY, hour);
|
||||||
c.set(Calendar.MINUTE, minute);
|
c.set(Calendar.MINUTE, minute);
|
||||||
c.set(Calendar.SECOND, 0);
|
c.set(Calendar.SECOND, 0);
|
||||||
c.set(Calendar.MILLISECOND, 0);
|
c.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
if (c.getTimeInMillis() - System.currentTimeMillis() > 86400000) {
|
if (c.getTimeInMillis() - System.currentTimeMillis() > 86400000) {
|
||||||
c = Calendar.getInstance();
|
c = Calendar.getInstance();
|
||||||
|
|
||||||
c.set(Calendar.HOUR_OF_DAY, hour);
|
c.set(Calendar.HOUR_OF_DAY, hour);
|
||||||
c.set(Calendar.MINUTE, minute);
|
c.set(Calendar.MINUTE, minute);
|
||||||
c.set(Calendar.SECOND, 0);
|
c.set(Calendar.SECOND, 0);
|
||||||
c.set(Calendar.MILLISECOND, 0);
|
c.set(Calendar.MILLISECOND, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
validUntil = c.getTimeInMillis();
|
validUntil = c.getTimeInMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
return validUntil;
|
return validUntil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValidUntil(Long validUntil) {
|
public void setValidUntil(long validUntil) {
|
||||||
this.validUntil = validUntil;
|
this.validUntil = validUntil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +189,7 @@ public class Quest {
|
|||||||
|
|
||||||
public void setObjectives(Map<ActionType, Map<String, QuestObjective>> objectives) {
|
public void setObjectives(Map<ActionType, Map<String, QuestObjective>> objectives) {
|
||||||
if (objectives == null) {
|
if (objectives == null) {
|
||||||
objectives = new HashMap<>();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.objectives = objectives;
|
this.objectives = objectives;
|
||||||
|
@ -65,16 +65,16 @@ public class QuestProgression {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getValidUntil() {
|
public long getValidUntil() {
|
||||||
return validUntil;
|
return validUntil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValidUntil(Long validUntil) {
|
public void setValidUntil(long validUntil) {
|
||||||
this.validUntil = validUntil;
|
this.validUntil = validUntil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return validUntil == getValidUntil();
|
return !isEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnded() {
|
public boolean isEnded() {
|
||||||
@ -103,7 +103,7 @@ public class QuestProgression {
|
|||||||
org.bukkit.entity.Player player = jPlayer.getPlayer();
|
org.bukkit.entity.Player player = jPlayer.getPlayer();
|
||||||
|
|
||||||
for (String area : quest.getRestrictedAreas()) {
|
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())) {
|
if (a.getKey().equalsIgnoreCase(area) && a.getValue().inRestrictedArea(player.getLocation())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -120,8 +120,10 @@ public class QuestProgression {
|
|||||||
|
|
||||||
if (!isCompleted()) {
|
if (!isCompleted()) {
|
||||||
QuestObjective objective = null;
|
QuestObjective objective = null;
|
||||||
|
|
||||||
if (byAction != null) {
|
if (byAction != null) {
|
||||||
objective = byAction.get(action.getName());
|
objective = byAction.get(action.getName());
|
||||||
|
|
||||||
if (objective == null)
|
if (objective == null)
|
||||||
objective = byAction.get(action.getNameWithSub());
|
objective = byAction.get(action.getNameWithSub());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user