优化边界显示

This commit is contained in:
zhangyuheng 2024-07-18 11:32:05 +08:00
parent 9c2d18cc3e
commit 4beeea5040
10 changed files with 40 additions and 37 deletions

View File

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

View File

@ -1,9 +1,12 @@
package cn.lunadeer.dominion; package cn.lunadeer.dominion;
import cn.lunadeer.dominion.dtos.*; import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.dtos.Flag;
import cn.lunadeer.dominion.dtos.GroupDTO;
import cn.lunadeer.dominion.dtos.MemberDTO;
import cn.lunadeer.dominion.utils.Particle;
import cn.lunadeer.dominion.utils.ResMigration; import cn.lunadeer.dominion.utils.ResMigration;
import cn.lunadeer.minecraftpluginutils.Notification; import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.minecraftpluginutils.ParticleRender;
import cn.lunadeer.minecraftpluginutils.Scheduler; import cn.lunadeer.minecraftpluginutils.Scheduler;
import cn.lunadeer.minecraftpluginutils.XLogger; import cn.lunadeer.minecraftpluginutils.XLogger;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -11,7 +14,6 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -20,6 +22,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import static cn.lunadeer.dominion.DominionNode.getLocInDominionNode; import static cn.lunadeer.dominion.DominionNode.getLocInDominionNode;
import static cn.lunadeer.dominion.DominionNode.isInDominion;
public class Cache { public class Cache {
@ -212,7 +215,7 @@ public class Cache {
if (last_in_dom_id != null) { if (last_in_dom_id != null) {
last_dominion = id_dominions.get(last_in_dom_id); last_dominion = id_dominions.get(last_in_dom_id);
} }
if (isInDominion(last_dominion, player)) { if (isInDominion(last_dominion, player.getLocation())) {
if (dominion_children.get(last_in_dom_id) == null || dominion_children.get(last_in_dom_id).size() == 0) { if (dominion_children.get(last_in_dom_id) == null || dominion_children.get(last_in_dom_id).size() == 0) {
// 如果玩家仍在领地内且领地没有子领地则直接返回 // 如果玩家仍在领地内且领地没有子领地则直接返回
if (recheckPlayerState) { if (recheckPlayerState) {
@ -249,9 +252,7 @@ public class Cache {
player_current_dominion_id.put(player.getUniqueId(), current_dominion.getId()); player_current_dominion_id.put(player.getUniqueId(), current_dominion.getId());
// show border // show border
if (current_dominion.getFlagValue(Flag.SHOW_BORDER)) { if (current_dominion.getFlagValue(Flag.SHOW_BORDER)) {
ParticleRender.showBoxFace(player, Particle.showBorder(player, current_dominion);
current_dominion.getLocation1(),
current_dominion.getLocation2());
} }
return current_dominion; return current_dominion;
} }
@ -361,17 +362,6 @@ public class Cache {
return player_uuid_to_member.get(player_uuid).get(dominion.getId()); return player_uuid_to_member.get(player_uuid).get(dominion.getId());
} }
private static boolean isInDominion(@Nullable DominionDTO dominion, Player player) {
if (dominion == null) return false;
if (!Objects.equals(dominion.getWorld(), player.getWorld().getName())) return false;
double x = player.getLocation().getX();
double y = player.getLocation().getY();
double z = player.getLocation().getZ();
return x >= dominion.getX1() && x <= dominion.getX2() &&
y >= dominion.getY1() && y <= dominion.getY2() &&
z >= dominion.getZ1() && z <= dominion.getZ2();
}
public DominionDTO getDominion(Integer id) { public DominionDTO getDominion(Integer id) {
return id_dominions.get(id); return id_dominions.get(id);
} }

View File

@ -1,6 +1,5 @@
package cn.lunadeer.dominion; package cn.lunadeer.dominion;
import cn.lunadeer.dominion.dtos.PrivilegeTemplateDTO;
import cn.lunadeer.dominion.events.EnvironmentEvents; import cn.lunadeer.dominion.events.EnvironmentEvents;
import cn.lunadeer.dominion.events.PlayerEvents; import cn.lunadeer.dominion.events.PlayerEvents;
import cn.lunadeer.dominion.events.SelectPointEvents; import cn.lunadeer.dominion.events.SelectPointEvents;

View File

@ -72,8 +72,8 @@ public class DominionNode {
double x = location.getX(); double x = location.getX();
double y = location.getY(); double y = location.getY();
double z = location.getZ(); double z = location.getZ();
return x >= dominion.getX1() && x <= dominion.getX2() && return x >= dominion.getX1() && x < dominion.getX2() &&
y >= dominion.getY1() && y <= dominion.getY2() && y >= dominion.getY1() && y < dominion.getY2() &&
z >= dominion.getZ1() && z <= dominion.getZ2(); z >= dominion.getZ1() && z < dominion.getZ2();
} }
} }

View File

@ -4,8 +4,8 @@ import cn.lunadeer.dominion.Cache;
import cn.lunadeer.dominion.Dominion; import cn.lunadeer.dominion.Dominion;
import cn.lunadeer.dominion.dtos.DominionDTO; import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.dtos.PlayerDTO; import cn.lunadeer.dominion.dtos.PlayerDTO;
import cn.lunadeer.dominion.utils.Particle;
import cn.lunadeer.minecraftpluginutils.Notification; import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.minecraftpluginutils.ParticleRender;
import cn.lunadeer.minecraftpluginutils.VaultConnect; import cn.lunadeer.minecraftpluginutils.VaultConnect;
import cn.lunadeer.minecraftpluginutils.XLogger; import cn.lunadeer.minecraftpluginutils.XLogger;
import org.bukkit.Location; import org.bukkit.Location;
@ -786,9 +786,7 @@ public class DominionController {
*/ */
private static void handleParticle(AbstractOperator operator, DominionDTO dominion) { private static void handleParticle(AbstractOperator operator, DominionDTO dominion) {
if (operator instanceof BukkitPlayerOperator) { if (operator instanceof BukkitPlayerOperator) {
ParticleRender.showBoxFace(operator.getPlayer(), Particle.showBorder(operator.getPlayer(), dominion);
dominion.getLocation1(),
dominion.getLocation2());
} }
} }

View File

@ -1,10 +1,9 @@
package cn.lunadeer.dominion.events; package cn.lunadeer.dominion.events;
import cn.lunadeer.dominion.Cache;
import cn.lunadeer.dominion.Dominion; import cn.lunadeer.dominion.Dominion;
import cn.lunadeer.dominion.dtos.DominionDTO; import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.utils.Particle;
import cn.lunadeer.minecraftpluginutils.Notification; import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.minecraftpluginutils.ParticleRender;
import cn.lunadeer.minecraftpluginutils.VaultConnect; import cn.lunadeer.minecraftpluginutils.VaultConnect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -95,7 +94,7 @@ public class SelectPointEvents implements Listener {
float price = count * Dominion.config.getEconomyPrice(); float price = count * Dominion.config.getEconomyPrice();
Notification.info(player, "预计领地创建价格为 %.2f %s", price, VaultConnect.instance.currencyNamePlural()); Notification.info(player, "预计领地创建价格为 %.2f %s", price, VaultConnect.instance.currencyNamePlural());
} }
ParticleRender.showBoxFace(player, dominion.getLocation1(), dominion.getLocation2()); Particle.showBorder(player, dominion);
Notification.info(player, "尺寸: %d x %d x %d", dominion.getWidthX(), dominion.getHeight(), dominion.getWidthZ()); 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.getSquare());
Notification.info(player, "高度: %d", dominion.getHeight()); Notification.info(player, "高度: %d", dominion.getHeight());

View File

@ -1,6 +1,5 @@
package cn.lunadeer.dominion.tuis; package cn.lunadeer.dominion.tuis;
import cn.lunadeer.dominion.Cache;
import cn.lunadeer.dominion.DominionNode; import cn.lunadeer.dominion.DominionNode;
import cn.lunadeer.dominion.dtos.DominionDTO; import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.minecraftpluginutils.stui.ListView; import cn.lunadeer.minecraftpluginutils.stui.ListView;

View File

@ -1,6 +1,5 @@
package cn.lunadeer.dominion.tuis.dominion; package cn.lunadeer.dominion.tuis.dominion;
import cn.lunadeer.dominion.Cache;
import cn.lunadeer.dominion.DominionNode; import cn.lunadeer.dominion.DominionNode;
import cn.lunadeer.dominion.dtos.DominionDTO; import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.minecraftpluginutils.stui.ListView; import cn.lunadeer.minecraftpluginutils.stui.ListView;

View File

@ -1,11 +1,10 @@
package cn.lunadeer.dominion.tuis.dominion.manage; package cn.lunadeer.dominion.tuis.dominion.manage;
import cn.lunadeer.dominion.Dominion;
import cn.lunadeer.dominion.controllers.PlayerController; import cn.lunadeer.dominion.controllers.PlayerController;
import cn.lunadeer.dominion.dtos.DominionDTO; import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.dtos.PlayerDTO; import cn.lunadeer.dominion.dtos.PlayerDTO;
import cn.lunadeer.dominion.utils.Particle;
import cn.lunadeer.minecraftpluginutils.Notification; import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.minecraftpluginutils.ParticleRender;
import cn.lunadeer.minecraftpluginutils.stui.View; import cn.lunadeer.minecraftpluginutils.stui.View;
import cn.lunadeer.minecraftpluginutils.stui.components.Button; import cn.lunadeer.minecraftpluginutils.stui.components.Button;
import cn.lunadeer.minecraftpluginutils.stui.components.Line; import cn.lunadeer.minecraftpluginutils.stui.components.Line;
@ -49,8 +48,6 @@ public class SizeInfo {
.append(Button.create("管理界面").setExecuteCommand("/dominion manage " + dominion.getName()).build()) .append(Button.create("管理界面").setExecuteCommand("/dominion manage " + dominion.getName()).build())
.append(Button.create("访客权限").setExecuteCommand("/dominion guest_setting " + dominion.getName()).build())) .append(Button.create("访客权限").setExecuteCommand("/dominion guest_setting " + dominion.getName()).build()))
.showOn(player); .showOn(player);
ParticleRender.showBoxFace(player, Particle.showBorder(player, dominion);
dominion.getLocation1(),
dominion.getLocation2());
} }
} }

View File

@ -0,0 +1,22 @@
package cn.lunadeer.dominion.utils;
import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.minecraftpluginutils.ParticleRender;
import org.bukkit.entity.Player;
public class Particle {
public static void showBorder(Player player, DominionDTO dominion) {
// 由于领地的坐标系统是方块坐标所以大端需要减去1才是实际角点坐标
ParticleRender.showBoxFace(player,
dominion.getLocation1().getWorld(),
dominion.getLocation1().getBlockX(),
dominion.getLocation1().getBlockY(),
dominion.getLocation1().getBlockZ(),
dominion.getLocation2().getBlockX(),
dominion.getLocation2().getBlockY(),
dominion.getLocation2().getBlockZ()
);
}
}