Add checks for unicode in home/description names if enabled

This commit is contained in:
William committed 2022-08-24 18:19:13 +01:00
1 parent e90fc481a9
commit 1c6902fc9e
8 files changed
+36 -19

No files matched your search

@@ -22,9 +22,11 @@ public class DelWarpCommand extends CommandBase implements TabCompletable {
final String warpName = args[0];
plugin.getSavedPositionManager().deleteWarp(warpName).thenAccept(deleted -> {
if (deleted) {
plugin.getLocales().getLocale("warp_deleted").ifPresent(onlineUser::sendMessage);
plugin.getLocales().getLocale("warp_deleted", warpName)
.ifPresent(onlineUser::sendMessage);
} else {
plugin.getLocales().getLocale("error_warp_invalid", warpName).ifPresent(onlineUser::sendMessage);
plugin.getLocales().getLocale("error_warp_invalid", warpName)
.ifPresent(onlineUser::sendMessage);
}
});
} else {
@@ -130,7 +130,7 @@ public class EditHomeCommand extends CommandBase implements TabCompletable {
case FAILED_DUPLICATE -> plugin.getLocales().getLocale("error_home_name_taken");
case FAILED_NAME_LENGTH -> plugin.getLocales().getLocale("error_home_name_length");
case FAILED_NAME_CHARACTERS -> plugin.getLocales().getLocale("error_home_name_characters");
default -> Optional.of(new MineDown(""));
default -> plugin.getLocales().getLocale("error_home_description_characters");
}).ifPresent(editor::sendMessage));
}
case "description" -> {
@@ -161,7 +161,7 @@ public class EditHomeCommand extends CommandBase implements TabCompletable {
plugin.getLocales().getLocale("error_home_description_length");
case FAILED_DESCRIPTION_CHARACTERS ->
plugin.getLocales().getLocale("error_home_description_characters");
default -> Optional.of(new MineDown(""));
default -> plugin.getLocales().getLocale("error_home_name_characters");
}).ifPresent(editor::sendMessage));
}
case "relocate" ->
@@ -92,7 +92,7 @@ public class EditWarpCommand extends CommandBase implements TabCompletable {
case FAILED_DUPLICATE -> plugin.getLocales().getLocale("error_warp_name_taken");
case FAILED_NAME_LENGTH -> plugin.getLocales().getLocale("error_warp_name_length");
case FAILED_NAME_CHARACTERS -> plugin.getLocales().getLocale("error_warp_name_characters");
default -> Optional.of(new MineDown(""));
default -> plugin.getLocales().getLocale("error_warp_description_characters");
}).ifPresent(editor::sendMessage));
}
case "description" -> {
@@ -111,7 +111,7 @@ public class EditWarpCommand extends CommandBase implements TabCompletable {
plugin.getLocales().getLocale("error_warp_description_length");
case FAILED_DESCRIPTION_CHARACTERS ->
plugin.getLocales().getLocale("error_warp_description_characters");
default -> Optional.of(new MineDown(""));
default -> plugin.getLocales().getLocale("error_warp_name_characters");
}).ifPresent(editor::sendMessage));
}
case "relocate" ->
@@ -102,7 +102,7 @@ public class SetHomeCommand extends CommandBase {
case FAILED_DUPLICATE -> plugin.getLocales().getLocale("error_home_name_taken");
case FAILED_NAME_LENGTH -> plugin.getLocales().getLocale("error_home_name_length");
case FAILED_NAME_CHARACTERS -> plugin.getLocales().getLocale("error_home_name_characters");
default -> Optional.of(new MineDown(""));
default -> plugin.getLocales().getLocale("error_home_description_characters");
}).ifPresent(onlineUser::sendMessage);
}
@@ -1,14 +1,11 @@
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.position.PositionMeta;
import net.william278.huskhomes.util.Permission;
import org.jetbrains.annotations.NotNull;
import java.util.Optional;
public class SetWarpCommand extends CommandBase {
protected SetWarpCommand(@NotNull HuskHomes implementor) {
@@ -37,7 +34,7 @@ public class SetWarpCommand extends CommandBase {
case FAILED_DUPLICATE -> plugin.getLocales().getLocale("error_warp_name_taken");
case FAILED_NAME_LENGTH -> plugin.getLocales().getLocale("error_warp_name_length");
case FAILED_NAME_CHARACTERS -> plugin.getLocales().getLocale("error_warp_name_characters");
default -> Optional.of(new MineDown(""));
default -> plugin.getLocales().getLocale("error_warp_description_characters");
}).ifPresent(onlineUser::sendMessage));
}