fix tab completion

This commit is contained in:
2024-01-20 14:47:23 -06:00
parent 86358e49b8
commit d2b524c259
16 changed files with 171 additions and 24 deletions
@@ -6,6 +6,10 @@ import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.exception.PlayerNotFoundException;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.extras.TFMExtras;
import dev.plex.util.PlexUtils;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
@@ -15,11 +19,6 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Taah
* @since 7:43 PM [24-08-2023]
*/
@CommandParameters(name = "myworld", usage = "/<command> <create | goto | manage | members | shared | add | remove | settings> [player]")
@CommandPermissions(permission = "plex.tfmextras.myworld", source = RequiredCommandSource.IN_GAME)
public class MyWorldCommand extends PlexCommand
@@ -81,4 +80,22 @@ public class MyWorldCommand extends PlexCommand
}
return null;
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
if (silentCheckPermission(sender, this.getPermission()))
{
if (args.length == 1)
{
return Arrays.asList("create", "goto", "manage", "members", "shared", "add", "remove", "settings");
}
if (args.length == 2)
{
return PlexUtils.getPlayerNameList();
}
return Collections.emptyList();
}
return Collections.emptyList();
}
}
@@ -8,6 +8,9 @@ import dev.plex.extras.TFMExtras;
import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
@@ -16,11 +19,6 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Taah
* @since 7:11 PM [24-08-2023]
*/
@CommandParameters(name = "slimemanager", usage = "/<command> <delete | list> [world | all]", description = "Manages the slime worlds handled by the plugin")
@CommandPermissions(source = RequiredCommandSource.CONSOLE, permission = "plex.tfmextras.slimemanager")
public class SlimeManagerCommand extends PlexCommand
@@ -97,4 +95,22 @@ public class SlimeManagerCommand extends PlexCommand
}
return null;
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
if (silentCheckPermission(sender, this.getPermission()))
{
if (args.length == 1)
{
return Arrays.asList("delete", "list");
}
if (args.length == 2)
{
return TFMExtras.getModule().getSlimeWorldHook().loadedWorlds().stream().toList();
}
return Collections.emptyList();
}
return Collections.emptyList();
}
}