1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

Lets fix quest description showing in list

This commit is contained in:
montlikadani 2019-11-05 19:03:14 +01:00
parent e52be093d6
commit ecf07433df
20 changed files with 46 additions and 58 deletions

View File

@ -1,5 +1,5 @@
# 4.15.0
- Fixed issue for jobs browse when opened and showing the same actions.
- Fixed issue when the quest description only showed one lines of list.
# 4.14.0
- Fixed %titlename% placeholder does not showed anything

View File

@ -2,9 +2,7 @@ package com.gamingmesh.jobs.Gui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

View File

@ -115,15 +115,15 @@ public class PlayerManager {
}
public void addPlayerToCache(JobsPlayer jPlayer) {
if (jPlayer.getUserName() != null && playersCache.get(jPlayer.getUserName().toLowerCase()) == null)
playersCache.put(jPlayer.getUserName().toLowerCase(), jPlayer);
if (jPlayer.getName() != null && playersCache.get(jPlayer.getName().toLowerCase()) == null)
playersCache.put(jPlayer.getName().toLowerCase(), jPlayer);
if (jPlayer.getUniqueId() != null && playersUUIDCache.get(jPlayer.getUniqueId()) == null)
playersUUIDCache.put(jPlayer.getUniqueId(), jPlayer);
}
public void addPlayer(JobsPlayer jPlayer) {
if (jPlayer.getUserName() != null && players.get(jPlayer.getUserName().toLowerCase()) == null)
players.put(jPlayer.getUserName().toLowerCase(), jPlayer);
if (jPlayer.getName() != null && players.get(jPlayer.getName().toLowerCase()) == null)
players.put(jPlayer.getName().toLowerCase(), jPlayer);
if (jPlayer.getUniqueId() != null && playersUUID.get(jPlayer.getUniqueId()) == null)
playersUUID.put(jPlayer.getUniqueId(), jPlayer);
}
@ -554,7 +554,7 @@ public class PlayerManager {
if (player != null)
message = message.replace("%playername%", player.getDisplayName());
else
message = message.replace("%playername%", jPlayer.getUserName());
message = message.replace("%playername%", jPlayer.getName());
message = message.replace("%joblevel%", "" + prog.getLevel());
message = message.replace("%lostLevel%", "" + oldLevel);
@ -714,7 +714,7 @@ public class PlayerManager {
if (player != null)
message = message.replace("%playername%", player.getDisplayName());
else
message = message.replace("%playername%", jPlayer.getUserName());
message = message.replace("%playername%", jPlayer.getName());
message = message.replace("%joblevel%", "" + prog.getLevel());
for (String line : message.split("\n")) {
@ -753,7 +753,7 @@ public class PlayerManager {
if (player != null)
message = message.replace("%playername%", player.getDisplayName());
else
message = message.replace("%playername%", jPlayer.getUserName());
message = message.replace("%playername%", jPlayer.getName());
message = message.replace("%titlename%", levelUpEvent.getNewTitleColor() + levelUpEvent.getNewTitleName());
message = message.replace("%jobname%", job.getChatColor() + job.getName());

View File

@ -36,10 +36,8 @@ import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.QuestProgression;
import com.gamingmesh.jobs.container.Title;
import com.gamingmesh.jobs.stuff.PageInfo;
import com.gamingmesh.jobs.stuff.TimeManage;
public class JobsCommands implements CommandExecutor {
public static final String label = "jobs";
@ -403,10 +401,10 @@ public class JobsCommands implements CommandExecutor {
String t = type == "" ? "" : " " + type;
if (sender instanceof Player)
if (sender.getName().equalsIgnoreCase(player.getUserName()))
if (sender.getName().equalsIgnoreCase(player.getName()))
plugin.ShowPagination(sender, pi.getTotalPages(), page, "jobs info " + job.getName() + t);
else
plugin.ShowPagination(sender, pi.getTotalPages(), page, "jobs playerinfo " + player.getUserName() + " " + job.getName() + t);
plugin.ShowPagination(sender, pi.getTotalPages(), page, "jobs playerinfo " + player.getName() + " " + job.getName() + t);
}
/**
@ -537,18 +535,4 @@ public class JobsCommands implements CommandExecutor {
"%jobmaxxp%", jobProg.getMaxExperience(level));
return " " + jobProgressMessage(jobProg.getMaxExperience(level), exp) + " " + message;
}
public String jobsQuestMessage(QuestProgression qp, JobProgression prog) {
String hoverMsg = Jobs.getLanguage().getMessage("command.quests.output.hover");
hoverMsg = hoverMsg.replace("[jobName]", prog.getJob().getName())
.replace("[time]", TimeManage.to24hourShort(qp.getValidUntil() - System.currentTimeMillis()));
if (hoverMsg.contains("[desc]")) {
for (String one : qp.getQuest().getDescription()) {
hoverMsg = hoverMsg.replace("[desc]", one);
}
}
return hoverMsg;
}
}

View File

@ -43,7 +43,7 @@ public class archive implements Cmd {
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getUserName()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getName()));
for (JobProgression jobInfo : AllJobs) {
RawMessage rm = new RawMessage();
if (jobInfo.canRejoin())

View File

@ -12,14 +12,12 @@ public class editpoints implements Cmd {
@Override
@JobCommand(475)
public boolean perform(Jobs plugin, CommandSender sender, String[] args) {
if (args.length != 3) {
Jobs.getCommandManager().sendUsage(sender, "editpoints");
return true;
}
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[1]);
if (jPlayer == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[1]));
return true;
@ -34,9 +32,8 @@ public class editpoints implements Cmd {
}
PlayerPoints pointInfo = Jobs.getPointsData().getPlayerPointsInfo(jPlayer.getUniqueId());
if (pointInfo == null) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", jPlayer.getUserName()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", jPlayer.getName()));
return true;
}
@ -44,21 +41,21 @@ public class editpoints implements Cmd {
case "take":
pointInfo.takePoints(amount);
sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.take",
"%playername%", jPlayer.getUserName(),
"%playername%", jPlayer.getName(),
"%amount%", amount,
"%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D));
break;
case "add":
pointInfo.addPoints(amount);
sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.add",
"%playername%", jPlayer.getUserName(),
"%playername%", jPlayer.getName(),
"%amount%", amount,
"%total%", (int) (pointInfo.getCurrentPoints() * 100) / 100D));
break;
case "set":
pointInfo.setPoints(amount);
sender.sendMessage(Jobs.getLanguage().getMessage("command.editpoints.output.set",
"%playername%", jPlayer.getUserName(),
"%playername%", jPlayer.getName(),
"%amount%", amount));
break;
default:

View File

@ -68,7 +68,7 @@ public class log implements Cmd {
unsortMap = Sorting.sortDoubleDESC(unsortMap);
int count = 0;
int max = 10;
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.topline", "%playername%", JPlayer.getUserName()));
sender.sendMessage(Jobs.getLanguage().getMessage("command.log.output.topline", "%playername%", JPlayer.getName()));
for (Entry<String, Log> l : logList.entrySet()) {
Log one = l.getValue();
HashMap<String, LogAmounts> AmountList = one.getAmountList();

View File

@ -40,7 +40,7 @@ public class points implements Cmd {
PlayerPoints pointInfo = Jobs.getPointsData().getPlayerPointsInfo(jPlayer.getUniqueId());
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getUserName()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getName()));
sender.sendMessage(Jobs.getLanguage().getMessage("command.points.currentpoints", "%currentpoints%", (int) (pointInfo.getCurrentPoints() * 100) / 100D));
sender.sendMessage(Jobs.getLanguage().getMessage("command.points.totalpoints", "%totalpoints%", (int) (pointInfo.getTotalPoints() * 100) / 100D));
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));

View File

@ -14,7 +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.stuff.TimeManage;
import com.gamingmesh.jobs.CMILib.RawMessage;
public class quests implements Cmd {
@ -50,7 +50,7 @@ public class quests implements Cmd {
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.toplineseparator", "[playerName]", jPlayer.getUserName(), "[questsDone]", jPlayer.getDoneQuests()));
sender.sendMessage(Jobs.getLanguage().getMessage("command.quests.toplineseparator", "[playerName]", jPlayer.getName(), "[questsDone]", jPlayer.getDoneQuests()));
if (sender instanceof Player) {
for (JobProgression jobProg : jPlayer.getJobProgression()) {
List<QuestProgression> list = jPlayer.getQuestProgressions(jobProg.getJob());
@ -65,8 +65,20 @@ public class quests implements Cmd {
String msg = Jobs.getLanguage().getMessage("command.quests.output.questLine", "[progress]",
progressLine, "[questName]", q.getQuest().getQuestName(), "[done]", q.getTotalAmountDone(), "[required]", q.getTotalAmountNeeded());
String hoverMsg = Jobs.getLanguage().getMessage("command.quests.output.hover");
List<String> hoverList = new ArrayList<>();
hoverList.add(Jobs.getCommandManager().jobsQuestMessage(q, jobProg));
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]")) {
for (String one : q.getQuest().getDescription()) {
hoverList.add(one);
}
} else {
hoverList.add(current);
}
}
for (Entry<String, QuestObjective> oneObjective : q.getQuest().getObjectives().entrySet()) {
hoverList.add(Jobs.getLanguage().getMessage("command.info.output." + oneObjective.getValue().getAction().toString().toLowerCase() + ".info") + " " +

View File

@ -24,7 +24,7 @@ public class resetlimit implements Cmd {
}
jPlayer.resetPaymentLimit();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetlimit.output.reseted", "%playername%", jPlayer.getUserName()));
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetlimit.output.reseted", "%playername%", jPlayer.getName()));
return true;
}

View File

@ -62,7 +62,7 @@ public class resetquest implements Cmd {
jPlayer.resetQuests();
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.reseted", "%playername%", jPlayer.getUserName()));
sender.sendMessage(Jobs.getLanguage().getMessage("command.resetquest.output.reseted", "%playername%", jPlayer.getName()));
return true;
}

View File

@ -36,7 +36,7 @@ public class stats implements Cmd {
return true;
}
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getUserName()));
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.toplineseparator", "%playername%", jPlayer.getName()));
for (JobProgression jobProg : jPlayer.getJobProgression()) {
String[] msg = Jobs.getCommandManager().jobStatsMessage(jobProg).split("\n");
sender.sendMessage(msg);

View File

@ -119,7 +119,7 @@ public class BossBarManager {
if (target == null)
return;
bar.addPlayer(target);
OldOne = new BossBarInfo(player.getUserName(), jobProg.getJob().getName(), bar);
OldOne = new BossBarInfo(player.getName(), jobProg.getJob().getName(), bar);
player.getBossBarInfo().add(OldOne);
}
bar.setVisible(true);
@ -133,7 +133,7 @@ public class BossBarManager {
@Override
public void run() {
for (BossBarInfo one : player.getBossBarInfo()) {
if (!one.getPlayerName().equalsIgnoreCase(player.getUserName()))
if (!one.getPlayerName().equalsIgnoreCase(player.getName()))
continue;
if (!one.getJobName().equalsIgnoreCase(jobProg.getJob().getName()))

View File

@ -193,7 +193,7 @@ public class ShopManager {
skullMeta.setLore(Lore);
if (item.isHeadOwner())
skullMeta.setOwner(Jobs.getPlayerManager().getJobsPlayer(player).getUserName());
skullMeta.setOwner(Jobs.getPlayerManager().getJobsPlayer(player).getName());
else {
try {
OfflinePlayer offPlayer = Bukkit.getOfflinePlayer(item.getCustomHead());

View File

@ -19,7 +19,6 @@
package com.gamingmesh.jobs.container;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@ -35,7 +34,6 @@ 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;

View File

@ -32,7 +32,7 @@ public class PlayerInfo {
if (player == null)
player = Jobs.getPlayerManager().getJobsPlayer(uuid);
if (player != null)
return player.getUserName();
return player.getName();
return name;
}

View File

@ -7,7 +7,6 @@ import org.bukkit.Bukkit;
import org.bukkit.event.server.ServerCommandEvent;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.stuff.Debug;
public class QuestProgression {

View File

@ -1786,7 +1786,7 @@ public abstract class JobsDAO {
public JobsPlayer loadFromDao(JobsPlayer jPlayer) {
List<JobsDAOData> list = getAllJobs(jPlayer.getUserName(), jPlayer.getUniqueId());
List<JobsDAOData> list = getAllJobs(jPlayer.getName(), jPlayer.getUniqueId());
// synchronized (jPlayer.saveLock) {
jPlayer.progression.clear();
for (JobsDAOData jobdata : list) {
@ -1943,7 +1943,7 @@ public abstract class JobsDAO {
+ "` = ?, `" + UserTableFields.quests.getCollumn()
+ "` = ? WHERE `id` = ?;");
prest.setLong(1, System.currentTimeMillis());
prest.setString(2, player.getUserName());
prest.setString(2, player.getName());
prest.setInt(3, player.getDoneQuests());
prest.setString(4, player.getQuestProgressionString());
prest.setInt(5, player.getUserId());
@ -1967,7 +1967,7 @@ public abstract class JobsDAO {
+ "`, `" + UserTableFields.donequests.getCollumn()
+ "`) VALUES (?, ?, ?, ?);");
prestt.setString(1, player.getUniqueId().toString());
prestt.setString(2, player.getUserName());
prestt.setString(2, player.getName());
prestt.setLong(3, player.getSeen());
prestt.setInt(4, 0);
prestt.executeUpdate();
@ -1987,7 +1987,7 @@ public abstract class JobsDAO {
int id = res.getInt("id");
player.setUserId(id);
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(
player.getUserName(),
player.getName(),
id,
player.getUniqueId(),
player.getSeen(),

View File

@ -1151,7 +1151,7 @@ public class JobsPaymentListener implements Listener {
if (lVictim instanceof Player && !lVictim.hasMetadata("NPC")) {
Player VPlayer = (Player) lVictim;
if (jDamager.getUserName().equalsIgnoreCase(VPlayer.getName()))
if (jDamager.getName().equalsIgnoreCase(VPlayer.getName()))
return;
}

View File

@ -16,7 +16,7 @@ public class PerformCommands {
return;
for (String one : cmds) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getUserName()).replace("[jobname]", job.getName()));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getName()).replace("[jobname]", job.getName()));
}
}
@ -27,7 +27,7 @@ public class PerformCommands {
return;
for (String one : cmds) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getUserName()).replace("[jobname]", job.getName()));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), one.replace("[name]", jPlayer.getName()).replace("[jobname]", job.getName()));
}
}
}