Add /edithome, use instant for timestamps, new locales

This commit is contained in:
William committed 2022-08-16 00:58:26 +01:00
1 parent eddae1051c
commit a91128ca3d
24 files changed
+793 -205

No files matched your search

@@ -18,19 +18,23 @@ public class HomeCommand extends CommandBase implements TabCompletable, ConsoleE
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
switch (args.length) {
case 0 -> plugin.getDatabase().getHomes(onlineUser).thenAccept(homes -> {
// Send the home list if they have homes set. If they have just one home set, teleport the player
switch (homes.size()) {
case 0 -> plugin.getLocales().getLocale("error_no_homes_set").ifPresent(onlineUser::sendMessage);
case 1 -> plugin.getTeleportManager().teleport(onlineUser, homes.get(0)).thenAccept(result ->
plugin.getTeleportManager().finishTeleport(onlineUser, result));
default -> {
final PrivateHomeList homeList = new PrivateHomeList(homes, onlineUser, plugin);
plugin.getCache().positionLists.put(onlineUser.uuid, homeList);
homeList.getDisplay(1).forEach(onlineUser::sendMessage);
try {
switch (homes.size()) {
case 0 ->
plugin.getLocales().getLocale("error_no_homes_set").ifPresent(onlineUser::sendMessage);
case 1 -> plugin.getTeleportManager().teleport(onlineUser, homes.get(0)).thenAccept(result ->
plugin.getTeleportManager().finishTeleport(onlineUser, result)).join();
default -> {
final PrivateHomeList homeList = new PrivateHomeList(homes, onlineUser, plugin);
plugin.getCache().positionLists.put(onlineUser.uuid, homeList);
homeList.getDisplay(1).forEach(onlineUser::sendMessage);
}
}
} catch (Exception e) {
e.printStackTrace();
}
});
case 1 -> {
@@ -55,7 +59,7 @@ public class HomeCommand extends CommandBase implements TabCompletable, ConsoleE
}
@Override
public List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
public @NotNull List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
return plugin.getCache().homes.get(onlineUser.uuid).stream()
.filter(s -> s.toLowerCase().startsWith(args.length >= 1 ? args[0].toLowerCase() : ""))
.sorted().collect(Collectors.toList());