mirror of
https://github.com/Maxlego08/zKoth.git
synced 2025-02-18 02:03:39 +01:00
🚧 Fix scoreboard
This commit is contained in:
parent
f7e88b3741
commit
2b5f8c7e31
@ -1,7 +1,7 @@
|
||||
name: zKoth
|
||||
author: Maxlego08
|
||||
main: fr.maxlego08.zkoth.ZKothPlugin
|
||||
version: 2.0.3.4
|
||||
version: 2.1.0.0
|
||||
softdepend: [PlaceholderAPI, Guilds, Factions, FactionsX, SuperiorSkyblock2, LegacyFactions, FeatherBoard, TAB, TitleManager, UltimateFactions]
|
||||
commands:
|
||||
api-version: 1.13
|
@ -47,25 +47,27 @@ public class KothExpension extends PlaceholderExpansion {
|
||||
if (koths.size() >= 1) {
|
||||
|
||||
Koth koth = koths.get(0);
|
||||
if (params.equals("name"))
|
||||
if (params.equals("name")) {
|
||||
return koth.getName();
|
||||
else if (params.equals("capture"))
|
||||
} else if (params.equals("capture")) {
|
||||
return String.valueOf(koth.getCurrentSecond());
|
||||
else if (params.equals("x"))
|
||||
} else if (params.equals("x")) {
|
||||
return String.valueOf(koth.getCenter().getBlockX());
|
||||
else if (params.equals("y"))
|
||||
} else if (params.equals("y")) {
|
||||
return String.valueOf(koth.getCenter().getBlockY());
|
||||
else if (params.equals("z"))
|
||||
} else if (params.equals("z")) {
|
||||
return String.valueOf(koth.getCenter().getBlockZ());
|
||||
else if (params.equals("faction"))
|
||||
} else if (params.equals("faction")) {
|
||||
return String.valueOf(koth.getCurrentFaction());
|
||||
else if (params.equals("player"))
|
||||
} else if (params.equals("player")) {
|
||||
return koth.getCurrentPlayer();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!params.contains("_"))
|
||||
if (!params.contains("_")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] args = params.split("_");
|
||||
|
||||
|
@ -487,12 +487,13 @@ public class ZKoth extends ZUtils implements Koth {
|
||||
|
||||
@Override
|
||||
public CollectionConsumer<Player> onScoreboard() {
|
||||
if (isCooldown)
|
||||
if (this.isCooldown) {
|
||||
return p -> Config.scoreboardCooldown.stream().map(e -> papi(replaceMessage(e), p))
|
||||
.collect(Collectors.toList());
|
||||
else
|
||||
} else {
|
||||
return p -> Config.scoreboard.stream().map(e -> papi(replaceMessage(e), p)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommand(String command) {
|
||||
|
@ -174,8 +174,9 @@ public class CommandManager extends ZUtils implements CommandExecutor, TabComple
|
||||
}
|
||||
|
||||
CommandType returnType = command.prePerform(main, sender, strings);
|
||||
if (returnType == CommandType.SYNTAX_ERROR)
|
||||
if (returnType == CommandType.SYNTAX_ERROR) {
|
||||
message(sender, Message.COMMAND_SYNTAXE_ERROR, command.getSyntaxe());
|
||||
}
|
||||
return returnType;
|
||||
}
|
||||
message(sender, Message.COMMAND_NO_PERMISSION);
|
||||
|
@ -48,6 +48,7 @@ public class Config implements Saveable {
|
||||
* static Singleton instance.
|
||||
*/
|
||||
private static volatile Config instance;
|
||||
public static boolean enableDebug;
|
||||
|
||||
/**
|
||||
* Private constructor for singleton.
|
||||
|
@ -1,7 +1,7 @@
|
||||
package fr.maxlego08.zkoth.scoreboard;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -47,11 +47,15 @@ public class ScoreBoardManager extends ZUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<String> lines = this.lines.accept(null);
|
||||
boards.forEach((player, board) -> {
|
||||
if (player.isOnline())
|
||||
board.updateLines(lines);
|
||||
});
|
||||
Iterator<FastBoard> iterator = this.boards.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
FastBoard b = iterator.next();
|
||||
if (b.isDeleted() || !b.getPlayer().isOnline()) {
|
||||
this.boards.remove(b.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
this.boards.forEach((player, board) -> board.updateLines(this.lines.accept(player)));
|
||||
|
||||
});
|
||||
}
|
||||
@ -65,16 +69,18 @@ public class ScoreBoardManager extends ZUtils {
|
||||
*/
|
||||
public FastBoard createBoard(Player player, String title) {
|
||||
|
||||
if (hasBoard(player))
|
||||
return getBoard(player);
|
||||
if (this.hasBoard(player)) {
|
||||
return this.getBoard(player);
|
||||
}
|
||||
|
||||
FastBoard board = new FastBoard(player);
|
||||
board.updateTitle(title);
|
||||
|
||||
if (lines != null)
|
||||
board.updateLines(lines.accept(player));
|
||||
if (this.lines != null) {
|
||||
board.updateLines(this.lines.accept(player));
|
||||
}
|
||||
|
||||
boards.put(player, board);
|
||||
this.boards.put(player, board);
|
||||
this.scoreboard.hide(player, create(board, player, title));
|
||||
|
||||
return board;
|
||||
@ -92,15 +98,16 @@ public class ScoreBoardManager extends ZUtils {
|
||||
|
||||
if (current != null)
|
||||
current.delete();
|
||||
boards.remove(player);
|
||||
this.boards.remove(player);
|
||||
|
||||
FastBoard board = new FastBoard(player);
|
||||
board.updateTitle(title);
|
||||
|
||||
if (lines != null)
|
||||
board.updateLines(lines.accept(player));
|
||||
if (this.lines != null) {
|
||||
board.updateLines(this.lines.accept(player));
|
||||
}
|
||||
|
||||
boards.put(player, board);
|
||||
this.boards.put(player, board);
|
||||
};
|
||||
}
|
||||
|
||||
@ -112,11 +119,14 @@ public class ScoreBoardManager extends ZUtils {
|
||||
*/
|
||||
public boolean delete(Player player) {
|
||||
|
||||
if (!hasBoard(player))
|
||||
if (!this.hasBoard(player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FastBoard board = getBoard(player);
|
||||
if (!board.isDeleted()) {
|
||||
board.delete();
|
||||
}
|
||||
|
||||
this.scoreboard.toggle(player, p -> {
|
||||
|
||||
@ -132,8 +142,9 @@ public class ScoreBoardManager extends ZUtils {
|
||||
* @return
|
||||
*/
|
||||
public boolean updateTitle(Player player, String title) {
|
||||
if (!hasBoard(player))
|
||||
if (!this.hasBoard(player)) {
|
||||
return false;
|
||||
}
|
||||
FastBoard board = getBoard(player);
|
||||
board.updateTitle(title);
|
||||
return true;
|
||||
@ -153,8 +164,9 @@ public class ScoreBoardManager extends ZUtils {
|
||||
* @return
|
||||
*/
|
||||
public boolean updateLine(Player player, int line, String string) {
|
||||
if (!hasBoard(player))
|
||||
if (!this.hasBoard(player)) {
|
||||
return false;
|
||||
}
|
||||
FastBoard board = getBoard(player);
|
||||
board.updateLine(line, string);
|
||||
return true;
|
||||
@ -166,7 +178,7 @@ public class ScoreBoardManager extends ZUtils {
|
||||
* @return {@link Boolean}
|
||||
*/
|
||||
public boolean hasBoard(Player player) {
|
||||
return boards.containsKey(player);
|
||||
return this.boards.containsKey(player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,28 +187,28 @@ public class ScoreBoardManager extends ZUtils {
|
||||
* @return {@link FastBoard}
|
||||
*/
|
||||
public FastBoard getBoard(Player player) {
|
||||
return boards.getOrDefault(player, null);
|
||||
return this.boards.getOrDefault(player, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the boards
|
||||
*/
|
||||
public Map<Player, FastBoard> getBoards() {
|
||||
return boards;
|
||||
return this.boards;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isRunning
|
||||
*/
|
||||
public boolean isRunning() {
|
||||
return isRunning;
|
||||
return this.isRunning;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lines
|
||||
*/
|
||||
public CollectionConsumer<Player> getLines() {
|
||||
return lines;
|
||||
return this.lines;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user