mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2025-01-27 13:53:59 +08:00
修复了领地显示尺寸与实际尺寸不一致问题
This commit is contained in:
parent
4c8066f7cb
commit
0fe7f28c64
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>Dominion</artifactId>
|
||||
<version>1.36.0-beta</version>
|
||||
<version>1.36.1-beta</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Dominion</name>
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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() {
|
||||
|
@ -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());
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user