Skip to content

Commit

Permalink
Fixed Issue 15 (#153)
Browse files Browse the repository at this point in the history
* fixed issue #72
#72

* fixed issue #15
#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 <[email protected]>
  • Loading branch information
devpeaqe and peaqe authored Nov 3, 2024
1 parent 912014a commit f89b080
Show file tree
Hide file tree
Showing 33 changed files with 191 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public List<String> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ public List<String> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public List<String> 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public List<String> 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, "<b>Information about the " + hologram.getData().getName() + " hologram:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public List<String> 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:open_url:'https://modrinth.com/plugin/fancynpcs/versions'><u>click here</u></click>.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public List<String> 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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public List<String> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public List<String> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public List<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public List<String> 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;
Expand Down
Loading

0 comments on commit f89b080

Please sign in to comment.