From ba81403d6f2cae0dcfa2ad5eef49b2b41dd18df9 Mon Sep 17 00:00:00 2001 From: zhangyuheng Date: Fri, 12 Jul 2024 21:11:51 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=9E=82=E7=9B=B4=E9=80=89=E5=8F=96=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../dominion/events/SelectPointEvents.java | 20 +++++++++++-------- .../java/cn/lunadeer/dominion/tuis/Menu.java | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 5ce751d..9f43d91 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cn.lunadeer Dominion - 1.35.10-beta + 1.35.13-beta jar Dominion diff --git a/src/main/java/cn/lunadeer/dominion/events/SelectPointEvents.java b/src/main/java/cn/lunadeer/dominion/events/SelectPointEvents.java index 9a036b9..bdaaf23 100644 --- a/src/main/java/cn/lunadeer/dominion/events/SelectPointEvents.java +++ b/src/main/java/cn/lunadeer/dominion/events/SelectPointEvents.java @@ -42,14 +42,23 @@ public class SelectPointEvents implements Listener { if (action == Action.LEFT_CLICK_BLOCK) { event.setCancelled(true); Notification.info(player, "已选择第一个点: %d %d %d", block.getX(), block.getY(), block.getZ()); - points.put(0, block.getLocation()); + Location loc = block.getLocation(); + if (Dominion.config.getLimitVert()) { + loc.setY(Dominion.config.getLimitMinY()); + } + points.put(0, loc); } else if (action == Action.RIGHT_CLICK_BLOCK) { event.setCancelled(true); Notification.info(player, "已选择第二个点: %d %d %d", block.getX(), block.getY(), block.getZ()); - points.put(1, block.getLocation()); + Location loc = block.getLocation(); + if (Dominion.config.getLimitVert()) { + loc.setY(Dominion.config.getLimitMaxY()); + } + points.put(1, loc); } else { return; } + Dominion.pointsSelect.put(player.getUniqueId(), points); if (points.size() == 2) { World world = points.get(0).getWorld(); @@ -57,7 +66,7 @@ public class SelectPointEvents implements Listener { return; } if (!points.get(0).getWorld().equals(points.get(1).getWorld())) { - Notification.error(player, "两个点不在同一个世界"); + Notification.warn(player, "两个点不在同一个世界"); return; } Notification.info(player, "已选择两个点,可以使用 /dominion create <领地名称> 创建领地"); @@ -69,10 +78,6 @@ public class SelectPointEvents implements Listener { int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX()); int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY()); int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ()); - if (Dominion.config.getLimitVert()) { - minY = Dominion.config.getLimitMinY(); - maxY = Dominion.config.getLimitMaxY(); - } DominionDTO dominion = new DominionDTO(player.getUniqueId(), "", loc1.getWorld().getName(), minX, minY, minZ, maxX, maxY, maxZ); if (Dominion.config.getEconomyEnable()) { @@ -95,6 +100,5 @@ public class SelectPointEvents implements Listener { Notification.info(player, "高度: %d", dominion.getHeight()); Notification.info(player, "体积: %d", dominion.getVolume()); } - Dominion.pointsSelect.put(player.getUniqueId(), points); } } diff --git a/src/main/java/cn/lunadeer/dominion/tuis/Menu.java b/src/main/java/cn/lunadeer/dominion/tuis/Menu.java index 5499939..7214eba 100644 --- a/src/main/java/cn/lunadeer/dominion/tuis/Menu.java +++ b/src/main/java/cn/lunadeer/dominion/tuis/Menu.java @@ -46,7 +46,7 @@ public class Menu { .append(Button.create("所有领地").setExecuteCommand("/dominion all_dominion").build()) .append("查看所有领地"); Line config = Line.create() - .append(Button.create("系统配置").setExecuteCommand("/dominion config").build()) + .append(Button.create("系统配置").setExecuteCommand("/dominion sys_config").build()) .append("查看/修改系统配置"); Line reload_cache = Line.create() .append(Button.create("重载缓存").setExecuteCommand("/dominion reload_cache").build()) From cc2423dd1ba4e7a53a5a40e1cc1f026f3e6611e7 Mon Sep 17 00:00:00 2001 From: zhangyuheng Date: Sat, 13 Jul 2024 16:33:41 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E2=80=9C=E6=9C=AB?= =?UTF-8?q?=E5=BD=B1=E9=BE=99=E7=A0=B4=E5=9D=8F=E6=96=B9=E5=9D=97=E2=80=9D?= =?UTF-8?q?=E9=A2=86=E5=9C=B0=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- src/main/java/cn/lunadeer/dominion/dtos/Flag.java | 3 ++- .../cn/lunadeer/dominion/events/EnvironmentEvents.java | 10 ++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5ce751d..92fbc94 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cn.lunadeer Dominion - 1.35.10-beta + 1.36.0-beta jar Dominion diff --git a/src/main/java/cn/lunadeer/dominion/dtos/Flag.java b/src/main/java/cn/lunadeer/dominion/dtos/Flag.java index 3e5d1ae..aea6364 100644 --- a/src/main/java/cn/lunadeer/dominion/dtos/Flag.java +++ b/src/main/java/cn/lunadeer/dominion/dtos/Flag.java @@ -25,9 +25,10 @@ public enum Flag { CAKE("cake", "吃蛋糕", "是否可以吃蛋糕", false, false, true), CONTAINER("container", "一般容器", "包含:箱子/木桶/潜影盒/盔甲架/展示框", false, false, true), CRAFT("craft", "使用工作台", "是否可以使用工作台", false, false, true), - CREEPER_EXPLODE("creeper_explode", "实体爆炸", "包含:苦力怕/凋零头颅/水晶爆炸", false, true, true), + CREEPER_EXPLODE("creeper_explode", "实体爆炸", "包含:苦力怕/凋零头颅/末影水晶/火球", false, true, true), COMPARER("comparer", "比较器交互", "是否可以修改比较器状态", false, false, true), DOOR("door", "门交互", "是否可以使用各种材质的门(包括活板门)", false, false, true), + DRAGON_BREAK_BLOCK("dragon_break_block", "末影龙破坏方块", "末影龙冲撞是否可以破坏方块", false, true, true), DRAGON_EGG("dragon_egg", "触碰龙蛋", "是否可以触碰龙蛋", false, false, true), DYE("dye", "染色", "是否可以使用染料(对羊、狗项圈、猫项圈)染色", false, false, true), EDIT_SIGN("edit_sign", "编辑告示牌", "是否可以编辑告示牌", false, false, true), diff --git a/src/main/java/cn/lunadeer/dominion/events/EnvironmentEvents.java b/src/main/java/cn/lunadeer/dominion/events/EnvironmentEvents.java index 3b72a91..ba73faa 100644 --- a/src/main/java/cn/lunadeer/dominion/events/EnvironmentEvents.java +++ b/src/main/java/cn/lunadeer/dominion/events/EnvironmentEvents.java @@ -38,6 +38,16 @@ public class EnvironmentEvents implements Listener { checkFlag(dom, Flag.CREEPER_EXPLODE, event); } + @EventHandler(priority = EventPriority.HIGHEST) // dragon_break_block + public void onDragonBreakBlock(EntityExplodeEvent event) { + Entity entity = event.getEntity(); + if (entity.getType() != EntityType.ENDER_DRAGON) { + return; + } + DominionDTO dom = Cache.instance.getDominion(event.getLocation()); + checkFlag(dom, Flag.DRAGON_BREAK_BLOCK, event); + } + @EventHandler(priority = EventPriority.HIGHEST) // fire_spread public void onFireSpread(BlockIgniteEvent event) { Player player = event.getPlayer(); From 0fe7f28c6478c0e60852801eb6e0e9c389f0a010 Mon Sep 17 00:00:00 2001 From: zhangyuheng Date: Mon, 15 Jul 2024 15:20:13 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E9=A2=86?= =?UTF-8?q?=E5=9C=B0=E6=98=BE=E7=A4=BA=E5=B0=BA=E5=AF=B8=E4=B8=8E=E5=AE=9E?= =?UTF-8?q?=E9=99=85=E5=B0=BA=E5=AF=B8=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- src/main/java/cn/lunadeer/dominion/Cache.java | 2 +- .../controllers/DominionController.java | 56 +++++++------------ .../lunadeer/dominion/dtos/DominionDTO.java | 10 ++-- .../dominion/events/SelectPointEvents.java | 9 +-- .../tuis/dominion/manage/SizeInfo.java | 2 +- 6 files changed, 33 insertions(+), 48 deletions(-) diff --git a/pom.xml b/pom.xml index 92fbc94..bcc2c0e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cn.lunadeer Dominion - 1.36.0-beta + 1.36.1-beta jar Dominion diff --git a/src/main/java/cn/lunadeer/dominion/Cache.java b/src/main/java/cn/lunadeer/dominion/Cache.java index 5b64aea..d108027 100644 --- a/src/main/java/cn/lunadeer/dominion/Cache.java +++ b/src/main/java/cn/lunadeer/dominion/Cache.java @@ -251,7 +251,7 @@ public class Cache { player_current_dominion_id.put(player.getUniqueId(), current_dominion.getId()); // show border if (current_dominion.getFlagValue(Flag.SHOW_BORDER)) { - ParticleRender.showBoxFace(Dominion.instance, player, + ParticleRender.showBoxFace(player, current_dominion.getLocation1(), current_dominion.getLocation2()); } diff --git a/src/main/java/cn/lunadeer/dominion/controllers/DominionController.java b/src/main/java/cn/lunadeer/dominion/controllers/DominionController.java index 24f3d1c..8d54463 100644 --- a/src/main/java/cn/lunadeer/dominion/controllers/DominionController.java +++ b/src/main/java/cn/lunadeer/dominion/controllers/DominionController.java @@ -106,10 +106,14 @@ public class DominionController { operator.setResponse(FAIL.addMessage("你的领地数量已达上限(%d个)", Dominion.config.getLimitAmount())); return; } + int minX = Math.min(loc1.getBlockX(), loc2.getBlockX()); + int minY = Math.min(loc1.getBlockY(), loc2.getBlockY()); + int minZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ()); + int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX()) + 1; + int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY()) + 1; + int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ()) + 1; // 检查领地大小是否合法 - if (sizeNotValid(operator, - loc1.getBlockX(), loc1.getBlockY(), loc1.getBlockZ(), - loc2.getBlockX(), loc2.getBlockY(), loc2.getBlockZ())) { + if (sizeNotValid(operator, minX, minY, minZ, maxX, maxY, maxZ)) { return; } DominionDTO parent_dominion; @@ -134,9 +138,7 @@ public class DominionController { } // 创建 dominion (此步骤不会写入数据) DominionDTO dominion = DominionDTO.create(operator.getUniqueId(), name, loc1.getWorld().getName(), - (int) Math.min(loc1.getX(), loc2.getX()), (int) Math.min(loc1.getY(), loc2.getY()), - (int) Math.min(loc1.getZ(), loc2.getZ()), (int) Math.max(loc1.getX(), loc2.getX()), - (int) Math.max(loc1.getY(), loc2.getY()), (int) Math.max(loc1.getZ(), loc2.getZ()), parent_dominion); + minX, minY, minZ, maxX, maxY, maxZ, parent_dominion); // 如果parent_dominion不为-1 检查是否在同一世界 if (parent_dominion.getId() != -1 && !parent_dominion.getWorld().equals(dominion.getWorld())) { operator.setResponse(FAIL.addMessage("父领地与子领地不在同一世界。")); @@ -169,7 +171,7 @@ public class DominionController { return; } // 显示粒子效果 - handleParticle(operator, dominion.getWorld(), dominion.getX1(), dominion.getY1(), dominion.getZ1(), dominion.getX2(), dominion.getY2(), dominion.getZ2(), FAIL); + handleParticle(operator, dominion); operator.setResponse(SUCCESS); } @@ -232,8 +234,8 @@ public class DominionController { handleEconomy(operator, Dominion.config.getEconomyOnlyXZ() ? sqr(newCords) - dominion.getSquare() : vol(newCords) - dominion.getVolume() , true, FAIL, SUCCESS); // 显示粒子效果 - handleParticle(operator, dominion.getWorld(), newCords, FAIL); - dominion.setXYZ(newCords); + dominion = dominion.setXYZ(newCords); + handleParticle(operator, dominion); operator.setResponse(SUCCESS); } @@ -284,8 +286,8 @@ public class DominionController { handleEconomy(operator, Dominion.config.getEconomyOnlyXZ() ? dominion.getSquare() - sqr(newCords) : dominion.getVolume() - vol(newCords) , false, FAIL, SUCCESS); // 显示粒子效果 - handleParticle(operator, dominion.getWorld(), newCords, FAIL); - dominion.setXYZ(newCords); + dominion = dominion.setXYZ(newCords); + handleParticle(operator, dominion); operator.setResponse(SUCCESS); } @@ -577,9 +579,7 @@ public class DominionController { * 判断两个领地是否相交 */ private static boolean isIntersect(DominionDTO a, DominionDTO b) { - return a.getX1() < b.getX2() && a.getX2() > b.getX1() && - a.getY1() < b.getY2() && a.getY2() > b.getY1() && - a.getZ1() < b.getZ2() && a.getZ2() > b.getZ1(); + return isIntersect(a, b.getX1(), b.getY1(), b.getZ1(), b.getX2(), b.getY2(), b.getZ2()); } private static boolean isIntersect(DominionDTO a, Integer x1, Integer y1, Integer z1, Integer x2, Integer y2, Integer z2) { @@ -781,33 +781,17 @@ public class DominionController { /** * 显示粒子效果 * - * @param operator 操作者 - * @param worldName 世界名称 - * @param x1 x1 - * @param y1 y1 - * @param z1 z1 - * @param x2 x2 - * @param y2 y2 - * @param z2 z2 - * @param FAIL 失败消息 + * @param operator 操作者 + * @param dominion 领地 */ - private static void handleParticle(AbstractOperator operator, String worldName, Integer x1, Integer y1, Integer z1, Integer x2, Integer y2, Integer z2, AbstractOperator.Result FAIL) { + private static void handleParticle(AbstractOperator operator, DominionDTO dominion) { if (operator instanceof BukkitPlayerOperator) { - World world = Dominion.instance.getServer().getWorld(worldName); - if (world == null) { - operator.setResponse(FAIL.addMessage("世界 %s 不存在", worldName)); - return; - } - ParticleRender.showBoxFace(Dominion.instance, operator.getPlayer(), - new Location(world, x1, y1, z1), - new Location(world, x2, y2, z2)); + ParticleRender.showBoxFace(operator.getPlayer(), + dominion.getLocation1(), + dominion.getLocation2()); } } - private static void handleParticle(AbstractOperator operator, String worldName, int[] cords, AbstractOperator.Result FAIL) { - handleParticle(operator, worldName, cords[0], cords[1], cords[2], cords[3], cords[4], cords[5], FAIL); - } - private static @Nullable DominionDTO expandContractPreCheck(AbstractOperator operator, @Nullable DominionDTO dominion, AbstractOperator.Result FAIL) { if (dominion == null) { return null; diff --git a/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java b/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java index 1490180..1ecb31b 100644 --- a/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java +++ b/src/main/java/cn/lunadeer/dominion/dtos/DominionDTO.java @@ -311,23 +311,23 @@ public class DominionDTO { } public Integer getSquare() { - return (getX2() - getX1() + 1) * (getZ2() - getZ1() + 1); + return getWidthX() * getWidthZ(); } public Integer getVolume() { - return getSquare() * (getY2() - getY1() + 1); + return getSquare() * getHeight(); } public Integer getWidthX() { - return getX2() - getX1() + 1; + return getX2() - getX1(); } public Integer getHeight() { - return getY2() - getY1() + 1; + return getY2() - getY1(); } public Integer getWidthZ() { - return getZ2() - getZ1() + 1; + return getZ2() - getZ1(); } public Integer getParentDomId() { diff --git a/src/main/java/cn/lunadeer/dominion/events/SelectPointEvents.java b/src/main/java/cn/lunadeer/dominion/events/SelectPointEvents.java index bdaaf23..d9ecccd 100644 --- a/src/main/java/cn/lunadeer/dominion/events/SelectPointEvents.java +++ b/src/main/java/cn/lunadeer/dominion/events/SelectPointEvents.java @@ -1,5 +1,6 @@ package cn.lunadeer.dominion.events; +import cn.lunadeer.dominion.Cache; import cn.lunadeer.dominion.Dominion; import cn.lunadeer.dominion.dtos.DominionDTO; import cn.lunadeer.minecraftpluginutils.Notification; @@ -75,9 +76,9 @@ public class SelectPointEvents implements Listener { int minX = Math.min(loc1.getBlockX(), loc2.getBlockX()); int minY = Math.min(loc1.getBlockY(), loc2.getBlockY()); int minZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ()); - int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX()); - int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY()); - int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ()); + int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX()) + 1; + int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY()) + 1; + int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ()) + 1; DominionDTO dominion = new DominionDTO(player.getUniqueId(), "", loc1.getWorld().getName(), minX, minY, minZ, maxX, maxY, maxZ); if (Dominion.config.getEconomyEnable()) { @@ -94,7 +95,7 @@ public class SelectPointEvents implements Listener { float price = count * Dominion.config.getEconomyPrice(); Notification.info(player, "预计领地创建价格为 %.2f %s", price, VaultConnect.instance.currencyNamePlural()); } - ParticleRender.showBoxFace(Dominion.instance, player, loc1, loc2); + ParticleRender.showBoxFace(player, dominion.getLocation1(), dominion.getLocation2()); Notification.info(player, "尺寸: %d x %d x %d", dominion.getWidthX(), dominion.getHeight(), dominion.getWidthZ()); Notification.info(player, "面积: %d", dominion.getSquare()); Notification.info(player, "高度: %d", dominion.getHeight()); diff --git a/src/main/java/cn/lunadeer/dominion/tuis/dominion/manage/SizeInfo.java b/src/main/java/cn/lunadeer/dominion/tuis/dominion/manage/SizeInfo.java index 3d28b2a..0ecde11 100644 --- a/src/main/java/cn/lunadeer/dominion/tuis/dominion/manage/SizeInfo.java +++ b/src/main/java/cn/lunadeer/dominion/tuis/dominion/manage/SizeInfo.java @@ -49,7 +49,7 @@ public class SizeInfo { .append(Button.create("管理界面").setExecuteCommand("/dominion manage " + dominion.getName()).build()) .append(Button.create("访客权限").setExecuteCommand("/dominion guest_setting " + dominion.getName()).build())) .showOn(player); - ParticleRender.showBoxFace(Dominion.instance, player, + ParticleRender.showBoxFace(player, dominion.getLocation1(), dominion.getLocation2()); }