实现reload

This commit is contained in:
2024-12-20 04:31:33 +08:00
parent 145557b024
commit a9bfb32db0

View File

@@ -109,21 +109,44 @@ public class ZbCommand implements CommandExecutor, TabCompleter {
player.openBook(book);
}
protected void reload(Player player, String[] strings) throws SQLException {
if (strings.length > 1) {
player.sendMessage(ChatColor.RED + "命令过长");
return;
}
PlayerData data = PlayerMap.getCurrent().getPlayerData(player);
if (data == null) {
player.sendMessage(ChatColor.RED + "玩家未登录");
return;
}
data.locationListUpdate();
player.sendMessage("已重新载入数据");
}
protected boolean execute(Player player, String[] strings) {
if (strings.length < 1) {
player.sendMessage(ChatColor.RED + "语法错误:需要 [选项]");
return false;
}
if (strings[0].equals("add")) {
add(player, strings);
try {
switch (strings[0]) {
case "add":
add(player, strings);
break;
case "help":
help(player);
break;
case "remove":
remove(player, strings);
break;
case "reload":
reload(player, strings);
break;
}
} catch (SQLException e) {
player.sendMessage(ChatColor.RED + "服务器内部错误,请联系管理员");
CoordinateRecorder.getCurrent().getLogger().severe("SQL操作出错" + e.getMessage());
}
if (strings[0].equals("help")) {
help(player);
}
if (strings[0].equals("remove")) {
remove(player, strings);
}
return true;
}