新增提示语指令支持
All checks were successful
Java CI-CD with Maven / build (push) Successful in 38m14s

This commit is contained in:
zhangyuheng 2024-02-22 14:20:43 +08:00
parent 7482aba2a8
commit b797140d30
6 changed files with 64 additions and 2 deletions

View File

@ -139,6 +139,8 @@
| 重置玩家特权 | `/dominion clear_privilege <玩家名称> [领地名称]` |
| 查看领地玩家特权列表 | `/dominion privilege_list [领地名称] [页码]` |
| 查看玩家特权信息 | `/dominion privilege_info <玩家名称> [领地名称] [页码]` |
| 设置进入领地的提示语 | `/dominion set_enter_msg <提示语> [领地名称]` |
| 设置离开领地的提示语 | `/dominion set_leave_msg <提示语> [领地名称]` |
### 管理员指令

View File

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

View File

@ -117,6 +117,12 @@ public class Commands implements TabExecutor {
case "select_player_create_privilege":
SelectPlayer.show(sender, args);
break;
case "set_enter_msg":
DominionOperate.setEnterMessage(sender, args);
break;
case "set_leave_msg":
DominionOperate.setLeaveMessage(sender, args);
break;
default:
return false;
}
@ -141,7 +147,9 @@ public class Commands implements TabExecutor {
if (args.length == 1) {
return Arrays.asList("menu", "help", "info", "manage", "flag_info", "group_list", "privilege_list", "group",
"create", "auto_create", "create_sub", "auto_create_sub", "expand", "contract", "delete", "set",
"create_privilege", "set_privilege", "clear_privilege", "list", "privilege_info"
"create_privilege", "set_privilege", "clear_privilege", "list", "privilege_info",
"set_enter_msg",
"set_leave_msg"
);
}
if (args.length == 2) {
@ -171,6 +179,10 @@ public class Commands implements TabExecutor {
case "create_sub":
case "auto_create_sub":
return Collections.singletonList("子领地名称");
case "set_enter_msg":
return Collections.singletonList("进入提示语内容");
case "set_leave_msg":
return Collections.singletonList("离开提示语内容");
}
}
if (args.length == 3) {
@ -186,6 +198,8 @@ public class Commands implements TabExecutor {
case "privilege_info":
case "auto_create_sub":
case "create_sub":
case "set_enter_msg":
case "set_leave_msg":
return playerDominions(sender);
}
}

View File

@ -213,4 +213,46 @@ public class DominionOperate {
}
Notification.error(sender, "用法: /dominion delete <领地名称> [force]");
}
/**
* 设置领地进入提示
* /dominion set_enter_msg <提示语> [领地名称]
*
* @param sender 命令发送者
* @param args 命令参数
*/
public static void setEnterMessage(CommandSender sender, String[] args) {
Player player = playerOnly(sender);
if (player == null) return;
if (args.length == 2) {
DominionController.setJoinMessage(player, args[1]);
return;
}
if (args.length == 3) {
DominionController.setJoinMessage(player, args[1], args[2]);
return;
}
Notification.error(sender, "用法: /dominion set_enter_msg <提示语> [领地名称]");
}
/**
* 设置领地离开提示
* /dominion set_leave_msg <提示语> [领地名称]
*
* @param sender 命令发送者
* @param args 命令参数
*/
public static void setLeaveMessage(CommandSender sender, String[] args) {
Player player = playerOnly(sender);
if (player == null) return;
if (args.length == 2) {
DominionController.setLeaveMessage(player, args[1]);
return;
}
if (args.length == 3) {
DominionController.setLeaveMessage(player, args[1], args[2]);
return;
}
Notification.error(sender, "用法: /dominion set_leave_msg <提示语> [领地名称]");
}
}

View File

@ -360,6 +360,7 @@ public class DominionController {
return;
}
if (notOwner(operator, dominion)) {
Notification.error(operator, "你不是领地 " + dominion_name + " 的拥有者,无法执行此操作");
return;
}
dominion.setJoinMessage(message);
@ -393,6 +394,7 @@ public class DominionController {
return;
}
if (notOwner(operator, dominion)) {
Notification.error(operator, "你不是领地 " + dominion_name + " 的拥有者,无法执行此操作");
return;
}
dominion.setLeaveMessage(message);

View File

@ -95,6 +95,8 @@ public class Apis {
.add(Line.create().append("重置玩家特权").append("/dominion clear_privilege <玩家名称> [领地名称]"))
.add(Line.create().append("查看领地玩家特权列表").append("/dominion privilege_list [领地名称] [页码]"))
.add(Line.create().append("查看玩家特权信息").append("/dominion privilege_info <玩家名称> [领地名称] [页码]"))
.add(Line.create().append("设置进入领地的提示语").append("/dominion set_enter_msg <提示语> [领地名称]"))
.add(Line.create().append("设置离开领地的提示语").append("/dominion set_leave_msg <提示语> [领地名称]"))
.showOn(player, page);
}