mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2025-01-28 00:14:01 +08:00
管理员可通过游戏内TUI实现领地系统配置
This commit is contained in:
parent
21369533ea
commit
1eb31e2ce5
@ -36,6 +36,7 @@
|
||||
- 采用 TUI 方式进行权限配置交互,简单快捷;
|
||||
- 支持基础价格系统;
|
||||
- 领地区域可视化;
|
||||
- 管理员可在游戏内使用TUI配置领地系统;
|
||||
|
||||
## 支持版本
|
||||
|
||||
@ -44,7 +45,6 @@
|
||||
## TODO
|
||||
|
||||
- WebUI
|
||||
- Admin TUI
|
||||
|
||||
## 建议与反馈
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>Dominion</artifactId>
|
||||
<version>1.22.2-beta</version>
|
||||
<version>1.23.8-beta</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Dominion</name>
|
||||
|
@ -1,12 +1,10 @@
|
||||
package cn.lunadeer.dominion;
|
||||
|
||||
import cn.lunadeer.dominion.commands.DominionFlag;
|
||||
import cn.lunadeer.dominion.commands.DominionOperate;
|
||||
import cn.lunadeer.dominion.commands.Operator;
|
||||
import cn.lunadeer.dominion.commands.PlayerPrivilege;
|
||||
import cn.lunadeer.dominion.commands.*;
|
||||
import cn.lunadeer.dominion.controllers.PlayerController;
|
||||
import cn.lunadeer.dominion.dtos.PlayerDTO;
|
||||
import cn.lunadeer.dominion.tuis.*;
|
||||
import cn.lunadeer.dominion.tuis.Apis;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@ -149,6 +147,9 @@ public class Commands implements TabExecutor {
|
||||
case "config":
|
||||
DominionConfig.show(sender, args);
|
||||
break;
|
||||
case "set_config":
|
||||
SetConfig.handler(sender, args);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ public final class Dominion extends JavaPlugin {
|
||||
if (config.getEconomyEnable()) {
|
||||
vault = new VaultConnect(this);
|
||||
if (vault.getEconomy() == null) {
|
||||
XLogger.err("你没有安装 Vault 前置插件,无法使用经济功能。");
|
||||
config.setEconomyEnable(false);
|
||||
}
|
||||
}
|
||||
|
@ -391,8 +391,9 @@ public class DominionOperate {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Notification.info(player, "传送将在 " + Dominion.config.getTpDelay() + " 秒后执行");
|
||||
if (Dominion.config.getTpDelay() > 0) {
|
||||
Notification.info(player, "传送将在 " + Dominion.config.getTpDelay() + " 秒后执行");
|
||||
}
|
||||
Cache.instance.NextTimeAllowTeleport.put(player.getUniqueId(), now.plusSeconds(Dominion.config.getTpCoolDown()));
|
||||
Dominion.scheduler.region.runDelayed(Dominion.instance, (instance) -> {
|
||||
if (player.isOnline()) {
|
||||
|
254
src/main/java/cn/lunadeer/dominion/commands/SetConfig.java
Normal file
254
src/main/java/cn/lunadeer/dominion/commands/SetConfig.java
Normal file
@ -0,0 +1,254 @@
|
||||
package cn.lunadeer.dominion.commands;
|
||||
|
||||
import cn.lunadeer.dominion.Dominion;
|
||||
import cn.lunadeer.dominion.tuis.DominionConfig;
|
||||
import cn.lunadeer.dominion.utils.Notification;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static cn.lunadeer.dominion.commands.Apis.notOpOrConsole;
|
||||
|
||||
public class SetConfig {
|
||||
|
||||
public static void handler(CommandSender sender, String[] args) {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (args.length < 2) {
|
||||
Notification.error(sender, "参数错误");
|
||||
return;
|
||||
}
|
||||
switch (args[1]) {
|
||||
case "auto_create_radius":
|
||||
setAutoCreateRadius(sender, args);
|
||||
break;
|
||||
case "limit_max_y":
|
||||
setLimitMaxY(sender, args);
|
||||
break;
|
||||
case "limit_min_y":
|
||||
setLimitMinY(sender, args);
|
||||
break;
|
||||
case "limit_size_x":
|
||||
setLimitSizeX(sender, args);
|
||||
break;
|
||||
case "limit_size_z":
|
||||
setLimitSizeZ(sender, args);
|
||||
break;
|
||||
case "limit_size_y":
|
||||
setLimitSizeY(sender, args);
|
||||
break;
|
||||
case "limit_amount":
|
||||
setLimitAmount(sender, args);
|
||||
break;
|
||||
case "limit_depth":
|
||||
setLimitDepth(sender, args);
|
||||
break;
|
||||
case "limit_vert":
|
||||
setLimitVert(sender, args);
|
||||
break;
|
||||
case "limit_op_bypass":
|
||||
setLimitOpBypass(sender, args);
|
||||
break;
|
||||
case "tp_enable":
|
||||
setTpEnable(sender, args);
|
||||
break;
|
||||
case "tp_delay":
|
||||
setTpDelay(sender, args);
|
||||
break;
|
||||
case "tp_cool_down":
|
||||
setTpCoolDown(sender, args);
|
||||
break;
|
||||
case "economy_enable":
|
||||
setEconomyEnable(sender, args);
|
||||
break;
|
||||
case "economy_price":
|
||||
setEconomyPrice(sender, args);
|
||||
break;
|
||||
case "economy_only_xz":
|
||||
setEconomyOnlyXZ(sender, args);
|
||||
break;
|
||||
case "economy_refund":
|
||||
setEconomyRefund(sender, args);
|
||||
break;
|
||||
default:
|
||||
Notification.error(sender, "未知参数");
|
||||
}
|
||||
}
|
||||
|
||||
public static void refreshPageOrNot(CommandSender sender, String[] args) {
|
||||
if (args.length == 4) {
|
||||
int page = Integer.parseInt(args[3]);
|
||||
String[] newArgs = new String[2];
|
||||
newArgs[0] = "config";
|
||||
newArgs[1] = String.valueOf(page);
|
||||
DominionConfig.show(sender, newArgs);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setAutoCreateRadius(CommandSender sender, String[] args) {
|
||||
int size = Integer.parseInt(args[2]);
|
||||
if (size < 2) {
|
||||
Dominion.config.setAutoCreateRadius(2);
|
||||
Notification.error(sender, "自动创建半径不能小于2");
|
||||
} else {
|
||||
Dominion.config.setAutoCreateRadius(size);
|
||||
}
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void adjustSizeY() {
|
||||
if (Dominion.config.getLimitVert()) {
|
||||
Dominion.config.setLimitSizeY(Dominion.config.getLimitMaxY() - Dominion.config.getLimitMinY() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setLimitMaxY(CommandSender sender, String[] args) {
|
||||
int maxY = Integer.parseInt(args[2]);
|
||||
if (maxY <= Dominion.config.getLimitMinY()) {
|
||||
Notification.error(sender, "最高Y坐标限制不能小于最低Y坐标限制");
|
||||
return;
|
||||
}
|
||||
Dominion.config.setLimitMaxY(maxY);
|
||||
adjustSizeY();
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setLimitMinY(CommandSender sender, String[] args) {
|
||||
int minY = Integer.parseInt(args[2]);
|
||||
if (minY >= Dominion.config.getLimitMaxY()) {
|
||||
Notification.error(sender, "最低Y坐标限制不能大于最高Y坐标限制");
|
||||
return;
|
||||
}
|
||||
Dominion.config.setLimitMinY(minY);
|
||||
adjustSizeY();
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setLimitSizeX(CommandSender sender, String[] args) {
|
||||
int sizeX = Integer.parseInt(args[2]);
|
||||
if (sizeX != -1 && sizeX < 4) {
|
||||
Dominion.config.setLimitSizeX(4);
|
||||
Notification.error(sender, "X轴(东西)最大尺寸不能小于4");
|
||||
} else {
|
||||
Dominion.config.setLimitSizeX(sizeX);
|
||||
}
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setLimitSizeZ(CommandSender sender, String[] args) {
|
||||
int sizeZ = Integer.parseInt(args[2]);
|
||||
if (sizeZ != -1 && sizeZ < 4) {
|
||||
Dominion.config.setLimitSizeZ(4);
|
||||
Notification.error(sender, "Z轴(南北)最大尺寸不能小于4");
|
||||
return;
|
||||
} else {
|
||||
Dominion.config.setLimitSizeZ(sizeZ);
|
||||
}
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setLimitSizeY(CommandSender sender, String[] args) {
|
||||
int sizeY = Integer.parseInt(args[2]);
|
||||
if (sizeY != -1 && sizeY < 4) {
|
||||
Dominion.config.setLimitSizeY(4);
|
||||
Notification.error(sender, "Y轴(垂直)最大尺寸不能小于4");
|
||||
} else {
|
||||
Dominion.config.setLimitSizeY(sizeY);
|
||||
}
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setLimitAmount(CommandSender sender, String[] args) {
|
||||
int amount = Integer.parseInt(args[2]);
|
||||
if (amount != -1 && amount < 0) {
|
||||
Dominion.config.setLimitAmount(0);
|
||||
Notification.error(sender, "每个玩家领地数量限制不能小于0");
|
||||
} else {
|
||||
Dominion.config.setLimitAmount(amount);
|
||||
}
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setLimitDepth(CommandSender sender, String[] args) {
|
||||
int depth = Integer.parseInt(args[2]);
|
||||
if (depth != -1 && depth < 0) {
|
||||
Dominion.config.setLimitDepth(0);
|
||||
Notification.error(sender, "领地深度限制不能小于0");
|
||||
} else {
|
||||
Dominion.config.setLimitDepth(depth);
|
||||
}
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setLimitVert(CommandSender sender, String[] args) {
|
||||
boolean limitVert = Boolean.parseBoolean(args[2]);
|
||||
Dominion.config.setLimitVert(limitVert);
|
||||
adjustSizeY();
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setLimitOpBypass(CommandSender sender, String[] args) {
|
||||
boolean limitOpBypass = Boolean.parseBoolean(args[2]);
|
||||
Dominion.config.setLimitOpBypass(limitOpBypass);
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setTpEnable(CommandSender sender, String[] args) {
|
||||
boolean tpEnable = Boolean.parseBoolean(args[2]);
|
||||
Dominion.config.setTpEnable(tpEnable);
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setTpDelay(CommandSender sender, String[] args) {
|
||||
int tpDelay = Integer.parseInt(args[2]);
|
||||
if (tpDelay < 0) {
|
||||
Dominion.config.setTpDelay(0);
|
||||
Notification.error(sender, "传送延迟不能小于0");
|
||||
} else {
|
||||
Dominion.config.setTpDelay(tpDelay);
|
||||
}
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setTpCoolDown(CommandSender sender, String[] args) {
|
||||
int tpCoolDown = Integer.parseInt(args[2]);
|
||||
if (tpCoolDown < 0) {
|
||||
Dominion.config.setTpCoolDown(0);
|
||||
Notification.error(sender, "传送冷却时间不能小于0");
|
||||
} else {
|
||||
Dominion.config.setTpCoolDown(tpCoolDown);
|
||||
}
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setEconomyEnable(CommandSender sender, String[] args) {
|
||||
boolean economyEnable = Boolean.parseBoolean(args[2]);
|
||||
Dominion.config.setEconomyEnable(economyEnable);
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setEconomyPrice(CommandSender sender, String[] args) {
|
||||
float economyPrice = Float.parseFloat(args[2]);
|
||||
if (economyPrice < 0) {
|
||||
Dominion.config.setEconomyPrice(0.0f);
|
||||
Notification.error(sender, "每方块单价不能小于0");
|
||||
} else {
|
||||
Dominion.config.setEconomyPrice(economyPrice);
|
||||
}
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setEconomyOnlyXZ(CommandSender sender, String[] args) {
|
||||
boolean economyOnlyXZ = Boolean.parseBoolean(args[2]);
|
||||
Dominion.config.setEconomyOnlyXZ(economyOnlyXZ);
|
||||
refreshPageOrNot(sender, args);
|
||||
}
|
||||
|
||||
private static void setEconomyRefund(CommandSender sender, String[] args) {
|
||||
float economyRefund = Float.parseFloat(args[2]);
|
||||
if (economyRefund < 0) {
|
||||
Dominion.config.setEconomyRefund(0.0f);
|
||||
Notification.error(sender, "领地退款比例不能小于0");
|
||||
} else {
|
||||
Dominion.config.setEconomyRefund(economyRefund);
|
||||
}
|
||||
}
|
||||
}
|
@ -76,13 +76,11 @@ public class DominionController {
|
||||
return null;
|
||||
}
|
||||
// 检查世界是否可以创建
|
||||
if (Dominion.config.getWorldBlackList().contains(owner.getWorld().getName())) {
|
||||
Notification.error(owner, "禁止在世界 " + owner.getWorld().getName() + " 创建领地");
|
||||
if (worldNotValid(owner)) {
|
||||
return null;
|
||||
}
|
||||
// 检查领地数量是否达到上限
|
||||
if (Cache.instance.getPlayerDominionCount(owner) >= Dominion.config.getLimitAmount() && Dominion.config.getLimitAmount() > 0) {
|
||||
Notification.error(owner, "你的领地数量已达上限,当前上限为 " + Dominion.config.getLimitAmount());
|
||||
if (amountNotValid(owner)) {
|
||||
return null;
|
||||
}
|
||||
// 检查领地大小是否合法
|
||||
@ -677,6 +675,9 @@ public class DominionController {
|
||||
}
|
||||
|
||||
private static boolean sizeNotValid(Player operator, int x1, int y1, int z1, int x2, int y2, int z2) {
|
||||
if (operator.isOp() && Dominion.config.getLimitOpBypass()) {
|
||||
return false;
|
||||
}
|
||||
// 如果 1 > 2 则交换
|
||||
if (x1 > x2) {
|
||||
int temp = x1;
|
||||
@ -712,11 +713,11 @@ public class DominionController {
|
||||
Notification.error(operator, "领地Z方向长度不能超过 " + Dominion.config.getLimitSizeZ());
|
||||
return true;
|
||||
}
|
||||
if (y2 > Dominion.config.getLimitMaxY() && Dominion.config.getLimitMaxY() > 0) {
|
||||
if (y2 > Dominion.config.getLimitMaxY()) {
|
||||
Notification.error(operator, "领地Y坐标不能超过 " + Dominion.config.getLimitMaxY());
|
||||
return true;
|
||||
}
|
||||
if (y1 < Dominion.config.getLimitMinY() && Dominion.config.getLimitMinY() > 0) {
|
||||
if (y1 < Dominion.config.getLimitMinY()) {
|
||||
Notification.error(operator, "领地Y坐标不能低于 " + Dominion.config.getLimitMinY());
|
||||
return true;
|
||||
}
|
||||
@ -724,7 +725,10 @@ public class DominionController {
|
||||
}
|
||||
|
||||
private static boolean depthNotValid(Player operator, DominionDTO parent_dom) {
|
||||
if (Dominion.config.getLimitDepth() < 0) {
|
||||
if (operator.isOp() && Dominion.config.getLimitOpBypass()) {
|
||||
return false;
|
||||
}
|
||||
if (Dominion.config.getLimitDepth() == -1) {
|
||||
return false;
|
||||
}
|
||||
if (parent_dom.getId() != -1 && Dominion.config.getLimitDepth() == 0) {
|
||||
@ -745,4 +749,26 @@ public class DominionController {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean amountNotValid(Player operator) {
|
||||
if (operator.isOp() && Dominion.config.getLimitOpBypass()) {
|
||||
return false;
|
||||
}
|
||||
if (Cache.instance.getPlayerDominionCount(operator) >= Dominion.config.getLimitAmount() && Dominion.config.getLimitAmount() != -1) {
|
||||
Notification.error(operator, "你的领地数量已达上限,当前上限为 " + Dominion.config.getLimitAmount());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean worldNotValid(Player operator) {
|
||||
if (operator.isOp() && Dominion.config.getLimitOpBypass()) {
|
||||
return false;
|
||||
}
|
||||
if (Dominion.config.getWorldBlackList().contains(operator.getWorld().getName())) {
|
||||
Notification.error(operator, "禁止在世界 " + operator.getWorld().getName() + " 创建领地");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,13 @@
|
||||
package cn.lunadeer.dominion.tuis;
|
||||
|
||||
import cn.lunadeer.dominion.Dominion;
|
||||
import cn.lunadeer.dominion.utils.STUI.Button;
|
||||
import cn.lunadeer.dominion.utils.STUI.NumChanger;
|
||||
import cn.lunadeer.dominion.utils.STUI.Line;
|
||||
import cn.lunadeer.dominion.utils.STUI.ListView;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -17,7 +22,133 @@ public class DominionConfig {
|
||||
ListView view = ListView.create(10, "/dominion config");
|
||||
view.title("系统配置");
|
||||
view.navigator(Line.create().append(Button.create("主菜单", "/dominion menu")).append("系统配置"));
|
||||
// todo: add config items
|
||||
|
||||
Line limitSize = Line.create()
|
||||
.append(Component.text("领地尺寸限制"));
|
||||
view.add(limitSize);
|
||||
Line limitSizeX = Line.create()
|
||||
.append(Component.text(" X轴(东西)"));
|
||||
if (Dominion.config.getLimitSizeX() == -1) {
|
||||
limitSizeX.append(Component.text("无限制")).append(Button.create("设置数值", "/dominion set_config limit_size_x 64 " + page));
|
||||
} else {
|
||||
limitSizeX.append(NumChanger.create(Dominion.config.getLimitSizeX(), "/dominion set_config limit_size_x").setPageNumber(page).build());
|
||||
limitSizeX.append(Button.create("设置无限制", "/dominion set_config limit_size_x -1 " + page));
|
||||
}
|
||||
view.add(limitSizeX);
|
||||
Line limitSizeZ = Line.create()
|
||||
.append(Component.text(" Z轴(南北)"));
|
||||
if (Dominion.config.getLimitSizeZ() == -1) {
|
||||
limitSizeZ.append(Component.text("无限制")).append(Button.create("设置数值", "/dominion set_config limit_size_z 64 " + page));
|
||||
} else {
|
||||
limitSizeZ.append(NumChanger.create(Dominion.config.getLimitSizeZ(), "/dominion set_config limit_size_z").setPageNumber(page).build());
|
||||
limitSizeZ.append(Button.create("设置无限制", "/dominion set_config limit_size_z -1 " + page));
|
||||
}
|
||||
view.add(limitSizeZ);
|
||||
Line limitSizeY = Line.create()
|
||||
.append(Component.text(" Y轴(垂直)"));
|
||||
if (!Dominion.config.getLimitVert()) {
|
||||
if (Dominion.config.getLimitSizeY() == -1) {
|
||||
limitSizeY.append(Component.text("无限制")).append(Button.create("设置数值", "/dominion set_config limit_size_y 64 " + page));
|
||||
} else {
|
||||
limitSizeY.append(NumChanger.create(Dominion.config.getLimitSizeY(), "/dominion set_config limit_size_y").setPageNumber(page).build());
|
||||
limitSizeY.append(Button.create("设置无限制", "/dominion set_config limit_size_y -1 " + page));
|
||||
}
|
||||
} else {
|
||||
limitSizeY.append(Component.text(Dominion.config.getLimitSizeY())
|
||||
.style(Style.style(TextDecoration.STRIKETHROUGH))
|
||||
.hoverEvent(Component.text("因为垂直自动延伸已开启,此设置不可手动修改")));
|
||||
}
|
||||
view.add(limitSizeY);
|
||||
if (Dominion.config.getLimitVert()) {
|
||||
view.add(Line.create()
|
||||
.append("垂直自动延伸")
|
||||
.append(Button.createGreen("☑", "/dominion set_config limit_vert false " + page)));
|
||||
} else {
|
||||
view.add(Line.create()
|
||||
.append("垂直自动延伸")
|
||||
.append(Button.createRed("☐", "/dominion set_config limit_vert true " + page)));
|
||||
}
|
||||
Line limitMaxY = Line.create()
|
||||
.append(Component.text("最高Y坐标限制"));
|
||||
limitMaxY.append(NumChanger.create(Dominion.config.getLimitMaxY(), "/dominion set_config limit_max_y").setPageNumber(page).build());
|
||||
view.add(limitMaxY);
|
||||
Line limitMinY = Line.create()
|
||||
.append(Component.text("最低Y坐标限制"));
|
||||
limitMinY.append(NumChanger.create(Dominion.config.getLimitMinY(), "/dominion set_config limit_min_y").setPageNumber(page).build());
|
||||
view.add(limitMinY);
|
||||
Line limitAmount = Line.create()
|
||||
.append(Component.text("每个玩家领地数量限制"));
|
||||
if (Dominion.config.getLimitAmount() == -1) {
|
||||
limitAmount.append(Component.text("无限制")).append(Button.create("设置数值", "/dominion set_config limit_amount 3 " + page));
|
||||
} else {
|
||||
limitAmount.append(NumChanger.create(Dominion.config.getLimitAmount(), "/dominion set_config limit_amount").setPageNumber(page).build());
|
||||
limitAmount.append(Button.create("设置无限制", "/dominion set_config limit_amount -1 " + page));
|
||||
}
|
||||
view.add(limitAmount);
|
||||
Line limitDepth = Line.create()
|
||||
.append(Component.text("领地深度限制"));
|
||||
if (Dominion.config.getLimitDepth() == -1) {
|
||||
limitDepth.append(Component.text("无限制")).append(Button.create("设置数值", "/dominion set_config limit_depth 64 " + page));
|
||||
} else {
|
||||
limitDepth.append(NumChanger.create(Dominion.config.getLimitDepth(), "/dominion set_config limit_depth").setPageNumber(page).build());
|
||||
limitDepth.append(Button.create("设置无限制", "/dominion set_config limit_depth -1 " + page));
|
||||
}
|
||||
view.add(limitDepth);
|
||||
|
||||
if (Dominion.config.getLimitOpBypass()) {
|
||||
view.add(Line.create()
|
||||
.append("OP是否可以无视限制")
|
||||
.append(Button.createGreen("☑", "/dominion set_config limit_op_bypass false " + page)));
|
||||
} else {
|
||||
view.add(Line.create()
|
||||
.append("OP是否可以无视限制")
|
||||
.append(Button.createRed("☐", "/dominion set_config limit_op_bypass true " + page)));
|
||||
}
|
||||
|
||||
Line autoCreateRadius = Line.create()
|
||||
.append(Component.text("自动创建半径"))
|
||||
.append(NumChanger.create(Dominion.config.getAutoCreateRadius(), "/dominion set_config auto_create_radius").setPageNumber(page).build());
|
||||
view.add(autoCreateRadius);
|
||||
|
||||
if (Dominion.config.getTpEnable()) {
|
||||
view.add(Line.create()
|
||||
.append("领地传送功能")
|
||||
.append(Button.createGreen("☑", "/dominion set_config tp_enable false " + page)));
|
||||
} else {
|
||||
view.add(Line.create()
|
||||
.append("领地传送功能")
|
||||
.append(Button.createRed("☐", "/dominion set_config tp_enable true " + page)));
|
||||
}
|
||||
Line tpDelay = Line.create()
|
||||
.append(Component.text(" 传送延迟"))
|
||||
.append(NumChanger.create(Dominion.config.getTpDelay(), "/dominion set_config tp_delay").setPageNumber(page).build());
|
||||
view.add(tpDelay);
|
||||
Line tpCoolDown = Line.create()
|
||||
.append(Component.text(" 传送冷却"))
|
||||
.append(NumChanger.create(Dominion.config.getTpCoolDown(), "/dominion set_config tp_cool_down").setPageNumber(page).build());
|
||||
view.add(tpCoolDown);
|
||||
if (Dominion.config.getEconomyEnable()) {
|
||||
Line economy = Line.create()
|
||||
.append("经济系统");
|
||||
view.add(economy);
|
||||
Line price = Line.create()
|
||||
.append(Component.text(" 每方块单价"))
|
||||
.append(NumChanger.create(Dominion.config.getEconomyPrice(), "/dominion set_config economy_price", 0.1).setPageNumber(page).build());
|
||||
view.add(price);
|
||||
if (Dominion.config.getEconomyOnlyXZ()) {
|
||||
view.add(Line.create()
|
||||
.append(" 仅计价平面积")
|
||||
.append(Button.createGreen("☑", "/dominion set_config economy_only_xz false " + page)));
|
||||
} else {
|
||||
view.add(Line.create()
|
||||
.append(" 仅计价平面积")
|
||||
.append(Button.createRed("☐", "/dominion set_config economy_only_xz true " + page)));
|
||||
}
|
||||
Line refund = Line.create()
|
||||
.append(Component.text(" 删除/缩小领地退还比例"))
|
||||
.append(NumChanger.create(Dominion.config.getEconomyRefund(), "/dominion set_config economy_refund", 0.01).setPageNumber(page).build());
|
||||
view.add(refund);
|
||||
}
|
||||
view.showOn(player, page);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ public class Menu {
|
||||
.add(help)
|
||||
.add(link);
|
||||
if (player.isOp()) {
|
||||
view.add(Line.create().append(""));
|
||||
view.add(Line.create().append("---以下选项仅OP可见---"));
|
||||
view.add(config);
|
||||
view.add(reload_cache);
|
||||
view.add(reload_config);
|
||||
|
@ -64,20 +64,11 @@ public class ConfigManager {
|
||||
_limit_amount = _file.getInt("Limit.Amount", 10);
|
||||
_limit_depth = _file.getInt("Limit.Depth", 10);
|
||||
_limit_vert = _file.getBoolean("Limit.Vert", false);
|
||||
if (_limit_vert) {
|
||||
if (_limit_min_y == -1) {
|
||||
XLogger.warn("启用 Limit.Vert 时 Limit.MinY 不能设置为无限,已自动调整为 -64");
|
||||
setLimitMinY(-64);
|
||||
}
|
||||
if (_limit_max_y == -1) {
|
||||
XLogger.warn("启用 Limit.Vert 时 Limit.MaxY 不能设置为无限,已自动调整为 320");
|
||||
setLimitMaxY(320);
|
||||
}
|
||||
if (_limit_size_y <= _limit_max_y - _limit_min_y) {
|
||||
setLimitSizeY(_limit_max_y - _limit_min_y + 1);
|
||||
XLogger.warn("启用 Limit.Vert 时 Limit.SizeY 不能小于 Limit.MaxY - Limit.MinY,已自动调整为 " + (_limit_max_y - _limit_min_y + 1));
|
||||
}
|
||||
if (_limit_vert && _limit_size_y <= _limit_max_y - _limit_min_y) {
|
||||
setLimitSizeY(_limit_max_y - _limit_min_y + 1);
|
||||
XLogger.warn("启用 Limit.Vert 时 Limit.SizeY 不能小于 Limit.MaxY - Limit.MinY,已自动调整为 " + (_limit_max_y - _limit_min_y + 1));
|
||||
}
|
||||
_limit_op_bypass = _file.getBoolean("Limit.OpByPass", true);
|
||||
_world_black_list = _file.getStringList("Limit.WorldBlackList");
|
||||
_check_update = _file.getBoolean("CheckUpdate", true);
|
||||
_tp_enable = _file.getBoolean("Teleport.Enable", false);
|
||||
@ -256,10 +247,26 @@ public class ConfigManager {
|
||||
return _limit_vert;
|
||||
}
|
||||
|
||||
public void setLimitVert(Boolean limit_vert) {
|
||||
_limit_vert = limit_vert;
|
||||
_file.set("Limit.Vert", limit_vert);
|
||||
_plugin.saveConfig();
|
||||
}
|
||||
|
||||
public List<String> getWorldBlackList() {
|
||||
return _world_black_list;
|
||||
}
|
||||
|
||||
public Boolean getLimitOpBypass() {
|
||||
return _limit_op_bypass;
|
||||
}
|
||||
|
||||
public void setLimitOpBypass(Boolean limit_op_bypass) {
|
||||
_limit_op_bypass = limit_op_bypass;
|
||||
_file.set("Limit.OpByPass", limit_op_bypass);
|
||||
_plugin.saveConfig();
|
||||
}
|
||||
|
||||
public Boolean getCheckUpdate() {
|
||||
return _check_update;
|
||||
}
|
||||
@ -316,14 +323,32 @@ public class ConfigManager {
|
||||
return _economy_price;
|
||||
}
|
||||
|
||||
public void setEconomyPrice(Float economy_price) {
|
||||
_economy_price = economy_price;
|
||||
_file.set("Economy.Price", economy_price);
|
||||
_plugin.saveConfig();
|
||||
}
|
||||
|
||||
public Boolean getEconomyOnlyXZ() {
|
||||
return _economy_only_xz;
|
||||
}
|
||||
|
||||
public void setEconomyOnlyXZ(Boolean economy_only_xz) {
|
||||
_economy_only_xz = economy_only_xz;
|
||||
_file.set("Economy.OnlyXZ", economy_only_xz);
|
||||
_plugin.saveConfig();
|
||||
}
|
||||
|
||||
public Float getEconomyRefund() {
|
||||
return _economy_refund;
|
||||
}
|
||||
|
||||
public void setEconomyRefund(Float economy_refund) {
|
||||
_economy_refund = economy_refund;
|
||||
_file.set("Economy.Refund", economy_refund);
|
||||
_plugin.saveConfig();
|
||||
}
|
||||
|
||||
private final Dominion _plugin;
|
||||
private FileConfiguration _file;
|
||||
private Boolean _debug;
|
||||
@ -340,6 +365,7 @@ public class ConfigManager {
|
||||
private Integer _limit_size_x;
|
||||
private Integer _limit_size_y;
|
||||
private Integer _limit_size_z;
|
||||
private Boolean _limit_op_bypass;
|
||||
|
||||
private Boolean _blue_map;
|
||||
private Integer _auto_clean_after_days;
|
||||
|
@ -1,61 +0,0 @@
|
||||
package cn.lunadeer.dominion.utils.STUI;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
||||
public class IntegerChanger {
|
||||
|
||||
private final Integer value;
|
||||
private final String changeCommand;
|
||||
private Integer pageNumber;
|
||||
|
||||
private IntegerChanger(Integer value, String changeCommand) {
|
||||
this.value = value;
|
||||
this.changeCommand = changeCommand;
|
||||
}
|
||||
|
||||
public void setPageNumber(Integer pageNumber) {
|
||||
this.pageNumber = pageNumber;
|
||||
}
|
||||
|
||||
public static IntegerChanger create(Integer value, String changeCommand) {
|
||||
return new IntegerChanger(value, changeCommand);
|
||||
}
|
||||
|
||||
public TextComponent build() {
|
||||
TextComponent plus = Component.text("+").clickEvent(
|
||||
ClickEvent.clickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
changeCommand + " " + (value + 1) + (pageNumber == null ? "" : " " + pageNumber)
|
||||
)
|
||||
).hoverEvent(
|
||||
Component.text("增加1").asHoverEvent()
|
||||
).color(ViewStyles.action_color);
|
||||
TextComponent minus = Component.text("-").clickEvent(
|
||||
ClickEvent.clickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
changeCommand + " " + (value - 1) + (pageNumber == null ? "" : " " + pageNumber)
|
||||
)
|
||||
).hoverEvent(
|
||||
Component.text("减少1").asHoverEvent()
|
||||
).color(ViewStyles.action_color);
|
||||
TextComponent plus10 = Component.text(">>").clickEvent(
|
||||
ClickEvent.clickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
changeCommand + " " + (value + 10) + (pageNumber == null ? "" : " " + pageNumber)
|
||||
)
|
||||
).hoverEvent(
|
||||
Component.text("增加10").asHoverEvent()
|
||||
).color(ViewStyles.action_color);
|
||||
TextComponent minus10 = Component.text("<<").clickEvent(
|
||||
ClickEvent.clickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
changeCommand + " " + (value - 10) + (pageNumber == null ? "" : " " + pageNumber)
|
||||
)
|
||||
).hoverEvent(
|
||||
Component.text("减少10").asHoverEvent()
|
||||
).color(ViewStyles.action_color);
|
||||
return Component.text().append(minus).append(minus10).append(Component.text(value.toString())).append(plus10).append(plus).build();
|
||||
}
|
||||
}
|
102
src/main/java/cn/lunadeer/dominion/utils/STUI/NumChanger.java
Normal file
102
src/main/java/cn/lunadeer/dominion/utils/STUI/NumChanger.java
Normal file
@ -0,0 +1,102 @@
|
||||
package cn.lunadeer.dominion.utils.STUI;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
||||
public class NumChanger {
|
||||
|
||||
private final Double value;
|
||||
private final String changeCommand;
|
||||
private Integer pageNumber;
|
||||
private Double step;
|
||||
|
||||
private NumChanger(Double value, String changeCommand) {
|
||||
this.value = value;
|
||||
this.changeCommand = changeCommand;
|
||||
this.step = 1.0;
|
||||
}
|
||||
|
||||
private NumChanger(Double value, String changeCommand, Double step) {
|
||||
this.value = value;
|
||||
this.changeCommand = changeCommand;
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public NumChanger setPageNumber(Integer pageNumber) {
|
||||
this.pageNumber = pageNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static NumChanger create(Double value, String changeCommand) {
|
||||
return new NumChanger(value, changeCommand);
|
||||
}
|
||||
|
||||
public static NumChanger create(Double value, String changeCommand, Double step) {
|
||||
return new NumChanger(value, changeCommand, step);
|
||||
}
|
||||
|
||||
public static NumChanger create(Float value, String changeCommand) {
|
||||
return new NumChanger(value.doubleValue(), changeCommand);
|
||||
}
|
||||
|
||||
public static NumChanger create(Float value, String changeCommand, Double step) {
|
||||
return new NumChanger(value.doubleValue(), changeCommand, step);
|
||||
}
|
||||
|
||||
public static NumChanger create(Integer value, String changeCommand) {
|
||||
return new NumChanger(value.doubleValue(), changeCommand);
|
||||
}
|
||||
|
||||
public static NumChanger create(Integer value, String changeCommand, Double step) {
|
||||
return new NumChanger(value.doubleValue(), changeCommand, step);
|
||||
}
|
||||
|
||||
private static String intIfNoDecimal(Double value) {
|
||||
if (value % 1 == 0) {
|
||||
return String.valueOf(value.intValue());
|
||||
}
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
public TextComponent build() {
|
||||
TextComponent plus = Component.text("+").clickEvent(
|
||||
ClickEvent.clickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
changeCommand + " " + intIfNoDecimal(value + step) + (pageNumber == null ? "" : " " + pageNumber)
|
||||
)
|
||||
).hoverEvent(
|
||||
Component.text("增加" + intIfNoDecimal(step)).asHoverEvent()
|
||||
).color(ViewStyles.action_color);
|
||||
TextComponent minus = Component.text("-").clickEvent(
|
||||
ClickEvent.clickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
changeCommand + " " + intIfNoDecimal(value - step) + (pageNumber == null ? "" : " " + pageNumber)
|
||||
)
|
||||
).hoverEvent(
|
||||
Component.text("减少" + intIfNoDecimal(step)).asHoverEvent()
|
||||
).color(ViewStyles.action_color);
|
||||
TextComponent plus10 = Component.text(">>").clickEvent(
|
||||
ClickEvent.clickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
changeCommand + " " + intIfNoDecimal(value + step * 10) + (pageNumber == null ? "" : " " + pageNumber)
|
||||
)
|
||||
).hoverEvent(
|
||||
Component.text("增加" + intIfNoDecimal(step * 10)).asHoverEvent()
|
||||
).color(ViewStyles.action_color);
|
||||
TextComponent minus10 = Component.text("<<").clickEvent(
|
||||
ClickEvent.clickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
changeCommand + " " + intIfNoDecimal(value - step * 10) + (pageNumber == null ? "" : " " + pageNumber)
|
||||
)
|
||||
).hoverEvent(
|
||||
Component.text("减少" + intIfNoDecimal(step * 10)).asHoverEvent()
|
||||
).color(ViewStyles.action_color);
|
||||
return Component.text()
|
||||
.append(minus10).append(minus)
|
||||
.append(Component.text(" "))
|
||||
.append(Component.text(intIfNoDecimal(value)))
|
||||
.append(Component.text(" "))
|
||||
.append(plus).append(plus10).build();
|
||||
}
|
||||
}
|
@ -9,17 +9,17 @@ Database:
|
||||
# 自动圈地大小
|
||||
AutoCreateRadius: 10 #-1 表示不开启
|
||||
|
||||
# -1 表示不限制
|
||||
Limit:
|
||||
MinY: -64 # 最小Y坐标
|
||||
MaxY: 320 # 最大Y坐标
|
||||
SizeX: 128 # X方向最大长度
|
||||
SizeY: 64 # Y方向最大长度
|
||||
SizeZ: 128 # Z方向最大长度
|
||||
Amount: 10 # 最大领地数量
|
||||
SizeX: 128 # X方向最大长度 -1:表示不限制
|
||||
SizeY: 64 # Y方向最大长度 -1:表示不限制
|
||||
SizeZ: 128 # Z方向最大长度 -1:表示不限制
|
||||
Amount: 10 # 最大领地数量 -1:表示不限制
|
||||
Depth: 3 # 子领地深度 0:不允许子领地 -1:不限制
|
||||
Vert: false # 是否自动延伸到 MaxY 和 MinY
|
||||
WorldBlackList: [ ] # 不允许领地的世界
|
||||
OpByPass: true # 是否允许OP无视领地限制
|
||||
|
||||
Teleport:
|
||||
Enable: true
|
||||
|
Loading…
Reference in New Issue
Block a user