diff --git a/core/AllMusic.java b/core/AllMusic.java index ebfe41be..bdb89600 100644 --- a/core/AllMusic.java +++ b/core/AllMusic.java @@ -35,7 +35,7 @@ public class AllMusic { /** * 插件版本号 */ - public static final String version = "3.1.4"; + public static final String version = "3.1.5"; /** * 配置文件版本号 */ @@ -61,10 +61,6 @@ public class AllMusic { * 正在播放的玩家 */ private static final Set nowPlayPlayer = new HashSet<>(); - /** - * 暂时不往玩家发送数据包 - */ - private static final Set pauseSendPlayer = new HashSet<>(); /** * 日志 */ @@ -140,14 +136,13 @@ private static void messageCheck() { * @param checkList 是否检查正在播放的列表 * @return 结果 */ - public static boolean isOK(String name, String server, boolean checkList) { + public static boolean isSkip(String name, String server, boolean checkList) { try { + name = name.toLowerCase(); if (server != null && AllMusic.getConfig().muteServer.contains(server)) return true; if (AllMusic.getConfig().mutePlayer.contains(name)) return true; - if (AllMusic.isPause(name)) - return true; if (!checkList) return false; return AllMusic.containNowPlay(name); @@ -163,6 +158,7 @@ public static boolean isOK(String name, String server, boolean checkList) { * @return 是否存在 */ public static boolean containNowPlay(String player) { + player = player.toLowerCase(); return !nowPlayPlayer.contains(player); } @@ -199,6 +195,7 @@ public static MessageObj getMessage() { * @param page 结果 */ public static void addSearch(String player, SearchPageObj page) { + player = player.toLowerCase(); searchSave.put(player, page); } @@ -209,6 +206,7 @@ public static void addSearch(String player, SearchPageObj page) { * @return 结果 */ public static SearchPageObj getSearch(String player) { + player = player.toLowerCase(); return searchSave.get(player); } @@ -218,6 +216,7 @@ public static SearchPageObj getSearch(String player) { * @param player 用户名 */ public static void removeSearch(String player) { + player = player.toLowerCase(); searchSave.remove(player); } @@ -227,6 +226,7 @@ public static void removeSearch(String player) { * @param player 用户名 */ public static void addVote(String player) { + player = player.toLowerCase(); votePlayer.add(player); } @@ -236,6 +236,7 @@ public static void addVote(String player) { * @param player 用户名 */ public static void addPush(String player) { + player = player.toLowerCase(); pushPlayer.add(player); } @@ -255,6 +256,9 @@ public static void clearVote() { votePlayer.clear(); } + /** + * 清空插歌 + */ public static void clearPush() { pushPlayer.clear(); } @@ -266,10 +270,12 @@ public static void clearPush() { * @return 结果 */ public static boolean containVote(String player) { + player = player.toLowerCase(); return votePlayer.contains(player); } public static boolean containPush(String player) { + player = player.toLowerCase(); return pushPlayer.contains(player); } @@ -279,6 +285,7 @@ public static boolean containPush(String player) { * @param player 用户名 */ public static void addNowPlayPlayer(String player) { + player = player.toLowerCase(); nowPlayPlayer.add(player); } @@ -288,8 +295,8 @@ public static void addNowPlayPlayer(String player) { * @param player 用户名 */ public static void removeNowPlayPlayer(String player) { + player = player.toLowerCase(); nowPlayPlayer.remove(player); - pauseSendPlayer.remove(player); } /** @@ -444,46 +451,26 @@ private static void loadConfig() { * @param player 用户名 */ public static void joinPlay(String player) { + player = player.toLowerCase(); if (getConfig().mutePlayer.contains(player) || nowPlayPlayer.contains(player)) { - pauseSendPlayer.remove(player); return; } + String finalPlayer = player; AllMusic.side.runTask(() -> { if (PlayMusic.nowPlayMusic != null && PlayGo.url != null) { - AllMusic.side.sendHudPos(player); - AllMusic.side.sendMusic(player, PlayGo.url); + AllMusic.side.sendHudPos(finalPlayer); + AllMusic.side.sendMusic(finalPlayer, PlayGo.url); if (!PlayMusic.nowPlayMusic.isUrl()) { AllMusic.side.runTask(() -> - AllMusic.side.sendPic(player, PlayMusic.nowPlayMusic.getPicUrl()), 15); + AllMusic.side.sendPic(finalPlayer, PlayMusic.nowPlayMusic.getPicUrl()), 15); } AllMusic.side.runTask(() -> - AllMusic.side.sendPos(player, PlayMusic.musicNowTime + 1000), 40); + AllMusic.side.sendPos(finalPlayer, PlayMusic.musicNowTime + 1000), 40); } - - pauseSendPlayer.remove(player); }, 40); } - /** - * 将玩家添加到暂停发送列表 - * - * @param player 玩家名 - */ - public static void pauseSend(String player) { - pauseSendPlayer.add(player); - } - - /** - * 暂停发送列表中是否存在玩家 - * - * @param player 玩家名 - * @return 是否存在 - */ - public static boolean isPause(String player) { - return pauseSendPlayer.contains(player); - } - /** * 读取配置文件 * diff --git a/core/objs/config/ConfigObj.java b/core/objs/config/ConfigObj.java index ec254e8e..b7dae5a9 100644 --- a/core/objs/config/ConfigObj.java +++ b/core/objs/config/ConfigObj.java @@ -3,6 +3,7 @@ import com.coloryr.allmusic.server.core.AllMusic; import java.util.HashSet; +import java.util.Locale; import java.util.Set; /** @@ -138,18 +139,21 @@ public void addBanMusic(String id) { AllMusic.saveConfig(); } - public void addBanPlayer(String id) { - banPlayer.add(id); + public void addBanPlayer(String name) { + name = name.toLowerCase(Locale.ROOT); + banPlayer.add(name); AllMusic.saveConfig(); } - public void addNoMusicPlayer(String ID) { - mutePlayer.add(ID); + public void addNoMusicPlayer(String name) { + name = name.toLowerCase(Locale.ROOT); + mutePlayer.add(name); AllMusic.saveConfig(); } - public void removeNoMusicPlayer(String ID) { - mutePlayer.remove(ID); + public void removeNoMusicPlayer(String name) { + name = name.toLowerCase(Locale.ROOT); + mutePlayer.remove(name); AllMusic.saveConfig(); } diff --git a/forge_1_16_5/src/main/resources/META-INF/mods.toml b/forge_1_16_5/src/main/resources/META-INF/mods.toml index f17bf670..c1831968 100644 --- a/forge_1_16_5/src/main/resources/META-INF/mods.toml +++ b/forge_1_16_5/src/main/resources/META-INF/mods.toml @@ -20,7 +20,7 @@ modId="allmusic_server" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata # see the associated build.gradle script for how to populate this completely automatically during a build -version="3.1.4" #mandatory +version="3.1.5" #mandatory # A display name for the mod displayName="AllMusic Server" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ diff --git a/forge_1_18_2/src/main/resources/META-INF/mods.toml b/forge_1_18_2/src/main/resources/META-INF/mods.toml index 2d501b8f..7d9c446c 100644 --- a/forge_1_18_2/src/main/resources/META-INF/mods.toml +++ b/forge_1_18_2/src/main/resources/META-INF/mods.toml @@ -19,7 +19,7 @@ modId="allmusic_server" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata # see the associated build.gradle script for how to populate this completely automatically during a build -version="3.1.4" #mandatory +version="3.1.5" #mandatory # A display name for the mod displayName="AllMusic Serevr" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ diff --git a/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/SideBukkit.java b/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/SideBukkit.java index 3fc430c6..8eb7c875 100644 --- a/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/SideBukkit.java +++ b/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/SideBukkit.java @@ -81,7 +81,7 @@ public void sendHudLyric(String data) { Object obj1 = pack(ComType.LYRIC, data, 0); byte[] temp = (byte[]) arrayM.invoke(obj1); for (Player player : Bukkit.getOnlinePlayers()) { - if (AllMusic.isOK(player.getName(), null, true)) + if (AllMusic.isSkip(player.getName(), null, true)) continue; String name = player.getName(); SaveObj obj = HudUtils.get(name); @@ -101,7 +101,7 @@ public void sendHudInfo(String data) { Object obj1 = pack(ComType.INFO, data, 0); byte[] temp = (byte[]) arrayM.invoke(obj1); for (Player player : Bukkit.getOnlinePlayers()) { - if (AllMusic.isOK(player.getName(), null, true)) + if (AllMusic.isSkip(player.getName(), null, true)) continue; String name = player.getName(); SaveObj obj = HudUtils.get(name); @@ -121,7 +121,7 @@ public void sendHudPos(String name) { Player player = Bukkit.getPlayer(name); if (player == null) return; - if (AllMusic.isOK(name, null, false)) + if (AllMusic.isSkip(name, null, false)) return; SaveObj obj = HudUtils.get(name); String data = AllMusic.gson.toJson(obj); @@ -144,7 +144,7 @@ public void sendHud(String name, HudType pos, String data) { if (player == null) return; - if (AllMusic.isOK(name, null, true)) + if (AllMusic.isSkip(name, null, true)) return; Object obj1 = null; switch (pos) { @@ -176,7 +176,7 @@ public void sendHudList(String data) { Object obj1 = pack(ComType.LIST, data, 0); byte[] temp = (byte[]) arrayM.invoke(obj1); for (Player player : Bukkit.getOnlinePlayers()) { - if (AllMusic.isOK(player.getName(), null, true)) + if (AllMusic.isSkip(player.getName(), null, true)) continue; String name = player.getName(); SaveObj obj = HudUtils.get(name); @@ -212,7 +212,7 @@ public void sendBar(String data) { if (AllMusicBukkit.spigotSet) { for (Player player : Bukkit.getOnlinePlayers()) { try { - if (AllMusic.isOK(player.getName(), null, true)) + if (AllMusic.isSkip(player.getName(), null, true)) continue; SpigotApi.sendBar(player, data); } catch (Exception e1) { @@ -231,8 +231,9 @@ public void sendMusic(String data) { Object obj1 = pack(ComType.PLAY, data, 0); byte[] temp = (byte[]) arrayM.invoke(obj1); for (Player player : Bukkit.getOnlinePlayers()) { - if (AllMusic.isOK(player.getName(), null, false)) + if (AllMusic.isSkip(player.getName(), null, false)) { continue; + } send(player, temp); AllMusic.addNowPlayPlayer(player.getName()); } @@ -248,8 +249,9 @@ protected void topSendMusic(String player, String data) { Player player1 = Bukkit.getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) { return; + } Object obj1 = pack(ComType.PLAY, data, 0); byte[] temp = (byte[]) arrayM.invoke(obj1); send(player1, temp); @@ -265,7 +267,7 @@ public void sendPic(String data) { Object obj1 = pack(ComType.IMG, data, 0); byte[] temp = (byte[]) arrayM.invoke(obj1); for (Player player : Bukkit.getOnlinePlayers()) { - if (AllMusic.isOK(player.getName(), null, true)) + if (AllMusic.isSkip(player.getName(), null, true)) continue; String name = player.getName(); SaveObj obj = HudUtils.get(name); @@ -285,7 +287,7 @@ public void sendPic(String player, String data) { Player player1 = Bukkit.getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName(), null, true)) + if (AllMusic.isSkip(player1.getName(), null, true)) return; Object obj1 = pack(ComType.IMG, data, 0); byte[] temp = (byte[]) arrayM.invoke(obj1); @@ -302,7 +304,7 @@ public void sendPos(String player, int pos) { Player player1 = Bukkit.getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName(), null, true)) + if (AllMusic.isSkip(player1.getName(), null, true)) return; Object obj1 = pack(ComType.POS, null, pos); byte[] temp = (byte[]) arrayM.invoke(obj1); @@ -374,7 +376,7 @@ public void clearHud() { @Override public void topBq(String data) { for (Player player : Bukkit.getOnlinePlayers()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName())) { + if (!AllMusic.isSkip(player.getName(), null, true)) { player.sendMessage(data); } } @@ -391,7 +393,7 @@ public boolean needPlay() { for (Player player : Bukkit.getOnlinePlayers()) { if (CitizensNPC.isNPC(player)) online--; - else if (AllMusic.getConfig().mutePlayer.contains(player.getName())) { + else if (AllMusic.isSkip(player.getName(), null, false)) { online--; } } diff --git a/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/hooks/SpigotApi.java b/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/hooks/SpigotApi.java index ce82bdff..54d475a0 100644 --- a/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/hooks/SpigotApi.java +++ b/server/src/main/java/com/coloryr/allmusic/server/side/bukkit/hooks/SpigotApi.java @@ -37,7 +37,7 @@ public static void sendMessageBqRun(String message, String end, String command) endtext.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)); send.addExtra(endtext); for (Player player : Bukkit.getOnlinePlayers()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName())) { + if (!AllMusic.isSkip(player.getName(), null, false)) { player.spigot().sendMessage(send); } } diff --git a/version b/version index b532f3dc..97ceee1b 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.1.4 \ No newline at end of file +3.1.5 \ No newline at end of file