diff --git a/pom.xml b/pom.xml index 92fbc946..bcc2c0e0 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 5b64aeab..d1080272 100644 --- a/src/main/java/cn/lunadeer/dominion/Cache.java +++ b/src/main/java/cn/lunadeer/dominion/Cache.java @@ -251,7 +251,7 @@ public DominionDTO getPlayerCurrentDominion(Player player) { 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 24f3d1c3..8d54463c 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 static void create(AbstractOperator operator, String name, 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 static void create(AbstractOperator operator, String name, } // 创建 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 static void create(AbstractOperator operator, String name, 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 static void expand(AbstractOperator operator, Integer size, String domini 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 static void contract(AbstractOperator operator, Integer size, String domi 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 static void setMapColor(AbstractOperator operator, String color) { * 判断两个领地是否相交 */ 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 @@ private static void handleEconomy(AbstractOperator operator, Integer count, bool /** * 显示粒子效果 * - * @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 14901804..1ecb31bb 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 DominionDTO setZ2(Integer z2) { } 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 bdaaf23e..d9ecccd7 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 void selectPoint(PlayerInteractEvent event) { 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 void selectPoint(PlayerInteractEvent event) { 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 3d28b2ae..0ecde11f 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 static void show(CommandSender sender, String[] args) { .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()); }