* Fixed being kicked for too long names in the scoreboard. Fixes #5.
This commit is contained in:
parent
012fac4c9a
commit
fc48dc2fae
@ -801,4 +801,20 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Short a String for like the Scoreboard title.
|
||||
*
|
||||
* @param string
|
||||
* String to be shorten.
|
||||
* @param maxLenght
|
||||
* Max lenght of the characters.
|
||||
* @return Shorten string, else normal string.
|
||||
*/
|
||||
public static String cutString(String string, int maxLenght) {
|
||||
if (string.length() > maxLenght) {
|
||||
string = string.substring(0, maxLenght);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
@ -19,22 +19,23 @@ public class ScoreboardHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
Objective object = board.registerNewObjective(arena.arenaName,
|
||||
"dummy");
|
||||
Objective object = board.registerNewObjective(
|
||||
BlockHunt.cutString(arena.arenaName, 32), "dummy");
|
||||
object.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
object.setDisplayName(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_title)));
|
||||
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_timeleft))));
|
||||
object.setDisplayName(BlockHunt.cutString(
|
||||
MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_title)), 32));
|
||||
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_timeleft)), 32)));
|
||||
timeleft.setScore(arena.timer);
|
||||
Score seekers = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_seekers))));
|
||||
Score seekers = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_seekers)), 32)));
|
||||
seekers.setScore(arena.seekers.size());
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_hiders))));
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_hiders)), 32)));
|
||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
@ -53,19 +54,20 @@ public class ScoreboardHandler {
|
||||
if ((Boolean) W.config.get(ConfigC.scoreboard_enabled) == true) {
|
||||
Scoreboard board = arena.scoreboard;
|
||||
Objective object = board.getObjective(DisplaySlot.SIDEBAR);
|
||||
object.setDisplayName(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_title)));
|
||||
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_timeleft))));
|
||||
object.setDisplayName(BlockHunt.cutString(
|
||||
MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_title)), 32));
|
||||
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_timeleft)), 32)));
|
||||
timeleft.setScore(arena.timer);
|
||||
Score seekers = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_seekers))));
|
||||
Score seekers = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_seekers)), 32)));
|
||||
seekers.setScore(arena.seekers.size());
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_hiders))));
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(BlockHunt
|
||||
.cutString(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_hiders)), 32)));
|
||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user