mirror of
https://e.coding.net/circlecloud/MiaoBoard.git
synced 2024-11-25 02:19:07 +00:00
feat: 2.0正式版完成
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
2e513d3b9f
commit
6cc671eb89
3
pom.xml
3
pom.xml
@ -3,8 +3,9 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>pw.yumc</groupId>
|
<groupId>pw.yumc</groupId>
|
||||||
<artifactId>MiaoBoard</artifactId>
|
<artifactId>MiaoBoard</artifactId>
|
||||||
<version>1.4.6</version>
|
<version>2.0</version>
|
||||||
<name>MiaoBoard</name>
|
<name>MiaoBoard</name>
|
||||||
|
<description>喵式记分板</description>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.name}</finalName>
|
<finalName>${project.name}</finalName>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -5,14 +5,13 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import pw.yumc.MiaoBoard.listener.PlayerListener;
|
import pw.yumc.MiaoBoard.listener.PlayerListener;
|
||||||
import pw.yumc.MiaoBoard.misc.Checker;
|
import pw.yumc.MiaoBoard.misc.Checker;
|
||||||
import pw.yumc.MiaoBoard.scoreboard.ScoreBoardManager;
|
import pw.yumc.MiaoBoard.scoreboard.ScoreBoardManager;
|
||||||
|
import pw.yumc.YumCore.bukkit.Log;
|
||||||
import pw.yumc.YumCore.commands.CommandArgument;
|
import pw.yumc.YumCore.commands.CommandArgument;
|
||||||
import pw.yumc.YumCore.commands.CommandExecutor;
|
import pw.yumc.YumCore.commands.CommandExecutor;
|
||||||
import pw.yumc.YumCore.commands.CommandManager;
|
import pw.yumc.YumCore.commands.CommandManager;
|
||||||
import pw.yumc.YumCore.commands.annotation.Cmd;
|
import pw.yumc.YumCore.commands.annotation.Cmd;
|
||||||
import pw.yumc.YumCore.commands.annotation.Help;
|
import pw.yumc.YumCore.commands.annotation.Help;
|
||||||
import pw.yumc.YumCore.commands.annotation.Sort;
|
import pw.yumc.YumCore.commands.annotation.Sort;
|
||||||
import pw.yumc.YumCore.statistic.Statistics;
|
|
||||||
import pw.yumc.YumCore.update.SubscribeTask;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 喵式记分板主类
|
* 喵式记分板主类
|
||||||
@ -21,46 +20,49 @@ import pw.yumc.YumCore.update.SubscribeTask;
|
|||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
*/
|
*/
|
||||||
public class MiaoBoard extends JavaPlugin implements CommandExecutor {
|
public class MiaoBoard extends JavaPlugin implements CommandExecutor {
|
||||||
|
private ScoreBoardManager scoreBoardManager;
|
||||||
|
|
||||||
@Cmd()
|
public ScoreBoardManager getScoreBoardManager() {
|
||||||
|
return scoreBoardManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cmd(permission = "mb.toggle")
|
||||||
@Help("关闭记分板")
|
@Help("关闭记分板")
|
||||||
@Sort(2)
|
@Sort(2)
|
||||||
public void off(final CommandArgument e) {
|
public void off(final CommandArgument e) {
|
||||||
Checker.offList.add(e.getSender().getName());
|
Checker.offList.add(e.getSender().getName());
|
||||||
e.getSender().sendMessage("§c记分板已关闭!");
|
Log.toSender(e.getSender(), "§c记分板已关闭!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cmd()
|
@Cmd(permission = "mb.toggle")
|
||||||
@Help("打开记分板")
|
@Help("打开记分板")
|
||||||
@Sort(1)
|
@Sort(1)
|
||||||
public void on(final CommandArgument e) {
|
public void on(final CommandArgument e) {
|
||||||
Checker.offList.remove(e.getSender().getName());
|
Checker.offList.remove(e.getSender().getName());
|
||||||
e.getSender().sendMessage("§a记分板已打开!");
|
Log.toSender(e.getSender(), "§a记分板已打开!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
ScoreBoardManager.getSidebarBoard().cancel();
|
scoreBoardManager.getSidebarBoard().cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
ScoreBoardManager.start();
|
scoreBoardManager.start();
|
||||||
new CommandManager("mb").register(this);
|
new CommandManager("mb").register(this);
|
||||||
new PlayerListener();
|
new PlayerListener();
|
||||||
new Statistics();
|
|
||||||
new SubscribeTask(true, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
ScoreBoardManager.load();
|
scoreBoardManager = new ScoreBoardManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cmd(permission = "mb.reload")
|
@Cmd(permission = "mb.reload")
|
||||||
@Help("重新载入配置文件")
|
@Help("重新载入配置文件")
|
||||||
public void reload(final CommandArgument e) {
|
public void reload(final CommandArgument e) {
|
||||||
ScoreBoardManager.reload();
|
scoreBoardManager.reload();
|
||||||
e.getSender().sendMessage("§a配置重载完毕!");
|
Log.toSender(e.getSender(), "§a配置重载完毕!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package pw.yumc.MiaoBoard.config;
|
package pw.yumc.MiaoBoard.config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cn.citycraft.PluginHelper.config.InjectConfig;
|
import pw.yumc.YumCore.config.InjectConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记分板配置文件类
|
* 记分板配置文件类
|
||||||
@ -12,9 +12,9 @@ import cn.citycraft.PluginHelper.config.InjectConfig;
|
|||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
*/
|
*/
|
||||||
public class MiaoBoardConfig extends InjectConfig {
|
public class MiaoBoardConfig extends InjectConfig {
|
||||||
public static Integer UpdateTime;
|
public transient static MiaoBoardConfig instance = new MiaoBoardConfig();
|
||||||
public static List<String> DisableWorld = new ArrayList<>();
|
private Integer UpdateTime;
|
||||||
public transient static MiaoBoardConfig instance = new MiaoBoardConfig();;
|
private List<String> DisableWorld;
|
||||||
|
|
||||||
public static MiaoBoardConfig i() {
|
public static MiaoBoardConfig i() {
|
||||||
return instance;
|
return instance;
|
||||||
@ -23,4 +23,15 @@ public class MiaoBoardConfig extends InjectConfig {
|
|||||||
public static void reInject() {
|
public static void reInject() {
|
||||||
instance.reload();
|
instance.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getDisableWorld() {
|
||||||
|
if (DisableWorld == null) {
|
||||||
|
DisableWorld = Collections.emptyList();
|
||||||
|
}
|
||||||
|
return DisableWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUpdateTime() {
|
||||||
|
return UpdateTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,11 @@ import org.bukkit.event.player.PlayerChangedWorldEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
import pw.yumc.MiaoBoard.MiaoBoard;
|
||||||
import pw.yumc.MiaoBoard.config.MiaoBoardConfig;
|
import pw.yumc.MiaoBoard.config.MiaoBoardConfig;
|
||||||
import pw.yumc.MiaoBoard.scoreboard.ScoreBoardManager;
|
|
||||||
import pw.yumc.YumCore.bukkit.P;
|
import pw.yumc.YumCore.bukkit.P;
|
||||||
|
import pw.yumc.YumCore.statistic.Statistics;
|
||||||
|
import pw.yumc.YumCore.update.SubscribeTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 玩家监听
|
* 玩家监听
|
||||||
@ -18,28 +20,30 @@ import pw.yumc.YumCore.bukkit.P;
|
|||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
*/
|
*/
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
|
MiaoBoard plugin = P.getPlugin();
|
||||||
|
|
||||||
public PlayerListener() {
|
public PlayerListener() {
|
||||||
Bukkit.getPluginManager().registerEvents(this, P.instance);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
|
new Statistics();
|
||||||
|
new SubscribeTask(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerChangeWorld(final PlayerChangedWorldEvent e) {
|
public void onPlayerChangeWorld(final PlayerChangedWorldEvent e) {
|
||||||
if (MiaoBoardConfig.DisableWorld.contains(e.getPlayer().getWorld().getName())) {
|
if (MiaoBoardConfig.i().getDisableWorld().contains(e.getPlayer().getWorld().getName())) {
|
||||||
ScoreBoardManager.getSidebarBoard().removeTarget(e.getPlayer());
|
plugin.getScoreBoardManager().getSidebarBoard().removeTarget(e.getPlayer());
|
||||||
} else {
|
} else {
|
||||||
ScoreBoardManager.getSidebarBoard().addTarget(e.getPlayer());
|
plugin.getScoreBoardManager().getSidebarBoard().addTarget(e.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(final PlayerJoinEvent e) {
|
public void onPlayerJoin(final PlayerJoinEvent e) {
|
||||||
if (!MiaoBoardConfig.DisableWorld.contains(e.getPlayer().getWorld().getName())) {
|
plugin.getScoreBoardManager().addTarget(e.getPlayer());
|
||||||
ScoreBoardManager.getSidebarBoard().addTarget(e.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(final PlayerQuitEvent e) {
|
public void onPlayerQuit(final PlayerQuitEvent e) {
|
||||||
ScoreBoardManager.getSidebarBoard().removeTarget(e.getPlayer());
|
plugin.getScoreBoardManager().getSidebarBoard().removeTarget(e.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,6 @@ public class Checker {
|
|||||||
|
|
||||||
public static boolean dataCheck(final BoardModel model) {
|
public static boolean dataCheck(final BoardModel model) {
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
return model.time_start != null && model.time_start.getTime() <= now && model.time_end != null && now <= model.time_end.getTime();
|
return (model.time_start == null || model.time_start.getTime() <= now) && (model.time_end == null || now <= model.time_end.getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@ import java.text.ParseException;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import cn.citycraft.PluginHelper.kit.StrKit;
|
import cn.citycraft.PluginHelper.kit.StrKit;
|
||||||
@ -15,12 +17,19 @@ import pw.yumc.YumCore.bukkit.P;
|
|||||||
import pw.yumc.YumCore.bukkit.compatible.C;
|
import pw.yumc.YumCore.bukkit.compatible.C;
|
||||||
|
|
||||||
public class Replace {
|
public class Replace {
|
||||||
|
public static List<String> $(final Player p, final List<String> text) {
|
||||||
|
for (int i = 0; i < text.size(); i++) {
|
||||||
|
text.set(i, $(p, text.get(i)));
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
public static String $(final Player p, final String text) {
|
public static String $(final Player p, final String text) {
|
||||||
return s(p(p, text));
|
return s(p(p, text));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String p(final Player p, final String text) {
|
private static String p(final Player p, final String text) {
|
||||||
return SimpleRelpace.$(p, PluginAPI.PlaceholderAPI(p, text));
|
return PluginAPI.PlaceholderAPI(p, SimpleRelpace.$(p, text));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String s(final String text) {
|
private static String s(final String text) {
|
||||||
@ -30,7 +39,6 @@ public class Replace {
|
|||||||
static class SimpleRelpace {
|
static class SimpleRelpace {
|
||||||
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]");
|
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("[%]([^%]+)[%]");
|
||||||
private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
private static final String EMPTY = "";
|
|
||||||
|
|
||||||
public static String $(final Player player, String text) {
|
public static String $(final Player player, String text) {
|
||||||
final Matcher m = PLACEHOLDER_PATTERN.matcher(text);
|
final Matcher m = PLACEHOLDER_PATTERN.matcher(text);
|
||||||
@ -38,7 +46,7 @@ public class Replace {
|
|||||||
final String format = m.group(1);
|
final String format = m.group(1);
|
||||||
if (format.contains("_")) {
|
if (format.contains("_")) {
|
||||||
final String[] ka = format.split("_", 2);
|
final String[] ka = format.split("_", 2);
|
||||||
String value = format;
|
String value = null;
|
||||||
switch (ka[0]) {
|
switch (ka[0]) {
|
||||||
case "player":
|
case "player":
|
||||||
value = player(player, ka[1]);
|
value = player(player, ka[1]);
|
||||||
@ -53,7 +61,9 @@ public class Replace {
|
|||||||
value = time(player, ka[1]);
|
value = time(player, ka[1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
text = text.replace("%" + format + "%", Matcher.quoteReplacement(value));
|
if (value != null) {
|
||||||
|
text = text.replace("%" + format + "%", Matcher.quoteReplacement(value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
@ -82,20 +92,20 @@ public class Replace {
|
|||||||
case "max_health":
|
case "max_health":
|
||||||
return String.valueOf(player.getMaxHealth());
|
return String.valueOf(player.getMaxHealth());
|
||||||
default:
|
default:
|
||||||
return EMPTY;
|
return String.format("%%player_%s%%", key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String plugin(final Player player, final String key) {
|
private static String plugin(final Player player, final String key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "version":
|
case "version":
|
||||||
return P.getDescription().getVersion();
|
return P.getDescription().getVersion().split("-")[0];
|
||||||
case "name":
|
case "name":
|
||||||
return P.getName();
|
return P.getName();
|
||||||
case "author":
|
case "author":
|
||||||
return Arrays.toString(P.getDescription().getAuthors().toArray());
|
return Arrays.toString(P.getDescription().getAuthors().toArray());
|
||||||
default:
|
default:
|
||||||
return EMPTY;
|
return String.format("%%plugin_%s%%", key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +114,10 @@ public class Replace {
|
|||||||
switch (key) {
|
switch (key) {
|
||||||
case "online":
|
case "online":
|
||||||
return String.valueOf(C.Player.getOnlinePlayers().size());
|
return String.valueOf(C.Player.getOnlinePlayers().size());
|
||||||
|
case "max":
|
||||||
|
return String.valueOf(Bukkit.getMaxPlayers());
|
||||||
|
case "unique_joins":
|
||||||
|
return String.valueOf(Bukkit.getOfflinePlayers().length);
|
||||||
case "ram_used":
|
case "ram_used":
|
||||||
return String.valueOf((runtime.totalMemory() - runtime.freeMemory()) / 1048576L);
|
return String.valueOf((runtime.totalMemory() - runtime.freeMemory()) / 1048576L);
|
||||||
case "ram_free":
|
case "ram_free":
|
||||||
@ -113,14 +127,14 @@ public class Replace {
|
|||||||
case "ram_max":
|
case "ram_max":
|
||||||
return String.valueOf(runtime.maxMemory() / 1048576L);
|
return String.valueOf(runtime.maxMemory() / 1048576L);
|
||||||
default:
|
default:
|
||||||
return EMPTY;
|
return String.format("%%server_%s%%", key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String time(final Player player, final String key) {
|
private static String time(final Player player, final String key) {
|
||||||
final Date date = new Date();
|
final Date date = new Date();
|
||||||
if (key.startsWith("left") && key.contains("_")) {
|
if (key.startsWith("left") && key.contains("_")) {
|
||||||
final String time = key.split("_")[1].replace("`", " ");
|
final String time = key.split("_")[1];
|
||||||
String value = "解析错误";
|
String value = "解析错误";
|
||||||
try {
|
try {
|
||||||
final long left = df.parse(time).getTime() - System.currentTimeMillis();
|
final long left = df.parse(time).getTime() - System.currentTimeMillis();
|
||||||
@ -145,7 +159,7 @@ public class Replace {
|
|||||||
case "second":
|
case "second":
|
||||||
return String.valueOf(date.getSeconds());
|
return String.valueOf(date.getSeconds());
|
||||||
}
|
}
|
||||||
return EMPTY;
|
return String.format("%%time_%s%%", key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import cn.citycraft.PluginHelper.config.InjectConfigurationSection;
|
import pw.yumc.YumCore.config.ConfigNode;
|
||||||
|
import pw.yumc.YumCore.config.InjectConfigurationSection;
|
||||||
|
import pw.yumc.YumCore.config.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记分板数据模型类
|
* 记分板数据模型类
|
||||||
@ -16,7 +18,11 @@ import cn.citycraft.PluginHelper.config.InjectConfigurationSection;
|
|||||||
public class BoardModel extends InjectConfigurationSection {
|
public class BoardModel extends InjectConfigurationSection {
|
||||||
public transient String name;
|
public transient String name;
|
||||||
public Integer index;
|
public Integer index;
|
||||||
|
@Nullable
|
||||||
|
@ConfigNode("time.start")
|
||||||
public Date time_start;
|
public Date time_start;
|
||||||
|
@Nullable
|
||||||
|
@ConfigNode("time.end")
|
||||||
public Date time_end;
|
public Date time_end;
|
||||||
public String title;
|
public String title;
|
||||||
public String permission;
|
public String permission;
|
||||||
|
@ -7,16 +7,16 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
|
||||||
import cn.citycraft.PluginHelper.scoreboard.BoardUpdateFunction;
|
|
||||||
import cn.citycraft.PluginHelper.scoreboard.Condition;
|
|
||||||
import cn.citycraft.PluginHelper.scoreboard.SidebarBoard;
|
|
||||||
import pw.yumc.MiaoBoard.config.MiaoBoardConfig;
|
import pw.yumc.MiaoBoard.config.MiaoBoardConfig;
|
||||||
import pw.yumc.MiaoBoard.model.BoardModel;
|
import pw.yumc.MiaoBoard.model.BoardModel;
|
||||||
|
import pw.yumc.MiaoBoard.scoreboard.core.BoardUpdateFunction;
|
||||||
|
import pw.yumc.MiaoBoard.scoreboard.core.Condition;
|
||||||
|
import pw.yumc.MiaoBoard.scoreboard.core.SidebarBoard;
|
||||||
import pw.yumc.MiaoBoard.scoreboard.updater.BodyUpdater;
|
import pw.yumc.MiaoBoard.scoreboard.updater.BodyUpdater;
|
||||||
import pw.yumc.MiaoBoard.scoreboard.updater.TitleUpdater;
|
import pw.yumc.MiaoBoard.scoreboard.updater.TitleUpdater;
|
||||||
import pw.yumc.YumCore.bukkit.P;
|
import pw.yumc.YumCore.bukkit.P;
|
||||||
import pw.yumc.YumCore.bukkit.compatible.C;
|
import pw.yumc.YumCore.bukkit.compatible.C;
|
||||||
|
import pw.yumc.YumCore.config.FileConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记分板管理类
|
* 记分板管理类
|
||||||
@ -25,20 +25,30 @@ import pw.yumc.YumCore.bukkit.compatible.C;
|
|||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
*/
|
*/
|
||||||
public class ScoreBoardManager {
|
public class ScoreBoardManager {
|
||||||
public static Status cot = new Status();
|
public Status cot = new Status();
|
||||||
public static SidebarBoard sbd = new SidebarBoard(P.instance, new BoardUpdateFunction(new TitleUpdater(), new BodyUpdater()));
|
public SidebarBoard sbd = new SidebarBoard(P.instance, new BoardUpdateFunction(new TitleUpdater(), new BodyUpdater()));
|
||||||
public static FileConfig config = MiaoBoardConfig.i().getConfig();;
|
public FileConfig config = MiaoBoardConfig.i().getConfig();
|
||||||
public static List<BoardModel> bms = new LinkedList<>();
|
public List<BoardModel> bms = new LinkedList<>();
|
||||||
|
|
||||||
public static List<BoardModel> getModels() {
|
public ScoreBoardManager() {
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTarget(final Player player) {
|
||||||
|
if (!MiaoBoardConfig.i().getDisableWorld().contains(player.getWorld().getName())) {
|
||||||
|
getSidebarBoard().addTarget(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BoardModel> getModels() {
|
||||||
return bms;
|
return bms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SidebarBoard getSidebarBoard() {
|
public SidebarBoard getSidebarBoard() {
|
||||||
return sbd;
|
return sbd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void load() {
|
public void load() {
|
||||||
bms.clear();
|
bms.clear();
|
||||||
for (final String bmn : config.getConfigurationSection("Boards").getKeys(false)) {
|
for (final String bmn : config.getConfigurationSection("Boards").getKeys(false)) {
|
||||||
bms.add(new BoardModel(config.getConfigurationSection("Boards." + bmn)).setName(bmn));
|
bms.add(new BoardModel(config.getConfigurationSection("Boards." + bmn)).setName(bmn));
|
||||||
@ -46,28 +56,28 @@ public class ScoreBoardManager {
|
|||||||
Collections.sort(bms, new BoardComparator());
|
Collections.sort(bms, new BoardComparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload() {
|
public void reload() {
|
||||||
sbd.cancel();
|
sbd.cancel();
|
||||||
MiaoBoardConfig.reInject();
|
MiaoBoardConfig.reInject();
|
||||||
load();
|
load();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void start() {
|
public void start() {
|
||||||
sbd.update(cot.set(true), MiaoBoardConfig.UpdateTime);
|
sbd.update(cot.set(true), MiaoBoardConfig.i().getUpdateTime());
|
||||||
for (final Player player : C.Player.getOnlinePlayers()) {
|
for (final Player player : C.Player.getOnlinePlayers()) {
|
||||||
sbd.addTarget(player);
|
addTarget(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BoardComparator implements Comparator<BoardModel> {
|
private class BoardComparator implements Comparator<BoardModel> {
|
||||||
@Override
|
@Override
|
||||||
public int compare(final BoardModel o1, final BoardModel o2) {
|
public int compare(final BoardModel o1, final BoardModel o2) {
|
||||||
return o1.index.compareTo(o2.index);
|
return o1.index.compareTo(o2.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Status implements Condition {
|
private class Status implements Condition {
|
||||||
private boolean status = true;
|
private boolean status = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
122
src/main/java/pw/yumc/MiaoBoard/scoreboard/core/Board.java
Normal file
122
src/main/java/pw/yumc/MiaoBoard/scoreboard/core/Board.java
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
package pw.yumc.MiaoBoard.scoreboard.core;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since 2016年7月4日 下午4:40:21
|
||||||
|
* @author 尘曲
|
||||||
|
*/
|
||||||
|
public abstract class Board implements Iterable<Player> {
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
private int taskId;
|
||||||
|
|
||||||
|
private final HashMap<Player, BoardPage> targets = new HashMap<>();
|
||||||
|
private final Set<Player> removeQueue = new HashSet<>();
|
||||||
|
|
||||||
|
private final BoardUpdateFunction updateFunction;
|
||||||
|
|
||||||
|
public Board(final Plugin plugin, final BoardUpdateFunction updateFunction) {
|
||||||
|
this.updateFunction = updateFunction;
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addTarget(final Player player) {
|
||||||
|
if (!this.isTarget(player)) {
|
||||||
|
final BoardPage boardPage = this.newPage();
|
||||||
|
this.targets.put(player, boardPage);
|
||||||
|
player.setScoreboard(boardPage.getBoard());
|
||||||
|
this.update(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancel() {
|
||||||
|
if (taskId != 0) {
|
||||||
|
plugin.getServer().getScheduler().cancelTask(taskId);
|
||||||
|
taskId = 0;
|
||||||
|
for (final Player player : this.targets.keySet()) {
|
||||||
|
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||||
|
}
|
||||||
|
this.targets.clear();
|
||||||
|
this.removeQueue.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoardPage getBoardPage(final Player player) {
|
||||||
|
return this.targets.get(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plugin getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Player> getTargets() {
|
||||||
|
return targets.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoardUpdateFunction getUpdateFunction() {
|
||||||
|
return updateFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRunning() {
|
||||||
|
return this.taskId != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTarget(final Player player) {
|
||||||
|
return this.targets.containsKey(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<Player> iterator() {
|
||||||
|
return this.targets.keySet().iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract BoardPage newPage();
|
||||||
|
|
||||||
|
public boolean removeTarget(final Player player) {
|
||||||
|
if (this.isTarget(player)) {
|
||||||
|
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||||
|
return this.removeQueue.add(player);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(final Condition condition, final int interval) {
|
||||||
|
taskId = plugin.getServer().getScheduler().runTaskTimer(plugin, new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (condition.get()) {
|
||||||
|
final Iterator<Player> iterator = iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
final Player next = iterator.next();
|
||||||
|
if (shouldRemove(next)) {
|
||||||
|
iterator.remove();
|
||||||
|
} else {
|
||||||
|
update(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, interval).getTaskId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void update(Player p);
|
||||||
|
|
||||||
|
private boolean shouldRemove(final Player player) {
|
||||||
|
return this.removeQueue.remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package pw.yumc.MiaoBoard.scoreboard.core;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since 2016年7月4日 下午4:40:21
|
||||||
|
* @author 尘曲
|
||||||
|
*/
|
||||||
|
public abstract class BoardPage {
|
||||||
|
|
||||||
|
private final Scoreboard board;
|
||||||
|
|
||||||
|
public BoardPage() {
|
||||||
|
board = Bukkit.getServer().getScoreboardManager().getNewScoreboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Scoreboard getBoard() {
|
||||||
|
return board;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package pw.yumc.MiaoBoard.scoreboard.core;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import cn.citycraft.PluginHelper.callback.CallBackReturn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since 2016年7月4日 下午4:40:21
|
||||||
|
* @author 尘曲
|
||||||
|
*/
|
||||||
|
public class BoardUpdateFunction {
|
||||||
|
|
||||||
|
private CallBackReturn.One<Player, String> titleFunction;
|
||||||
|
private CallBackReturn.One<Player, List<String>> bodyFunction;
|
||||||
|
|
||||||
|
public BoardUpdateFunction(final CallBackReturn.One<Player, String> titleFunction, final CallBackReturn.One<Player, List<String>> bodyFunction) {
|
||||||
|
this.titleFunction = titleFunction;
|
||||||
|
this.bodyFunction = bodyFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CallBackReturn.One<Player, List<String>> getBodyFunction() {
|
||||||
|
return bodyFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CallBackReturn.One<Player, String> getTitleFunction() {
|
||||||
|
return titleFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBodyFunction(final CallBackReturn.One<Player, List<String>> bodyFunction) {
|
||||||
|
this.bodyFunction = bodyFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitleFunction(final CallBackReturn.One<Player, String> titleFunction) {
|
||||||
|
this.titleFunction = titleFunction;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package pw.yumc.MiaoBoard.scoreboard.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since 2016年7月4日 下午4:40:21
|
||||||
|
* @author 尘曲
|
||||||
|
*/
|
||||||
|
public interface Condition {
|
||||||
|
|
||||||
|
boolean get();
|
||||||
|
|
||||||
|
}
|
45
src/main/java/pw/yumc/MiaoBoard/scoreboard/core/Entry.java
Normal file
45
src/main/java/pw/yumc/MiaoBoard/scoreboard/core/Entry.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package pw.yumc.MiaoBoard.scoreboard.core;
|
||||||
|
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
import org.bukkit.scoreboard.Score;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
public class Entry {
|
||||||
|
private final SiderbarBoardPage boardPage;
|
||||||
|
private Team team;
|
||||||
|
private final String id;
|
||||||
|
private String last;
|
||||||
|
private final int index;
|
||||||
|
|
||||||
|
public Entry(final SiderbarBoardPage boardPage, final int index) {
|
||||||
|
this.boardPage = boardPage;
|
||||||
|
this.id = String.valueOf(index);
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Team getTeam() {
|
||||||
|
return team;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregister() {
|
||||||
|
if (this.last != null) {
|
||||||
|
this.boardPage.getBoard().resetScores(last);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(final String text, final int score) {
|
||||||
|
this.unregister();
|
||||||
|
final Objective objective = boardPage.getObjective();
|
||||||
|
final Score scoreObject = objective.getScore(text);
|
||||||
|
scoreObject.setScore(score);
|
||||||
|
this.last = text;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package pw.yumc.MiaoBoard.scoreboard.core;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since 2016年7月4日 下午4:40:21
|
||||||
|
* @author 尘曲
|
||||||
|
*/
|
||||||
|
public class SidebarBoard extends Board {
|
||||||
|
private static final TreeMap<Integer, String> coloursById = new TreeMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
int i = 0;
|
||||||
|
for (final ChatColor chatColor : ChatColor.values()) {
|
||||||
|
coloursById.put(i++, chatColor.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SidebarBoard(final Plugin plugin, final BoardUpdateFunction updateFunction) {
|
||||||
|
super(plugin, updateFunction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiderbarBoardPage getBoardPage(final Player player) {
|
||||||
|
return (SiderbarBoardPage) super.getBoardPage(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SiderbarBoardPage newPage() {
|
||||||
|
return new SiderbarBoardPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(final Player player) {
|
||||||
|
final SiderbarBoardPage boardPage = this.getBoardPage(player);
|
||||||
|
if (boardPage == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String title = null;
|
||||||
|
if (this.getUpdateFunction().getTitleFunction() != null) {
|
||||||
|
title = this.getUpdateFunction().getTitleFunction().run(player);
|
||||||
|
} else {
|
||||||
|
this.removeTarget(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final List<String> newContents = this.getUpdateFunction().getBodyFunction().run(player);
|
||||||
|
this.formatBody(newContents);
|
||||||
|
final Objective objective = boardPage.getObjective();
|
||||||
|
objective.setDisplayName(title);
|
||||||
|
for (int i = 0; i < newContents.size(); i++) {
|
||||||
|
objective.getScore(newContents.get(i)).setScore(newContents.size() - i);
|
||||||
|
}
|
||||||
|
int index = 0;
|
||||||
|
if (boardPage.getLastEntries() != null) {
|
||||||
|
for (; index < boardPage.getLastEntries().size() && index < newContents.size(); index++) {
|
||||||
|
final Entry entry = boardPage.getLastEntries().get(index);
|
||||||
|
entry.update(newContents.get(index), newContents.size() - index - 1);
|
||||||
|
}
|
||||||
|
while (index < boardPage.getLastEntries().size()) {
|
||||||
|
final Entry entry = boardPage.getLastEntries().remove(index);
|
||||||
|
entry.unregister();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (boardPage.getLastEntries() == null) {
|
||||||
|
boardPage.setLastEntries(new ArrayList<Entry>());
|
||||||
|
}
|
||||||
|
for (; index < newContents.size(); index++) {
|
||||||
|
final String line = newContents.get(index);
|
||||||
|
final Entry entry = new Entry(boardPage, index);
|
||||||
|
entry.update(line, newContents.size() - index - 1);
|
||||||
|
boardPage.getLastEntries().add(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void formatBody(final List<String> texts) {
|
||||||
|
for (int i = 0; i < texts.size(); i++) {
|
||||||
|
final String line = texts.get(i);
|
||||||
|
texts.set(i, line + coloursById.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package pw.yumc.MiaoBoard.scoreboard.core;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since 2016年7月4日 下午4:40:21
|
||||||
|
* @author 尘曲
|
||||||
|
*/
|
||||||
|
public class SiderbarBoardPage extends BoardPage {
|
||||||
|
|
||||||
|
private final Objective objective;
|
||||||
|
private List<Entry> lastEntries;
|
||||||
|
|
||||||
|
public SiderbarBoardPage() {
|
||||||
|
super();
|
||||||
|
objective = getBoard().registerNewObjective("default", "dummy");
|
||||||
|
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Entry> getLastEntries() {
|
||||||
|
return lastEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Objective getObjective() {
|
||||||
|
return objective;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastEntries(final List<Entry> lastEntries) {
|
||||||
|
this.lastEntries = lastEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,16 +2,16 @@ package pw.yumc.MiaoBoard.scoreboard.updater;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import cn.citycraft.PluginHelper.callback.CallBackReturn;
|
import cn.citycraft.PluginHelper.callback.CallBackReturn;
|
||||||
|
import pw.yumc.MiaoBoard.MiaoBoard;
|
||||||
import pw.yumc.MiaoBoard.misc.Checker;
|
import pw.yumc.MiaoBoard.misc.Checker;
|
||||||
import pw.yumc.MiaoBoard.misc.Replace;
|
import pw.yumc.MiaoBoard.misc.Replace;
|
||||||
import pw.yumc.MiaoBoard.model.BoardModel;
|
import pw.yumc.MiaoBoard.model.BoardModel;
|
||||||
import pw.yumc.MiaoBoard.scoreboard.ScoreBoardManager;
|
import pw.yumc.YumCore.bukkit.P;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记分板行更新类
|
* 记分板行更新类
|
||||||
@ -20,18 +20,15 @@ import pw.yumc.MiaoBoard.scoreboard.ScoreBoardManager;
|
|||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
*/
|
*/
|
||||||
public class BodyUpdater extends CallBackReturn.One<Player, List<String>> {
|
public class BodyUpdater extends CallBackReturn.One<Player, List<String>> {
|
||||||
|
MiaoBoard plugin = P.getPlugin();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> run(final Player param) {
|
public List<String> run(final Player param) {
|
||||||
final Iterator<BoardModel> iterator = ScoreBoardManager.getModels().iterator();
|
final Iterator<BoardModel> iterator = plugin.getScoreBoardManager().getModels().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final BoardModel bmodel = iterator.next();
|
final BoardModel bmodel = iterator.next();
|
||||||
if (Checker.$(param, bmodel)) {
|
if (Checker.$(param, bmodel)) {
|
||||||
final List<String> temp = new LinkedList<>();
|
return Replace.$(param, bmodel.lines);
|
||||||
for (final String line : bmodel.lines) {
|
|
||||||
temp.add(Replace.$(param, line));
|
|
||||||
}
|
|
||||||
return temp;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -5,10 +5,11 @@ import java.util.Iterator;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import cn.citycraft.PluginHelper.callback.CallBackReturn;
|
import cn.citycraft.PluginHelper.callback.CallBackReturn;
|
||||||
|
import pw.yumc.MiaoBoard.MiaoBoard;
|
||||||
import pw.yumc.MiaoBoard.misc.Checker;
|
import pw.yumc.MiaoBoard.misc.Checker;
|
||||||
import pw.yumc.MiaoBoard.misc.Replace;
|
import pw.yumc.MiaoBoard.misc.Replace;
|
||||||
import pw.yumc.MiaoBoard.model.BoardModel;
|
import pw.yumc.MiaoBoard.model.BoardModel;
|
||||||
import pw.yumc.MiaoBoard.scoreboard.ScoreBoardManager;
|
import pw.yumc.YumCore.bukkit.P;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记分板标题更新类
|
* 记分板标题更新类
|
||||||
@ -17,17 +18,18 @@ import pw.yumc.MiaoBoard.scoreboard.ScoreBoardManager;
|
|||||||
* @author 喵♂呜
|
* @author 喵♂呜
|
||||||
*/
|
*/
|
||||||
public class TitleUpdater extends CallBackReturn.One<Player, String> {
|
public class TitleUpdater extends CallBackReturn.One<Player, String> {
|
||||||
|
MiaoBoard plugin = P.getPlugin();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String run(final Player param) {
|
public String run(final Player param) {
|
||||||
final Iterator<BoardModel> iterator = ScoreBoardManager.getModels().iterator();
|
final Iterator<BoardModel> iterator = plugin.getScoreBoardManager().getModels().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
final BoardModel bmodel = iterator.next();
|
final BoardModel bmodel = iterator.next();
|
||||||
if (Checker.$(param, bmodel)) {
|
if (Checker.$(param, bmodel)) {
|
||||||
return Replace.$(param, bmodel.title);
|
return Replace.$(param, bmodel.title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#配置文件版本号
|
#配置文件版本号
|
||||||
Version: 1.1
|
Version: 2.0
|
||||||
|
|
||||||
#更新时间(单位: Tick)
|
#更新时间(单位: Tick)
|
||||||
UpdateTime: 10
|
UpdateTime: 10
|
||||||
@ -17,25 +17,30 @@ Boards:
|
|||||||
start: '2016-01-01 00:00:00'
|
start: '2016-01-01 00:00:00'
|
||||||
end: '2020-01-01 00:00:00'
|
end: '2020-01-01 00:00:00'
|
||||||
#记分板标题
|
#记分板标题
|
||||||
title: '喵式记分板简介'
|
title: '玩家信息'
|
||||||
#记分板权限
|
#记分板权限
|
||||||
permission: mb.default
|
permission: mb.default
|
||||||
#记分板内容
|
#记分板内容(不得超过38个字符 包括颜色字符 超过部分自动截取)
|
||||||
#注意 不得超过38个字符 包括颜色字符 超过部分自动截取
|
|
||||||
#注意 不得超过15行 超出部分 自动忽略
|
|
||||||
lines:
|
lines:
|
||||||
- '&6插件名称: &a%plugin_name%'
|
- '&6名 称: &a%player_displayname%'
|
||||||
- '&7------------------------------'
|
- '&6世 界: &b%player_world%'
|
||||||
- '&6插件版本: &b%plugin_version%'
|
- '&6位 置: &3%player_x%,%player_y%,%player_z%'
|
||||||
- '&7------------------------------'
|
- '&6等 级: &e%player_level%'
|
||||||
- '&6插件作者: &c%plugin_author%'
|
- '&6血 量: &c%player_health%'
|
||||||
- '&7------------------------------'
|
- '&6饥 饿: &d%player_food_level%'
|
||||||
- '&6玩家名称: &a%player_displayname%'
|
- '&6模 式: &4%player_gamemode%'
|
||||||
- '&7------------------------------'
|
#默认记分板
|
||||||
- '&6您所在的位置: &b%player_world% &a%player_x%,%player_y%,%player_z%'
|
admin:
|
||||||
- '&7------------------------------'
|
#记分板顺序(将按照从小到大依次检测 比如 1-50 优先检测 1 符合则显示 不符合 检测 2 ...)
|
||||||
- '&6您所在的角度: &bYaw &a%player_yaw% &bPitch &a%player_pitch%'
|
index: 49
|
||||||
- '&7------------------------------'
|
#记分板标题
|
||||||
- '&6服务器使用内存: &a%server_ram_used%/%server_ram_total%'
|
title: '服务器信息'
|
||||||
- '&7------------------------------'
|
#记分板权限
|
||||||
- '&6离2017年还剩: &a%time_left_2017-01-01`00:00:00%秒'
|
permission: mb.reload
|
||||||
|
#记分板内容(不得超过38个字符 包括颜色字符 超过部分自动截取)
|
||||||
|
lines:
|
||||||
|
- '&6名 称: &a%plugin_name%'
|
||||||
|
- '&6版 本: &b%plugin_version%'
|
||||||
|
- '&6作 者: &c%plugin_author%'
|
||||||
|
- '&6人 数: &c%server_online%/%server_max%'
|
||||||
|
- '&6内 存: &a%server_ram_used%/%server_ram_total%/%server_ram_max%'
|
@ -12,7 +12,6 @@ commands:
|
|||||||
aliases:
|
aliases:
|
||||||
- mb
|
- mb
|
||||||
usage: §b使用/${project.artifactId} help 查看帮助!
|
usage: §b使用/${project.artifactId} help 查看帮助!
|
||||||
permission: mb.reload
|
|
||||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||||
permissions:
|
permissions:
|
||||||
mb.reload:
|
mb.reload:
|
||||||
@ -21,3 +20,6 @@ permissions:
|
|||||||
mb.default:
|
mb.default:
|
||||||
description: 默认记分板权限!
|
description: 默认记分板权限!
|
||||||
default: true
|
default: true
|
||||||
|
mb.toggle:
|
||||||
|
description: 开启关闭记分板!
|
||||||
|
default: true
|
Loading…
Reference in New Issue
Block a user