From f89b08021a8b8b168e9fe100c2209390a1afe231 Mon Sep 17 00:00:00 2001 From: peaqe <118134944+devpeaqe@users.noreply.github.com> Date: Sun, 3 Nov 2024 23:30:59 +0100 Subject: [PATCH] Fixed Issue 15 (#153) * fixed issue #72 https://github.com/FancyMcPlugins/FancyHolograms/issues/72 * fixed issue #15 https://github.com/FancyMcPlugins/FancyHolograms/issues/15 * Issue #15 changed the permissions that contain a "-" with an "_" * Issue #15 Removed issue #72 from the #15 * Issue #72 cancelt the running command if the provided text is empty implemented changes to the InsertBeforeCMD.java * Issue #72 removed command lines * Issue #72 changed from "return true" to "return false" --------- Co-authored-by: peaqe --- .../de/oliver/fancyholograms/commands/HologramCMD.java | 2 +- .../fancyholograms/commands/hologram/AddLineCMD.java | 5 +++++ .../fancyholograms/commands/hologram/BackgroundCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/BillboardCMD.java | 6 ++++++ .../oliver/fancyholograms/commands/hologram/BlockCMD.java | 7 ++++++- .../oliver/fancyholograms/commands/hologram/CenterCMD.java | 6 ++++++ .../oliver/fancyholograms/commands/hologram/CopyCMD.java | 6 ++++++ .../oliver/fancyholograms/commands/hologram/CreateCMD.java | 7 ++++++- .../oliver/fancyholograms/commands/hologram/InfoCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/InsertAfterCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/InsertBeforeCMD.java | 6 ++++++ .../oliver/fancyholograms/commands/hologram/ItemCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/LinkWithNpcCMD.java | 6 ++++++ .../oliver/fancyholograms/commands/hologram/ListCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/MoveHereCMD.java | 6 ++++++ .../oliver/fancyholograms/commands/hologram/MoveToCMD.java | 5 +++++ .../oliver/fancyholograms/commands/hologram/NearbyCMD.java | 6 ++++++ .../oliver/fancyholograms/commands/hologram/RemoveCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/RemoveLineCMD.java | 6 ++++++ .../oliver/fancyholograms/commands/hologram/RotateCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/RotatePitchCMD.java | 6 ++++++ .../oliver/fancyholograms/commands/hologram/ScaleCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/SeeThroughCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/SetLineCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/ShadowRadiusCMD.java | 6 ++++++ .../commands/hologram/ShadowStrengthCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/TeleportCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/TextAlignmentCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/TextShadowCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/UnlinkWithNpcCMD.java | 6 ++++++ .../commands/hologram/UpdateTextIntervalCMD.java | 6 ++++++ .../fancyholograms/commands/hologram/VisibilityCMD.java | 6 ++++++ .../commands/hologram/VisibilityDistanceCMD.java | 6 ++++++ 33 files changed, 191 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/oliver/fancyholograms/commands/HologramCMD.java b/src/main/java/de/oliver/fancyholograms/commands/HologramCMD.java index d398f737..bf1080f6 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/HologramCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/HologramCMD.java @@ -57,7 +57,7 @@ public boolean execute(@NotNull CommandSender sender, @NotNull String label, @No if (args.length == 0 || args[0].equalsIgnoreCase("help")) { MessageHelper.info(sender, Constants.HELP_TEXT + (!PluginUtils.isFancyNpcsEnabled() ? "" : "\n" + Constants.HELP_TEXT_NPCS)); - return true; + return false; } diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/AddLineCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/AddLineCMD.java index 0892c383..4563b8d6 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/AddLineCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/AddLineCMD.java @@ -19,6 +19,11 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + if (!(player.hasPermission("fancyholograms.hologram.edit.line.add"))) { + MessageHelper.error(player, "You don't have the required permission to add a line to this hologram"); + return false; + } + if (!(hologram.getData() instanceof TextHologramData textData)) { MessageHelper.error(player, "This command can only be used on text holograms"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/BackgroundCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/BackgroundCMD.java index c4dabc91..1c3a9f5f 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/BackgroundCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/BackgroundCMD.java @@ -26,11 +26,17 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + if (!(player.hasPermission("fancyholograms.hologram.edit.background"))) { + MessageHelper.error(player, "You don't have the required permission to chnage the background of a hologram"); + return false; + } + if (!(hologram.getData() instanceof TextHologramData textData)) { MessageHelper.error(player, "This command can only be used on text holograms"); return false; } + final var color = args[3].toLowerCase(Locale.ROOT); final Color background; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/BillboardCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/BillboardCMD.java index 0246a6d2..b76762e5 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/BillboardCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/BillboardCMD.java @@ -26,6 +26,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.billboard"))) { + MessageHelper.error(player, "You don't have the required permission to change the billboard of a hologram"); + return false; + } + final var billboard = Enums.getIfPresent(Display.Billboard.class, args[3].toUpperCase(Locale.ROOT)).orNull(); if (billboard == null) { diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/BlockCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/BlockCMD.java index cb6ebaac..a26269a3 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/BlockCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/BlockCMD.java @@ -23,11 +23,16 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.block"))) { + MessageHelper.error(player, "You don't have the required permission to change the block of this hologram"); + return false; + } + if (!(hologram.getData() instanceof BlockHologramData blockData)) { MessageHelper.error(player, "This command can only be used on item holograms"); return false; } - Material block = Material.getMaterial(args[3]); if (block == null) { MessageHelper.error(player, "Could not find block type"); diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/CenterCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/CenterCMD.java index 413e3097..83f97cf2 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/CenterCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/CenterCMD.java @@ -20,6 +20,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.center"))) { + MessageHelper.error(player, "You don't have the required permission to center a hologram"); + return false; + } + Location location = hologram.getData().getLocation(); location.set( diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/CopyCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/CopyCMD.java index 56d276b7..e1e7117d 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/CopyCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/CopyCMD.java @@ -23,11 +23,17 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender sender, @Nullable Hologram hologram, @NotNull String[] args) { + if (!(sender.hasPermission("fancyholograms.hologram.copy"))) { + MessageHelper.error(sender, "You don't have the required permission to clone a hologram"); + return false; + } + if (!(sender instanceof Player player)) { MessageHelper.error(sender, "You must be a sender to use this command"); return false; } + if (args.length < 3) { MessageHelper.error(sender, "Wrong usage: /hologram help"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/CreateCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/CreateCMD.java index 917ff91e..d85ccf65 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/CreateCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/CreateCMD.java @@ -25,11 +25,16 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender sender, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(sender.hasPermission("fancyholograms.hologram.create"))) { + MessageHelper.error(sender, "You don't have the required permission to create a hologram"); + return false; + } + if (!(sender instanceof Player player)) { MessageHelper.error(sender, "You must be a sender to use this command"); return false; } - if (args.length < 3) { MessageHelper.error(player, "Wrong usage: /hologram help"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/InfoCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/InfoCMD.java index b5307ec1..d147cce8 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/InfoCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/InfoCMD.java @@ -20,6 +20,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.info"))) { + MessageHelper.error(player, "You don't have the required permission to view the info of a hologram"); + return false; + } + HologramData data = hologram.getData(); MessageHelper.info(player, "Information about the " + hologram.getData().getName() + " hologram:"); diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/InsertAfterCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/InsertAfterCMD.java index 7c70ea84..7b468434 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/InsertAfterCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/InsertAfterCMD.java @@ -24,6 +24,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.insert_after"))) { + MessageHelper.error(player, "You don't have the required permission to edit a hologram"); + return false; + } + if (!(hologram.getData() instanceof TextHologramData textData)) { MessageHelper.error(player, "This command can only be used on text holograms"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/InsertBeforeCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/InsertBeforeCMD.java index 5fb50344..2affa56d 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/InsertBeforeCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/InsertBeforeCMD.java @@ -24,6 +24,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.insert_before"))) { + MessageHelper.error(player, "You don't have the required permission to edit a hologram"); + return false; + } + if (!(hologram.getData() instanceof TextHologramData textData)) { MessageHelper.error(player, "This command can only be used on text holograms"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/ItemCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/ItemCMD.java index e836d785..3a8323b1 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/ItemCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/ItemCMD.java @@ -24,6 +24,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender sender, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(sender.hasPermission("fancyholograms.hologram.edit.item"))) { + MessageHelper.error(sender, "You don't have the required permission to edit a hologram"); + return false; + } + if (!(sender instanceof Player player)) { MessageHelper.error(sender, "You must be a sender to use this command"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/LinkWithNpcCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/LinkWithNpcCMD.java index 131160d3..284fe0d4 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/LinkWithNpcCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/LinkWithNpcCMD.java @@ -21,6 +21,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.link"))) { + MessageHelper.error(player, "You don't have the required permission to link a hologram"); + return false; + } + if (!PluginUtils.isFancyNpcsEnabled()) { MessageHelper.warning(player, "You need to install the FancyNpcs plugin for this functionality to work"); MessageHelper.warning(player, "Download link: click here."); diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/ListCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/ListCMD.java index c7da9808..bf296ded 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/ListCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/ListCMD.java @@ -21,6 +21,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.list"))) { + MessageHelper.error(player, "You don't have the required permission to list the holograms"); + return false; + } + final var holograms = FancyHolograms.get().getHologramsManager().getPersistentHolograms(); if (holograms.isEmpty()) { diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/MoveHereCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/MoveHereCMD.java index 4ac6c42e..dd603cc7 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/MoveHereCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/MoveHereCMD.java @@ -21,6 +21,12 @@ public class MoveHereCMD implements Subcommand { public static boolean setLocation(Player player, Hologram hologram, Location location, boolean applyRotation) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.move_here"))) { + MessageHelper.error(player, "You don't have the required permission to move a hologram"); + return false; + } + final var copied = hologram.getData().copy(hologram.getName()); final Location newLocation = (applyRotation) ? location diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/MoveToCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/MoveToCMD.java index ae8d4da6..f921c580 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/MoveToCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/MoveToCMD.java @@ -20,6 +20,11 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender sender, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(sender.hasPermission("fancyholograms.hologram.edit.move_to"))) { + MessageHelper.error(sender, "You don't have the required permission to move a hologram"); + return false; + } if (!(sender instanceof Player player)) { MessageHelper.error(sender, "You must be a sender to use this command"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/NearbyCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/NearbyCMD.java index 4617a5a2..bd1868c3 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/NearbyCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/NearbyCMD.java @@ -26,6 +26,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.nearby"))) { + MessageHelper.error(player, "You don't have the required permission to see nearby holograms"); + return false; + } + if (!(player instanceof Player)) { MessageHelper.error(player, "This is a player only command."); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/RemoveCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/RemoveCMD.java index c8927310..d978ad66 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/RemoveCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/RemoveCMD.java @@ -21,6 +21,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.remove"))) { + MessageHelper.error(player, "You don't have the required permission to remove a hologram"); + return false; + } + if (!new HologramDeleteEvent(hologram, player).callEvent()) { MessageHelper.error(player, "Removing the hologram was cancelled"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/RemoveLineCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/RemoveLineCMD.java index d0646f89..26b93612 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/RemoveLineCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/RemoveLineCMD.java @@ -20,6 +20,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.line.remove"))) { + MessageHelper.error(player, "You don't have the required permission to remove a line from a hologram"); + return false; + } + if (!(hologram.getData() instanceof TextHologramData)) { MessageHelper.error(player, "This command can only be used on text holograms"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/RotateCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/RotateCMD.java index 0fc2e480..ea2be61c 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/RotateCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/RotateCMD.java @@ -20,6 +20,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender sender, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(sender.hasPermission("fancyholograms.hologram.edit.rotate"))) { + MessageHelper.error(sender, "You don't have the required permission to rotate a hologram"); + return false; + } + if (!(sender instanceof Player player)) { MessageHelper.error(sender, "You must be a sender to use this command"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/RotatePitchCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/RotatePitchCMD.java index ef0b2adb..8757be35 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/RotatePitchCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/RotatePitchCMD.java @@ -20,6 +20,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender sender, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(sender.hasPermission("fancyholograms.hologram.edit.rotate_pitch"))) { + MessageHelper.error(sender, "You don't have the required permission to rotate a hologram"); + return false; + } + if (!(sender instanceof Player player)) { MessageHelper.error(sender, "You must be a sender to use this command"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/ScaleCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/ScaleCMD.java index 1000d45c..38612f93 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/ScaleCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/ScaleCMD.java @@ -24,6 +24,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.scale"))) { + MessageHelper.error(player, "You don't have the required permission to change the scale of a hologram"); + return false; + } + final var scaleX = Floats.tryParse(args[3]); final var scaleY = args.length >= 6 ? Floats.tryParse(args[4]) : scaleX; final var scaleZ = args.length >= 6 ? Floats.tryParse(args[5]) : scaleX; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/SeeThroughCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/SeeThroughCMD.java index acb5159d..a4468440 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/SeeThroughCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/SeeThroughCMD.java @@ -23,6 +23,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.see_trough"))) { + MessageHelper.error(player, "You don't have the required permission to edit a hologram"); + return false; + } + if (!(hologram.getData() instanceof TextHologramData textData)) { MessageHelper.error(player, "This command can only be used on text holograms"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/SetLineCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/SetLineCMD.java index 7b6b8c61..a240cc3e 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/SetLineCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/SetLineCMD.java @@ -18,6 +18,12 @@ public class SetLineCMD implements Subcommand { public static boolean setLine(CommandSender player, Hologram hologram, int index, String text) { + + if (!(player.hasPermission("fancyholograms.hologram.line.set"))) { + MessageHelper.error(player, "You don't have the required permission to set a line to this hologram"); + return false; + } + if (!(hologram.getData() instanceof TextHologramData textData)) { MessageHelper.error(player, "This command can only be used on text holograms"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/ShadowRadiusCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/ShadowRadiusCMD.java index 0142d90c..28105469 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/ShadowRadiusCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/ShadowRadiusCMD.java @@ -23,6 +23,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.shadow_radius"))) { + MessageHelper.error(player, "You don't have the required permission to edit a hologram"); + return false; + } + final var radius = Floats.tryParse(args[3]); if (radius == null) { diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/ShadowStrengthCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/ShadowStrengthCMD.java index 24215d58..40daac04 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/ShadowStrengthCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/ShadowStrengthCMD.java @@ -23,6 +23,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.shadow_strength"))) { + MessageHelper.error(player, "You don't have the required permission to edit a hologram"); + return false; + } + final var strength = Floats.tryParse(args[3]); if (strength == null) { diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/TeleportCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/TeleportCMD.java index 5c21974d..9335a716 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/TeleportCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/TeleportCMD.java @@ -19,6 +19,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender sender, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(sender.hasPermission("fancyholograms.hologram.teleport"))) { + MessageHelper.error(sender, "You don't have the required permission to teleport you to a hologram"); + return false; + } + if (!(sender instanceof Player player)) { MessageHelper.error(sender, "You must be a sender to use this command"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/TextAlignmentCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/TextAlignmentCMD.java index 8e7a8ad1..a4e3e259 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/TextAlignmentCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/TextAlignmentCMD.java @@ -25,6 +25,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.text_alignment"))) { + MessageHelper.error(player, "You don't have the required permission to edit a hologram"); + return false; + } + if (!(hologram.getData() instanceof TextHologramData textData)) { MessageHelper.error(player, "This command can only be used on text holograms"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/TextShadowCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/TextShadowCMD.java index 6c4ff326..2564497d 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/TextShadowCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/TextShadowCMD.java @@ -23,6 +23,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.text_shadow"))) { + MessageHelper.error(player, "You don't have the required permission to edit a hologram"); + return false; + } + if (!(hologram.getData() instanceof TextHologramData textData)) { MessageHelper.error(player, "This command can only be used on text holograms"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/UnlinkWithNpcCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/UnlinkWithNpcCMD.java index ace4e01a..09d9a3ef 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/UnlinkWithNpcCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/UnlinkWithNpcCMD.java @@ -21,6 +21,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.unlink"))) { + MessageHelper.error(player, "You don't have the required permission to unlink a hologram"); + return false; + } + if (!PluginUtils.isFancyNpcsEnabled()) { MessageHelper.warning(player, "You need to install the FancyNpcs plugin for this functionality to work"); MessageHelper.warning(player, "Download link: click here."); diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/UpdateTextIntervalCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/UpdateTextIntervalCMD.java index 36cc2552..712b1a9f 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/UpdateTextIntervalCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/UpdateTextIntervalCMD.java @@ -24,6 +24,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.text_interval"))) { + MessageHelper.error(player, "You don't have the required permission to edit a hologram"); + return false; + } + if (!(hologram.getData() instanceof TextHologramData textData)) { MessageHelper.error(player, "This command can only be used on text holograms"); return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/VisibilityCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/VisibilityCMD.java index 7b2cead2..2152c213 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/VisibilityCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/VisibilityCMD.java @@ -24,6 +24,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.visibility"))) { + MessageHelper.error(player, "You don't have the required permission to edit a hologram"); + return false; + } + final var optionalVisibility = Visibility.byString(args[3]); if (hologram == null || optionalVisibility.isEmpty()) { return false; diff --git a/src/main/java/de/oliver/fancyholograms/commands/hologram/VisibilityDistanceCMD.java b/src/main/java/de/oliver/fancyholograms/commands/hologram/VisibilityDistanceCMD.java index 8c79f8d7..97c092b1 100644 --- a/src/main/java/de/oliver/fancyholograms/commands/hologram/VisibilityDistanceCMD.java +++ b/src/main/java/de/oliver/fancyholograms/commands/hologram/VisibilityDistanceCMD.java @@ -22,6 +22,12 @@ public List tabcompletion(@NotNull CommandSender player, @Nullable Holog @Override public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { + + if (!(player.hasPermission("fancyholograms.hologram.edit.visibility_distance"))) { + MessageHelper.error(player, "You don't have the required permission to edit a hologram"); + return false; + } + var visibilityDistance = Ints.tryParse(args[3]); if (visibilityDistance == null) {