mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2024-12-24 11:28:59 +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>
|
<groupId>cn.lunadeer</groupId>
|
||||||
<artifactId>Dominion</artifactId>
|
<artifactId>Dominion</artifactId>
|
||||||
<version>1.26.7-beta</version>
|
<version>1.27.0-beta</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Dominion</name>
|
<name>Dominion</name>
|
||||||
|
@ -149,6 +149,19 @@ public class Commands implements TabExecutor {
|
|||||||
case "set_config":
|
case "set_config":
|
||||||
SetConfig.handler(sender, args);
|
SetConfig.handler(sender, args);
|
||||||
break;
|
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:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import cn.lunadeer.dominion.events.SelectPointEvents;
|
|||||||
import cn.lunadeer.dominion.managers.ConfigManager;
|
import cn.lunadeer.dominion.managers.ConfigManager;
|
||||||
import cn.lunadeer.dominion.managers.DatabaseTables;
|
import cn.lunadeer.dominion.managers.DatabaseTables;
|
||||||
import cn.lunadeer.minecraftpluginutils.*;
|
import cn.lunadeer.minecraftpluginutils.*;
|
||||||
|
import cn.lunadeer.minecraftpluginutils.scui.CuiManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -58,6 +59,10 @@ public final class Dominion extends JavaPlugin {
|
|||||||
"Dominion");
|
"Dominion");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SCUI 初始化
|
||||||
|
Bukkit.getPluginManager().registerEvents(new CuiManager(this), this);
|
||||||
|
CuiManager.instance.setDebug(config.isDebug());
|
||||||
|
|
||||||
logger.info("领地插件已启动");
|
logger.info("领地插件已启动");
|
||||||
logger.info("版本:" + this.getPluginMeta().getVersion());
|
logger.info("版本:" + this.getPluginMeta().getVersion());
|
||||||
// http://patorjk.com/software/taag/#p=display&f=Big&t=Dominion
|
// 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, "领地名称不能包含空格");
|
Dominion.notification.error(operator, "领地名称不能包含空格");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (Objects.equals(old_name, new_name)) {
|
||||||
|
Dominion.notification.error(operator, "新名称与旧名称相同");
|
||||||
|
return;
|
||||||
|
}
|
||||||
DominionDTO dominion = getExistDomAndIsOwner(operator, old_name);
|
DominionDTO dominion = getExistDomAndIsOwner(operator, old_name);
|
||||||
if (dominion == null) {
|
if (dominion == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -34,6 +34,15 @@ public class DominionManage {
|
|||||||
Line set_tp = Line.create()
|
Line set_tp = Line.create()
|
||||||
.append(Button.create("设置传送点").setExecuteCommand("/dominion set_tp_location " + dominion.getName()).build())
|
.append(Button.create("设置传送点").setExecuteCommand("/dominion set_tp_location " + dominion.getName()).build())
|
||||||
.append("设置当前位置为此领地传送点");
|
.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());
|
ListView view = ListView.create(10, "/dominion manage " + dominion.getName());
|
||||||
view.title("领地 " + dominion.getName() + " 管理界面")
|
view.title("领地 " + dominion.getName() + " 管理界面")
|
||||||
.navigator(Line.create()
|
.navigator(Line.create()
|
||||||
@ -44,6 +53,9 @@ public class DominionManage {
|
|||||||
.add(flag_info)
|
.add(flag_info)
|
||||||
.add(privilege_list)
|
.add(privilege_list)
|
||||||
.add(set_tp)
|
.add(set_tp)
|
||||||
|
.add(rename)
|
||||||
|
.add(join_msg)
|
||||||
|
.add(leave_msg)
|
||||||
.showOn(player, 1);
|
.showOn(player, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,9 @@ public class Menu {
|
|||||||
public static void show(CommandSender sender, String[] args) {
|
public static void show(CommandSender sender, String[] args) {
|
||||||
Player player = playerOnly(sender);
|
Player player = playerOnly(sender);
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
Line create = Line.create()
|
||||||
|
.append(Button.create("创建领地").setExecuteCommand("/dominion cui_create").build())
|
||||||
|
.append("以你为中心自动创建一个新的领地");
|
||||||
Line list = Line.create()
|
Line list = Line.create()
|
||||||
.append(Button.create("我的领地").setExecuteCommand("/dominion list").build())
|
.append(Button.create("我的领地").setExecuteCommand("/dominion list").build())
|
||||||
.append("查看我的领地");
|
.append("查看我的领地");
|
||||||
@ -33,6 +36,7 @@ public class Menu {
|
|||||||
ListView view = ListView.create(10, "/dominion");
|
ListView view = ListView.create(10, "/dominion");
|
||||||
view.title("Dominion 领地系统")
|
view.title("Dominion 领地系统")
|
||||||
.navigator(Line.create().append("主菜单"))
|
.navigator(Line.create().append("主菜单"))
|
||||||
|
.add(create)
|
||||||
.add(list)
|
.add(list)
|
||||||
.add(help)
|
.add(help)
|
||||||
.add(link);
|
.add(link);
|
||||||
|
Loading…
Reference in New Issue
Block a user