diff --git a/src/main/java/de/shiewk/smoderation/command/BanCommand.java b/src/main/java/de/shiewk/smoderation/command/BanCommand.java index 221038a..8f248a1 100644 --- a/src/main/java/de/shiewk/smoderation/command/BanCommand.java +++ b/src/main/java/de/shiewk/smoderation/command/BanCommand.java @@ -17,6 +17,8 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import static net.kyori.adventure.text.Component.text; + public class BanCommand implements TabExecutor { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { @@ -45,6 +47,11 @@ public class BanCommand implements TabExecutor { sender.sendMessage(Component.text("This player is either offline or was never on this server.").color(NamedTextColor.RED)); return true; } + final Player toPlayer = Bukkit.getPlayer(uuid); + if (toPlayer != null && toPlayer.hasPermission("smod.preventban")){ + sender.sendMessage(text().content("This player can't be banned.").color(NamedTextColor.RED)); + return true; + } long duration = 0; int p = 1; for (int i = 1 /* start with index 1 to avoid player name */; i < args.length; i++) { diff --git a/src/main/java/de/shiewk/smoderation/command/KickCommand.java b/src/main/java/de/shiewk/smoderation/command/KickCommand.java index f645cf4..43a1b34 100644 --- a/src/main/java/de/shiewk/smoderation/command/KickCommand.java +++ b/src/main/java/de/shiewk/smoderation/command/KickCommand.java @@ -16,6 +16,8 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import static net.kyori.adventure.text.Component.text; + public class KickCommand implements TabExecutor { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { @@ -45,6 +47,10 @@ public class KickCommand implements TabExecutor { sender.sendMessage(Component.text("You can't kick yourself.").color(NamedTextColor.RED)); return true; } + if (player.hasPermission("smod.preventkick")){ + sender.sendMessage(text().content("This player can't be kicked.").color(NamedTextColor.RED)); + return true; + } StringBuilder reason = new StringBuilder(); for (int i = 1; i < args.length; i++) { if (!reason.isEmpty()){ diff --git a/src/main/java/de/shiewk/smoderation/command/MuteCommand.java b/src/main/java/de/shiewk/smoderation/command/MuteCommand.java index c9ff39a..29ec028 100644 --- a/src/main/java/de/shiewk/smoderation/command/MuteCommand.java +++ b/src/main/java/de/shiewk/smoderation/command/MuteCommand.java @@ -4,7 +4,6 @@ import de.shiewk.smoderation.SModeration; import de.shiewk.smoderation.punishments.Punishment; import de.shiewk.smoderation.util.PlayerUtil; import de.shiewk.smoderation.util.TimeUtil; -import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; import org.bukkit.command.*; @@ -17,6 +16,8 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import static net.kyori.adventure.text.Component.text; + public class MuteCommand implements TabExecutor { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { @@ -29,20 +30,25 @@ public class MuteCommand implements TabExecutor { } else if (sender instanceof Player pl){ senderUUID = pl.getUniqueId(); } else if (sender instanceof BlockCommandSender){ - sender.sendMessage(Component.text("Blocks can't execute this command.").color(NamedTextColor.RED)); + sender.sendMessage(text("Blocks can't execute this command.").color(NamedTextColor.RED)); return true; } else { - sender.sendMessage(Component.text("Your command sender type is unknown (%s).".formatted(sender.getClass().getName())).color(NamedTextColor.RED)); + sender.sendMessage(text("Your command sender type is unknown (%s).".formatted(sender.getClass().getName())).color(NamedTextColor.RED)); return true; } String playerName = args[0]; UUID uuid = PlayerUtil.offlinePlayerUUIDByName(playerName); if (senderUUID.equals(uuid)) { - sender.sendMessage(Component.text("You can't mute yourself.").color(NamedTextColor.RED)); + sender.sendMessage(text("You can't mute yourself.").color(NamedTextColor.RED)); return true; } if (uuid == null) { - sender.sendMessage(Component.text("This player is either offline or was never on this server.").color(NamedTextColor.RED)); + sender.sendMessage(text("This player is either offline or was never on this server.").color(NamedTextColor.RED)); + return true; + } + final Player toPlayer = Bukkit.getPlayer(uuid); + if (toPlayer != null && toPlayer.hasPermission("smod.preventmute")){ + sender.sendMessage(text().content("This player can't be muted.").color(NamedTextColor.RED)); return true; } long duration = 0; @@ -59,11 +65,11 @@ public class MuteCommand implements TabExecutor { if (i == args.length - 1){ p = args.length; } } if (duration == 0){ - sender.sendMessage(Component.text("Please provide a valid duration.").color(NamedTextColor.RED)); + sender.sendMessage(text("Please provide a valid duration.").color(NamedTextColor.RED)); return false; } if (duration < 0){ - sender.sendMessage(Component.text("Please provide a duration that's longer than 0ms.").color(NamedTextColor.RED)); + sender.sendMessage(text("Please provide a duration that's longer than 0ms.").color(NamedTextColor.RED)); return false; } StringBuilder reason = new StringBuilder(); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 1dd8336..7f51e9c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -116,4 +116,13 @@ permissions: default: op description: Allows the player to view and modify other players ender chests. children: - - smod.enderchestsee \ No newline at end of file + - smod.enderchestsee + smod.preventmute: + default: op + description: Prevents the player from being muted (if online) + smod.preventkick: + default: op + description: Prevents the player from being muted (if online) + smod.preventban: + default: op + description: Prevents the player from being muted (if online) \ No newline at end of file