禁止使用空字符串作为领地名称

This commit is contained in:
zhangyuheng 2024-05-27 10:17:11 +08:00
parent 23a9523ae2
commit 52887016db
2 changed files with 9 additions and 1 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>Dominion</artifactId>
<version>1.28.1-beta</version>
<version>1.28.2-beta</version>
<packaging>jar</packaging>
<name>Dominion</name>

View File

@ -57,6 +57,10 @@ public class DominionController {
public static DominionDTO create(Player owner, String name,
Location loc1, Location loc2,
String parent_dominion_name) {
if (name.isEmpty()) {
Dominion.notification.error(owner, "领地名称不能为空");
return null;
}
if (name.contains(" ")) {
Dominion.notification.error(owner, "领地名称不能包含空格");
return null;
@ -523,6 +527,10 @@ public class DominionController {
* @param new_name 新名称
*/
public static void rename(Player operator, String old_name, String new_name) {
if (new_name.isEmpty()) {
Dominion.notification.error(operator, "新名称不能为空");
return;
}
if (new_name.contains(" ")) {
Dominion.notification.error(operator, "领地名称不能包含空格");
return;