1
0
mirror of https://e.coding.net/circlecloud/MiaoBoard.git synced 2024-11-22 01:49:05 +00:00

feat: compatible to 1.19

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2022-06-24 18:15:18 +00:00
parent 3f193bbf46
commit 00db90be47
5 changed files with 88 additions and 77 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>MiaoBoard</artifactId> <artifactId>MiaoBoard</artifactId>
<version>2.5.1</version> <version>2.6.0</version>
<description>喵式记分板</description> <description>喵式记分板</description>
<parent> <parent>
@ -13,8 +13,10 @@
</parent> </parent>
<properties> <properties>
<update.description>§a正式版本 2.5.1</update.description> <update.description>§a正式版本 兼容 1.19 版本</update.description>
<update.changes> <update.changes>
§622-06-25 §afeat: 兼容 1.19 版本;
§621-06-23 §afeat: 解除32个字符限制(1.13+);
§621-05-31 §cfix: 修复记分板切换异常问题; §621-05-31 §cfix: 修复记分板切换异常问题;
§619-12-30 §cfix: 修复字符截取错误导致的报错; §619-12-30 §cfix: 修复字符截取错误导致的报错;
§619-10-24 §cfix: 调整默认配置的 time.end 为2099年; §619-10-24 §cfix: 调整默认配置的 time.end 为2099年;

View File

@ -1,71 +1,70 @@
package pw.yumc.MiaoBoard; package pw.yumc.MiaoBoard;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import pw.yumc.MiaoBoard.listener.PlayerListener;
import pw.yumc.MiaoBoard.listener.PlayerListener; import pw.yumc.MiaoBoard.listener.SelfListener;
import pw.yumc.MiaoBoard.listener.SelfListener; 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.bukkit.Log; import pw.yumc.YumCore.commands.CommandSub;
import pw.yumc.YumCore.commands.CommandSub; 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.commands.interfaces.Executor;
import pw.yumc.YumCore.commands.interfaces.Executor;
/**
/** * 喵式记分板主类
* 喵式记分板主类 *
* * @author MiaoWoo
* @author MiaoWoo * @since 2016年6月4日 上午9:08:13
* @since 2016年6月4日 上午9:08:13 */
*/ public class MiaoBoard extends JavaPlugin implements Executor {
public class MiaoBoard extends JavaPlugin implements Executor { private ScoreBoardManager scoreBoardManager;
private ScoreBoardManager scoreBoardManager;
public ScoreBoardManager getScoreBoardManager() {
public ScoreBoardManager getScoreBoardManager() { return scoreBoardManager;
return scoreBoardManager; }
}
@Cmd(permission = "mb.toggle", executor = Cmd.Executor.PLAYER)
@Cmd(permission = "mb.toggle", executor = Cmd.Executor.PLAYER) @Help("关闭记分板")
@Help("关闭记分板") @Sort(2)
@Sort(2) public void off(Player player) {
public void off(Player player) { Checker.offList.add(player.getName());
Checker.offList.add(player.getName()); Log.sender(player, "§c记分板已关闭!");
Log.sender(player, "§c记分板已关闭!"); }
}
@Cmd(permission = "mb.toggle", executor = Cmd.Executor.PLAYER)
@Cmd(permission = "mb.toggle", executor = Cmd.Executor.PLAYER) @Help("打开记分板")
@Help("打开记分板") @Sort(1)
@Sort(1) public void on(Player player) {
public void on(Player player) { Checker.offList.remove(player.getName());
Checker.offList.remove(player.getName()); Log.sender(player, "§a记分板已打开!");
Log.sender(player, "§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 CommandSub("mb", this);
new CommandSub("mb", this); new PlayerListener();
new PlayerListener(); new SelfListener();
new SelfListener(); }
}
@Override
@Override public void onLoad() {
public void onLoad() { scoreBoardManager = new ScoreBoardManager();
scoreBoardManager = new ScoreBoardManager(); }
}
@Cmd(permission = "mb.reload")
@Cmd(permission = "mb.reload") @Help("重新载入配置文件")
@Help("重新载入配置文件") public void reload(CommandSender sender) {
public void reload(CommandSender sender) { scoreBoardManager.reload();
scoreBoardManager.reload(); Log.sender(sender, "§a配置重载完毕!");
Log.sender(sender, "§a配置重载完毕!"); }
} }
}

View File

@ -2,11 +2,13 @@ package pw.yumc.MiaoBoard.scoreboard.core;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import pw.yumc.MiaoBoard.misc.FakePlayer; import pw.yumc.MiaoBoard.misc.FakePlayer;
import pw.yumc.YumCore.bukkit.Log;
import pw.yumc.YumCore.kit.StrKit; import pw.yumc.YumCore.kit.StrKit;
import java.util.ArrayList; import java.util.ArrayList;
@ -19,8 +21,8 @@ import java.util.List;
*/ */
public class SidebarBoardPage extends BoardPage { public class SidebarBoardPage extends BoardPage {
private static final List<ChatColor> COLORS = Arrays.asList(ChatColor.values()); private static final List<ChatColor> COLORS = Arrays.asList(ChatColor.values());
private static final int BOARD_LINE_MAX_CHARS = 16; private static int BOARD_LINE_MAX_CHARS = 16;
private static final int BOARD_LINE_MAX_CHARS_SUB1 = BOARD_LINE_MAX_CHARS - 1; private static int BOARD_LINE_MAX_CHARS_SUB1 = BOARD_LINE_MAX_CHARS - 1;
private static boolean newVer = true; private static boolean newVer = true;
static { static {
@ -29,6 +31,13 @@ public class SidebarBoardPage extends BoardPage {
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
newVer = false; newVer = false;
} }
try {
Material.valueOf("KELP");
BOARD_LINE_MAX_CHARS = 64;
BOARD_LINE_MAX_CHARS_SUB1 = BOARD_LINE_MAX_CHARS - 1;
Log.console("§a当前服务端支持新版记分板 长度限制为128个字符...");
} catch (IllegalArgumentException e) {
}
} }
private final Objective objective; private final Objective objective;

View File

@ -20,7 +20,7 @@ Boards:
title: '玩家信息' title: '玩家信息'
#记分板权限 #记分板权限
permission: mb.default permission: mb.default
#记分板内容(不得超过38字符 包括颜色字符 超过部分自动截取) #记分板内容(不得超过32个字符(1.13+限制为128字符) 包括颜色字符 超过部分自动截取)
lines: lines:
- '&6名 称: &a%player_displayname%' - '&6名 称: &a%player_displayname%'
- '&6世 界: &b%player_world%' - '&6世 界: &b%player_world%'
@ -38,7 +38,7 @@ Boards:
title: '服务器信息' title: '服务器信息'
#记分板权限 #记分板权限
permission: mb.reload permission: mb.reload
#记分板内容(不得超过38字符 包括颜色字符 超过部分自动截取) #记分板内容(不得超过32个字符(1.13+限制为128字符) 包括颜色字符 超过部分自动截取)
lines: lines:
- '&6名 称: &a%plugin_name%' - '&6名 称: &a%plugin_name%'
- '&6版 本: &b%plugin_version%' - '&6版 本: &b%plugin_version%'

View File

@ -1,6 +1,7 @@
name: ${project.artifactId} name: ${project.artifactId}
description: ${project.description} description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId} main: ${project.groupId}.${project.artifactId}.${project.artifactId}
api-version: 1.13
version: ${project.version}-git-${env.GIT_COMMIT} version: ${project.version}-git-${env.GIT_COMMIT}
author: 喵♂呜 author: 喵♂呜
website: ${ciManagement.url} website: ${ciManagement.url}