1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-03 23:08:07 +01:00

Sort scoreboard by seting line number instead of jobs level

This commit is contained in:
Zrips 2016-12-02 18:40:20 +02:00
parent 40741d1a7d
commit 851d4600e1
7 changed files with 472 additions and 460 deletions

View File

@ -701,7 +701,6 @@ public class PlayerManager {
if (Jobs.getGCManager().useDynamicPayment)
boost.add(BoostOf.Dynamic, new BoostMultiplier().add(prog.getBonus()));
boost.add(BoostOf.Item, Jobs.getPlayerManager().getItemBoost(player.getPlayer(), prog));
boost.add(BoostOf.Item, Jobs.getPlayerManager().getItemBoost(player.getPlayer(), prog));
boost.add(BoostOf.Area, new BoostMultiplier().add(Jobs.getRestrictedAreaManager().getRestrictedMultiplier(player.getPlayer())));
return boost;

View File

@ -13,10 +13,12 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.meta.SkullMeta;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.config.CommentedYamlConfiguration;
import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.stuff.Debug;
public class SignUtil {
@ -227,6 +229,7 @@ public class SignUtil {
skull.setOwner(Playername);
skull.update();
return;
}
}, timelapse * Jobs.getGCManager().InfoUpdateInterval * 20L);

View File

@ -72,13 +72,13 @@ public class gtop implements Cmd {
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName(Jobs.getLanguage().getMessage("scoreboard.gtopline"));
int i = start;
int line = 16;
for (TopList One : FullList) {
i++;
line--;
String playername = One.getPlayerName() != null ? One.getPlayerName() : "Unknown";
Score score = objective.getScore(Jobs.getLanguage().getMessage("scoreboard.lines", "%number%", i, "%playername%", playername));
score.setScore(One.getLevel());
Score score = objective.getScore(Jobs.getLanguage().getMessage("scoreboard.line", "%number%", i, "%playername%", playername, "%level%", One.getLevel()));
score.setScore(line);
}
player.setScoreboard(board);

View File

@ -51,9 +51,14 @@ public class top implements Cmd {
if (start < 0)
start = 0;
if (Jobs.getJob(args[0]) == null) {
player.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.top.error.nojob"));
return false;
}
List<TopList> FullList = Jobs.getJobsDAO().toplist(args[0], start);
if (FullList.size() <= 0) {
player.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.top.error.nojob"));
player.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.noinfo"));
return false;
}
@ -68,6 +73,7 @@ public class top implements Cmd {
for (TopList One : FullList) {
i++;
String PlayerName = One.getPlayerName() != null ? One.getPlayerName() : "Unknown";
player.sendMessage(Jobs.getLanguage().getMessage("command.top.output.list", "%number%", i, "%playername%", PlayerName, "%level%", One.getLevel(), "%exp%",
One.getExp()));
}
@ -81,12 +87,14 @@ public class top implements Cmd {
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName(Jobs.getLanguage().getMessage("scoreboard.topline", "%jobname%", jobName));
int i = start;
int line = 16;
for (TopList One : FullList) {
i++;
line--;
String playername = One.getPlayerName() != null ? One.getPlayerName() : "Unknown";
Score score = objective.getScore(Jobs.getLanguage().getMessage("scoreboard.lines", "%number%", i, "%playername%", playername));
score.setScore(One.getLevel());
Score score = objective.getScore(Jobs.getLanguage().getMessage("scoreboard.line", "%number%", i, "%playername%", playername, "%level%", One.getLevel()));
score.setScore(line);
}
player.setScoreboard(board);

View File

@ -438,7 +438,7 @@ public class LanguageManager {
//c.get("scoreboard.clear", "&eIf you want to remove scoreboard, type &2/jobs top clear");
c.get("scoreboard.topline", "&2Top &e%jobname%");
c.get("scoreboard.gtopline", "&2Global top list");
c.get("scoreboard.lines", "&2%number%. &e%playername%");
c.get("scoreboard.line", "&2%number%. &e%playername% (&6%level%&e)");
Jobs.getGCManager().keys = new ArrayList<String>(c.getC().getConfigurationSection("signs.secondline").getKeys(false));

View File

@ -51,6 +51,7 @@ import com.gamingmesh.jobs.container.LogAmounts;
import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.container.TopList;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.stuff.TimeManage;
/**
@ -890,7 +891,6 @@ public abstract class JobsDAO {
prest.setInt(2, player.getUserId());
prest.execute();
} catch (SQLException e) {
e.printStackTrace();
} finally {
close(prest);
}
@ -1335,7 +1335,7 @@ public abstract class JobsDAO {
PreparedStatement prest = null;
ResultSet res = null;
try {
prest = conn.prepareStatement("SELECT DISTINCT(userid), `level`, `experience` FROM `" + prefix
prest = conn.prepareStatement("SELECT `userid`, `level`, `experience` FROM `" + prefix
+ "jobs` WHERE `job` LIKE ? ORDER BY `level` DESC, LOWER(experience) DESC LIMIT " + limit + ", 15;");
prest.setString(1, jobsname);
res = prest.executeQuery();
@ -1343,8 +1343,10 @@ public abstract class JobsDAO {
while (res.next()) {
Entry<String, PlayerInfo> info = Jobs.getPlayerManager().getPlayerInfoById(res.getInt("userid"));
if (info == null)
if (info == null){
Debug.D("Continue " + res.getInt("userid"));
continue;
}
if (info.getValue().getName() == null)
continue;

View File

@ -229,7 +229,7 @@ public class JobsListener implements Listener {
Sign sign = (Sign) block.getState();
String FirstLine = sign.getLine(0);
if (!FirstLine.equalsIgnoreCase(Jobs.getLanguage().getMessage("signs.topline")))
if (!ChatColor.stripColor(FirstLine).equalsIgnoreCase(ChatColor.stripColor(Jobs.getLanguage().getMessage("signs.topline"))))
return;
String command = ChatColor.stripColor(sign.getLine(1));
@ -242,7 +242,7 @@ public class JobsListener implements Listener {
}
Player player = event.getPlayer();
Bukkit.dispatchCommand(player, "jobs " + command + " " + ChatColor.stripColor(sign.getLine(2)) + " " + ChatColor.stripColor(sign.getLine(3)));
player.performCommand("jobs " + command + " " + ChatColor.stripColor(sign.getLine(2)) + " " + ChatColor.stripColor(sign.getLine(3)));
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)