mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
Private home list display, caching
This commit is contained in:
1 parent
83d5a921ee
commit
bafd3837dd
10 files changed
+237
-19
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package net.william278.huskhomes.command;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.list.PrivateHomeList;
|
||||
import net.william278.huskhomes.player.Player;
|
||||
import net.william278.huskhomes.player.User;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -8,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class HomeCommand extends CommandBase implements TabCompletable {
|
||||
public class HomeCommand extends CommandBase implements TabCompletable, ConsoleExecutable {
|
||||
|
||||
private final static String PERMISSION = "huskhomes.command.home";
|
||||
|
||||
@@ -18,20 +19,28 @@ public class HomeCommand extends CommandBase implements TabCompletable {
|
||||
|
||||
@Override
|
||||
public void onExecute(@NotNull Player player, @NotNull String[] args) {
|
||||
if (args.length >= 1) {
|
||||
//todo check if its a public home, process. Support sending a player
|
||||
plugin.getTeleportManager().teleportToHome(player, new User(player), args[0]);
|
||||
} else {
|
||||
plugin.getDatabase().getHomes(new User(player)).thenAccept(homes -> {
|
||||
switch (args.length) {
|
||||
case 0 -> plugin.getDatabase().getHomes(new User(player)).thenAccept(homes -> {
|
||||
switch (homes.size()) {
|
||||
case 0 -> plugin.getLocales().getLocale("error_no_homes_set").ifPresent(player::sendMessage);
|
||||
case 1 -> plugin.getTeleportManager().executeTeleport(player, homes.get(0)).thenAccept(result ->
|
||||
plugin.getTeleportManager().finishTeleport(player, result));
|
||||
default -> {
|
||||
//todo show home list
|
||||
final User user = new User(player.getUuid(), player.getName());
|
||||
plugin.getDatabase().getHomes(user).thenAccept(playerHomes -> {
|
||||
final PrivateHomeList homeList = new PrivateHomeList(homes, user, plugin);
|
||||
plugin.getCache().positionLists.put(user.uuid, homeList);
|
||||
homeList.getDisplay(1).forEach(player::sendMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
case 1 -> {
|
||||
//todo check if its a public home, process. Support sending a player
|
||||
plugin.getTeleportManager().teleportToHome(player, new User(player), args[0]);
|
||||
}
|
||||
default -> plugin.getLocales().getLocale("error_invalid_syntax", "/home [name]")
|
||||
.ifPresent(player::sendMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,4 +50,9 @@ public class HomeCommand extends CommandBase implements TabCompletable {
|
||||
.filter(s -> s.startsWith(args.length >= 1 ? args[0] : ""))
|
||||
.sorted().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConsoleExecute(@NotNull String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user