修复了选区价格和创建价格不符问题、修复了玩家重新上线时飞行权限不生效问题
Java CI-CD with Maven / build (push) Successful in 13m14s Details

This commit is contained in:
zhangyuheng 2024-06-02 23:18:13 +08:00
parent 7b4d26970b
commit 9b7917aa14
6 changed files with 44 additions and 21 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>Dominion</artifactId>
<version>1.30.13-beta</version>
<version>1.30.14-beta</version>
<packaging>jar</packaging>
<name>Dominion</name>

View File

@ -125,7 +125,7 @@ public class Cache {
last_dominion = id_dominions.get(last_in_dom_id);
}
if (isInDominion(last_dominion, player)) {
if (dominion_children.get(last_in_dom_id) == null) {
if (dominion_children.get(last_in_dom_id) == null || dominion_children.get(last_in_dom_id).size() == 0) {
// 如果玩家仍在领地内且领地没有子领地则直接返回
return last_dominion;
}
@ -171,6 +171,17 @@ public class Cache {
return current_dominion;
}
/**
* 玩家退出时调用 用于清除玩家当前所在领地
* 会将玩家当前所在领地设置为null
* 这样当玩家下次进入领地时会重新检查玩家所在位置
*
* @param player 玩家
*/
public void onPlayerQuit(Player player) {
player_current_dominion_id.put(player.getUniqueId(), null);
}
/**
* 检查玩家是否需要设置为发光
*

View File

@ -146,9 +146,9 @@ public class DominionController {
if (Dominion.config.getEconomyEnable()) {
int count;
if (Dominion.config.getEconomyOnlyXZ()) {
count = (loc2.getBlockX() - loc1.getBlockX() + 1) * (loc2.getBlockZ() - loc1.getBlockZ() + 1);
count = dominion.getSquare();
} else {
count = (loc2.getBlockX() - loc1.getBlockX() + 1) * (loc2.getBlockY() - loc1.getBlockY() + 1) * (loc2.getBlockZ() - loc1.getBlockZ() + 1);
count = dominion.getVolume();
}
float price = count * Dominion.config.getEconomyPrice();
if (Dominion.vault.getEconomy().getBalance(operator.getPlayer()) < price) {

View File

@ -326,11 +326,23 @@ public class DominionDTO {
}
public Integer getSquare() {
return (x2 - x1) * (z2 - z1);
return (x2 - x1 + 1) * (z2 - z1 + 1);
}
public Integer getVolume() {
return getSquare() * (y2 - y1);
return getSquare() * (y2 - y1 + 1);
}
public Integer getWidthX() {
return x2 - x1 + 1;
}
public Integer getHeight() {
return y2 - y1 + 1;
}
public Integer getWidthZ() {
return z2 - z1 + 1;
}
public Integer getParentDomId() {

View File

@ -40,6 +40,12 @@ public class PlayerEvents implements Listener {
player.onJoin(); // update name
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player bukkitPlayer = event.getPlayer();
Cache.instance.onPlayerQuit(bukkitPlayer);
}
@EventHandler(priority = EventPriority.HIGHEST) // anchor
public void onRespawnAnchor(PlayerRespawnEvent event) {
Player bukkitPlayer = event.getPlayer();

View File

@ -1,6 +1,7 @@
package cn.lunadeer.dominion.events;
import cn.lunadeer.dominion.Dominion;
import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.minecraftpluginutils.ParticleRender;
import org.bukkit.Location;
@ -71,30 +72,23 @@ public class SelectPointEvents implements Listener {
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()) {
int count;
if (Dominion.config.getEconomyOnlyXZ()) {
count = (maxX - minX) * (maxZ - minZ);
count = dominion.getSquare();
} else {
count = (maxX - minX) * (maxY - minY) * (maxZ - minZ);
count = dominion.getVolume();
}
float price = count * Dominion.config.getEconomyPrice();
Notification.info(player, "预计领地创建价格为 %.2f %s", price, Dominion.vault.getEconomy().currencyNamePlural());
}
ParticleRender.showBoxFace(Dominion.instance, player, loc1, loc2);
Notification.info(player, "尺寸: %d x %d x %d",
Math.abs(points.get(1).getBlockX() - points.get(0).getBlockX()),
Math.abs(points.get(1).getBlockY() - points.get(0).getBlockY()),
Math.abs(points.get(1).getBlockZ() - points.get(0).getBlockZ()));
Notification.info(player, "面积: %d",
Math.abs(points.get(1).getBlockX() - points.get(0).getBlockX()) *
Math.abs(points.get(1).getBlockZ() - points.get(0).getBlockZ()));
Notification.info(player, "高度: %d",
Math.abs(points.get(1).getBlockY() - points.get(0).getBlockY()));
Notification.info(player, "体积: %d",
Math.abs(points.get(1).getBlockX() - points.get(0).getBlockX()) *
Math.abs(points.get(1).getBlockY() - points.get(0).getBlockY()) *
Math.abs(points.get(1).getBlockZ() - points.get(0).getBlockZ()));
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());
Notification.info(player, "体积: %d", dominion.getVolume());
}
Dominion.pointsSelect.put(player.getUniqueId(), points);
}