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

fix: 修复记分板切换异常问题

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2021-05-31 16:15:41 +08:00
parent e1ee7daa56
commit 3f193bbf46
2 changed files with 17 additions and 17 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.0</version> <version>2.5.1</version>
<description>喵式记分板</description> <description>喵式记分板</description>
<parent> <parent>
@ -13,13 +13,15 @@
</parent> </parent>
<properties> <properties>
<update.description>§a正式版本 2.5.0</update.description> <update.description>§a正式版本 2.5.1</update.description>
<update.changes> <update.changes>
§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年;
§618-03-05 §cfix: 修复1.12不兼容的问题 §619-06-22 §afeat: 新增换行符的支持(欠费夏独家赞助更新)
</update.changes> </update.changes>
<update.changelog> <update.changelog>
§618-03-05 §cfix: 修复1.12不兼容的问题;
§617-10-15 §cfix: 修复颜色字符分割错误; §617-10-15 §cfix: 修复颜色字符分割错误;
§617-08-15 §cfix: 修复事件未标记为异步的问题; §617-08-15 §cfix: 修复事件未标记为异步的问题;
§617-06-28 §cfix: 修复T端不兼容的问题; §617-06-28 §cfix: 修复T端不兼容的问题;

View File

@ -1,24 +1,26 @@
package pw.yumc.MiaoBoard.scoreboard.core; package pw.yumc.MiaoBoard.scoreboard.core;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
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.kit.StrKit; import pw.yumc.YumCore.kit.StrKit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/** /**
* @author 尘曲 * @author 尘曲
* @since 2016年7月4日 下午4:40:21 * @since 2016年7月4日 下午4:40:21
*/ */
public class SidebarBoardPage extends BoardPage { public class SidebarBoardPage extends BoardPage {
private static final List<ChatColor> COLORS = Arrays.asList(ChatColor.values());
private static final int BOARD_LINE_MAX_CHARS = 16;
private static final int BOARD_LINE_MAX_CHARS_SUB1 = BOARD_LINE_MAX_CHARS - 1;
private static boolean newVer = true; private static boolean newVer = true;
static { static {
@ -29,12 +31,9 @@ public class SidebarBoardPage extends BoardPage {
} }
} }
private static final List<ChatColor> COLORS = Arrays.asList(ChatColor.values());
private static final int BOARD_LINE_MAX_CHARS = 16;
private static final int BOARD_LINE_MAX_CHARS_SUB1 = BOARD_LINE_MAX_CHARS - 1;
private final Objective objective; private final Objective objective;
private final List<BoardLine> boardLines = new ArrayList<>(); private final List<BoardLine> boardLines = new ArrayList<>();
private int maxLine; private int currentSize;
public SidebarBoardPage() { public SidebarBoardPage() {
super(); super();
@ -76,17 +75,16 @@ public class SidebarBoardPage extends BoardPage {
} }
boardLine.getTeam().setPrefix(prefix); boardLine.getTeam().setPrefix(prefix);
boardLine.getTeam().setSuffix(suffix); boardLine.getTeam().setSuffix(suffix);
maxLine = line + 1;
} }
//all 5 [0 1 2 3 4] maxLine = 5 all 3 [0 1 2] maxLine=4 //all 5 [0 1 2 3 4] maxLine = 5 all 3 [0 1 2] maxLine=4
public void clear(int size) { public void clear(int size) {
if (maxLine > size) { if (size < currentSize) {
for (int i = size; i < maxLine; i++) { for (int i = size; i < currentSize; i++) {
removeLine(i); removeLine(i + 1);
} }
maxLine = size;
} }
currentSize = size;
} }
public void removeLine(int line) { public void removeLine(int line) {