i give up for the night

This commit is contained in:
Telesphoreo 2024-01-20 02:02:45 -06:00
parent 8710b478c1
commit 9e333a50b9
3 changed files with 20 additions and 7 deletions

View File

@ -0,0 +1,11 @@
package dev.plex.command;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface IPlexCommand
{
@NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args, List<String> list) throws IllegalArgumentException;
}

View File

@ -23,14 +23,13 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
/** /**
* Superclass for all commands * Superclass for all commands
*/ */
public abstract class PlexCommand extends Command implements PluginIdentifiableCommand public abstract class PlexCommand extends Command implements PluginIdentifiableCommand, IPlexCommand
{ {
/** /**
* Returns the instance of the plugin * Returns the instance of the plugin
@ -158,6 +157,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
try try
{ {
Component component = this.execute(sender, isConsole(sender) ? null : (Player) sender, args); Component component = this.execute(sender, isConsole(sender) ? null : (Player) sender, args);
this.tabComplete(sender, label, args, List.of(args));
if (component != null) if (component != null)
{ {
send(sender, component); send(sender, component);
@ -171,15 +171,16 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
return true; return true;
} }
/*@NotNull @NotNull
public abstract List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException; public abstract List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException;
*/
@NotNull @NotNull
public List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException @Override
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args, List<String> list) throws IllegalArgumentException
{ {
List<String> list = tabComplete(sender, alias, args); list = tabComplete(sender, alias, args);
return StringUtil.copyPartialMatches(args[args.length - 1], list, Lists.newArrayList()); return StringUtil.copyPartialMatches(args[args.length - 1], list, Lists.newArrayList());
//return List.of("test1", "test2");
} }
/** /**

View File

@ -1,5 +1,6 @@
package dev.plex.command.impl; package dev.plex.command.impl;
import dev.plex.command.IPlexCommand;
import dev.plex.command.PlexCommand; import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.annotation.CommandPermissions;
@ -19,7 +20,7 @@ import java.util.List;
@CommandPermissions(permission = "plex.blockedit") @CommandPermissions(permission = "plex.blockedit")
@CommandParameters(name = "blockedit", usage = "/<command> [list | purge | all | <player>]", aliases = "bedit", description = "Prevent players from modifying blocks") @CommandParameters(name = "blockedit", usage = "/<command> [list | purge | all | <player>]", aliases = "bedit", description = "Prevent players from modifying blocks")
public class BlockEditCMD extends PlexCommand public class BlockEditCMD extends PlexCommand implements IPlexCommand
{ {
private final BlockListener bl = new BlockListener(); private final BlockListener bl = new BlockListener();