diff --git a/README.md b/README.md index d23065bd..73736427 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ ### [开源地址](https://ssl.lunadeer.cn:14446/zhangyuheng/Dominion) | [文档地址](https://ssl.lunadeer.cn:14448/doc/23/) + ### [下载页面](https://ssl.lunadeer.cn:14446/zhangyuheng/Dominion/releases) + ### [统计页面](https://bstats.org/plugin/bukkit/Dominion/21445) | [Hangar](https://hangar.papermc.io/zhangyuheng/Dominion) @@ -147,6 +149,8 @@ | 缩小领地 | `/dominion contract [大小] [领地名称]` | | 设置进入领地的提示语 | `/dominion set_enter_msg <提示语> [领地名称]` | | 设置离开领地的提示语 | `/dominion set_leave_msg <提示语> [领地名称]` | +| 设置领地传送点 | `/dominion set_tp_location [领地名称]` | +| 传送到领地传送点 | `/dominion tp <领地名称>` | | 重命名领地 | `/dominion rename <原领地名称> <新领地名称>` | | 转让领地 | `/dominion give <领地名称> <玩家名称>` | | 删除领地 | `/dominion delete <领地名称>` | @@ -198,6 +202,13 @@ AutoCleanAfterDays: 180 BlueMap: true +Teleport: + Enable: true + # 传送延迟 秒 + Delay: 0 + # 冷却时间 秒 + CoolDown: 0 + CheckUpdate: true Debug: false diff --git a/pom.xml b/pom.xml index 62429da3..37748964 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cn.lunadeer Dominion - 1.17.2-beta + 1.18.3-beta jar Dominion diff --git a/src/main/java/cn/lunadeer/dominion/Cache.java b/src/main/java/cn/lunadeer/dominion/Cache.java index dd8bad47..389e78ec 100644 --- a/src/main/java/cn/lunadeer/dominion/Cache.java +++ b/src/main/java/cn/lunadeer/dominion/Cache.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Player; import javax.annotation.Nullable; +import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -270,4 +271,6 @@ public List getDominions() { private final AtomicLong _last_update_privilege = new AtomicLong(0); private final AtomicBoolean _update_privilege_is_scheduled = new AtomicBoolean(false); private static final long UPDATE_INTERVAL = 1000 * 4; + + public final Map NextTimeAllowTeleport = new java.util.HashMap<>(); } diff --git a/src/main/java/cn/lunadeer/dominion/Commands.java b/src/main/java/cn/lunadeer/dominion/Commands.java index 196db4ba..baf6f7f8 100644 --- a/src/main/java/cn/lunadeer/dominion/Commands.java +++ b/src/main/java/cn/lunadeer/dominion/Commands.java @@ -125,6 +125,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command case "set_leave_msg": DominionOperate.setLeaveMessage(sender, args); break; + case "set_tp_location": + DominionOperate.setTpLocation(sender, args); + break; + case "tp": + DominionOperate.teleportToDominion(sender, args); + break; case "rename": DominionOperate.renameDominion(sender, args); break; @@ -167,6 +173,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command "create_privilege", "set_privilege", "clear_privilege", "list", "privilege_info", "set_enter_msg", "set_leave_msg", + "set_tp_location", + "tp", "rename", "give", "reload_cache", @@ -189,7 +197,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command case "privilege_list": case "rename": case "give": + case "set_tp_location": return playerDominions(sender); + case "tp": + return allDominions(); case "set": return dominionFlags(); case "create_privilege": diff --git a/src/main/java/cn/lunadeer/dominion/commands/Apis.java b/src/main/java/cn/lunadeer/dominion/commands/Apis.java index fe74ea08..b79c44fd 100644 --- a/src/main/java/cn/lunadeer/dominion/commands/Apis.java +++ b/src/main/java/cn/lunadeer/dominion/commands/Apis.java @@ -30,6 +30,7 @@ public static void sizeInfo(CommandSender sender, DominionDTO dominionDTO) { Notification.info(sender, " 大小为" + (x2 - x1) + " x" + (y2 - y1) + " x" + (z2 - z1)); Notification.info(sender, " 中心坐标为 " + (x1 + (x2 - x1) / 2) + " " + (y1 + (y2 - y1) / 2) + " " + (z1 + (z2 - z1) / 2)); Notification.info(sender, " 高度为 " + (y2 - y1)); + Notification.info(sender, " Y1=" + y1 + " Y2=" + y2); Notification.info(sender, " 体积为 " + (x2 - x1) * (y2 - y1) * (z2 - z1)); Notification.info(sender, " 领地的世界为 " + dominionDTO.getWorld()); Notification.info(sender, " 领地的对角点坐标为 x1=" + x1 + " y1=" + y1 + " z1=" + z1 + " x2=" + x2 + " y2=" + y2 + " z2=" + z2); diff --git a/src/main/java/cn/lunadeer/dominion/commands/DominionOperate.java b/src/main/java/cn/lunadeer/dominion/commands/DominionOperate.java index 11265b2c..7a323f43 100644 --- a/src/main/java/cn/lunadeer/dominion/commands/DominionOperate.java +++ b/src/main/java/cn/lunadeer/dominion/commands/DominionOperate.java @@ -1,13 +1,18 @@ package cn.lunadeer.dominion.commands; +import cn.lunadeer.dominion.Cache; import cn.lunadeer.dominion.Dominion; import cn.lunadeer.dominion.controllers.DominionController; import cn.lunadeer.dominion.dtos.DominionDTO; +import cn.lunadeer.dominion.dtos.PlayerPrivilegeDTO; import cn.lunadeer.dominion.utils.Notification; +import cn.lunadeer.dominion.utils.XLogger; import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.time.LocalDateTime; import java.util.Map; import static cn.lunadeer.dominion.commands.Apis.*; @@ -272,6 +277,27 @@ public static void setLeaveMessage(CommandSender sender, String[] args) { Notification.error(sender, "用法: /dominion set_leave_msg <提示语> [领地名称]"); } + /** + * 设置领地传送点 + * /dominion set_tp_location [领地名称] + * + * @param sender 命令发送者 + * @param args 命令参数 + */ + public static void setTpLocation(CommandSender sender, String[] args) { + Player player = playerOnly(sender); + if (player == null) return; + if (args.length == 1) { + DominionController.setTpLocation(player); + return; + } + if (args.length == 2) { + DominionController.setTpLocation(player, args[1]); + return; + } + Notification.error(sender, "用法: /dominion set_tp_location [领地名称]"); + } + /** * 重命名领地 * /dominion rename <原领地名称> <新领地名称> @@ -315,4 +341,76 @@ public static void giveDominion(CommandSender sender, String[] args) { } Notification.error(sender, "用法: /dominion give <领地名称> <玩家名称>"); } + + /** + * 传送到领地 + * /dominion tp <领地名称> + * + * @param sender 命令发送者 + * @param args 命令参数 + */ + public static void teleportToDominion(CommandSender sender, String[] args) { + Player player = playerOnly(sender); + if (player == null) return; + if (args.length != 2) { + Notification.error(sender, "用法: /dominion tp <领地名称>"); + return; + } + if (!Dominion.config.getTpEnable()) { + Notification.error(sender, "管理员没有开启领地传送功能"); + return; + } + DominionDTO dominionDTO = DominionDTO.select(args[1]); + if (dominionDTO == null) { + Notification.error(sender, "领地不存在"); + return; + } + PlayerPrivilegeDTO privilegeDTO = PlayerPrivilegeDTO.select(player.getUniqueId(), dominionDTO.getId()); + if (privilegeDTO == null) { + if (!dominionDTO.getTeleport()) { + Notification.error(sender, "此领地禁止传送"); + return; + } + } else { + if (!privilegeDTO.getTeleport()) { + Notification.error(sender, "你不被允许传送到这个领地"); + return; + } + } + + Location location = dominionDTO.getTpLocation(); + if (location == null) { + Notification.error(sender, "此领地没有设置传送点"); + return; +// int center_x = (dominionDTO.getX1() + dominionDTO.getX2()) / 2; +// int center_z = (dominionDTO.getZ1() + dominionDTO.getZ2()) / 2; +// // find safe location +// World world = Dominion.instance.getServer().getWorld(dominionDTO.getWorld()); +// if (world == null) { +// Notification.error(sender, "此领地所在世界不存在"); +// XLogger.warn("领地 " + dominionDTO.getName() + " 所在世界不存在"); +// return; +// } +// location = world.getHighestBlockAt(center_x, center_z).getLocation(); + } + + LocalDateTime now = LocalDateTime.now(); + LocalDateTime next_time = Cache.instance.NextTimeAllowTeleport.get(player.getUniqueId()); + if (next_time != null) { + if (now.isBefore(next_time)) { + long secs_until_next = now.until(next_time, java.time.temporal.ChronoUnit.SECONDS); + Notification.error(player, "请等待 " + secs_until_next + " 秒后再次传送"); + return; + } + } + + 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()) { + player.teleportAsync(location); + Notification.info(player, "已将你传送到 " + dominionDTO.getName()); + } + }, Dominion.config.getTpDelay() == 0 ? 1 : 20L * Dominion.config.getTpDelay()); + } } diff --git a/src/main/java/cn/lunadeer/dominion/commands/Helper.java b/src/main/java/cn/lunadeer/dominion/commands/Helper.java index 18e3d592..3d6ef0e8 100644 --- a/src/main/java/cn/lunadeer/dominion/commands/Helper.java +++ b/src/main/java/cn/lunadeer/dominion/commands/Helper.java @@ -97,5 +97,13 @@ public static List playerAdminDominions(CommandSender sender) { return dominions_name; } + public static List allDominions() { + List dominions_name = new ArrayList<>(); + List dominions = DominionController.all(); + for (DominionDTO dominion : dominions) { + dominions_name.add(dominion.getName()); + } + return dominions_name; + } } diff --git a/src/main/java/cn/lunadeer/dominion/controllers/DominionController.java b/src/main/java/cn/lunadeer/dominion/controllers/DominionController.java index 9aa250c1..93f5ab45 100644 --- a/src/main/java/cn/lunadeer/dominion/controllers/DominionController.java +++ b/src/main/java/cn/lunadeer/dominion/controllers/DominionController.java @@ -23,6 +23,10 @@ public static List all(Player owner) { return DominionDTO.selectAll(owner.getUniqueId()); } + public static List all() { + return DominionDTO.selectAll(); + } + /** * 创建领地 * @@ -427,6 +431,55 @@ public static void setLeaveMessage(Player operator, String message, String domin Notification.info(operator, "成功设置领地 " + dominion_name + " 的离开消息"); } + /** + * 设置领地的传送点 + * + * @param operator 操作者 + */ + public static void setTpLocation(Player operator) { + DominionDTO dominion = getPlayerCurrentDominion(operator); + if (dominion == null) { + return; + } + setTpLocation(operator, dominion.getName()); + } + + /** + * 设置领地的传送点 + * + * @param operator 操作者 + * @param dominion_name 领地名称 + */ + public static void setTpLocation(Player operator, String dominion_name) { + DominionDTO dominion = DominionDTO.select(dominion_name); + if (dominion == null) { + Notification.error(operator, "领地 " + dominion_name + " 不存在"); + return; + } + if (notOwner(operator, dominion)) { + Notification.error(operator, "你不是领地 " + dominion_name + " 的拥有者,无法执行此操作"); + return; + } + // 检查是否在领地内 + if (operator.getWorld().getName().equals(dominion.getWorld()) && + operator.getLocation().getBlockX() >= dominion.getX1() && + operator.getLocation().getBlockX() <= dominion.getX2() && + operator.getLocation().getBlockY() >= dominion.getY1() && + operator.getLocation().getBlockY() <= dominion.getY2() && + operator.getLocation().getBlockZ() >= dominion.getZ1() && + operator.getLocation().getBlockZ() <= dominion.getZ2()) { + Location loc = operator.getLocation(); + loc.setY(loc.getY() + 1.5); + dominion.setTpLocation(loc); + Notification.info(operator, "成功设置领地 " + dominion_name + " 的传送点," + + "当前位置为 " + operator.getLocation().getBlockX() + " " + + operator.getLocation().getBlockY() + 1 + " " + + operator.getLocation().getBlockZ()); + } else { + Notification.error(operator, "你不在领地 " + dominion_name + " 内,无法设置传送点"); + } + } + /** * 重命名领地 * diff --git a/src/main/java/cn/lunadeer/dominion/controllers/FlagsController.java b/src/main/java/cn/lunadeer/dominion/controllers/FlagsController.java index 0956d526..56b2ca60 100644 --- a/src/main/java/cn/lunadeer/dominion/controllers/FlagsController.java +++ b/src/main/java/cn/lunadeer/dominion/controllers/FlagsController.java @@ -75,6 +75,7 @@ public static DominionDTO setFlag(Player operator, String flag, boolean value, S case "repeater": return dominion.setRepeater(value); case "shear": return dominion.setShear(value); case "shoot": return dominion.setShoot(value); + case "teleport": return dominion.setTeleport(value); case "tnt_explode": return dominion.setTntExplode(value); case "trade": return dominion.setTrade(value); case "trample": return dominion.setTrample(value); diff --git a/src/main/java/cn/lunadeer/dominion/controllers/PrivilegeController.java b/src/main/java/cn/lunadeer/dominion/controllers/PrivilegeController.java index 276cfe56..2417182d 100644 --- a/src/main/java/cn/lunadeer/dominion/controllers/PrivilegeController.java +++ b/src/main/java/cn/lunadeer/dominion/controllers/PrivilegeController.java @@ -205,6 +205,9 @@ public static boolean setPrivilege(Player operator, String player_name, String f case "shoot": privilege.setShoot(value); break; + case "teleport": + privilege.setTeleport(value); + break; case "trade": privilege.setTrade(value); break; @@ -266,7 +269,7 @@ private static PlayerPrivilegeDTO createPlayerPrivilege(Player operator, UUID pl dom.getPlace(), dom.getPressure(), dom.getRiding(), dom.getRepeater(), dom.getShear(), dom.getShoot(), - dom.getTrade(), + dom.getTeleport(), dom.getTrade(), dom.getVehicleDestroy(), dom.getVehicleSpawn()); privilege = PlayerPrivilegeDTO.insert(privilege); diff --git a/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java b/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java index c9976dad..73ec6f08 100644 --- a/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java +++ b/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java @@ -1,13 +1,17 @@ package cn.lunadeer.dominion.dtos; import cn.lunadeer.dominion.Cache; +import cn.lunadeer.dominion.Dominion; import cn.lunadeer.dominion.utils.Database; import cn.lunadeer.dominion.utils.XLogger; +import org.bukkit.Location; +import org.bukkit.World; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.UUID; public class DominionDTO { @@ -32,6 +36,7 @@ private static List query(String sql) { Integer y2 = rs.getInt("y2"); Integer z2 = rs.getInt("z2"); Integer parentDomId = rs.getInt("parent_dom_id"); + String tp_location = rs.getString("tp_location"); DominionDTO dominion = new DominionDTO(id, owner, name, world, x1, y1, z1, x2, y2, z2, parentDomId, rs.getString("join_message"), rs.getString("leave_message"), @@ -73,12 +78,14 @@ private static List query(String sql) { rs.getBoolean("repeater"), rs.getBoolean("shear"), rs.getBoolean("shoot"), + rs.getBoolean("teleport"), rs.getBoolean("tnt_explode"), rs.getBoolean("trade"), rs.getBoolean("trample"), rs.getBoolean("vehicle_destroy"), rs.getBoolean("vehicle_spawn"), - rs.getBoolean("wither_spawn") + rs.getBoolean("wither_spawn"), + tp_location ); dominions.add(dominion); } @@ -168,6 +175,13 @@ public static void delete(DominionDTO dominion) { } private static DominionDTO update(DominionDTO dominion) { + String tp_location; + if (dominion.getTpLocation() == null) { + tp_location = "default"; + } else { + Location loc = dominion.getTpLocation(); + tp_location = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ(); + } String sql = "UPDATE dominion SET " + "owner = '" + dominion.getOwner().toString() + "', " + "name = '" + dominion.getName() + "', " + @@ -219,12 +233,14 @@ private static DominionDTO update(DominionDTO dominion) { "repeater = " + dominion.getRepeater() + ", " + "shear = " + dominion.getShear() + ", " + "shoot = " + dominion.getShoot() + ", " + + "teleport = " + dominion.getTeleport() + ", " + "tnt_explode = " + dominion.getTntExplode() + ", " + // dom only "trade = " + dominion.getTrade() + ", " + "trample = " + dominion.getTrample() + ", " + // dom only "vehicle_destroy = " + dominion.getVehicleDestroy() + ", " + "vehicle_spawn = " + dominion.getVehicleSpawn() + ", " + - "wither_spawn = " + dominion.getWitherSpawn() + " " + // dom only + "wither_spawn = " + dominion.getWitherSpawn() + ", " + // dom only + "tp_location = '" + tp_location + "' " + " WHERE id = " + dominion.getId() + " RETURNING *;"; List dominions = query(sql); @@ -250,10 +266,11 @@ private DominionDTO(Integer id, UUID owner, String name, String world, Boolean place, Boolean pressure, Boolean riding, Boolean repeater, Boolean shear, Boolean shoot, - Boolean tntExplode, Boolean trade, Boolean trample, + Boolean teleport, Boolean tntExplode, Boolean trade, Boolean trample, Boolean vehicleDestroy, Boolean vehicleSpawn, - Boolean witherSpawn) { + Boolean witherSpawn, + String tp_location) { this.id = id; this.owner = owner; this.name = name; @@ -305,27 +322,43 @@ private DominionDTO(Integer id, UUID owner, String name, String world, this.repeater = repeater; this.shear = shear; this.shoot = shoot; + this.teleport = teleport; this.tntExplode = tntExplode; this.trade = trade; this.trample = trample; this.vehicleDestroy = vehicleDestroy; this.vehicleSpawn = vehicleSpawn; this.witherSpawn = witherSpawn; + if (Objects.equals(tp_location, "default")) { + this.tp_location = null; + } else { + // 0:0:0 + String[] loc = tp_location.split(":"); + World w = Dominion.instance.getServer().getWorld(world); + if (loc.length == 3 && w != null) { + this.tp_location = new Location(w, Integer.parseInt(loc[0]), Integer.parseInt(loc[1]), Integer.parseInt(loc[2])); + } else { + XLogger.warn("领地传送点数据异常: " + tp_location); + this.tp_location = null; + } + } } private DominionDTO(Integer id, UUID owner, String name, String world, Integer x1, Integer y1, Integer z1, Integer x2, Integer y2, Integer z2, Integer parentDomId) { - this(id, owner, name, world, x1, y1, z1, x2, y2, z2, parentDomId, - "欢迎", "再见", - false, false, false, false, false, - false, false, false, false, false, - false, false, false, false, false, false, - false, false, false, false, false, true, - true, false, false, false, false, false, false, true, - false, true, false, false, false, false, - false, false, false, false, false, false, false, false); + this.id = id; + this.owner = owner; + this.name = name; + this.world = world; + this.x1 = x1; + this.y1 = y1; + this.z1 = z1; + this.x2 = x2; + this.y2 = y2; + this.z2 = z2; + this.parentDomId = parentDomId; } public DominionDTO(UUID owner, String name, String world, @@ -383,6 +416,7 @@ public DominionDTO(UUID owner, String name, String world, private Boolean repeater = false; private Boolean shear = false; private Boolean shoot = false; + private Boolean teleport = false; private Boolean tntExplode = false; private Boolean trade = false; private Boolean trample = false; @@ -390,6 +424,7 @@ public DominionDTO(UUID owner, String name, String world, private Boolean vehicleSpawn = false; private Boolean witherSpawn = false; private Boolean harvest = false; + private Location tp_location = null; // getters and setters public Integer getId() { @@ -837,6 +872,15 @@ public DominionDTO setShoot(Boolean shoot) { return update(this); } + public Boolean getTeleport() { + return teleport; + } + + public DominionDTO setTeleport(Boolean teleport) { + this.teleport = teleport; + return update(this); + } + public Boolean getTntExplode() { return tntExplode; } @@ -909,4 +953,13 @@ public DominionDTO setXYZ(Integer x1, Integer y1, Integer z1, Integer x2, Intege this.z2 = z2; return update(this); } + + public Location getTpLocation() { + return tp_location; + } + + public DominionDTO setTpLocation(Location loc) { + this.tp_location = loc; + return update(this); + } } diff --git a/src/main/java/cn/lunadeer/dominion/dtos/PlayerPrivilegeDTO.java b/src/main/java/cn/lunadeer/dominion/dtos/PlayerPrivilegeDTO.java index 0bc7e44f..a09dd216 100644 --- a/src/main/java/cn/lunadeer/dominion/dtos/PlayerPrivilegeDTO.java +++ b/src/main/java/cn/lunadeer/dominion/dtos/PlayerPrivilegeDTO.java @@ -27,7 +27,7 @@ public static PlayerPrivilegeDTO insert(PlayerPrivilegeDTO player) { "place, pressure, " + "riding, repeater, " + "shear, shoot, " + - "trade, " + + "teleport, trade, " + "vehicle_destroy, " + "vehicle_spawn" + ") VALUES (" + @@ -46,7 +46,7 @@ public static PlayerPrivilegeDTO insert(PlayerPrivilegeDTO player) { player.getPlace() + ", " + player.getPressure() + ", " + player.getRiding() + ", " + player.getRepeater() + ", " + player.getShear() + ", " + player.getShoot() + ", " + - player.getTrade() + ", " + + player.getTeleport() + ", " + player.getTrade() + ", " + player.getVehicleDestroy() + ", " + player.getVehicleSpawn() + " " + ") RETURNING *;"; @@ -121,6 +121,7 @@ public static List selectAll(UUID player) { private Boolean repeater; private Boolean shear; private Boolean shoot; + private Boolean teleport; private Boolean trade; private Boolean vehicleDestroy; private Boolean vehicleSpawn; @@ -273,6 +274,10 @@ public Boolean getShoot() { return shoot; } + public Boolean getTeleport() { + return teleport; + } + public Boolean getTrade() { return trade; } @@ -445,6 +450,11 @@ public PlayerPrivilegeDTO setShoot(Boolean shoot) { return update(this); } + public PlayerPrivilegeDTO setTeleport(Boolean teleport) { + this.teleport = teleport; + return update(this); + } + public PlayerPrivilegeDTO setTrade(Boolean trade) { this.trade = trade; return update(this); @@ -485,7 +495,7 @@ private PlayerPrivilegeDTO(Integer id, UUID playerUUID, Boolean admin, Integer d Boolean place, Boolean pressure, Boolean riding, Boolean repeater, Boolean shear, Boolean shoot, - Boolean trade, + Boolean teleport, Boolean trade, Boolean vehicleDestroy, Boolean vehicleSpawn) { this.id = id; @@ -525,6 +535,7 @@ private PlayerPrivilegeDTO(Integer id, UUID playerUUID, Boolean admin, Integer d this.repeater = repeater; this.shear = shear; this.shoot = shoot; + this.teleport = teleport; this.trade = trade; this.vehicleDestroy = vehicleDestroy; this.vehicleSpawn = vehicleSpawn; @@ -545,7 +556,7 @@ public PlayerPrivilegeDTO(UUID playerUUID, Integer domID, Boolean place, Boolean pressure, Boolean riding, Boolean repeater, Boolean shear, Boolean shoot, - Boolean trade, + Boolean teleport, Boolean trade, Boolean vehicleDestroy, Boolean vehicleSpawn ) { @@ -564,7 +575,7 @@ public PlayerPrivilegeDTO(UUID playerUUID, Integer domID, place, pressure, riding, repeater, shear, shoot, - trade, + teleport, trade, vehicleDestroy, vehicleSpawn); } @@ -616,6 +627,7 @@ private static List query(String sql) { rs.getBoolean("repeater"), rs.getBoolean("shear"), rs.getBoolean("shoot"), + rs.getBoolean("teleport"), rs.getBoolean("trade"), rs.getBoolean("vehicle_destroy"), rs.getBoolean("vehicle_spawn") @@ -666,6 +678,7 @@ private static PlayerPrivilegeDTO update(PlayerPrivilegeDTO player) { "repeater = " + player.getRepeater() + ", " + "shear = " + player.getShear() + ", " + "shoot = " + player.getShoot() + ", " + + "teleport = " + player.getTeleport() + ", " + "trade = " + player.getTrade() + ", " + "vehicle_destroy = " + player.getVehicleDestroy() + ", " + "vehicle_spawn = " + player.getVehicleSpawn() + " " + diff --git a/src/main/java/cn/lunadeer/dominion/tuis/Apis.java b/src/main/java/cn/lunadeer/dominion/tuis/Apis.java index 3d49120c..757ba6cd 100644 --- a/src/main/java/cn/lunadeer/dominion/tuis/Apis.java +++ b/src/main/java/cn/lunadeer/dominion/tuis/Apis.java @@ -87,6 +87,8 @@ public static void printHelp(CommandSender sender, String[] args) { .add(Line.create().append("缩小领地").append("/dominion contract [大小] [领地名称]")) .add(Line.create().append("设置进入领地的提示语").append("/dominion set_enter_msg <提示语> [领地名称]")) .add(Line.create().append("设置离开领地的提示语").append("/dominion set_leave_msg <提示语> [领地名称]")) + .add(Line.create().append("设置领地传送点").append("/dominion set_tp_location [领地名称]")) + .add(Line.create().append("传送到领地").append("/dominion tp <领地名称>")) .add(Line.create().append("重命名领地").append("/dominion rename <原领地名称> <新领地名称>")) .add(Line.create().append("转让领地").append("/dominion give <领地名称> <玩家名称> [force]")) .add(Line.create().append("删除领地").append("/dominion delete <领地名称> [force]")) diff --git a/src/main/java/cn/lunadeer/dominion/tuis/DominionFlagInfo.java b/src/main/java/cn/lunadeer/dominion/tuis/DominionFlagInfo.java index c600beee..9d582396 100644 --- a/src/main/java/cn/lunadeer/dominion/tuis/DominionFlagInfo.java +++ b/src/main/java/cn/lunadeer/dominion/tuis/DominionFlagInfo.java @@ -50,11 +50,11 @@ public static void show(CommandSender sender, String[] args) { if (dominion.getAnimalKilling()) { view.add(Line.create() .append(Button.createGreen("☑", "/dominion set animal_killing false " + dominion.getName() + " " + page)) - .append("动物伤害")); + .append("对动物造成伤害")); } else { view.add(Line.create() .append(Button.createRed("☐", "/dominion set animal_killing true " + dominion.getName() + " " + page)) - .append("动物伤害")); + .append("对动物造成伤害")); } if (dominion.getAnvil()) { view.add(Line.create() @@ -131,11 +131,11 @@ public static void show(CommandSender sender, String[] args) { if (dominion.getCraft()) { view.add(Line.create() .append(Button.createGreen("☑", "/dominion set craft false " + dominion.getName() + " " + page)) - .append("工作台")); + .append("使用工作台")); } else { view.add(Line.create() .append(Button.createRed("☐", "/dominion set craft true " + dominion.getName() + " " + page)) - .append("工作台")); + .append("使用工作台")); } if (dominion.getCreeperExplode()) { view.add(Line.create() @@ -230,20 +230,20 @@ public static void show(CommandSender sender, String[] args) { if (dominion.getFlowInProtection()) { view.add(Line.create() .append(Button.createGreen("☑", "/dominion set flow_in_protection false " + dominion.getName() + " " + page)) - .append("流体保护")); + .append("外部流体是否可以进入")); } else { view.add(Line.create() .append(Button.createRed("☐", "/dominion set flow_in_protection true " + dominion.getName() + " " + page)) - .append("流体保护")); + .append("外部流体是否可以进入")); } if (dominion.getGlow()) { view.add(Line.create() .append(Button.createGreen("☑", "/dominion set glow false " + dominion.getName() + " " + page)) - .append("发光")); + .append("玩家发光")); } else { view.add(Line.create() .append(Button.createRed("☐", "/dominion set glow true " + dominion.getName() + " " + page)) - .append("发光")); + .append("玩家发光")); } if (dominion.getHarvest()) { view.add(Line.create() @@ -311,11 +311,11 @@ public static void show(CommandSender sender, String[] args) { if (dominion.getMonsterKilling()) { view.add(Line.create() .append(Button.createGreen("☑", "/dominion set monster_killing false " + dominion.getName() + " " + page)) - .append("怪物伤害")); + .append("对怪物造成伤害")); } else { view.add(Line.create() .append(Button.createRed("☐", "/dominion set monster_killing true " + dominion.getName() + " " + page)) - .append("怪物伤害")); + .append("对怪物造成伤害")); } if (dominion.getMove()) { view.add(Line.create() @@ -380,6 +380,15 @@ public static void show(CommandSender sender, String[] args) { .append(Button.createRed("☐", "/dominion set shoot true " + dominion.getName() + " " + page)) .append("射箭/雪球/三叉戟")); } + if (dominion.getTeleport()) { + view.add(Line.create() + .append(Button.createGreen("☑", "/dominion set teleport false " + dominion.getName() + " " + page)) + .append("领地传送")); + } else { + view.add(Line.create() + .append(Button.createRed("☐", "/dominion set teleport true " + dominion.getName() + " " + page)) + .append("领地传送")); + } if (dominion.getTntExplode()) { view.add(Line.create() .append(Button.createGreen("☑", "/dominion set tnt_explode false " + dominion.getName() + " " + page)) diff --git a/src/main/java/cn/lunadeer/dominion/tuis/DominionManage.java b/src/main/java/cn/lunadeer/dominion/tuis/DominionManage.java index 605589f1..9dfc6dde 100644 --- a/src/main/java/cn/lunadeer/dominion/tuis/DominionManage.java +++ b/src/main/java/cn/lunadeer/dominion/tuis/DominionManage.java @@ -24,14 +24,17 @@ public static void show(CommandSender sender, String[] args) { } if (noAuthToManage(player, dominion)) return; Line size_info = Line.create() - .append(Button.create("尺寸信息", "/dominion info " + dominion.getName())) - .append("查看领地尺寸信息"); + .append(Button.create("详细信息", "/dominion info " + dominion.getName())) + .append("查看领地详细信息"); Line flag_info = Line.create() .append(Button.create("权限设置", "/dominion flag_info " + dominion.getName())) .append("管理领地默认权限"); Line privilege_list = Line.create() .append(Button.create("玩家权限", "/dominion privilege_list " + dominion.getName())) .append("管理玩家特权"); + Line set_tp = Line.create() + .append(Button.create("设置传送点", "/dominion set_tp_location " + dominion.getName())) + .append("设置当前位置为此领地传送点"); ListView view = ListView.create(10, "/dominion manage " + dominion.getName()); view.title("领地 " + dominion.getName() + " 管理界面") .navigator(Line.create() @@ -41,6 +44,7 @@ public static void show(CommandSender sender, String[] args) { .add(size_info) .add(flag_info) .add(privilege_list) + .add(set_tp) .showOn(player, 1); } } diff --git a/src/main/java/cn/lunadeer/dominion/tuis/DominionSizeInfo.java b/src/main/java/cn/lunadeer/dominion/tuis/DominionSizeInfo.java index a1548fdf..a9a09923 100644 --- a/src/main/java/cn/lunadeer/dominion/tuis/DominionSizeInfo.java +++ b/src/main/java/cn/lunadeer/dominion/tuis/DominionSizeInfo.java @@ -38,6 +38,11 @@ public static void show(CommandSender sender, String[] args) { .addLine(Line.create().append("Y轴坐标:").append(y1 + " ~ " + y2)) .addLine(Line.create().append("水平面积:").append(String.valueOf((x2 - x1) * (z2 - z1)))) .addLine(Line.create().append("领地体积:").append(String.valueOf((x2 - x1) * (y2 - y1) * (z2 - z1)))) + .addLine(Line.create().append("传送点坐标:").append( + dominion.getTpLocation() == null ? + "无" : + dominion.getTpLocation().getX() + " " + dominion.getTpLocation().getY() + " " + dominion.getTpLocation().getZ() + )) .actionBar(Line.create() .append(Button.create("管理界面", "/dominion manage " + dominion.getName())) .append(Button.create("权限列表", "/dominion flag_info " + dominion.getName()))) diff --git a/src/main/java/cn/lunadeer/dominion/tuis/PrivilegeInfo.java b/src/main/java/cn/lunadeer/dominion/tuis/PrivilegeInfo.java index 64d194fc..087c1184 100644 --- a/src/main/java/cn/lunadeer/dominion/tuis/PrivilegeInfo.java +++ b/src/main/java/cn/lunadeer/dominion/tuis/PrivilegeInfo.java @@ -359,6 +359,15 @@ public static void show(CommandSender sender, String[] args) { .append(Button.createRed("☐", "/dominion set_privilege " + playerName + " shoot true " + dominion.getName() + " " + page)) .append("射箭/雪球/三叉戟")); } + if (privilege.getTeleport()) { + view.add(Line.create() + .append(Button.createGreen("☑", "/dominion set_privilege " + playerName + " teleport false " + dominion.getName() + " " + page)) + .append("领地传送")); + } else { + view.add(Line.create() + .append(Button.createRed("☐", "/dominion set_privilege " + playerName + " teleport true " + dominion.getName() + " " + page)) + .append("领地传送")); + } if (privilege.getTrade()) { view.add(Line.create() .append(Button.createGreen("☑", "/dominion set_privilege " + playerName + " trade false " + dominion.getName() + " " + page)) diff --git a/src/main/java/cn/lunadeer/dominion/utils/ConfigManager.java b/src/main/java/cn/lunadeer/dominion/utils/ConfigManager.java index 1ad4dda2..2c6cd5c9 100644 --- a/src/main/java/cn/lunadeer/dominion/utils/ConfigManager.java +++ b/src/main/java/cn/lunadeer/dominion/utils/ConfigManager.java @@ -59,6 +59,9 @@ public void reload() { _limit_depth = _file.getInt("Limit.Depth", 10); _world_black_list = _file.getStringList("WorldBlackList"); _check_update = _file.getBoolean("CheckUpdate", true); + _tp_enable = _file.getBoolean("Teleport.Enable", false); + _tp_delay = _file.getInt("Teleport.Delay", 0); + _tp_cool_down = _file.getInt("Teleport.CoolDown", 0); } public Boolean isDebug() { @@ -227,6 +230,36 @@ public Boolean getCheckUpdate() { return _check_update; } + public Boolean getTpEnable() { + return _tp_enable; + } + + public void setTpEnable(Boolean tp_enable) { + _tp_enable = tp_enable; + _file.set("Teleport.Enable", tp_enable); + _plugin.saveConfig(); + } + + public Integer getTpDelay() { + return _tp_delay; + } + + public void setTpDelay(Integer tp_delay) { + _tp_delay = tp_delay; + _file.set("Teleport.Delay", tp_delay); + _plugin.saveConfig(); + } + + public Integer getTpCoolDown() { + return _tp_cool_down; + } + + public void setTpCoolDown(Integer tp_cool_down) { + _tp_cool_down = tp_cool_down; + _file.set("Teleport.CoolDown", tp_cool_down); + _plugin.saveConfig(); + } + private final Dominion _plugin; private FileConfiguration _file; @@ -253,4 +286,8 @@ public Boolean getCheckUpdate() { private Integer _limit_depth; private List _world_black_list; private Boolean _check_update; + + private Boolean _tp_enable; + private Integer _tp_delay; + private Integer _tp_cool_down; } diff --git a/src/main/java/cn/lunadeer/dominion/utils/Database.java b/src/main/java/cn/lunadeer/dominion/utils/Database.java index 2278b0d3..b2368771 100644 --- a/src/main/java/cn/lunadeer/dominion/utils/Database.java +++ b/src/main/java/cn/lunadeer/dominion/utils/Database.java @@ -240,5 +240,10 @@ public static void migrate() { // 1.12.0 addColumnIfNotExists("dominion", "ender_man", "BOOLEAN NOT NULL DEFAULT FAlSE"); + + // 1.18.0 + addColumnIfNotExists("dominion", "tp_location", "TEXT NOT NULL DEFAULT 'default'"); + addColumnIfNotExists("dominion", "teleport", "BOOLEAN NOT NULL DEFAULT FALSE"); + addColumnIfNotExists("player_privilege", "teleport", "BOOLEAN NOT NULL DEFAULT FALSE"); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5f61426f..7a673772 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -20,6 +20,13 @@ Limit: Depth: 3 # 子领地深度 0:不允许子领地 -1:不限制 WorldBlackList: [] +Teleport: + Enable: true + # 传送延迟 秒 + Delay: 0 + # 冷却时间 秒 + CoolDown: 0 + # -1 表示不开启 AutoCleanAfterDays: 180