diff --git a/core/AllMusic.java b/core/AllMusic.java index 7a553314..8d269b1d 100644 --- a/core/AllMusic.java +++ b/core/AllMusic.java @@ -36,7 +36,7 @@ public class AllMusic { /** * 插件版本号 */ - public static final String version = "3.3.0"; + public static final String version = "3.3.1"; /** * 配置文件版本号 */ diff --git a/core/command/CommandEX.java b/core/command/CommandEX.java index 3943dc07..995eb018 100644 --- a/core/command/CommandEX.java +++ b/core/command/CommandEX.java @@ -206,6 +206,16 @@ else if (args[0].contains("&user")) AllMusic.side.sendMessage(sender, AllMusic.getMessage().addMusic.noID); } + private static boolean isAdmin(String name) + { + for (String item : AllMusic.getConfig().adminList) { + if (item.equalsIgnoreCase(name)) { + return true; + } + } + return false; + } + /** * 执行命令 * @@ -224,7 +234,7 @@ public static void ex(Object sender, String name, String[] args) { return; } - if (AllMusic.side.checkPermission(name)) { + if (isAdmin(name) || AllMusic.side.checkPermission(sender)) { command = commandAdminList.get(args[0]); if (command != null) { command.ex(sender, name, args); @@ -232,7 +242,7 @@ public static void ex(Object sender, String name, String[] args) { } } if (AllMusic.getConfig().needPermission && - !AllMusic.side.checkPermission(name, "allmusic.addmusic")) + !AllMusic.side.checkPermission(sender, "allmusic.addmusic")) AllMusic.side.sendMessage(sender, AllMusic.getMessage().command.noPer); else { switch (AllMusic.getConfig().defaultAddMusic) { diff --git a/core/objs/config/ConfigObj.java b/core/objs/config/ConfigObj.java index 1ab28404..d5012182 100644 --- a/core/objs/config/ConfigObj.java +++ b/core/objs/config/ConfigObj.java @@ -213,7 +213,6 @@ public void init() { minVote = 3; voteTime = 30; adminList = new HashSet<>(); - adminList.add("console"); adminList.add("color_yr"); muteServer = new HashSet<>(); mutePlayer = new HashSet<>(); diff --git a/core/side/BaseSide.java b/core/side/BaseSide.java index 24fac6f0..85c180be 100644 --- a/core/side/BaseSide.java +++ b/core/side/BaseSide.java @@ -39,19 +39,19 @@ public abstract class BaseSide { /** * 检查权限 * - * @param player 用户名 + * @param player 用户 * @return 是否有权限 */ - public abstract boolean checkPermission(String player); + public abstract boolean checkPermission(Object player); /** * 检查权限 * - * @param player 用户名 + * @param player 用户 * @param permission 权限 * @return 是否有权限 */ - public abstract boolean checkPermission(String player, String permission); + public abstract boolean checkPermission(Object player, String permission); /** * 是否需要播放 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 fa86492f..8e5b64a8 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 @@ -16,7 +16,9 @@ import com.coloryr.allmusic.server.side.fabric.event.MusicPlayEvent; import io.netty.buffer.ByteBuf; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.entity.Entity; import net.minecraft.network.PacketByteBuf; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandOutput; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -54,21 +56,18 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - ServerPlayerEntity player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); - if (player1 == null) - return false; - - return player1.hasPermissionLevel(2); + if (player instanceof Entity) { + return ((Entity) player).hasPermissionLevel(2); + } + return false; } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } 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 ae923565..a0fc3670 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 @@ -16,7 +16,9 @@ import com.coloryr.allmusic.server.side.fabric.event.MusicPlayEvent; import io.netty.buffer.ByteBuf; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.entity.Entity; import net.minecraft.network.PacketByteBuf; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandOutput; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -54,21 +56,18 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - ServerPlayerEntity player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); - if (player1 == null) - return false; - - return player1.hasPermissionLevel(2); + if (player instanceof Entity) { + return ((Entity) player).hasPermissionLevel(2); + } + return false; } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } 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 8dad7ce8..776669ea 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 @@ -17,7 +17,9 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.entity.Entity; import net.minecraft.network.PacketByteBuf; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandOutput; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -55,21 +57,18 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); - if (player1 == null) - return false; - - return player1.hasPermissionLevel(2); + if (player instanceof Entity) { + return ((Entity) player).hasPermissionLevel(2); + } + return false; } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } 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 ec8f4371..1ef546e7 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 @@ -16,7 +16,9 @@ import com.coloryr.allmusic.server.side.fabric.event.MusicPlayEvent; import io.netty.buffer.ByteBuf; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.entity.Entity; import net.minecraft.network.PacketByteBuf; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandOutput; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -53,21 +55,18 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); - if (player1 == null) - return false; - - return player1.hasPermissionLevel(2); + if (player instanceof Entity) { + return ((Entity) player).hasPermissionLevel(2); + } + return false; } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } 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 ec8f4371..1ef546e7 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 @@ -16,7 +16,9 @@ import com.coloryr.allmusic.server.side.fabric.event.MusicPlayEvent; import io.netty.buffer.ByteBuf; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.entity.Entity; import net.minecraft.network.PacketByteBuf; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandOutput; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -53,21 +55,18 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); - if (player1 == null) - return false; - - return player1.hasPermissionLevel(2); + if (player instanceof Entity) { + return ((Entity) player).hasPermissionLevel(2); + } + return false; } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } diff --git a/fabric_1_20_2/build.gradle b/fabric_1_20_2/build.gradle index cac2939f..144eb2bf 100644 --- a/fabric_1_20_2/build.gradle +++ b/fabric_1_20_2/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.6-SNAPSHOT' + id 'fabric-loom' version '1.8-SNAPSHOT' id 'maven-publish' id "org.jetbrains.kotlin.jvm" version "1.9.23" } diff --git a/fabric_1_20_2/gradle/wrapper/gradle-wrapper.properties b/fabric_1_20_2/gradle/wrapper/gradle-wrapper.properties index b82aa23a..94113f20 100644 --- a/fabric_1_20_2/gradle/wrapper/gradle-wrapper.properties +++ b/fabric_1_20_2/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME 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 86563bc2..a2d96a54 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 @@ -17,7 +17,9 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.PacketByteBuf; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandOutput; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -55,21 +57,18 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); - if (player1 == null) - return false; - - return player1.hasPermissionLevel(2); + if (player instanceof PlayerEntity) { + return ((PlayerEntity) player).hasPermissionLevel(2); + } + return false; } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } diff --git a/fabric_1_20_6/build.gradle b/fabric_1_20_6/build.gradle index cac2939f..144eb2bf 100644 --- a/fabric_1_20_6/build.gradle +++ b/fabric_1_20_6/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.6-SNAPSHOT' + id 'fabric-loom' version '1.8-SNAPSHOT' id 'maven-publish' id "org.jetbrains.kotlin.jvm" version "1.9.23" } diff --git a/fabric_1_20_6/gradle/wrapper/gradle-wrapper.properties b/fabric_1_20_6/gradle/wrapper/gradle-wrapper.properties index b82aa23a..94113f20 100644 --- a/fabric_1_20_6/gradle/wrapper/gradle-wrapper.properties +++ b/fabric_1_20_6/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME 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 5fc1abc8..53a94ed7 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 @@ -15,6 +15,8 @@ import com.coloryr.allmusic.server.side.fabric.event.MusicAddEvent; import com.coloryr.allmusic.server.side.fabric.event.MusicPlayEvent; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandOutput; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -51,21 +53,18 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); - if (player1 == null) - return false; - - return player1.hasPermissionLevel(2); + if (player instanceof PlayerEntity) { + return ((PlayerEntity) player).hasPermissionLevel(2); + } + return false; } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } diff --git a/fabric_1_21/build.gradle b/fabric_1_21/build.gradle index c61eeb46..b383af70 100644 --- a/fabric_1_21/build.gradle +++ b/fabric_1_21/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.6-SNAPSHOT' + id 'fabric-loom' version '1.8-SNAPSHOT' id 'maven-publish' id "org.jetbrains.kotlin.jvm" version "2.0.0" } diff --git a/fabric_1_21/gradle/wrapper/gradle-wrapper.properties b/fabric_1_21/gradle/wrapper/gradle-wrapper.properties index b82aa23a..94113f20 100644 --- a/fabric_1_21/gradle/wrapper/gradle-wrapper.properties +++ b/fabric_1_21/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME 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 7424e93d..8c28d7f1 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 @@ -16,6 +16,8 @@ import com.coloryr.allmusic.server.side.fabric.event.MusicPlayEvent; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandOutput; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -52,21 +54,18 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player); - if (player1 == null) - return false; - - return player1.hasPermissionLevel(2); + if (player instanceof PlayerEntity) { + return ((PlayerEntity) player).hasPermissionLevel(2); + } + return false; } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } diff --git a/folia/gradle/wrapper/gradle-wrapper.properties b/folia/gradle/wrapper/gradle-wrapper.properties index 1af9e093..94113f20 100644 --- a/folia/gradle/wrapper/gradle-wrapper.properties +++ b/folia/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME 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 a4dd1c96..fac33f22 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 @@ -18,7 +18,10 @@ import io.papermc.paper.threadedregions.scheduler.ScheduledTask; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; +import org.bukkit.permissions.Permissible; +import org.bukkit.permissions.ServerOperator; import java.util.List; import java.util.Locale; @@ -355,27 +358,25 @@ public void reload() { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { if (checkPermission(player)) { return true; } - Player player1 = Bukkit.getPlayer(player); - if (player1 == null) - return false; - return player1.hasPermission(permission); + if (player instanceof Permissible permissible) { + return permissible.hasPermission(permission); + } + return false; } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof ConsoleCommandSender) { + return true; + } + if (player instanceof ServerOperator player1) { + return player1.isOp(); } - Player player1 = Bukkit.getPlayer(player); - if (player1 == null) - return false; - return player1.isOp(); + return false; } @Override 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 b6e4adbc..fcac57b2 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 @@ -19,6 +19,7 @@ import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.PacketBuffer; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.TextComponentString; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; @@ -56,22 +57,20 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; + } + if (player instanceof EntityPlayerMP) { + return ((EntityPlayerMP) player).canUseCommand(2, "music"); } - EntityPlayerMP player1 = AllMusicForge.server.getPlayerList().getPlayerByUsername(player); - if (player1 == null) - return false; - return player1.canUseCommand(2, "music"); + return false; } @Override 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 290a9782..873c6f4f 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 @@ -20,6 +20,7 @@ import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.network.PacketBuffer; import net.minecraft.network.play.server.SCustomPayloadPlayPacket; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.network.PacketDistributor; @@ -57,22 +58,20 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; + } + if (player instanceof ServerPlayerEntity) { + return ((ServerPlayerEntity) player).hasPermissions(2); } - ServerPlayerEntity player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); - if (player1 == null) - return false; - return player1.hasPermissions(2); + return false; } @Override 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 c30a523d..d37496b4 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 @@ -20,6 +20,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.network.PacketDistributor; @@ -57,22 +58,19 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); - if (player1 == null) - return false; - - return player1.hasPermissions(2); + if (player instanceof ServerPlayer) { + return ((ServerPlayer) player).hasPermissions(2); + } + return false; } @Override 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 cf5f64fc..16f5cb14 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 @@ -20,6 +20,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.network.PacketDistributor; @@ -56,22 +57,19 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); - if (player1 == null) - return false; - - return player1.hasPermissions(2); + if (player instanceof ServerPlayer) { + return ((ServerPlayer) player).hasPermissions(2); + } + return false; } @Override 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 41b1798d..39e1fed5 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 @@ -20,6 +20,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.network.PacketDistributor; @@ -56,22 +57,19 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); - if (player1 == null) - return false; - - return player1.hasPermissions(2); + if (player instanceof ServerPlayer) { + return ((ServerPlayer) player).hasPermissions(2); + } + return false; } @Override diff --git a/forge_1_7_10/gradle/wrapper/gradle-wrapper.properties b/forge_1_7_10/gradle/wrapper/gradle-wrapper.properties index 7cf08140..92c1ac1b 100644 --- a/forge_1_7_10/gradle/wrapper/gradle-wrapper.properties +++ b/forge_1_7_10/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME 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 4a3a90f5..8a05210d 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 @@ -21,6 +21,7 @@ import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.PacketBuffer; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; import net.minecraftforge.common.MinecraftForge; @@ -56,22 +57,20 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; + } + if (player instanceof EntityPlayerMP) { + return ((EntityPlayerMP) player).canCommandSenderUseCommand(2, "music"); } - EntityPlayerMP player1 = AllMusicForge.server.getConfigurationManager().func_152612_a(player); - if (player1 == null) - return false; - return player1.canCommandSenderUseCommand(2, "music"); + return false; } @Override 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 21027389..6a657ef7 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 @@ -16,6 +16,7 @@ import com.google.gson.Gson; import net.minecraft.commands.CommandSource; import net.minecraft.network.chat.Component; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.network.PacketDistributor; @@ -52,22 +53,19 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); - if (player1 == null) - return false; - - return player1.hasPermissions(2); + if (player instanceof ServerPlayer) { + return ((ServerPlayer) player).hasPermissions(2); + } + return false; } @Override 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 40b38688..28a02f8f 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 @@ -16,6 +16,7 @@ import com.google.gson.Gson; import net.minecraft.commands.CommandSource; import net.minecraft.network.chat.Component; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.network.PacketDistributor; @@ -52,22 +53,19 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); - if (player1 == null) - return false; - - return player1.hasPermissions(2); + if (player instanceof ServerPlayer) { + return ((ServerPlayer) player).hasPermissions(2); + } + return false; } @Override 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 40b38688..28a02f8f 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 @@ -16,6 +16,7 @@ import com.google.gson.Gson; import net.minecraft.commands.CommandSource; import net.minecraft.network.chat.Component; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.network.PacketDistributor; @@ -52,22 +53,19 @@ public void runTask(Runnable run1, int delay) { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { return checkPermission(player); } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof MinecraftServer) { + return true; } - ServerPlayer player1 = AllMusicForge.server.getPlayerList().getPlayerByName(player); - if (player1 == null) - return false; - - return player1.hasPermissions(2); + if (player instanceof ServerPlayer) { + return ((ServerPlayer) player).hasPermissions(2); + } + return false; } @Override 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 66360e9d..68f27e85 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 @@ -15,7 +15,10 @@ import com.coloryr.allmusic.server.side.bukkit.hooks.SpigotApi; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; +import org.bukkit.permissions.Permissible; +import org.bukkit.permissions.ServerOperator; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -437,27 +440,29 @@ public void reload() { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { if (checkPermission(player)) { return true; } - Player player1 = Bukkit.getPlayer(player); - if (player1 == null) - return false; - return player1.hasPermission(permission); + if (player instanceof Permissible) { + Permissible player1 = (Permissible) player; + return player1.hasPermission(permission); + } + + return false; } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player) { + if (player instanceof ConsoleCommandSender) { + return true; + } + if (player instanceof ServerOperator) { + ServerOperator sender = (ServerOperator) player; + return sender.isOp(); } - Player player1 = Bukkit.getPlayer(player); - if (player1 == null) - return false; - return player1.isOp(); + + return false; } @Override 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 43b70016..e3e42384 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 @@ -461,27 +461,19 @@ public void reload() { } @Override - public boolean checkPermission(String player, String permission) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } + public boolean checkPermission(Object player, String permission) { + if (checkPermission(player)) { + return true; } - ProxiedPlayer player1 = ProxyServer.getInstance().getPlayer(player); - if (player1 == null) - return false; - return player1.hasPermission(permission); + if (player instanceof CommandSender) { + return ((CommandSender) player).hasPermission(permission); + } + return false; } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } - } - - return false; + public boolean checkPermission(Object player) { + return player.equals(ProxyServer.getInstance().getConsole()); } @Override 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 3ecf54d2..e8e969b5 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 @@ -17,6 +17,8 @@ import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import com.velocitypowered.api.command.CommandSource; +import com.velocitypowered.api.permission.PermissionSubject; +import com.velocitypowered.api.proxy.ConsoleCommandSource; import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.ServerConnection; import io.netty.buffer.ByteBuf; @@ -472,23 +474,19 @@ public void reload() { } @Override - public boolean checkPermission(String player, String permission) { + public boolean checkPermission(Object player, String permission) { if (checkPermission(player)) { return true; } - Optional player1 = AllMusicVelocity.plugin.server.getPlayer(player); - return player1.map(value -> value.hasPermission(permission)).orElse(false); + if (player instanceof PermissionSubject) { + return ((PermissionSubject) player).hasPermission(permission); + } + return false; } @Override - public boolean checkPermission(String player) { - for (String item : AllMusic.getConfig().adminList) { - if (item.equalsIgnoreCase(player)) { - return true; - } - } - - return false; + public boolean checkPermission(Object player) { + return player instanceof ConsoleCommandSource; } @Override diff --git a/version b/version index 0fa4ae48..712bd5a6 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.3.0 \ No newline at end of file +3.3.1 \ No newline at end of file