mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Add /edithome, use instant for timestamps, new locales
This commit is contained in:
1 parent
eddae1051c
commit
a91128ca3d
24 files changed
+793
-205
No files matched your search
@@ -2,6 +2,7 @@ package net.william278.huskhomes.command;
|
||||
|
||||
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;
|
||||
@@ -21,7 +22,7 @@ public class DelHomeCommand extends CommandBase implements TabCompletable, Conso
|
||||
switch (args.length) {
|
||||
case 0 -> plugin.getDatabase().getHomes(onlineUser).thenAccept(homes -> {
|
||||
if (homes.size() == 1) {
|
||||
homes.stream().findFirst().ifPresent(home -> plugin.getSavedPositionManager().deleteHome(onlineUser, home.meta.name));
|
||||
homes.stream().findFirst().ifPresent(home -> deletePlayerHome(onlineUser, onlineUser, home.meta.name));
|
||||
} else {
|
||||
plugin.getLocales().getLocale("error_invalid_syntax", "/delhome <name>")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
@@ -39,24 +40,49 @@ public class DelHomeCommand extends CommandBase implements TabCompletable, Conso
|
||||
return;
|
||||
}
|
||||
}
|
||||
plugin.getSavedPositionManager().deleteHome(userData.user(), homeIdentifier.homeName());
|
||||
deletePlayerHome(onlineUser, userData.user(), homeName);
|
||||
},
|
||||
() -> plugin.getLocales().getLocale("error_home_invalid_other",
|
||||
homeIdentifier.ownerName(), homeIdentifier.homeName()).ifPresent(onlineUser::sendMessage))),
|
||||
() -> plugin.getSavedPositionManager().deleteHome(onlineUser, homeName));
|
||||
() -> deletePlayerHome(onlineUser, onlineUser, homeName));
|
||||
}
|
||||
default -> plugin.getLocales().getLocale("error_invalid_syntax", "/delhome <name>")
|
||||
.ifPresent(onlineUser::sendMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a player's home
|
||||
*
|
||||
* @param deleter the player who is deleting the home
|
||||
* @param homeOwner The player who owns the home
|
||||
* @param homeName The home name to delete
|
||||
*/
|
||||
private void deletePlayerHome(@NotNull OnlineUser deleter, @NotNull User homeOwner, @NotNull String homeName) {
|
||||
plugin.getSavedPositionManager().deleteHome(homeOwner, homeName).thenAccept(deleted -> {
|
||||
if (deleter.uuid.equals(homeOwner.uuid)) {
|
||||
if (deleted) {
|
||||
plugin.getLocales().getLocale("home_deleted", homeName).ifPresent(deleter::sendMessage);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("error_home_invalid_other", homeName).ifPresent(deleter::sendMessage);
|
||||
}
|
||||
} else {
|
||||
if (deleted) {
|
||||
plugin.getLocales().getLocale("home_deleted_other", homeOwner.username, homeName).ifPresent(deleter::sendMessage);
|
||||
} else {
|
||||
plugin.getLocales().getLocale("error_home_invalid_other", homeOwner.username, homeName).ifPresent(deleter::sendMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConsoleExecute(@NotNull String[] args) {
|
||||
|
||||
}
|
||||
|
||||
@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.startsWith(args.length >= 1 ? args[0] : ""))
|
||||
.sorted().collect(Collectors.toList());
|
||||
|
||||
Reference in new issue
Block a user