Safety: Make edithome, editwarp and sethome execute asynchronously

This commit is contained in:
William278 committed 2022-09-06 14:16:44 +03:00
1 parent 300a01a2c2
commit 4fce90dbbe
3 files changed
+4 -4

No files matched your search

@@ -36,7 +36,7 @@ public class EditHomeCommand extends CommandBase implements TabCompletable {
RegexUtil.matchDisambiguatedHomeIdentifier(homeName).ifPresentOrElse(
homeIdentifier -> plugin.getDatabase().getUserDataByName(homeIdentifier.ownerName())
.thenAccept(optionalUserData -> optionalUserData.ifPresentOrElse(userData -> {
.thenAcceptAsync(optionalUserData -> optionalUserData.ifPresentOrElse(userData -> {
if (!userData.getUserUuid().equals(onlineUser.uuid)) {
if (!onlineUser.hasPermission(Permission.COMMAND_EDIT_HOME_OTHER.node)) {
plugin.getLocales().getLocale("error_no_permission")
@@ -58,7 +58,7 @@ public class EditHomeCommand extends CommandBase implements TabCompletable {
() -> plugin.getLocales().getLocale("error_home_invalid_other",
homeIdentifier.ownerName(), homeIdentifier.homeName())
.ifPresent(onlineUser::sendMessage))),
() -> plugin.getDatabase().getHome(onlineUser, homeName).thenAccept(optionalHome -> {
() -> plugin.getDatabase().getHome(onlineUser, homeName).thenAcceptAsync(optionalHome -> {
if (optionalHome.isEmpty()) {
plugin.getLocales().getLocale("error_home_invalid", homeName)
.ifPresent(onlineUser::sendMessage);
@@ -31,7 +31,7 @@ public class EditWarpCommand extends CommandBase implements TabCompletable {
final String editOperation = args.length >= 2 ? args[1] : null;
final String editArgs = getEditArguments(args);
plugin.getDatabase().getWarp(warpName).thenAccept(optionalWarp -> {
plugin.getDatabase().getWarp(warpName).thenAcceptAsync(optionalWarp -> {
if (optionalWarp.isEmpty()) {
plugin.getLocales().getLocale("error_warp_invalid", warpName)
.ifPresent(onlineUser::sendMessage);
@@ -21,7 +21,7 @@ public class SetHomeCommand extends CommandBase {
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
plugin.getDatabase().getHomes(onlineUser).thenAccept(homes -> {
plugin.getDatabase().getHomes(onlineUser).thenAcceptAsync(homes -> {
switch (args.length) {
case 0 -> {
if (homes.isEmpty()) {