mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Finish fixing TAB completion via console
This commit is contained in:
1 parent
16206b72eb
commit
32f05de853
15 files changed
+42
-22
No files matched your search
@@ -1,12 +1,12 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import de.themoep.minedown.MineDown;
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.player.User;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import net.william278.huskhomes.util.RegexUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -84,8 +84,11 @@ public class DelHomeCommand extends CommandBase implements TabCompletable, Conso
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
return args.length > 1 ? Collections.emptyList() : plugin.getCache().homes.get(onlineUser.uuid).stream()
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
if (user == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return args.length > 1 ? Collections.emptyList() : plugin.getCache().homes.get(user.uuid).stream()
|
||||
.filter(s -> s.startsWith(args.length == 1 ? args[0] : ""))
|
||||
.sorted().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -38,7 +39,7 @@ public class DelWarpCommand extends CommandBase implements TabCompletable, Conso
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
return args.length > 1 ? Collections.emptyList() : plugin.getCache().warps.stream()
|
||||
.filter(s -> s.startsWith(args.length == 1 ? args[0] : ""))
|
||||
.sorted().collect(Collectors.toList());
|
||||
|
||||
@@ -342,9 +342,12 @@ public class EditHomeCommand extends CommandBase implements TabCompletable, Cons
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
if (user == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return switch (args.length) {
|
||||
case 0, 1 -> plugin.getCache().homes.get(onlineUser.uuid).stream()
|
||||
case 0, 1 -> plugin.getCache().homes.get(user.uuid).stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
||||
.sorted().collect(Collectors.toList());
|
||||
case 2 -> Arrays.stream(EDIT_HOME_COMPLETIONS)
|
||||
|
||||
@@ -203,7 +203,7 @@ public class EditWarpCommand extends CommandBase implements TabCompletable, Cons
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
return switch (args.length) {
|
||||
case 0, 1 -> plugin.getCache().warps.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import net.william278.huskhomes.util.RegexUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -51,9 +52,12 @@ public class HomeCommand extends CommandBase implements TabCompletable, ConsoleE
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
return args.length > 1 ? Collections.emptyList() : plugin.getCache().homes.get(onlineUser.uuid).stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.length >= 1 ? args[0].toLowerCase() : ""))
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
if (user == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return args.length > 1 ? Collections.emptyList() : plugin.getCache().homes.get(user.uuid).stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
||||
.sorted().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import net.william278.huskhomes.util.RegexUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -64,14 +65,14 @@ public class PublicHomeCommand extends CommandBase implements TabCompletable, Co
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
// Return every public home name as username.home_name from the cache
|
||||
final List<String> publicHomes = new ArrayList<>();
|
||||
plugin.getCache().publicHomes.forEach((ownerName, homeNames) ->
|
||||
homeNames.forEach(homeName -> publicHomes.add(ownerName + "." + homeName)));
|
||||
return args.length > 1 ? Collections.emptyList() : publicHomes.stream().filter(publicHomeIdentifier ->
|
||||
publicHomeIdentifier.split(Pattern.quote("."))[1].toLowerCase()
|
||||
.startsWith(args.length >= 1 ? args[0].toLowerCase() : ""))
|
||||
.startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
||||
.sorted().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,6 +18,6 @@ public interface TabCompletable {
|
||||
* @return List of String arguments to offer TAB suggestions
|
||||
*/
|
||||
@NotNull
|
||||
List<String> onTabComplete(@NotNull String[] args);
|
||||
List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user);
|
||||
|
||||
}
|
||||
@@ -112,8 +112,8 @@ public class TpCommand extends CommandBase implements TabCompletable, ConsoleExe
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
return Collections.emptyList();
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
return Collections.emptyList();//todo
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -26,7 +27,7 @@ public class TpHereCommand extends CommandBase implements TabCompletable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
return args.length <= 1 ? plugin.getCache().players.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
||||
.sorted().collect(Collectors.toList()) : Collections.emptyList();
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -42,7 +43,7 @@ public class TpOfflineCommand extends CommandBase implements TabCompletable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
return args.length <= 1 ? plugin.getCache().players.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
||||
.sorted().collect(Collectors.toList()) : Collections.emptyList();
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -40,7 +41,7 @@ public class TpRespondCommand extends CommandBase implements TabCompletable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
return args.length <= 1 ? plugin.getCache().players.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
||||
.sorted().collect(Collectors.toList()) : Collections.emptyList();
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.request.TeleportRequest;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -33,7 +34,7 @@ public class TpaCommand extends CommandBase implements TabCompletable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
return args.length <= 1 ? plugin.getCache().players.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
||||
.sorted().collect(Collectors.toList()) : Collections.emptyList();
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.request.TeleportRequest;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -33,7 +34,7 @@ public class TpaHereCommand extends CommandBase implements TabCompletable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
return args.length <= 1 ? plugin.getCache().players.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
|
||||
.sorted().collect(Collectors.toList()) : Collections.emptyList();
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.player.OnlineUser;
|
||||
import net.william278.huskhomes.util.Permission;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -35,7 +36,7 @@ public class WarpCommand extends CommandBase implements TabCompletable, ConsoleE
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
||||
public @NotNull List<String> onTabComplete(@NotNull String[] args, @Nullable OnlineUser user) {
|
||||
return plugin.getCache().warps.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args.length >= 1 ? args[0].toLowerCase() : ""))
|
||||
.sorted().collect(Collectors.toList());
|
||||
|
||||
Reference in new issue
Block a user