From d6e2287b6a611921538e21cd594d5378ee26e307 Mon Sep 17 00:00:00 2001 From: Sceptor Date: Mon, 25 Mar 2024 02:00:48 +0000 Subject: [PATCH 1/4] Reintroduced the clownfish and fixed an issue with orbit --- .../plex/extras/command/ClownfishCommand.java | 72 ++++++++++++++++ .../extras/listener/ClownfishListener.java | 83 +++++++++++++++++++ .../extras/listener/OrbitEffectListener.java | 16 ++++ src/main/resources/tfmextras/config.yml | 5 ++ 4 files changed, 176 insertions(+) create mode 100644 src/main/java/dev/plex/extras/command/ClownfishCommand.java create mode 100644 src/main/java/dev/plex/extras/listener/ClownfishListener.java diff --git a/src/main/java/dev/plex/extras/command/ClownfishCommand.java b/src/main/java/dev/plex/extras/command/ClownfishCommand.java new file mode 100644 index 0000000..3da8507 --- /dev/null +++ b/src/main/java/dev/plex/extras/command/ClownfishCommand.java @@ -0,0 +1,72 @@ +package dev.plex.extras.command; + +import dev.plex.command.PlexCommand; +import dev.plex.command.annotation.CommandParameters; +import dev.plex.command.annotation.CommandPermissions; +import dev.plex.extras.TFMExtras; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; +import org.bukkit.Material; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collections; +import java.util.List; + +@CommandParameters(name = "clownfish", description = "Gives a player a clownfish capable of knocking people back") +@CommandPermissions(permission = "plex.tfmextras.clownfish") +public class ClownfishCommand extends PlexCommand +{ + @Override + protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args) + { + if (args.length == 0) + { + ItemStack clownfish = new ItemStack(Material.TROPICAL_FISH); + ItemMeta meta = clownfish.getItemMeta(); + + meta.displayName(Component.text("Clownfish")); + clownfish.setItemMeta(meta); + + player.getInventory().addItem(clownfish); + return MiniMessage.miniMessage().deserialize("blub blub... ><_>"); + } + else if (args[0].equals("toggle")) + { + List toggledPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.toggled_players"); + boolean isToggled = toggledPlayers.contains(player.getName()); + + if (isToggled) + { + toggledPlayers.remove(player.getName()); + } + else + { + toggledPlayers.add(player.getName()); + } + + TFMExtras.getModule().getConfig().set("server.clownfish.toggled_players", toggledPlayers); + TFMExtras.getModule().getConfig().save(); + + return MiniMessage.miniMessage().deserialize("You " + (isToggled ? "will" : "will no longer") + " be affected by the clownfish"); + } + else + { + return MiniMessage.miniMessage().deserialize("Incorrect usage. Use either /clownfish or /clownfish toggle"); + } + } + + @Override + public @NotNull List smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { + if (args.length == 1) + { + return List.of("toggle"); + } + + return Collections.emptyList(); + } +} diff --git a/src/main/java/dev/plex/extras/listener/ClownfishListener.java b/src/main/java/dev/plex/extras/listener/ClownfishListener.java new file mode 100644 index 0000000..f67baf9 --- /dev/null +++ b/src/main/java/dev/plex/extras/listener/ClownfishListener.java @@ -0,0 +1,83 @@ +package dev.plex.extras.listener; + +import dev.plex.extras.TFMExtras; +import dev.plex.listener.PlexListener; +import net.kyori.adventure.text.Component; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.SoundCategory; +import org.bukkit.Particle; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class ClownfishListener extends PlexListener +{ + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!player.hasPermission("plex.tfmextras.clownfish")) + { + return; + } + + if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) + { + ItemStack item = player.getInventory().getItemInMainHand(); + + if (item.getType() == Material.TROPICAL_FISH && item.hasItemMeta()) + { + ItemMeta meta = item.getItemMeta(); + + if (meta.hasDisplayName() && Objects.equals(meta.displayName(), Component.text("Clownfish"))) + { + double radius = TFMExtras.getModule().getConfig().getInt("server.clownfish.radius"); + double strength = TFMExtras.getModule().getConfig().getInt("server.clownfish.strength"); + + List pushedPlayers = new ArrayList<>(); + final Vector senderPos = player.getLocation().toVector(); + final List players = player.getWorld().getPlayers(); + final List toggledPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.toggled_players"); + + for (final Player target : players) + { + if (target.equals(player) || toggledPlayers.contains(target.getName())) + { + continue; + } + + final Location targetPos = target.getLocation(); + final Vector targetPosVec = targetPos.toVector(); + + if (targetPosVec.distanceSquared(senderPos) < (radius * radius)) + { + target.playSound(target.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, SoundCategory.PLAYERS, 1.0f, 1.0f); + target.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation(), 1); + target.setVelocity(targetPosVec.subtract(senderPos).normalize().multiply(strength)); + + pushedPlayers.add(target.getName()); + } + } + + if (!pushedPlayers.isEmpty()) + { + player.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, SoundCategory.PLAYERS, 1.0f, 1.0f); + } + } + } + } + } +} diff --git a/src/main/java/dev/plex/extras/listener/OrbitEffectListener.java b/src/main/java/dev/plex/extras/listener/OrbitEffectListener.java index 037dae9..9ba21fe 100644 --- a/src/main/java/dev/plex/extras/listener/OrbitEffectListener.java +++ b/src/main/java/dev/plex/extras/listener/OrbitEffectListener.java @@ -3,11 +3,13 @@ package dev.plex.extras.listener; import dev.plex.Plex; import dev.plex.extras.command.OrbitCommand; import org.bukkit.Bukkit; +import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import dev.plex.listener.PlexListener; import org.bukkit.event.entity.EntityPotionEffectEvent; +import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -32,4 +34,18 @@ public class OrbitEffectListener extends PlexListener } } } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) + { + Player player = event.getPlayer(); + + Bukkit.getScheduler().runTaskLater(Plex.get(), () -> + { + if (OrbitCommand.isPlayerOrbited(player.getUniqueId()) && event.getNewGameMode() != GameMode.SURVIVAL) + { + player.setGameMode(GameMode.SURVIVAL); + } + }, 2); + } } \ No newline at end of file diff --git a/src/main/resources/tfmextras/config.yml b/src/main/resources/tfmextras/config.yml index 705961d..b5223e3 100755 --- a/src/main/resources/tfmextras/config.yml +++ b/src/main/resources/tfmextras/config.yml @@ -12,5 +12,10 @@ server: teleport-on-join: - "Taahh" allow-unsafe-enchantments: true + clownfish: + radius: 5 + strength: 2.5 + toggled_players: + - "shdwo" player-worlds: size: 500 \ No newline at end of file From 7e40a9ebd7cdbeeb24541820b368650eaefacc46 Mon Sep 17 00:00:00 2001 From: Sceptor Date: Mon, 25 Mar 2024 18:52:51 +0000 Subject: [PATCH 2/4] Implemented changes mentioned in PR --- src/main/java/dev/plex/extras/TFMExtras.java | 4 +- .../plex/extras/command/ClownfishCommand.java | 12 ++-- .../command/RestrictClownfishCommand.java | 62 +++++++++++++++++++ .../extras/listener/ClownfishListener.java | 35 +++++++++-- src/main/resources/tfmextras/config.yml | 4 +- 5 files changed, 104 insertions(+), 13 deletions(-) create mode 100644 src/main/java/dev/plex/extras/command/RestrictClownfishCommand.java diff --git a/src/main/java/dev/plex/extras/TFMExtras.java b/src/main/java/dev/plex/extras/TFMExtras.java index b49c867..b288ed0 100755 --- a/src/main/java/dev/plex/extras/TFMExtras.java +++ b/src/main/java/dev/plex/extras/TFMExtras.java @@ -93,9 +93,11 @@ public class TFMExtras extends PlexModule } }); - addDefaultMessage("playerOrbited", "{0} - Orbiting {1}", "0 - The command sender, 1 - The person being orbited"); + addDefaultMessage("playerOrbited", "{0} - Orbiting {1}", "0 - The command sender", "1 - The person being orbited"); addDefaultMessage("stoppedOrbiting", "No longer orbiting {0}", "0 - The person no longer being orbited"); addDefaultMessage("alreadyOrbited", "{0} is already being orbited!", "0 - The person that is already orbited"); + addDefaultMessage("restrictClownfish", "{0} will {1} be able to use the clownfish.", "0 - The player who will be restricted", "1 - Whether they had this option toggled (returns: 'no longer', 'now')"); + addDefaultMessage("toggleClownfish", "You will {0} be affected by the clownfish.", "0 - Whether they had this option toggled (returns: 'no longer', 'now')"); addDefaultMessage("emptyAdminInfo", "The admin information section of the config.yml file has not been configured."); addDefaultMessage("cakeLyrics", "But there's no sense crying over every mistake. You just keep on trying till you run out of cake."); addDefaultMessage("areaEffectCloudClear", "{0} - Removing all area effect clouds", "0 - The command sender"); diff --git a/src/main/java/dev/plex/extras/command/ClownfishCommand.java b/src/main/java/dev/plex/extras/command/ClownfishCommand.java index 3da8507..ae8eaf8 100644 --- a/src/main/java/dev/plex/extras/command/ClownfishCommand.java +++ b/src/main/java/dev/plex/extras/command/ClownfishCommand.java @@ -17,7 +17,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; -@CommandParameters(name = "clownfish", description = "Gives a player a clownfish capable of knocking people back") +@CommandParameters(name = "clownfish", description = "Gives a player a clownfish capable of knocking people back", usage = "/ []") @CommandPermissions(permission = "plex.tfmextras.clownfish") public class ClownfishCommand extends PlexCommand { @@ -38,25 +38,25 @@ public class ClownfishCommand extends PlexCommand else if (args[0].equals("toggle")) { List toggledPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.toggled_players"); - boolean isToggled = toggledPlayers.contains(player.getName()); + boolean isToggled = toggledPlayers.contains(player.getUniqueId().toString()); if (isToggled) { - toggledPlayers.remove(player.getName()); + toggledPlayers.remove(player.getUniqueId().toString()); } else { - toggledPlayers.add(player.getName()); + toggledPlayers.add(player.getUniqueId().toString()); } TFMExtras.getModule().getConfig().set("server.clownfish.toggled_players", toggledPlayers); TFMExtras.getModule().getConfig().save(); - return MiniMessage.miniMessage().deserialize("You " + (isToggled ? "will" : "will no longer") + " be affected by the clownfish"); + return messageComponent("toggleClownfish", isToggled ? "now" : "no longer"); } else { - return MiniMessage.miniMessage().deserialize("Incorrect usage. Use either /clownfish or /clownfish toggle"); + return usage(); } } diff --git a/src/main/java/dev/plex/extras/command/RestrictClownfishCommand.java b/src/main/java/dev/plex/extras/command/RestrictClownfishCommand.java new file mode 100644 index 0000000..c8c574b --- /dev/null +++ b/src/main/java/dev/plex/extras/command/RestrictClownfishCommand.java @@ -0,0 +1,62 @@ +package dev.plex.extras.command; + +import com.google.common.collect.ImmutableList; +import dev.plex.cache.DataUtils; +import dev.plex.command.PlexCommand; +import dev.plex.command.annotation.CommandParameters; +import dev.plex.command.annotation.CommandPermissions; +import dev.plex.command.exception.PlayerNotFoundException; +import dev.plex.extras.TFMExtras; +import dev.plex.player.PlexPlayer; +import dev.plex.util.PlexUtils; + +import net.kyori.adventure.text.Component; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +@CommandParameters(name = "toggleclownfish", description = "Toggles the ability to use the clownfish for a specified player", usage = "/ ") +@CommandPermissions(permission = "plex.tfmextras.toggleclownfish") +public class RestrictClownfishCommand extends PlexCommand +{ + @Override + protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args) + { + if (args.length == 0) + { + return usage(); + } + + PlexPlayer target = DataUtils.getPlayer(args[0]); + if (target == null) + { + throw new PlayerNotFoundException(); + } + + List restrictedPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.restricted"); + + boolean isRestricted = restrictedPlayers.contains(target.getUuid().toString()); + if (isRestricted) + { + restrictedPlayers.remove(target.getUuid().toString()); + } + else + { + restrictedPlayers.add(target.getUuid().toString()); + } + + TFMExtras.getModule().getConfig().set("server.clownfish.restricted", restrictedPlayers); + TFMExtras.getModule().getConfig().save(); + + return messageComponent("restrictClownfish", target.getName(), isRestricted ? "now" : "no longer"); + } + + @Override + public @NotNull List smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { + return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of(); + } +} diff --git a/src/main/java/dev/plex/extras/listener/ClownfishListener.java b/src/main/java/dev/plex/extras/listener/ClownfishListener.java index f67baf9..09e2765 100644 --- a/src/main/java/dev/plex/extras/listener/ClownfishListener.java +++ b/src/main/java/dev/plex/extras/listener/ClownfishListener.java @@ -4,10 +4,10 @@ import dev.plex.extras.TFMExtras; import dev.plex.listener.PlexListener; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.SoundCategory; import org.bukkit.Particle; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -20,6 +20,7 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Random; public class ClownfishListener extends PlexListener { @@ -44,6 +45,13 @@ public class ClownfishListener extends PlexListener if (meta.hasDisplayName() && Objects.equals(meta.displayName(), Component.text("Clownfish"))) { + final List restrictedPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.restricted"); + if (restrictedPlayers.contains(player.getUniqueId().toString())) + { + player.sendMessage(MiniMessage.miniMessage().deserialize("You have been restricted from using the clownfish")); + return; + } + double radius = TFMExtras.getModule().getConfig().getInt("server.clownfish.radius"); double strength = TFMExtras.getModule().getConfig().getInt("server.clownfish.strength"); @@ -54,7 +62,7 @@ public class ClownfishListener extends PlexListener for (final Player target : players) { - if (target.equals(player) || toggledPlayers.contains(target.getName())) + if (target.equals(player) || toggledPlayers.contains(target.getUniqueId().toString())) { continue; } @@ -64,8 +72,18 @@ public class ClownfishListener extends PlexListener if (targetPosVec.distanceSquared(senderPos) < (radius * radius)) { - target.playSound(target.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, SoundCategory.PLAYERS, 1.0f, 1.0f); - target.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation(), 1); + target.setFlying(false); + + final Sound[] listOfSounds = Sound.values(); + for (Sound sound : listOfSounds) + { + if (sound.toString().contains("HIT")) + { + target.playSound(target.getLocation(), sound, 100.0f, 0.5f + new Random().nextFloat() * 2.0f); + } + } + + target.getWorld().spawnParticle(Particle.CLOUD, target.getLocation(), 5); target.setVelocity(targetPosVec.subtract(senderPos).normalize().multiply(strength)); pushedPlayers.add(target.getName()); @@ -74,7 +92,14 @@ public class ClownfishListener extends PlexListener if (!pushedPlayers.isEmpty()) { - player.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, SoundCategory.PLAYERS, 1.0f, 1.0f); + final Sound[] listOfSounds = Sound.values(); + for (Sound sound : listOfSounds) + { + if (sound.toString().contains("HIT")) + { + player.playSound(player.getLocation(), sound, 100.0f, 0.5f + new Random().nextFloat() * 2.0f); + } + } } } } diff --git a/src/main/resources/tfmextras/config.yml b/src/main/resources/tfmextras/config.yml index b5223e3..d2bad6c 100755 --- a/src/main/resources/tfmextras/config.yml +++ b/src/main/resources/tfmextras/config.yml @@ -16,6 +16,8 @@ server: radius: 5 strength: 2.5 toggled_players: - - "shdwo" + - "9285ace6-7393-45c5-9420-00fc66374ff4" + restricted: + - "9285ace6-7393-45c5-9420-00fc66374ff4" player-worlds: size: 500 \ No newline at end of file From 5908c96cf4b7b457b4483aee71712ad7cc5f00cc Mon Sep 17 00:00:00 2001 From: james <75051061+notsceptor@users.noreply.github.com> Date: Wed, 27 Mar 2024 15:16:20 +0000 Subject: [PATCH 3/4] Made restrict a subcommand of /clownfish rather than a standnalone command --- .../plex/extras/command/ClownfishCommand.java | 49 +++++++++++++++ .../command/RestrictClownfishCommand.java | 62 ------------------- 2 files changed, 49 insertions(+), 62 deletions(-) delete mode 100644 src/main/java/dev/plex/extras/command/RestrictClownfishCommand.java diff --git a/src/main/java/dev/plex/extras/command/ClownfishCommand.java b/src/main/java/dev/plex/extras/command/ClownfishCommand.java index ae8eaf8..ff026db 100644 --- a/src/main/java/dev/plex/extras/command/ClownfishCommand.java +++ b/src/main/java/dev/plex/extras/command/ClownfishCommand.java @@ -1,9 +1,13 @@ package dev.plex.extras.command; +import dev.plex.cache.DataUtils; import dev.plex.command.PlexCommand; import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandPermissions; +import dev.plex.command.exception.PlayerNotFoundException; import dev.plex.extras.TFMExtras; +import dev.plex.player.PlexPlayer; +import dev.plex.util.PlexUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Material; @@ -14,6 +18,7 @@ import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -54,6 +59,38 @@ public class ClownfishCommand extends PlexCommand return messageComponent("toggleClownfish", isToggled ? "now" : "no longer"); } + else if (args[0].equals("restrict") && args.length == 2) + { + if (silentCheckPermission(commandSender, "plex.tfmextras.restrictclownfish")) + { + PlexPlayer target = DataUtils.getPlayer(args[1]); + if (target == null) + { + throw new PlayerNotFoundException(); + } + + List restrictedPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.restricted"); + + boolean isRestricted = restrictedPlayers.contains(target.getUuid().toString()); + if (isRestricted) + { + restrictedPlayers.remove(target.getUuid().toString()); + } + else + { + restrictedPlayers.add(target.getUuid().toString()); + } + + TFMExtras.getModule().getConfig().set("server.clownfish.restricted", restrictedPlayers); + TFMExtras.getModule().getConfig().save(); + + return messageComponent("restrictClownfish", target.getName(), isRestricted ? "now" : "no longer"); + } + else + { + return MiniMessage.miniMessage().deserialize("You do not have permission to use this command."); + } + } else { return usage(); @@ -62,6 +99,18 @@ public class ClownfishCommand extends PlexCommand @Override public @NotNull List smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { + if (silentCheckPermission(sender, "plex.tfmextras.restrictclownfish")) + { + if (args.length == 1) + { + return Arrays.asList("toggle", "restrict"); + } + else if (args.length == 2 && args[0].equals("restrict")) + { + return PlexUtils.getPlayerNameList(); + } + } + if (args.length == 1) { return List.of("toggle"); diff --git a/src/main/java/dev/plex/extras/command/RestrictClownfishCommand.java b/src/main/java/dev/plex/extras/command/RestrictClownfishCommand.java deleted file mode 100644 index c8c574b..0000000 --- a/src/main/java/dev/plex/extras/command/RestrictClownfishCommand.java +++ /dev/null @@ -1,62 +0,0 @@ -package dev.plex.extras.command; - -import com.google.common.collect.ImmutableList; -import dev.plex.cache.DataUtils; -import dev.plex.command.PlexCommand; -import dev.plex.command.annotation.CommandParameters; -import dev.plex.command.annotation.CommandPermissions; -import dev.plex.command.exception.PlayerNotFoundException; -import dev.plex.extras.TFMExtras; -import dev.plex.player.PlexPlayer; -import dev.plex.util.PlexUtils; - -import net.kyori.adventure.text.Component; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -@CommandParameters(name = "toggleclownfish", description = "Toggles the ability to use the clownfish for a specified player", usage = "/ ") -@CommandPermissions(permission = "plex.tfmextras.toggleclownfish") -public class RestrictClownfishCommand extends PlexCommand -{ - @Override - protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args) - { - if (args.length == 0) - { - return usage(); - } - - PlexPlayer target = DataUtils.getPlayer(args[0]); - if (target == null) - { - throw new PlayerNotFoundException(); - } - - List restrictedPlayers = TFMExtras.getModule().getConfig().getStringList("server.clownfish.restricted"); - - boolean isRestricted = restrictedPlayers.contains(target.getUuid().toString()); - if (isRestricted) - { - restrictedPlayers.remove(target.getUuid().toString()); - } - else - { - restrictedPlayers.add(target.getUuid().toString()); - } - - TFMExtras.getModule().getConfig().set("server.clownfish.restricted", restrictedPlayers); - TFMExtras.getModule().getConfig().save(); - - return messageComponent("restrictClownfish", target.getName(), isRestricted ? "now" : "no longer"); - } - - @Override - public @NotNull List smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { - return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of(); - } -} From ab17e05cf725f475ef3d0833be96fff4db0d830b Mon Sep 17 00:00:00 2001 From: james <75051061+notsceptor@users.noreply.github.com> Date: Wed, 27 Mar 2024 23:30:33 +0000 Subject: [PATCH 4/4] Removed the redundant variable declaration and changed the permission name. --- .../java/dev/plex/extras/command/ClownfishCommand.java | 7 +++---- .../java/dev/plex/extras/listener/ClownfishListener.java | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/dev/plex/extras/command/ClownfishCommand.java b/src/main/java/dev/plex/extras/command/ClownfishCommand.java index ff026db..b3fe481 100644 --- a/src/main/java/dev/plex/extras/command/ClownfishCommand.java +++ b/src/main/java/dev/plex/extras/command/ClownfishCommand.java @@ -61,7 +61,7 @@ public class ClownfishCommand extends PlexCommand } else if (args[0].equals("restrict") && args.length == 2) { - if (silentCheckPermission(commandSender, "plex.tfmextras.restrictclownfish")) + if (silentCheckPermission(commandSender, "plex.tfmextras.clownfish.restrict")) { PlexPlayer target = DataUtils.getPlayer(args[1]); if (target == null) @@ -99,7 +99,7 @@ public class ClownfishCommand extends PlexCommand @Override public @NotNull List smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { - if (silentCheckPermission(sender, "plex.tfmextras.restrictclownfish")) + if (silentCheckPermission(sender, "plex.tfmextras.clownfish.restrict")) { if (args.length == 1) { @@ -110,8 +110,7 @@ public class ClownfishCommand extends PlexCommand return PlexUtils.getPlayerNameList(); } } - - if (args.length == 1) + else if (args.length == 1) { return List.of("toggle"); } diff --git a/src/main/java/dev/plex/extras/listener/ClownfishListener.java b/src/main/java/dev/plex/extras/listener/ClownfishListener.java index 09e2765..26e0940 100644 --- a/src/main/java/dev/plex/extras/listener/ClownfishListener.java +++ b/src/main/java/dev/plex/extras/listener/ClownfishListener.java @@ -74,8 +74,7 @@ public class ClownfishListener extends PlexListener { target.setFlying(false); - final Sound[] listOfSounds = Sound.values(); - for (Sound sound : listOfSounds) + for (Sound sound : Sound.values()) { if (sound.toString().contains("HIT")) { @@ -92,8 +91,7 @@ public class ClownfishListener extends PlexListener if (!pushedPlayers.isEmpty()) { - final Sound[] listOfSounds = Sound.values(); - for (Sound sound : listOfSounds) + for (Sound sound : Sound.values()) { if (sound.toString().contains("HIT")) {