Skip to content

Commit

Permalink
Use longer labels as aliases instead of the main label
Browse files Browse the repository at this point in the history
  • Loading branch information
md5sha256 committed Mar 23, 2024
1 parent dca6305 commit 489f52d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public String stringDescription() {

@Override
protected @Nonnull Command.Builder<? extends CommandSender> configureCommand(@Nonnull Command.Builder<CommandSender> builder) {
return builder.literal("deletefriend", "delfriend")
return builder.literal("delfriend", "deletefriend")
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser(), this::suggestFriends)
.flag(this.regionFlag)
.handler(this::handleCommand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends CommandSender> configureCommand(@Nonnull Command.Builder<CommandSender> 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<Player> 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<RegionSign> 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<? extends CommandSender> configureCommand(@Nonnull Command.Builder<CommandSender> 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<Player> 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<RegionSign> 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);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String stringDescription() {
@NotNull
@Override
protected Command.Builder<? extends CommandSender> configureCommand(@NotNull Command.Builder<CommandSender> builder) {
return builder.literal("teleport", "tp")
return builder.literal("tp", "teleport")
.senderType(Player.class)
.required(KEY_REGION, GeneralRegionParser.generalRegionParser(this.fileManager))
.handler(this::handleCommand);
Expand Down

0 comments on commit 489f52d

Please sign in to comment.