mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2025-01-12 00:24:27 +08:00
Merge branch 'cui_test'
# Conflicts: # pom.xml
This commit is contained in:
commit
ee59530e0a
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>Dominion</artifactId>
|
||||
<version>1.26.7-beta</version>
|
||||
<version>1.27.0-beta</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Dominion</name>
|
||||
|
@ -149,6 +149,19 @@ public class Commands implements TabExecutor {
|
||||
case "set_config":
|
||||
SetConfig.handler(sender, args);
|
||||
break;
|
||||
// ---=== CUI ===---
|
||||
case "cui_rename":
|
||||
OpenCUI.RenameDominion(sender, args);
|
||||
break;
|
||||
case "cui_edit_join_message":
|
||||
OpenCUI.EditJoinMessage(sender, args);
|
||||
break;
|
||||
case "cui_edit_leave_message":
|
||||
OpenCUI.EditLeaveMessage(sender, args);
|
||||
break;
|
||||
case "cui_create":
|
||||
OpenCUI.CreateDominion(sender, args);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import cn.lunadeer.dominion.events.SelectPointEvents;
|
||||
import cn.lunadeer.dominion.managers.ConfigManager;
|
||||
import cn.lunadeer.dominion.managers.DatabaseTables;
|
||||
import cn.lunadeer.minecraftpluginutils.*;
|
||||
import cn.lunadeer.minecraftpluginutils.scui.CuiManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -58,6 +59,10 @@ public final class Dominion extends JavaPlugin {
|
||||
"Dominion");
|
||||
}
|
||||
|
||||
// SCUI 初始化
|
||||
Bukkit.getPluginManager().registerEvents(new CuiManager(this), this);
|
||||
CuiManager.instance.setDebug(config.isDebug());
|
||||
|
||||
logger.info("领地插件已启动");
|
||||
logger.info("版本:" + this.getPluginMeta().getVersion());
|
||||
// http://patorjk.com/software/taag/#p=display&f=Big&t=Dominion
|
||||
|
135
src/main/java/cn/lunadeer/dominion/commands/OpenCUI.java
Normal file
135
src/main/java/cn/lunadeer/dominion/commands/OpenCUI.java
Normal file
@ -0,0 +1,135 @@
|
||||
package cn.lunadeer.dominion.commands;
|
||||
|
||||
import cn.lunadeer.dominion.Dominion;
|
||||
import cn.lunadeer.dominion.controllers.DominionController;
|
||||
import cn.lunadeer.dominion.dtos.DominionDTO;
|
||||
import cn.lunadeer.dominion.tuis.DominionManage;
|
||||
import cn.lunadeer.minecraftpluginutils.scui.CuiTextInput;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.lunadeer.dominion.commands.Apis.autoPoints;
|
||||
import static cn.lunadeer.dominion.commands.Apis.playerOnly;
|
||||
|
||||
public class OpenCUI {
|
||||
private static class renameDominionCB implements CuiTextInput.InputCallback {
|
||||
private final Player sender;
|
||||
private final String oldName;
|
||||
|
||||
public renameDominionCB(Player sender, String oldName) {
|
||||
this.sender = sender;
|
||||
this.oldName = oldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleData(String input) {
|
||||
Dominion.logger.debug("renameDominionCB.run: %s", input);
|
||||
DominionController.rename(sender, oldName, input);
|
||||
DominionManage.show(sender, new String[]{"manage", input});
|
||||
}
|
||||
}
|
||||
|
||||
private static class editJoinMessageCB implements CuiTextInput.InputCallback {
|
||||
private final Player sender;
|
||||
private final String dominionName;
|
||||
|
||||
public editJoinMessageCB(Player sender, String dominionName) {
|
||||
this.sender = sender;
|
||||
this.dominionName = dominionName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleData(String input) {
|
||||
Dominion.logger.debug("editJoinMessageCB.run: %s", input);
|
||||
DominionController.setJoinMessage(sender, input, dominionName);
|
||||
DominionManage.show(sender, new String[]{"manage", dominionName});
|
||||
}
|
||||
}
|
||||
|
||||
private static class editLeaveMessageCB implements CuiTextInput.InputCallback {
|
||||
private final Player sender;
|
||||
private final String dominionName;
|
||||
|
||||
public editLeaveMessageCB(Player sender, String dominionName) {
|
||||
this.sender = sender;
|
||||
this.dominionName = dominionName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleData(String input) {
|
||||
Dominion.logger.debug("editLeaveMessageCB.run: %s", input);
|
||||
DominionController.setLeaveMessage(sender, input, dominionName);
|
||||
DominionManage.show(sender, new String[]{"manage", dominionName});
|
||||
}
|
||||
}
|
||||
|
||||
private static class createDominionCB implements CuiTextInput.InputCallback {
|
||||
private final Player sender;
|
||||
|
||||
public createDominionCB(Player sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleData(String input) {
|
||||
Dominion.logger.debug("createDominionCB.run: %s", input);
|
||||
autoPoints(sender);
|
||||
Map<Integer, Location> points = Dominion.pointsSelect.get(sender.getUniqueId());
|
||||
if (points == null || points.get(0) == null || points.get(1) == null) {
|
||||
Dominion.notification.error(sender, "自动选点失败");
|
||||
return;
|
||||
}
|
||||
if (DominionController.create(sender, input, points.get(0), points.get(1)) != null) {
|
||||
Dominion.notification.info(sender, "成功创建: %s", input);
|
||||
DominionManage.show(sender, new String[]{"list"});
|
||||
} else {
|
||||
Dominion.notification.error(sender, "创建领地失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RenameDominion(CommandSender sender, String[] args) {
|
||||
Player player = playerOnly(sender);
|
||||
if (player == null) return;
|
||||
CuiTextInput.InputCallback renameDominionCB = new renameDominionCB(player, args[1]);
|
||||
CuiTextInput view = CuiTextInput.create(renameDominionCB).setText(args[1]).title("领地重命名");
|
||||
view.open(player);
|
||||
}
|
||||
|
||||
public static void EditJoinMessage(CommandSender sender, String[] args) {
|
||||
Player player = playerOnly(sender);
|
||||
if (player == null) return;
|
||||
DominionDTO dominion = DominionDTO.select(args[1]);
|
||||
if (dominion == null) {
|
||||
Dominion.notification.error(sender, "领地不存在");
|
||||
return;
|
||||
}
|
||||
CuiTextInput.InputCallback editJoinMessageCB = new editJoinMessageCB(player, dominion.getName());
|
||||
CuiTextInput view = CuiTextInput.create(editJoinMessageCB).setText(dominion.getJoinMessage()).title("编辑欢迎提示语");
|
||||
view.open(player);
|
||||
}
|
||||
|
||||
public static void EditLeaveMessage(CommandSender sender, String[] args) {
|
||||
Player player = playerOnly(sender);
|
||||
if (player == null) return;
|
||||
DominionDTO dominion = DominionDTO.select(args[1]);
|
||||
if (dominion == null) {
|
||||
Dominion.notification.error(sender, "领地不存在");
|
||||
return;
|
||||
}
|
||||
CuiTextInput.InputCallback editLeaveMessageCB = new editLeaveMessageCB(player, dominion.getName());
|
||||
CuiTextInput view = CuiTextInput.create(editLeaveMessageCB).setText(dominion.getLeaveMessage()).title("编辑离开提示语");
|
||||
view.open(player);
|
||||
}
|
||||
|
||||
public static void CreateDominion(CommandSender sender, String[] args) {
|
||||
Player player = playerOnly(sender);
|
||||
if (player == null) return;
|
||||
CuiTextInput.InputCallback createDominionCB = new createDominionCB(player);
|
||||
CuiTextInput view = CuiTextInput.create(createDominionCB).setText("未命名领地").title("输入要创建的领地名称");
|
||||
view.open(player);
|
||||
}
|
||||
}
|
@ -527,6 +527,10 @@ public class DominionController {
|
||||
Dominion.notification.error(operator, "领地名称不能包含空格");
|
||||
return;
|
||||
}
|
||||
if (Objects.equals(old_name, new_name)) {
|
||||
Dominion.notification.error(operator, "新名称与旧名称相同");
|
||||
return;
|
||||
}
|
||||
DominionDTO dominion = getExistDomAndIsOwner(operator, old_name);
|
||||
if (dominion == null) {
|
||||
return;
|
||||
|
@ -34,6 +34,15 @@ public class DominionManage {
|
||||
Line set_tp = Line.create()
|
||||
.append(Button.create("设置传送点").setExecuteCommand("/dominion set_tp_location " + dominion.getName()).build())
|
||||
.append("设置当前位置为此领地传送点");
|
||||
Line rename = Line.create()
|
||||
.append(Button.create("重命名").setExecuteCommand("/dominion cui_rename " + dominion.getName()).build())
|
||||
.append("重命名领地");
|
||||
Line join_msg = Line.create()
|
||||
.append(Button.create("编辑欢迎提示语").setExecuteCommand("/dominion cui_edit_join_message " + dominion.getName()).build())
|
||||
.append("当玩家进入领地时显示的消息");
|
||||
Line leave_msg = Line.create()
|
||||
.append(Button.create("编辑离开提示语").setExecuteCommand("/dominion cui_edit_leave_message " + dominion.getName()).build())
|
||||
.append("当玩家离开领地时显示的消息");
|
||||
ListView view = ListView.create(10, "/dominion manage " + dominion.getName());
|
||||
view.title("领地 " + dominion.getName() + " 管理界面")
|
||||
.navigator(Line.create()
|
||||
@ -44,6 +53,9 @@ public class DominionManage {
|
||||
.add(flag_info)
|
||||
.add(privilege_list)
|
||||
.add(set_tp)
|
||||
.add(rename)
|
||||
.add(join_msg)
|
||||
.add(leave_msg)
|
||||
.showOn(player, 1);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ public class Menu {
|
||||
public static void show(CommandSender sender, String[] args) {
|
||||
Player player = playerOnly(sender);
|
||||
if (player == null) return;
|
||||
Line create = Line.create()
|
||||
.append(Button.create("创建领地").setExecuteCommand("/dominion cui_create").build())
|
||||
.append("以你为中心自动创建一个新的领地");
|
||||
Line list = Line.create()
|
||||
.append(Button.create("我的领地").setExecuteCommand("/dominion list").build())
|
||||
.append("查看我的领地");
|
||||
@ -33,6 +36,7 @@ public class Menu {
|
||||
ListView view = ListView.create(10, "/dominion");
|
||||
view.title("Dominion 领地系统")
|
||||
.navigator(Line.create().append("主菜单"))
|
||||
.add(create)
|
||||
.add(list)
|
||||
.add(help)
|
||||
.add(link);
|
||||
|
Loading…
Reference in New Issue
Block a user