diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelCommand.java b/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelCommand.java index 35572491..eaf9001e 100644 --- a/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelCommand.java +++ b/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelCommand.java @@ -57,7 +57,8 @@ public String stringDescription() { @Override public String getHelpKey(CommandSender target) { - if(target.hasPermission("areashop.destroyrent") || target.hasPermission("areashop.destroybuy") || target.hasPermission("areashop.destroyrent.landlord") || target.hasPermission("areashop.destroybuy.landlord")) { + if (target.hasPermission("areashop.destroyrent") || target.hasPermission("areashop.destroybuy") || target.hasPermission( + "areashop.destroyrent.landlord") || target.hasPermission("areashop.destroybuy.landlord")) { return "help-del"; } return null; @@ -74,7 +75,7 @@ public String getHelpKey(CommandSender target) { new GeneralRegionParser<>(this.fileManager), GeneralRegion.class ); - return builder.literal("delete", "del") + return builder.literal("del", "delete") .optional(KEY_REGION, regionParser) .handler(this::handleCommand); } diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelFriendCommand.java b/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelFriendCommand.java index 993f98e5..3858bca3 100644 --- a/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelFriendCommand.java +++ b/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelFriendCommand.java @@ -82,7 +82,7 @@ public String stringDescription() { @Override protected @Nonnull Command.Builder configureCommand(@Nonnull Command.Builder builder) { - return builder.literal("deletefriend", "delfriend") + return builder.literal("delfriend", "deletefriend") .required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser(), this::suggestFriends) .flag(this.regionFlag) .handler(this::handleCommand); diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelSignCommand.java b/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelSignCommand.java index d2904e20..081db43f 100644 --- a/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelSignCommand.java +++ b/AreaShop/src/main/java/me/wiefferink/areashop/commands/DelSignCommand.java @@ -23,67 +23,68 @@ @Singleton public class DelSignCommand extends AreashopCommandBean { - private final SignManager signManager; - private final MessageBridge messageBridge; - @Inject - public DelSignCommand(@Nonnull MessageBridge messageBridge, @Nonnull SignManager signManager) { - this.signManager = signManager; - this.messageBridge = messageBridge; - } + private final SignManager signManager; + private final MessageBridge messageBridge; - @Override - public String stringDescription() { - return null; - } + @Inject + public DelSignCommand(@Nonnull MessageBridge messageBridge, @Nonnull SignManager signManager) { + this.signManager = signManager; + this.messageBridge = messageBridge; + } + + @Override + public String stringDescription() { + return null; + } @Override protected @Nonnull CommandProperties properties() { - return CommandProperties.of("deletesign", "delsign"); - } - - @Override - protected @Nonnull Command.Builder configureCommand(@Nonnull Command.Builder builder) { - return builder.literal("deletesign", "delsign") - .senderType(Player.class) - .handler(this::handleCommand); - } - - @Override - public String getHelpKey(CommandSender target) { - if(target.hasPermission("areashop.delsign")) { - return "help-delsign"; - } - return null; - } - - private void handleCommand(@Nonnull CommandContext context) { - Player sender = context.sender(); - if (!sender.hasPermission("areashop.delsign")) { - throw new AreaShopCommandException("delsign-noPermission"); - } - // Get the sign - Block block = null; - BlockIterator blockIterator = new BlockIterator(sender, 100); - while(blockIterator.hasNext() && block == null) { - Block next = blockIterator.next(); - if(!next.getType().isAir()) { - block = next; - } - } - if(block == null || !Materials.isSign(block.getType())) { - throw new AreaShopCommandException("delsign-noSign"); - } - Optional optionalSign = signManager.removeSign(block.getLocation()); - if(optionalSign.isEmpty()) { - throw new AreaShopCommandException("delsign-noRegion"); - } - RegionSign regionSign = optionalSign.get(); - messageBridge.message(sender, "delsign-success", regionSign.getRegion()); - regionSign.remove(); - // Sometimes the RegionSign data is corrupted. Forcefully set the block to air - block.setType(Material.AIR); - } + return CommandProperties.of("deletesign", "delsign"); + } + + @Override + protected @Nonnull Command.Builder configureCommand(@Nonnull Command.Builder builder) { + return builder.literal("delsign", "deletesign") + .senderType(Player.class) + .handler(this::handleCommand); + } + + @Override + public String getHelpKey(CommandSender target) { + if (target.hasPermission("areashop.delsign")) { + return "help-delsign"; + } + return null; + } + + private void handleCommand(@Nonnull CommandContext context) { + Player sender = context.sender(); + if (!sender.hasPermission("areashop.delsign")) { + throw new AreaShopCommandException("delsign-noPermission"); + } + // Get the sign + Block block = null; + BlockIterator blockIterator = new BlockIterator(sender, 100); + while (blockIterator.hasNext() && block == null) { + Block next = blockIterator.next(); + if (!next.getType().isAir()) { + block = next; + } + } + if (block == null || !Materials.isSign(block.getType())) { + throw new AreaShopCommandException("delsign-noSign"); + } + Optional optionalSign = signManager.removeSign(block.getLocation()); + if (optionalSign.isEmpty()) { + throw new AreaShopCommandException("delsign-noRegion"); + } + RegionSign regionSign = optionalSign.get(); + messageBridge.message(sender, "delsign-success", regionSign.getRegion()); + regionSign.remove(); + // Sometimes the RegionSign data is corrupted. Forcefully set the block to air + block.setType(Material.AIR); + } } diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/commands/TeleportCommand.java b/AreaShop/src/main/java/me/wiefferink/areashop/commands/TeleportCommand.java index f7251c1f..bc8db459 100644 --- a/AreaShop/src/main/java/me/wiefferink/areashop/commands/TeleportCommand.java +++ b/AreaShop/src/main/java/me/wiefferink/areashop/commands/TeleportCommand.java @@ -68,7 +68,7 @@ public String stringDescription() { @NotNull @Override protected Command.Builder configureCommand(@NotNull Command.Builder builder) { - return builder.literal("teleport", "tp") + return builder.literal("tp", "teleport") .senderType(Player.class) .required(KEY_REGION, GeneralRegionParser.generalRegionParser(this.fileManager)) .handler(this::handleCommand);