feat: allow /phome <name> on uniquely named homes

If multiple public homes with the same name exist, typing /phome (name) will bring up a filtered public home list containing the list of public homes with that name for you to click on. The username-prefixed name will also be the only one to show up in TAB.

This commit also fixes a bug with home/warp lists showing a blank description on hover instead of `(none)`.
This commit is contained in:
William committed 2024-03-31 17:40:38 +01:00
1 parent 0135966c6e
commit 4e9046395c
32 files changed
+353 -81

No files matched your search

@@ -20,6 +20,7 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.position.Home;
import net.william278.huskhomes.user.CommandUser;
import org.jetbrains.annotations.NotNull;
@@ -28,7 +29,7 @@ import java.util.List;
public class PublicHomeCommand extends HomeCommand implements TabProvider {
protected PublicHomeCommand(@NotNull HuskHomes plugin) {
super("phome", List.of("publichome"), plugin);
super("phome", List.of("publichome"), PositionCommandType.PUBLIC_HOME, plugin);
}
@Override
@@ -36,7 +37,7 @@ public class PublicHomeCommand extends HomeCommand implements TabProvider {
// Display the public home list if no arguments are provided
if (args.length == 0) {
plugin.getCommand(PublicHomeListCommand.class)
.ifPresent(command -> command.showPublicHomeList(executor, 1));
.ifPresent(command -> command.showPublicHomeList(executor, null, 1));
return;
}
super.execute(executor, args);
@@ -46,7 +47,10 @@ public class PublicHomeCommand extends HomeCommand implements TabProvider {
@NotNull
public List<String> suggest(@NotNull CommandUser executor, @NotNull String[] args) {
if (args.length <= 2) {
return filter(plugin.getManager().homes().getPublicHomeIdentifiers(), args);
if (args.length >= 1 && args[0].contains(Home.IDENTIFIER_DELIMITER)) {
return plugin.getManager().homes().getPublicHomeIdentifierNames();
}
return plugin.getManager().homes().getPublicHomeNames();
}
return List.of();
}