diff --git a/core/command/CommandEX.java b/core/command/CommandEX.java index 32718163..69f9bc93 100644 --- a/core/command/CommandEX.java +++ b/core/command/CommandEX.java @@ -254,7 +254,7 @@ public static List getTabList(String name, String[] arg) { List arguments = new ArrayList<>(); if (arg.length == 0) { arguments.addAll(normal); - if (AllMusic.getConfig().adminList.contains(name)) { + if (AllMusic.side.checkPermission(name)) { arguments.addAll(admin); } if (AllMusic.getSearch(name) != null) { @@ -263,7 +263,7 @@ public static List getTabList(String name, String[] arg) { } else { if (arg[0] == null || arg[0].isEmpty() || arg.length == 1) { arguments.addAll(normal); - if (AllMusic.getConfig().adminList.contains(name)) { + if (AllMusic.side.checkPermission(name)) { arguments.addAll(admin); } if (arg[0] == null || arg[0].isEmpty()) { @@ -276,9 +276,11 @@ public static List getTabList(String name, String[] arg) { if (command != null) { arguments.addAll(command.tab(name, arg, 1)); } - command = CommandEX.commandAdminList.get(arg[0]); - if (command != null) { - arguments.addAll(command.tab(name, arg, 1)); + if (AllMusic.side.checkPermission(name)) { + command = CommandEX.commandAdminList.get(arg[0]); + if (command != null) { + arguments.addAll(command.tab(name, arg, 1)); + } } } } diff --git a/core/command/CommandHelp.java b/core/command/CommandHelp.java index f359f536..788b73a6 100644 --- a/core/command/CommandHelp.java +++ b/core/command/CommandHelp.java @@ -52,7 +52,7 @@ public void ex(Object sender, String name, String[] args) { AllMusic.getMessage().click.clickCheck, "/music hud pic rotate "); AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().help.normal.hud5, AllMusic.getMessage().click.clickCheck, "/music hud pic speed "); - if (AllMusic.getConfig().adminList.contains(name)) { + if (AllMusic.side.checkPermission(name)) { AllMusic.side.sendMessageRun(sender, AllMusic.getMessage().help.admin.reload, AllMusic.getMessage().click.clickRun, "/music reload"); AllMusic.side.sendMessageRun(sender, AllMusic.getMessage().help.admin.next, diff --git a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java index e168a7b9..ca61f197 100644 --- a/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java +++ b/fabric_1_16_5/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java @@ -74,13 +74,12 @@ public boolean checkPermission(String player, String permission) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -112,7 +111,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -129,7 +128,7 @@ protected void topSendMusic(String player, String data) { ServerPlayerEntity player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -142,7 +141,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -162,7 +161,7 @@ public void sendPic(String player, String data) { ServerPlayerEntity player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -177,7 +176,7 @@ public void sendPos(String player, int pos) { ServerPlayerEntity player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -190,7 +189,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -208,7 +207,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -247,7 +246,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; switch (pos) { @@ -271,7 +270,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -304,7 +303,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; FabricApi.sendBar(player, data); } catch (Exception e1) { @@ -342,7 +341,7 @@ public void clearHud() { @Override public void topBq(String data) { for (ServerPlayerEntity player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(data), false); } } diff --git a/fabric_1_18_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java b/fabric_1_18_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java index 4b61f55f..9fd48977 100644 --- a/fabric_1_18_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java +++ b/fabric_1_18_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java @@ -74,13 +74,12 @@ public boolean checkPermission(String player, String permission) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -112,7 +111,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -129,7 +128,7 @@ protected void topSendMusic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -142,7 +141,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -162,7 +161,7 @@ public void sendPic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -177,7 +176,7 @@ public void sendPos(String player, int pos) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -190,7 +189,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -208,7 +207,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -247,7 +246,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; switch (pos) { @@ -271,7 +270,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -304,7 +303,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; FabricApi.sendBar(player, data); } catch (Exception e1) { @@ -342,7 +341,7 @@ public void clearHud() { @Override public void topBq(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(data), false); } } diff --git a/fabric_1_19_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java b/fabric_1_19_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java index 74624255..b5d1e55d 100644 --- a/fabric_1_19_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java +++ b/fabric_1_19_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java @@ -77,7 +77,7 @@ public boolean checkPermission(String player, String permission) { public boolean needPlay() { int online = getPlayerSize(); for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (AllMusic.isSkip(player.getName().getString(), null, false)) { online--; } } @@ -113,7 +113,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -130,7 +130,7 @@ protected void topSendMusic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -143,7 +143,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -163,7 +163,7 @@ public void sendPic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -178,7 +178,7 @@ public void sendPos(String player, int pos) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -191,7 +191,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -209,7 +209,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -248,7 +248,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; switch (pos) { @@ -272,7 +272,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -305,7 +305,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; FabricApi.sendBar(player, data); } catch (Exception e1) { @@ -343,7 +343,7 @@ public void clearHud() { @Override public void topBq(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(data), false); } } diff --git a/fabric_1_19_3/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java b/fabric_1_19_3/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java index 23cc9d9c..36d4bd28 100644 --- a/fabric_1_19_3/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java +++ b/fabric_1_19_3/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java @@ -73,13 +73,12 @@ public boolean checkPermission(String player, String permission) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -111,7 +110,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -128,7 +127,7 @@ protected void topSendMusic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -141,7 +140,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -161,7 +160,7 @@ public void sendPic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -176,7 +175,7 @@ public void sendPos(String player, int pos) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -189,7 +188,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -207,7 +206,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -246,7 +245,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; switch (pos) { @@ -270,7 +269,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -303,7 +302,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; FabricApi.sendBar(player, data); } catch (Exception e1) { @@ -341,7 +340,7 @@ public void clearHud() { @Override public void topBq(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(data), false); } } diff --git a/fabric_1_20/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java b/fabric_1_20/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java index 23cc9d9c..36d4bd28 100644 --- a/fabric_1_20/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java +++ b/fabric_1_20/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java @@ -73,13 +73,12 @@ public boolean checkPermission(String player, String permission) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -111,7 +110,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -128,7 +127,7 @@ protected void topSendMusic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -141,7 +140,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -161,7 +160,7 @@ public void sendPic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -176,7 +175,7 @@ public void sendPos(String player, int pos) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -189,7 +188,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -207,7 +206,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -246,7 +245,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; switch (pos) { @@ -270,7 +269,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -303,7 +302,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; FabricApi.sendBar(player, data); } catch (Exception e1) { @@ -341,7 +340,7 @@ public void clearHud() { @Override public void topBq(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(data), false); } } diff --git a/fabric_1_20_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java b/fabric_1_20_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java index 74624255..5c7757cc 100644 --- a/fabric_1_20_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java +++ b/fabric_1_20_2/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java @@ -75,13 +75,12 @@ public boolean checkPermission(String player, String permission) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -113,7 +112,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -130,7 +129,7 @@ protected void topSendMusic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -143,7 +142,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -163,7 +162,7 @@ public void sendPic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -178,7 +177,7 @@ public void sendPos(String player, int pos) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -191,7 +190,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -209,7 +208,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -248,7 +247,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; switch (pos) { @@ -272,7 +271,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -305,7 +304,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; FabricApi.sendBar(player, data); } catch (Exception e1) { @@ -343,7 +342,7 @@ public void clearHud() { @Override public void topBq(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(data), false); } } diff --git a/fabric_1_20_6/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java b/fabric_1_20_6/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java index abadc9ed..c3d81fe3 100644 --- a/fabric_1_20_6/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java +++ b/fabric_1_20_6/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java @@ -71,13 +71,12 @@ public boolean checkPermission(String player, String permission) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -109,7 +108,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, new PackPayload(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -126,7 +125,7 @@ protected void topSendMusic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, new PackPayload(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -139,7 +138,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -159,7 +158,7 @@ public void sendPic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, new PackPayload(ComType.IMG, data, 0)); } catch (Exception e) { @@ -174,7 +173,7 @@ public void sendPos(String player, int pos) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, new PackPayload(ComType.POS, null, pos)); } catch (Exception e) { @@ -187,7 +186,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -205,7 +204,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -244,7 +243,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; switch (pos) { @@ -268,7 +267,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -301,7 +300,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; FabricApi.sendBar(player, data); } catch (Exception e1) { @@ -339,7 +338,7 @@ public void clearHud() { @Override public void topBq(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(data), false); } } diff --git a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java index abadc9ed..c3d81fe3 100644 --- a/fabric_1_21/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java +++ b/fabric_1_21/src/main/java/com/coloryr/allmusic/server/side/fabric/SideFabric.java @@ -71,13 +71,12 @@ public boolean checkPermission(String player, String permission) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -109,7 +108,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, new PackPayload(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -126,7 +125,7 @@ protected void topSendMusic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, new PackPayload(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -139,7 +138,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -159,7 +158,7 @@ public void sendPic(String player, String data) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, new PackPayload(ComType.IMG, data, 0)); } catch (Exception e) { @@ -174,7 +173,7 @@ public void sendPos(String player, int pos) { var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, new PackPayload(ComType.POS, null, pos)); } catch (Exception e) { @@ -187,7 +186,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -205,7 +204,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -244,7 +243,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; switch (pos) { @@ -268,7 +267,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -301,7 +300,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; FabricApi.sendBar(player, data); } catch (Exception e1) { @@ -339,7 +338,7 @@ public void clearHud() { @Override public void topBq(String data) { for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(Text.of(data), false); } } diff --git a/folia/src/main/java/com/coloryr/allmusic/server/side/folia/SideFolia.java b/folia/src/main/java/com/coloryr/allmusic/server/side/folia/SideFolia.java index c6eb4a5d..c64b91ae 100644 --- a/folia/src/main/java/com/coloryr/allmusic/server/side/folia/SideFolia.java +++ b/folia/src/main/java/com/coloryr/allmusic/server/side/folia/SideFolia.java @@ -33,7 +33,7 @@ public int getPlayerSize() { public void sendHudLyric(String data) { try { 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); @@ -51,7 +51,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { 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); @@ -71,7 +71,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); @@ -92,7 +92,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; switch (pos) { @@ -116,7 +116,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { 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); @@ -150,7 +150,7 @@ public void sendBar(String data) { if (AllMusicFolia.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) { @@ -167,7 +167,7 @@ public void sendBar(String data) { public void sendMusic(String data) { try { for (Player player : Bukkit.getOnlinePlayers()) { - if (AllMusic.isOK(player.getName(), null, false)) + if (AllMusic.isSkip(player.getName(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName()); @@ -184,7 +184,7 @@ 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; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -197,7 +197,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { 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); @@ -217,7 +217,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; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -232,7 +232,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; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -294,7 +294,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, false)) { player.sendMessage(data); } } @@ -311,7 +311,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--; } } @@ -356,10 +356,8 @@ public void reload() { @Override public boolean checkPermission(String player, String permission) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + if (checkPermission(player)) { + return true; } Player player1 = Bukkit.getPlayer(player); if (player1 == null) diff --git a/forge_1_12_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java b/forge_1_12_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java index 0aea8a2d..3acc9a0d 100644 --- a/forge_1_12_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java +++ b/forge_1_12_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java @@ -76,13 +76,12 @@ public boolean checkPermission(String player) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (EntityPlayerMP player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName())) { - online--; + if (AllMusic.isSkip(player.getName(), null,false)) { + return true; } } - return online > 0; + return false; } @Override @@ -114,7 +113,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (EntityPlayerMP player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName(), null, false)) + if (AllMusic.isSkip(player.getName(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName()); @@ -131,7 +130,7 @@ protected void topSendMusic(String player, String data) { EntityPlayerMP player1 = AllMusicForge.server.getPlayerList().getPlayerByUsername(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -144,7 +143,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (EntityPlayerMP player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName(), null, true)) + if (AllMusic.isSkip(player.getName(), null, true)) continue; String name = player.getName(); SaveObj obj = HudUtils.get(name); @@ -164,7 +163,7 @@ public void sendPic(String player, String data) { EntityPlayerMP player1 = AllMusicForge.server.getPlayerList().getPlayerByUsername(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName(), null, true)) + if (AllMusic.isSkip(player1.getName(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -179,7 +178,7 @@ public void sendPos(String player, int pos) { EntityPlayerMP player1 = AllMusicForge.server.getPlayerList().getPlayerByUsername(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName(), null, true)) + if (AllMusic.isSkip(player1.getName(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -192,7 +191,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (EntityPlayerMP player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName(), null, true)) + if (AllMusic.isSkip(player.getName(), null, true)) continue; String name = player.getName(); SaveObj obj = HudUtils.get(name); @@ -210,7 +209,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (EntityPlayerMP player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName(), null, true)) + if (AllMusic.isSkip(player.getName(), null, true)) continue; String name = player.getName(); SaveObj obj = HudUtils.get(name); @@ -248,7 +247,7 @@ public void sendHud(String name, HudType pos, String data) { EntityPlayerMP player = AllMusicForge.server.getPlayerList().getPlayerByUsername(name); if (player == null) return; - if (AllMusic.isOK(name, null, true)) + if (AllMusic.isSkip(name, null, true)) return; switch (pos) { case INFO: @@ -271,7 +270,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (EntityPlayerMP player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName(), null, true)) + if (AllMusic.isSkip(player.getName(), null, true)) continue; String name = player.getName(); SaveObj obj = HudUtils.get(name); @@ -304,7 +303,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (EntityPlayerMP player : AllMusicForge.server.getPlayerList().getPlayers()) { try { - if (AllMusic.isOK(player.getName(), null, true)) + if (AllMusic.isSkip(player.getName(), null, true)) continue; ForgeApi.sendBar(player, data); } catch (Exception e1) { @@ -342,7 +341,7 @@ public void clearHud() { @Override public void topBq(String data) { for (EntityPlayerMP player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName())) { + if (!AllMusic.isSkip(player.getName(), null, false)) { player.sendMessage(new TextComponentString(data)); } } diff --git a/forge_1_16_5/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java b/forge_1_16_5/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java index 76da49d7..7b3b8691 100644 --- a/forge_1_16_5/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java +++ b/forge_1_16_5/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java @@ -77,13 +77,12 @@ public boolean checkPermission(String player) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (ServerPlayerEntity player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -115,7 +114,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (ServerPlayerEntity player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -132,7 +131,7 @@ protected void topSendMusic(String player, String data) { ServerPlayerEntity player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -145,7 +144,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (ServerPlayerEntity player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -165,7 +164,7 @@ public void sendPic(String player, String data) { ServerPlayerEntity player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -180,7 +179,7 @@ public void sendPos(String player, int pos) { ServerPlayerEntity player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -193,7 +192,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (ServerPlayerEntity player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -211,7 +210,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (ServerPlayerEntity player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -249,7 +248,7 @@ public void sendHud(String name, HudType pos, String data) { ServerPlayerEntity player = AllMusicForge.server.getPlayerList().getPlayerByName(name); if (player == null) return; - if (AllMusic.isOK(name, null, true)) + if (AllMusic.isSkip(name, null, true)) return; switch (pos) { case INFO: @@ -272,7 +271,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (ServerPlayerEntity player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -305,7 +304,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (ServerPlayerEntity player : AllMusicForge.server.getPlayerList().getPlayers()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; ForgeApi.sendBar(player, data); } catch (Exception e1) { @@ -343,7 +342,7 @@ public void clearHud() { @Override public void topBq(String data) { for (ServerPlayerEntity player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(new StringTextComponent(data), UUID.randomUUID()); } } diff --git a/forge_1_18_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java b/forge_1_18_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java index e2675cb2..07894548 100644 --- a/forge_1_18_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java +++ b/forge_1_18_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java @@ -77,13 +77,12 @@ public boolean checkPermission(String player) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -115,7 +114,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -132,7 +131,7 @@ protected void topSendMusic(String player, String data) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -145,7 +144,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -165,7 +164,7 @@ public void sendPic(String player, String data) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -180,7 +179,7 @@ public void sendPos(String player, int pos) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -193,7 +192,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -211,7 +210,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -249,7 +248,7 @@ public void sendHud(String name, HudType pos, String data) { ServerPlayer player = AllMusicForge.server.getPlayerList().getPlayerByName(name); if (player == null) return; - if (AllMusic.isOK(name, null, true)) + if (AllMusic.isSkip(name, null, true)) return; switch (pos) { case INFO: @@ -272,7 +271,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -305,7 +304,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; ForgeApi.sendBar(player, data); } catch (Exception e1) { @@ -343,7 +342,7 @@ public void clearHud() { @Override public void topBq(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendMessage(new TextComponent(data), UUID.randomUUID()); } } diff --git a/forge_1_19_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java b/forge_1_19_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java index e96aa9d8..3b04685d 100644 --- a/forge_1_19_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java +++ b/forge_1_19_2/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java @@ -76,13 +76,12 @@ public boolean checkPermission(String player) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -114,7 +113,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -131,7 +130,7 @@ protected void topSendMusic(String player, String data) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -144,7 +143,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -164,7 +163,7 @@ public void sendPic(String player, String data) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -179,7 +178,7 @@ public void sendPos(String player, int pos) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -192,7 +191,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -210,7 +209,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -248,7 +247,7 @@ public void sendHud(String name, HudType pos, String data) { ServerPlayer player = AllMusicForge.server.getPlayerList().getPlayerByName(name); if (player == null) return; - if (AllMusic.isOK(name, null, true)) + if (AllMusic.isSkip(name, null, true)) return; switch (pos) { case INFO: @@ -271,7 +270,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -304,7 +303,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; ForgeApi.sendBar(player, data); } catch (Exception e1) { @@ -342,7 +341,7 @@ public void clearHud() { @Override public void topBq(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendSystemMessage(Component.literal(data)); } } diff --git a/forge_1_20/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java b/forge_1_20/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java index 71d2acfe..285082f5 100644 --- a/forge_1_20/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java +++ b/forge_1_20/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java @@ -76,13 +76,12 @@ public boolean checkPermission(String player) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -114,7 +113,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -131,7 +130,7 @@ protected void topSendMusic(String player, String data) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -144,7 +143,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -164,7 +163,7 @@ public void sendPic(String player, String data) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -179,7 +178,7 @@ public void sendPos(String player, int pos) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -192,7 +191,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -210,7 +209,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -248,7 +247,7 @@ public void sendHud(String name, HudType pos, String data) { ServerPlayer player = AllMusicForge.server.getPlayerList().getPlayerByName(name); if (player == null) return; - if (AllMusic.isOK(name, null, true)) + if (AllMusic.isSkip(name, null, true)) return; switch (pos) { case INFO: @@ -271,7 +270,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -304,7 +303,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; ForgeApi.sendBar(player, data); } catch (Exception e1) { @@ -342,7 +341,7 @@ public void clearHud() { @Override public void topBq(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendSystemMessage(Component.literal(data)); } } diff --git a/forge_1_7_10/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java b/forge_1_7_10/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java index d3f9d080..20ec3b2e 100644 --- a/forge_1_7_10/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java +++ b/forge_1_7_10/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java @@ -76,14 +76,13 @@ public boolean checkPermission(String player) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (Object player1 : AllMusicForge.server.getConfigurationManager().playerEntityList) { EntityPlayerMP player = (EntityPlayerMP) player1; - if (AllMusic.getConfig().mutePlayer.contains(player.getCommandSenderName())) { - online--; + if (!AllMusic.isSkip(player.getCommandSenderName(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -117,7 +116,7 @@ public void sendMusic(String data) { try { for (Object player1 : AllMusicForge.server.getConfigurationManager().playerEntityList) { EntityPlayerMP player = (EntityPlayerMP) player1; - if (AllMusic.isOK(player.getCommandSenderName(), null, false)) + if (AllMusic.isSkip(player.getCommandSenderName(), null, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getCommandSenderName()); @@ -134,7 +133,7 @@ protected void topSendMusic(String player, String data) { EntityPlayerMP player1 = AllMusicForge.server.getConfigurationManager().func_152612_a(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -148,7 +147,7 @@ public void sendPic(String data) { try { for (Object player1 : AllMusicForge.server.getConfigurationManager().playerEntityList) { EntityPlayerMP player = (EntityPlayerMP) player1; - if (AllMusic.isOK(player.getCommandSenderName(), null, true)) + if (AllMusic.isSkip(player.getCommandSenderName(), null, true)) continue; String name = player.getCommandSenderName(); SaveObj obj = HudUtils.get(name); @@ -168,7 +167,7 @@ public void sendPic(String player, String data) { EntityPlayerMP player1 = AllMusicForge.server.getConfigurationManager().func_152612_a(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getCommandSenderName(), null, true)) + if (AllMusic.isSkip(player1.getCommandSenderName(), null, true)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -183,7 +182,7 @@ public void sendPos(String player, int pos) { EntityPlayerMP player1 = AllMusicForge.server.getConfigurationManager().func_152612_a(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getCommandSenderName(), null, true)) + if (AllMusic.isSkip(player1.getCommandSenderName(), null, true)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -197,7 +196,7 @@ public void sendHudLyric(String data) { try { for (Object player1 : AllMusicForge.server.getConfigurationManager().playerEntityList) { EntityPlayerMP player = (EntityPlayerMP) player1; - if (AllMusic.isOK(player.getCommandSenderName(), null, true)) + if (AllMusic.isSkip(player.getCommandSenderName(), null, true)) continue; String name = player.getCommandSenderName(); SaveObj obj = HudUtils.get(name); @@ -216,7 +215,7 @@ public void sendHudInfo(String data) { try { for (Object player1 : AllMusicForge.server.getConfigurationManager().playerEntityList) { EntityPlayerMP player = (EntityPlayerMP) player1; - if (AllMusic.isOK(player.getCommandSenderName(), null, true)) + if (AllMusic.isSkip(player.getCommandSenderName(), null, true)) continue; String name = player.getCommandSenderName(); SaveObj obj = HudUtils.get(name); @@ -254,7 +253,7 @@ public void sendHud(String name, HudType pos, String data) { EntityPlayerMP player = AllMusicForge.server.getConfigurationManager().func_152612_a(name); if (player == null) return; - if (AllMusic.isOK(name, null, true)) + if (AllMusic.isSkip(name, null, true)) return; switch (pos) { case INFO: @@ -278,7 +277,7 @@ public void sendHudList(String data) { try { for (Object player1 : AllMusicForge.server.getConfigurationManager().playerEntityList) { EntityPlayerMP player = (EntityPlayerMP) player1; - if (AllMusic.isOK(player.getCommandSenderName(), null, true)) + if (AllMusic.isSkip(player.getCommandSenderName(), null, true)) continue; String name = player.getCommandSenderName(); SaveObj obj = HudUtils.get(name); @@ -313,7 +312,7 @@ public void sendBar(String data) { for (Object player1 : AllMusicForge.server.getConfigurationManager().playerEntityList) { EntityPlayerMP player = (EntityPlayerMP) player1; try { - if (AllMusic.isOK(player.getCommandSenderName(), null, true)) + if (AllMusic.isSkip(player.getCommandSenderName(), null, true)) continue; ForgeApi.sendBar(player, data); } catch (Exception e1) { @@ -353,7 +352,7 @@ public void clearHud() { public void topBq(String data) { for (Object player1 : AllMusicForge.server.getConfigurationManager().playerEntityList) { EntityPlayerMP player = (EntityPlayerMP) player1; - if (!AllMusic.getConfig().mutePlayer.contains(player.getCommandSenderName())) { + if (!AllMusic.isSkip(player.getCommandSenderName(), null, false)) { player.addChatMessage(new ChatComponentText(data)); } } diff --git a/neoforge_1_20_4/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java b/neoforge_1_20_4/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java index abdf9070..7b7c7563 100644 --- a/neoforge_1_20_4/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java +++ b/neoforge_1_20_4/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java @@ -72,13 +72,12 @@ public boolean checkPermission(String player) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -110,7 +109,7 @@ protected void topSendStop(String name) { public void sendMusic(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, new PackData(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -127,7 +126,7 @@ protected void topSendMusic(String player, String data) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, new PackData(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -140,7 +139,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -160,7 +159,7 @@ public void sendPic(String player, String data) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, new PackData(ComType.IMG, data, 0)); } catch (Exception e) { @@ -175,7 +174,7 @@ public void sendPos(String player, int pos) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, new PackData(ComType.POS, null, pos)); } catch (Exception e) { @@ -188,7 +187,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -206,7 +205,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -244,7 +243,7 @@ public void sendHud(String name, HudType pos, String data) { ServerPlayer player = AllMusicForge.server.getPlayerList().getPlayerByName(name); if (player == null) return; - if (AllMusic.isOK(name, null, true)) + if (AllMusic.isSkip(name, null, true)) return; switch (pos) { case INFO: @@ -267,7 +266,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -300,7 +299,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; ForgeApi.sendBar(player, data); } catch (Exception e1) { @@ -338,7 +337,7 @@ public void clearHud() { @Override public void topBq(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendSystemMessage(Component.literal(data)); } } diff --git a/neoforge_1_20_5/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java b/neoforge_1_20_5/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java index 561088fe..a40f2a52 100644 --- a/neoforge_1_20_5/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java +++ b/neoforge_1_20_5/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java @@ -72,13 +72,12 @@ public boolean checkPermission(String player) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -110,7 +109,7 @@ protected void topSendStop(String name) { public void sendMusic(String url) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, new PackData(ComType.PLAY, url, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -127,7 +126,7 @@ protected void topSendMusic(String player, String url) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, new PackData(ComType.PLAY, url, 0)); } catch (Exception e) { @@ -140,7 +139,7 @@ protected void topSendMusic(String player, String url) { public void sendPic(String url) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -160,7 +159,7 @@ public void sendPic(String player, String url) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, new PackData(ComType.IMG, url, 0)); } catch (Exception e) { @@ -175,7 +174,7 @@ public void sendPos(String player, int pos) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, new PackData(ComType.POS, null, pos)); } catch (Exception e) { @@ -188,7 +187,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -206,7 +205,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -244,7 +243,7 @@ public void sendHud(String name, HudType pos, String data) { ServerPlayer player = AllMusicForge.server.getPlayerList().getPlayerByName(name); if (player == null) return; - if (AllMusic.isOK(name, null, true)) + if (AllMusic.isSkip(name, null, true)) return; switch (pos) { case INFO: @@ -267,7 +266,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -300,7 +299,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; ForgeApi.sendBar(player, data); } catch (Exception e1) { @@ -338,7 +337,7 @@ public void clearHud() { @Override public void topBq(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendSystemMessage(Component.literal(data)); } } diff --git a/neoforge_1_21/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java b/neoforge_1_21/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java index 561088fe..a40f2a52 100644 --- a/neoforge_1_21/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java +++ b/neoforge_1_21/src/main/java/com/coloryr/allmusic/server/side/forge/SideForge.java @@ -72,13 +72,12 @@ public boolean checkPermission(String player) { @Override public boolean needPlay() { - int online = getPlayerSize(); for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { - online--; + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { + return true; } } - return online > 0; + return false; } @Override @@ -110,7 +109,7 @@ protected void topSendStop(String name) { public void sendMusic(String url) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, false)) + if (AllMusic.isSkip(player.getName().getString(), null, false)) continue; send(player, new PackData(ComType.PLAY, url, 0)); AllMusic.addNowPlayPlayer(player.getName().getString()); @@ -127,7 +126,7 @@ protected void topSendMusic(String player, String url) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player, null, false)) + if (AllMusic.isSkip(player, null, false)) return; send(player1, new PackData(ComType.PLAY, url, 0)); } catch (Exception e) { @@ -140,7 +139,7 @@ protected void topSendMusic(String player, String url) { public void sendPic(String url) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -160,7 +159,7 @@ public void sendPic(String player, String url) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, new PackData(ComType.IMG, url, 0)); } catch (Exception e) { @@ -175,7 +174,7 @@ public void sendPos(String player, int pos) { ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); if (player1 == null) return; - if (AllMusic.isOK(player1.getName().getString(), null, true)) + if (AllMusic.isSkip(player1.getName().getString(), null, true)) return; send(player1, new PackData(ComType.POS, null, pos)); } catch (Exception e) { @@ -188,7 +187,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -206,7 +205,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -244,7 +243,7 @@ public void sendHud(String name, HudType pos, String data) { ServerPlayer player = AllMusicForge.server.getPlayerList().getPlayerByName(name); if (player == null) return; - if (AllMusic.isOK(name, null, true)) + if (AllMusic.isSkip(name, null, true)) return; switch (pos) { case INFO: @@ -267,7 +266,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; String name = player.getName().getString(); SaveObj obj = HudUtils.get(name); @@ -300,7 +299,7 @@ public void sendHudUtilsAll() { public void sendBar(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { try { - if (AllMusic.isOK(player.getName().getString(), null, true)) + if (AllMusic.isSkip(player.getName().getString(), null, true)) continue; ForgeApi.sendBar(player, data); } catch (Exception e1) { @@ -338,7 +337,7 @@ public void clearHud() { @Override public void topBq(String data) { for (ServerPlayer player : AllMusicForge.server.getPlayerList().getPlayers()) { - if (!AllMusic.getConfig().mutePlayer.contains(player.getName().getString())) { + if (!AllMusic.isSkip(player.getName().getString(), null, false)) { player.sendSystemMessage(Component.literal(data)); } } 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 8eb7c875..f31f1216 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 @@ -376,7 +376,7 @@ public void clearHud() { @Override public void topBq(String data) { for (Player player : Bukkit.getOnlinePlayers()) { - if (!AllMusic.isSkip(player.getName(), null, true)) { + if (!AllMusic.isSkip(player.getName(), null, false)) { player.sendMessage(data); } } @@ -438,10 +438,8 @@ public void reload() { @Override public boolean checkPermission(String player, String permission) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + if (checkPermission(player)) { + return true; } Player player1 = Bukkit.getPlayer(player); if (player1 == null) diff --git a/server_top/src/main/java/com/coloryr/allmusic/server/side/bc/ListenerBC.java b/server_top/src/main/java/com/coloryr/allmusic/server/side/bc/ListenerBC.java index 46c11e3a..046e00a1 100644 --- a/server_top/src/main/java/com/coloryr/allmusic/server/side/bc/ListenerBC.java +++ b/server_top/src/main/java/com/coloryr/allmusic/server/side/bc/ListenerBC.java @@ -14,26 +14,6 @@ public void onPlayerDisconnectEvent(final PlayerDisconnectEvent event) { AllMusic.removeNowPlayPlayer(event.getPlayer().getName()); } - @EventHandler - public void onLoginEvent(PostLoginEvent event) { - AllMusic.pauseSend(event.getPlayer().getName()); - } - - @EventHandler - public void onServerKickEvent(ServerKickEvent event) { - AllMusic.pauseSend(event.getPlayer().getName()); - } - - @EventHandler - public void onServerSwitchEvent(ServerSwitchEvent event) { - AllMusic.pauseSend(event.getPlayer().getName()); - } - - @EventHandler - public void onServerConnectEvent(ServerConnectEvent event) { - AllMusic.pauseSend(event.getPlayer().getName()); - } - @EventHandler public void onServerConnectedEvent(ServerConnectedEvent event) { AllMusic.side.runTask(() -> { diff --git a/server_top/src/main/java/com/coloryr/allmusic/server/side/bc/SideBC.java b/server_top/src/main/java/com/coloryr/allmusic/server/side/bc/SideBC.java index 289f597f..72c3b51a 100644 --- a/server_top/src/main/java/com/coloryr/allmusic/server/side/bc/SideBC.java +++ b/server_top/src/main/java/com/coloryr/allmusic/server/side/bc/SideBC.java @@ -135,7 +135,7 @@ public int getPlayerSize() { public void sendHudLyric(String data) { try { for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { - if (ok(player)) + if (skip(player)) continue; SaveObj obj = HudUtils.get(player.getName()); if (!obj.lyric.enable) @@ -152,7 +152,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { - if (ok(player)) + if (skip(player)) continue; SaveObj obj = HudUtils.get(player.getName()); if (!obj.info.enable) @@ -169,7 +169,7 @@ public void sendHudInfo(String data) { public void sendHudList(String data) { try { for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { - if (ok(player)) + if (skip(player)) continue; String name = player.getName(); SaveObj obj = HudUtils.get(name); @@ -215,7 +215,7 @@ public void sendMusic(String data) { try { for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { String server = player.getServer() == null ? null : player.getServer().getInfo().getName(); - if (AllMusic.isOK(player.getName(), server, false)) + if (AllMusic.isSkip(player.getName(), server, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getName()); @@ -233,7 +233,7 @@ protected void topSendMusic(String player, String data) { if (player1 == null) return; String server = player1.getServer() == null ? null : player1.getServer().getInfo().getName(); - if (AllMusic.isOK(player1.getName(), server, false)) + if (AllMusic.isSkip(player1.getName(), server, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } catch (Exception e) { @@ -249,7 +249,7 @@ public void sendHudPos(String player) { if (player1 == null) return; String server = player1.getServer() == null ? null : player1.getServer().getInfo().getName(); - if (AllMusic.isOK(player1.getName(), server, false)) + if (AllMusic.isSkip(player1.getName(), server, false)) return; SaveObj obj = HudUtils.get(player); @@ -270,7 +270,7 @@ public void sendHud(String name, HudType pos, String data) { ProxiedPlayer player1 = ProxyServer.getInstance().getPlayer(name); if (player1 == null) return; - if (ok(player1)) + if (skip(player1)) return; switch (pos) { @@ -294,7 +294,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendPic(String data) { try { for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { - if (ok(player)) + if (skip(player)) continue; String name = player.getName(); SaveObj obj = HudUtils.get(name); @@ -314,7 +314,7 @@ public void sendPic(String player, String data) { ProxiedPlayer player1 = ProxyServer.getInstance().getPlayer(player); if (player1 == null) return; - if (ok(player1)) + if (skip(player1)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } catch (Exception e) { @@ -329,7 +329,7 @@ public void sendPos(String player, int pos) { ProxiedPlayer player1 = ProxyServer.getInstance().getPlayer(player); if (player1 == null) return; - if (ok(player1)) + if (skip(player1)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } catch (Exception e) { @@ -393,7 +393,7 @@ public void clearHud() { public void topBq(String data) { TextComponent message = new TextComponent(data); for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { - if (ok(player)) + if (skip(player)) continue; player.sendMessage(message); } @@ -406,7 +406,7 @@ public void bqRun(String message, String end, String command) { endtext.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)); send.addExtra(endtext); for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { - if (ok(player)) + if (skip(player)) continue; player.sendMessage(send); } @@ -414,15 +414,13 @@ public void bqRun(String message, String end, String command) { @Override public boolean needPlay() { - int online = 0; - for (ServerInfo server : ProxyServer.getInstance().getServers().values()) { - if (AllMusic.getConfig().muteServer.contains(server.getName())) - continue; - for (ProxiedPlayer player : server.getPlayers()) - if (!AllMusic.getConfig().mutePlayer.contains(player.getName())) - online++; + for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { + if (!skip(player)) { + return true; + } } - return online > 0; + + return false; } @Override @@ -563,9 +561,9 @@ private void send(ProxiedPlayer players, ByteBuf data) { } } - private boolean ok(ProxiedPlayer player) { + private boolean skip(ProxiedPlayer player) { String server = player.getServer() == null ? null : player.getServer().getInfo().getName(); - return AllMusic.isOK(player.getName(), server, true); + return AllMusic.isSkip(player.getName(), server, true); } @Override diff --git a/server_top/src/main/java/com/coloryr/allmusic/server/side/velocity/ListenerVelocity.java b/server_top/src/main/java/com/coloryr/allmusic/server/side/velocity/ListenerVelocity.java index ecd78569..8760efe3 100644 --- a/server_top/src/main/java/com/coloryr/allmusic/server/side/velocity/ListenerVelocity.java +++ b/server_top/src/main/java/com/coloryr/allmusic/server/side/velocity/ListenerVelocity.java @@ -17,21 +17,6 @@ public void onDisconnectEvent(final DisconnectEvent event) { AllMusic.removeNowPlayPlayer(event.getPlayer().getUsername()); } - @Subscribe - public void onPostLoginEvent(final PostLoginEvent event) { - AllMusic.pauseSend(event.getPlayer().getUsername()); - } - - @Subscribe - public void onKickedFromServerEvent(KickedFromServerEvent event) { - AllMusic.pauseSend(event.getPlayer().getUsername()); - } - - @Subscribe - public void onServerPreConnectEvent(ServerPreConnectEvent event) { - AllMusic.pauseSend(event.getPlayer().getUsername()); - } - @Subscribe public void onServerPostConnectEvent(ServerPostConnectEvent event) { AllMusic.side.runTask(() -> { diff --git a/server_top/src/main/java/com/coloryr/allmusic/server/side/velocity/SideVelocity.java b/server_top/src/main/java/com/coloryr/allmusic/server/side/velocity/SideVelocity.java index d5dfa617..6b34ced4 100644 --- a/server_top/src/main/java/com/coloryr/allmusic/server/side/velocity/SideVelocity.java +++ b/server_top/src/main/java/com/coloryr/allmusic/server/side/velocity/SideVelocity.java @@ -19,7 +19,6 @@ import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ServerConnection; -import com.velocitypowered.api.proxy.server.RegisteredServer; import io.netty.buffer.ByteBuf; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; @@ -139,12 +138,12 @@ public int getPlayerSize() { @Override public void topBq(String data) { Component message = Component.text(data); - for (RegisteredServer server : AllMusicVelocity.plugin.server.getAllServers()) { - if (AllMusic.getConfig().muteServer.contains(server.getServerInfo().getName())) + for (Player player : AllMusicVelocity.plugin.server.getAllPlayers()) { + if (skip(player)) { continue; - for (Player player : server.getPlayersConnected()) - if (!AllMusic.getConfig().mutePlayer.contains(player.getUsername())) - player.sendMessage(message); + } + + player.sendMessage(message); } } @@ -153,33 +152,24 @@ public void bqRun(String message, String end, String command) { TextComponent endtext = Component.text(end) .clickEvent(ClickEvent.runCommand(command)); TextComponent send = Component.text(message).append(endtext); - for (RegisteredServer server : AllMusicVelocity.plugin.server.getAllServers()) { - if (AllMusic.getConfig().muteServer.contains(server.getServerInfo().getName())) + for (Player player : AllMusicVelocity.plugin.server.getAllPlayers()) { + if (skip(player)) { continue; - for (Player player : server.getPlayersConnected()) - if (!AllMusic.getConfig().mutePlayer.contains(player.getUsername())) - player.sendMessage(send); + } + + player.sendMessage(send); } } @Override public boolean needPlay() { - int online = 0; for (Player player : AllMusicVelocity.plugin.server.getAllPlayers()) { - if (player.getCurrentServer().isPresent()) { - continue; + if (!skip(player)) { + return true; } - if (!AllMusic.getConfig().mutePlayer.contains(player.getUsername())) - online++; - } - for (RegisteredServer server : AllMusicVelocity.plugin.server.getAllServers()) { - if (AllMusic.getConfig().muteServer.contains(server.getServerInfo().getName())) - continue; - for (Player player : server.getPlayersConnected()) - if (!AllMusic.getConfig().mutePlayer.contains(player.getUsername())) - online++; } - return online > 0; + + return false; } @Override @@ -213,7 +203,7 @@ public void sendMusic(String data) { for (Player player : AllMusicVelocity.plugin.server.getAllPlayers()) { String server = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : null; - if (AllMusic.isOK(player.getUsername(), server, false)) + if (AllMusic.isSkip(player.getUsername(), server, false)) continue; send(player, PacketCodec.pack(ComType.PLAY, data, 0)); AllMusic.addNowPlayPlayer(player.getUsername()); @@ -231,7 +221,7 @@ protected void topSendMusic(String player, String data) { Player player1 = AllMusicVelocity.plugin.server.getPlayer(player).get(); String server = player1.getCurrentServer().isPresent() ? player1.getCurrentServer().get().getServerInfo().getName() : null; - if (AllMusic.isOK(player1.getUsername(), server, false)) + if (AllMusic.isSkip(player1.getUsername(), server, false)) return; send(player1, PacketCodec.pack(ComType.PLAY, data, 0)); } @@ -245,7 +235,7 @@ protected void topSendMusic(String player, String data) { public void sendPic(String data) { try { for (Player player : AllMusicVelocity.plugin.server.getAllPlayers()) { - if (ok(player)) + if (skip(player)) continue; String name = player.getUsername(); SaveObj obj = HudUtils.get(name); @@ -264,7 +254,7 @@ public void sendPic(String player, String data) { try { if (AllMusicVelocity.plugin.server.getPlayer(player).isPresent()) { Player player1 = AllMusicVelocity.plugin.server.getPlayer(player).get(); - if (ok(player1)) + if (skip(player1)) return; send(player1, PacketCodec.pack(ComType.IMG, data, 0)); } @@ -279,7 +269,7 @@ public void sendPos(String player, int pos) { try { if (AllMusicVelocity.plugin.server.getPlayer(player).isPresent()) { Player player1 = AllMusicVelocity.plugin.server.getPlayer(player).get(); - if (ok(player1)) + if (skip(player1)) return; send(player1, PacketCodec.pack(ComType.POS, null, pos)); } @@ -293,7 +283,7 @@ public void sendPos(String player, int pos) { public void sendHudLyric(String data) { try { for (Player player : AllMusicVelocity.plugin.server.getAllPlayers()) { - if (ok(player)) + if (skip(player)) continue; SaveObj obj = HudUtils.get(player.getUsername()); if (!obj.lyric.enable) @@ -310,7 +300,7 @@ public void sendHudLyric(String data) { public void sendHudInfo(String data) { try { for (Player player : AllMusicVelocity.plugin.server.getAllPlayers()) { - if (ok(player)) + if (skip(player)) continue; SaveObj obj = HudUtils.get(player.getUsername()); if (!obj.info.enable) @@ -348,7 +338,7 @@ public void sendHud(String name, HudType pos, String data) { if (!player.isPresent()) return; - if (ok(player.get())) + if (skip(player.get())) return; switch (pos) { @@ -372,7 +362,7 @@ public void sendHud(String name, HudType pos, String data) { public void sendHudList(String data) { try { for (Player player : AllMusicVelocity.plugin.server.getAllPlayers()) { - if (ok(player)) + if (skip(player)) continue; String name = player.getUsername(); SaveObj obj = HudUtils.get(name); @@ -405,7 +395,7 @@ public void sendBar(String data) { Component message = Component.text(data); for (Player player : AllMusicVelocity.plugin.server.getAllPlayers()) { try { - if (ok(player)) + if (skip(player)) continue; player.sendActionBar(message); } catch (Exception e1) { @@ -478,10 +468,8 @@ public void reload() { @Override public boolean checkPermission(String player, String permission) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + if (checkPermission(player)) { + return true; } Optional player1 = AllMusicVelocity.plugin.server.getPlayer(player); return player1.map(value -> value.hasPermission(permission)).orElse(false); @@ -571,10 +559,13 @@ private void send(Player players, ByteBuf data) { } } - private boolean ok(Player player) { - String server = player.getCurrentServer().isPresent() ? - player.getCurrentServer().get().getServerInfo().getName() : null; - return AllMusic.isOK(player.getUsername(), server, true); + private boolean skip(Player player) { + String server = null; + if (player.getCurrentServer().isPresent()) { + server = player.getCurrentServer().get().getServerInfo().getName(); + } + + return AllMusic.isSkip(player.getUsername(), server, true); } @Override