mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +01:00
Fixing stats command when reaching max level limits
This commit is contained in:
parent
abd04d9653
commit
b7cfc104bb
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -17,6 +18,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.list.gtop;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.TopList;
|
||||
|
||||
|
@ -12,11 +12,13 @@ public class jobsSign {
|
||||
|
||||
private String worldName;
|
||||
|
||||
private Integer x, y, z;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private World world;
|
||||
private Location loc;
|
||||
|
||||
private Integer number;
|
||||
private int number = 0;
|
||||
private String jobName;
|
||||
private boolean special = false;
|
||||
private SignTopType type;
|
||||
|
@ -7,7 +7,6 @@ import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -28,6 +27,7 @@ import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
||||
import net.Zrips.CMILib.Colors.CMIChatColor;
|
||||
import net.Zrips.CMILib.Container.CMIArray;
|
||||
import net.Zrips.CMILib.Container.PageInfo;
|
||||
import net.Zrips.CMILib.Locale.LC;
|
||||
@ -373,15 +373,15 @@ public class JobsCommands implements CommandExecutor {
|
||||
double income = info.getIncome(level, numjobs, player.maxJobsEquation);
|
||||
|
||||
income = boost.getFinalAmount(CurrencyType.MONEY, income);
|
||||
String incomeColor = income >= 0 ? "" : ChatColor.DARK_RED.toString();
|
||||
String incomeColor = income >= 0 ? "" : CMIChatColor.DARK_RED.toString();
|
||||
|
||||
double xp = info.getExperience(level, numjobs, player.maxJobsEquation);
|
||||
xp = boost.getFinalAmount(CurrencyType.EXP, xp);
|
||||
String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString();
|
||||
String xpColor = xp >= 0 ? "" : CMIChatColor.GRAY.toString();
|
||||
|
||||
double points = info.getPoints(level, numjobs, player.maxJobsEquation);
|
||||
points = boost.getFinalAmount(CurrencyType.POINTS, points);
|
||||
String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString();
|
||||
String pointsColor = xp >= 0 ? "" : CMIChatColor.RED.toString();
|
||||
|
||||
if (income == 0D && points == 0D && xp == 0D)
|
||||
continue;
|
||||
@ -390,7 +390,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
|
||||
message.append(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", materialName));
|
||||
if (prog != null && !info.isInLevelRange(prog.getLevel()))
|
||||
message.append(ChatColor.RED + " -> ");
|
||||
message.append(CMIChatColor.RED + " -> ");
|
||||
else
|
||||
message.append(" -> ");
|
||||
|
||||
@ -417,19 +417,27 @@ public class JobsCommands implements CommandExecutor {
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String jobStatsMessage(JobProgression jobProg) {
|
||||
return jobStatsMessage(jobProg, null, true);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String jobStatsMessage(JobProgression jobProg, boolean progressBar) {
|
||||
return jobStatsMessage(jobProg, null, progressBar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays job stats about a particular player's job
|
||||
* @param jobProg - the job progress of the players job
|
||||
* @param jPlayer - the player of the job
|
||||
* @param progressBar - if the progress bar should be displayed
|
||||
* @return the message
|
||||
*/
|
||||
public String jobStatsMessage(JobProgression jobProg) {
|
||||
return jobStatsMessage(jobProg, true);
|
||||
}
|
||||
public String jobStatsMessage(JobProgression jobProg, JobsPlayer jPlayer, boolean progressBar) {
|
||||
|
||||
public String jobStatsMessage(JobProgression jobProg, boolean progressBar) {
|
||||
boolean isMaxLevelReached = jobProg.getLevel() == jobProg.getJob().getMaxLevel();
|
||||
String path = "command.stats.output." + (isMaxLevelReached ? "max-level"
|
||||
: "message");
|
||||
boolean isMaxLevelReached = jobProg.getLevel() >= (jPlayer == null ? jobProg.getJob().getMaxLevel() : jPlayer.getMaxJobLevelAllowed(jobProg.getJob()));
|
||||
String path = "command.stats.output." + (isMaxLevelReached ? "max-level" : "message");
|
||||
|
||||
Title title = Jobs.getTitleManager().getTitle(jobProg.getLevel(), jobProg.getJob().getName());
|
||||
String message = Jobs.getLanguage().getMessage(path,
|
||||
|
@ -103,7 +103,7 @@ public class gtop implements Cmd {
|
||||
pi.autoPagination(sender, "jobs gtop");
|
||||
}
|
||||
|
||||
private static boolean hasToBeSeenInGlobalTop(TopList topList) {
|
||||
public static boolean hasToBeSeenInGlobalTop(TopList topList) {
|
||||
Player player = topList.getPlayerInfo().getJobsPlayer().getPlayer();
|
||||
if (player != null)
|
||||
return !player.hasPermission("jobs.hidegtop");
|
||||
|
@ -47,7 +47,7 @@ public class stats implements Cmd {
|
||||
String pref = JobsCommands.LABEL + " " + info.class.getSimpleName() + " ";
|
||||
|
||||
for (JobProgression jobProg : jPlayer.getJobProgression()) {
|
||||
for (String msg : Jobs.getCommandManager().jobStatsMessage(jobProg, sender instanceof Player).split("\n")) {
|
||||
for (String msg : Jobs.getCommandManager().jobStatsMessage(jobProg, jPlayer, sender instanceof Player).split("\n")) {
|
||||
new RawMessage().addText(msg).addHover(leftClick).addCommand(pref + jobProg.getJob().getName()).show(sender);
|
||||
}
|
||||
}
|
||||
|
@ -258,21 +258,22 @@ public class BlockOwnerShip {
|
||||
|
||||
public UUID getOwnerByLocation(Location loc) {
|
||||
Map<String, UUID> record = ownerMapByLocation.get(loc.getWorld().getName());
|
||||
if (record == null) {
|
||||
if (record == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
blockLoc bl = new blockLoc(loc);
|
||||
return record.get(bl.toVectorString());
|
||||
}
|
||||
|
||||
public int clear(UUID uuid) {
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.remove(uuid);
|
||||
if (ls == null) {
|
||||
if (ls == null)
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (blockLoc one : ls.values()) {
|
||||
if (one.getBlock() != null) {
|
||||
if (one.getBlock() == null)
|
||||
continue;
|
||||
|
||||
one.getBlock().removeMetadata(metadataName, plugin);
|
||||
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.get(one.getWorldName());
|
||||
@ -280,8 +281,6 @@ public class BlockOwnerShip {
|
||||
oldRecord.remove(one.toVectorString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ls.size();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user