Add desination identifier tab completion.

This commit is contained in:
benwoo1110 2020-12-20 14:49:54 +08:00
parent 94c8189d2e
commit 65c332f93d
3 changed files with 18 additions and 12 deletions

View File

@ -23,7 +23,7 @@ public class CheckCommand extends MultiverseCommand {
@Subcommand("check")
@CommandPermission("multiverse.core.debug")
@Syntax("[player] <destination>")
@CommandCompletion("@players")
@CommandCompletion("@players @destinations|@MVWorlds")
@Description("Checks to see if a player can go to a destination. Prints debug if false.")
public void onCheckCommand(@NotNull CommandSender sender,
@NotNull @Flags("other,defaultself,fallbackself") Player player,

View File

@ -43,9 +43,8 @@ public class TeleportCommand extends MultiverseCommand {
public class Teleport extends BaseCommand {
@Subcommand("teleport")
@CommandPermission("@destinations")
@Syntax("[player] <destination>")
@CommandCompletion("@players|@MVWorlds @MVWorlds")
@CommandCompletion("@players|@MVWorlds|@destinations @MVWorlds|@destinations")
@Description("Allows you to the teleport to a location on your server!")
public void doTeleportCommand(@NotNull CommandSender sender,
@NotNull @Flags("other,defaultself,fallbackself") Player player,
@ -63,10 +62,9 @@ public class TeleportCommand extends MultiverseCommand {
public class AliasTeleport extends BaseCommand {
@CommandAlias("mvtp")
@CommandPermission("@destinations")
@Syntax("[player] <destination>")
//TODO: playerOnly flag
@CommandCompletion("@players|@MVWorlds @MVWorlds")
@CommandCompletion("@players|@MVWorlds|@destinations @MVWorlds|@destinations")
@Description("Alias for /mv tp")
public void doTeleportCommand(@NotNull CommandSender sender,
@NotNull @Flags("other,defaultself,fallbackself") Player player,

View File

@ -36,17 +36,25 @@ public class MVCommandCompletions extends PaperCommandCompletions {
registerAsyncCompletion("unloadedWorlds", this::suggestUnloadedWorlds);
registerAsyncCompletion("potentialWorlds", this::suggestPotentialWorlds);
registerAsyncCompletion("location", this::suggestLocation);
registerStaticCompletion("MVConfigs", suggestMVConfig());
registerStaticCompletion("gameRules", suggestGameRules());
registerStaticCompletion("environments", suggestEnvironments());
registerStaticCompletion("setProperties", suggestSetProperties());
registerStaticCompletion("addProperties", suggestAddProperties());
registerStaticCompletion("livingEntities", suggestEntities());
registerStaticCompletion("pasteTypes", suggestPasteTypes());
registerAsyncCompletion("destinations", this::suggestDestinations);
registerStaticCompletion("MVConfigs", this::suggestMVConfig);
registerStaticCompletion("gameRules", this::suggestGameRules);
registerStaticCompletion("environments", this::suggestEnvironments);
registerStaticCompletion("setProperties", this::suggestSetProperties);
registerStaticCompletion("addProperties", this::suggestAddProperties);
registerStaticCompletion("livingEntities", this::suggestEntities);
registerStaticCompletion("pasteTypes", this::suggestPasteTypes);
//TODO: Destinations
}
private Collection<String> suggestDestinations(@NotNull BukkitCommandCompletionContext context) {
//TODO: There is one empty dest need to remove.
return this.plugin.getDestFactory().getIdentifiers().stream()
.map(id -> id + ":")
.collect(Collectors.toList());
}
@NotNull
private Collection<String> suggestMVWorlds(@NotNull BukkitCommandCompletionContext context) {
return this.worldManager.getMVWorlds().stream()