Skip to content

Commit

Permalink
Enhance command argument suggestions based on world environment
Browse files Browse the repository at this point in the history
Updated the WorldLinkCreateCommand and WorldLinkRemoveCommand to suggest arguments based on the world environment. This ensures that only appropriate worlds are suggested for source, destination, and relative arguments, improving the user experience and command accuracy.
  • Loading branch information
NonSwag committed Aug 14, 2024
1 parent a029352 commit 328f745
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ public class WorldLinkCreateCommand {
return Commands.literal("create")
.requires(source -> source.getSender().hasPermission("worlds.command.link.create"))
.then(Commands.argument("source", ArgumentTypes.world())
.suggests(new WorldSuggestionProvider<>(plugin))
.suggests(new WorldSuggestionProvider<>(plugin, world ->
world.getEnvironment().equals(World.Environment.NORMAL)))
.then(Commands.argument("destination", ArgumentTypes.world())
.suggests(new WorldSuggestionProvider<>(plugin, world ->
!world.getEnvironment().equals(World.Environment.NORMAL)))
.executes(context -> {
var source = context.getArgument("source", World.class);
var destination = context.getArgument("destination", World.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public class WorldLinkRemoveCommand {
return Commands.literal("remove")
.requires(source -> source.getSender().hasPermission("worlds.command.link.remove"))
.then(Commands.argument("world", ArgumentTypes.world())
.suggests(new WorldSuggestionProvider<>(plugin))
.then(Commands.argument("relative", new RelativeArgument())
.suggests(new WorldSuggestionProvider<>(plugin, world ->
world.getEnvironment().equals(World.Environment.NORMAL)))
.then(Commands.argument("relative", new RelativeArgument(relative ->
!relative.equals(Relative.OVERWORLD)))
.executes(context -> {
var world = context.getArgument("world", World.class);
var relative = context.getArgument("relative", Relative.class);
Expand Down

0 comments on commit 328f745

Please sign in to comment.