实现了采用world uid存储世界而不是name(如果使用此版本出现问题请不要回退版本!请立即和作者取得联系!)
All checks were successful
Java CI-CD with Gradle / build (push) Successful in 4m4s
All checks were successful
Java CI-CD with Gradle / build (push) Successful in 4m4s
This commit is contained in:
parent
87fc89407d
commit
eeb0f1adc7
@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "cn.lunadeer"
|
group = "cn.lunadeer"
|
||||||
version = "2.2.4-beta"
|
version = "2.3.0-beta"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||||
|
@ -10,6 +10,7 @@ import cn.lunadeer.minecraftpluginutils.Scheduler;
|
|||||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -463,10 +464,10 @@ public class Cache {
|
|||||||
B | A
|
B | A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private ConcurrentHashMap<String, List<DominionNode>> world_dominion_tree_sector_a; // x >= 0, z >= 0
|
private ConcurrentHashMap<UUID, List<DominionNode>> world_dominion_tree_sector_a; // x >= 0, z >= 0
|
||||||
private ConcurrentHashMap<String, List<DominionNode>> world_dominion_tree_sector_b; // x <= 0, z >= 0
|
private ConcurrentHashMap<UUID, List<DominionNode>> world_dominion_tree_sector_b; // x <= 0, z >= 0
|
||||||
private ConcurrentHashMap<String, List<DominionNode>> world_dominion_tree_sector_c; // x >= 0, z <= 0
|
private ConcurrentHashMap<UUID, List<DominionNode>> world_dominion_tree_sector_c; // x >= 0, z <= 0
|
||||||
private ConcurrentHashMap<String, List<DominionNode>> world_dominion_tree_sector_d; // x <= 0, z <= 0
|
private ConcurrentHashMap<UUID, List<DominionNode>> world_dominion_tree_sector_d; // x <= 0, z <= 0
|
||||||
|
|
||||||
public DominionDTO getLocInDominionDTO(@NotNull Location loc) {
|
public DominionDTO getLocInDominionDTO(@NotNull Location loc) {
|
||||||
try (AutoTimer ignored = new AutoTimer(Dominion.config.TimerEnabled())) {
|
try (AutoTimer ignored = new AutoTimer(Dominion.config.TimerEnabled())) {
|
||||||
@ -479,11 +480,15 @@ public class Cache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<DominionNode> getNodes(Location loc) {
|
public List<DominionNode> getNodes(@NotNull Location loc) {
|
||||||
return getNodes(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ());
|
return getNodes(loc.getWorld().getUID(), loc.getBlockX(), loc.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DominionNode> getNodes(String world, int x, int z) {
|
public List<DominionNode> getNodes(World world, int x, int z) {
|
||||||
|
return getNodes(world.getUID(), x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DominionNode> getNodes(UUID world, int x, int z) {
|
||||||
if (x >= 0 && z >= 0) {
|
if (x >= 0 && z >= 0) {
|
||||||
return world_dominion_tree_sector_a.get(world);
|
return world_dominion_tree_sector_a.get(world);
|
||||||
}
|
}
|
||||||
@ -507,64 +512,64 @@ public class Cache {
|
|||||||
world_dominion_tree_sector_c = new ConcurrentHashMap<>();
|
world_dominion_tree_sector_c = new ConcurrentHashMap<>();
|
||||||
world_dominion_tree_sector_d = new ConcurrentHashMap<>();
|
world_dominion_tree_sector_d = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
Map<String, List<DominionDTO>> world_dominions_sector_a = new HashMap<>();
|
Map<UUID, List<DominionDTO>> world_dominions_sector_a = new HashMap<>();
|
||||||
Map<String, List<DominionDTO>> world_dominions_sector_b = new HashMap<>();
|
Map<UUID, List<DominionDTO>> world_dominions_sector_b = new HashMap<>();
|
||||||
Map<String, List<DominionDTO>> world_dominions_sector_c = new HashMap<>();
|
Map<UUID, List<DominionDTO>> world_dominions_sector_c = new HashMap<>();
|
||||||
Map<String, List<DominionDTO>> world_dominions_sector_d = new HashMap<>();
|
Map<UUID, List<DominionDTO>> world_dominions_sector_d = new HashMap<>();
|
||||||
for (DominionDTO d : dominions) {
|
for (DominionDTO d : dominions) {
|
||||||
// 对每个世界的领地进行四个象限的划分
|
// 对每个世界的领地进行四个象限的划分
|
||||||
if (!world_dominions_sector_a.containsKey(d.getWorld()) ||
|
if (!world_dominions_sector_a.containsKey(d.getWorldUid()) ||
|
||||||
!world_dominions_sector_b.containsKey(d.getWorld()) ||
|
!world_dominions_sector_b.containsKey(d.getWorldUid()) ||
|
||||||
!world_dominions_sector_c.containsKey(d.getWorld()) ||
|
!world_dominions_sector_c.containsKey(d.getWorldUid()) ||
|
||||||
!world_dominions_sector_d.containsKey(d.getWorld())) {
|
!world_dominions_sector_d.containsKey(d.getWorldUid())) {
|
||||||
world_dominions_sector_a.put(d.getWorld(), new ArrayList<>());
|
world_dominions_sector_a.put(d.getWorldUid(), new ArrayList<>());
|
||||||
world_dominions_sector_b.put(d.getWorld(), new ArrayList<>());
|
world_dominions_sector_b.put(d.getWorldUid(), new ArrayList<>());
|
||||||
world_dominions_sector_c.put(d.getWorld(), new ArrayList<>());
|
world_dominions_sector_c.put(d.getWorldUid(), new ArrayList<>());
|
||||||
world_dominions_sector_d.put(d.getWorld(), new ArrayList<>());
|
world_dominions_sector_d.put(d.getWorldUid(), new ArrayList<>());
|
||||||
}
|
}
|
||||||
if (d.getX1() >= 0 && d.getZ1() >= 0) {
|
if (d.getX1() >= 0 && d.getZ1() >= 0) {
|
||||||
world_dominions_sector_a.get(d.getWorld()).add(d);
|
world_dominions_sector_a.get(d.getWorldUid()).add(d);
|
||||||
} else if (d.getX1() <= 0 && d.getZ1() >= 0) {
|
} else if (d.getX1() <= 0 && d.getZ1() >= 0) {
|
||||||
if (d.getX2() >= 0) {
|
if (d.getX2() >= 0) {
|
||||||
world_dominions_sector_a.get(d.getWorld()).add(d);
|
world_dominions_sector_a.get(d.getWorldUid()).add(d);
|
||||||
world_dominions_sector_b.get(d.getWorld()).add(d);
|
world_dominions_sector_b.get(d.getWorldUid()).add(d);
|
||||||
} else {
|
} else {
|
||||||
world_dominions_sector_b.get(d.getWorld()).add(d);
|
world_dominions_sector_b.get(d.getWorldUid()).add(d);
|
||||||
}
|
}
|
||||||
} else if (d.getX1() >= 0 && d.getZ1() <= 0) {
|
} else if (d.getX1() >= 0 && d.getZ1() <= 0) {
|
||||||
if (d.getZ2() >= 0) {
|
if (d.getZ2() >= 0) {
|
||||||
world_dominions_sector_a.get(d.getWorld()).add(d);
|
world_dominions_sector_a.get(d.getWorldUid()).add(d);
|
||||||
world_dominions_sector_c.get(d.getWorld()).add(d);
|
world_dominions_sector_c.get(d.getWorldUid()).add(d);
|
||||||
} else {
|
} else {
|
||||||
world_dominions_sector_c.get(d.getWorld()).add(d);
|
world_dominions_sector_c.get(d.getWorldUid()).add(d);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (d.getX2() >= 0 && d.getZ2() >= 0) {
|
if (d.getX2() >= 0 && d.getZ2() >= 0) {
|
||||||
world_dominions_sector_a.get(d.getWorld()).add(d);
|
world_dominions_sector_a.get(d.getWorldUid()).add(d);
|
||||||
world_dominions_sector_b.get(d.getWorld()).add(d);
|
world_dominions_sector_b.get(d.getWorldUid()).add(d);
|
||||||
world_dominions_sector_c.get(d.getWorld()).add(d);
|
world_dominions_sector_c.get(d.getWorldUid()).add(d);
|
||||||
world_dominions_sector_d.get(d.getWorld()).add(d);
|
world_dominions_sector_d.get(d.getWorldUid()).add(d);
|
||||||
} else if (d.getX2() >= 0 && d.getZ2() <= 0) {
|
} else if (d.getX2() >= 0 && d.getZ2() <= 0) {
|
||||||
world_dominions_sector_c.get(d.getWorld()).add(d);
|
world_dominions_sector_c.get(d.getWorldUid()).add(d);
|
||||||
world_dominions_sector_d.get(d.getWorld()).add(d);
|
world_dominions_sector_d.get(d.getWorldUid()).add(d);
|
||||||
} else if (d.getZ2() >= 0 && d.getX2() <= 0) {
|
} else if (d.getZ2() >= 0 && d.getX2() <= 0) {
|
||||||
world_dominions_sector_b.get(d.getWorld()).add(d);
|
world_dominions_sector_b.get(d.getWorldUid()).add(d);
|
||||||
world_dominions_sector_d.get(d.getWorld()).add(d);
|
world_dominions_sector_d.get(d.getWorldUid()).add(d);
|
||||||
} else {
|
} else {
|
||||||
world_dominions_sector_d.get(d.getWorld()).add(d);
|
world_dominions_sector_d.get(d.getWorldUid()).add(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, List<DominionDTO>> entry : world_dominions_sector_a.entrySet()) {
|
for (Map.Entry<UUID, List<DominionDTO>> entry : world_dominions_sector_a.entrySet()) {
|
||||||
world_dominion_tree_sector_a.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
world_dominion_tree_sector_a.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, List<DominionDTO>> entry : world_dominions_sector_b.entrySet()) {
|
for (Map.Entry<UUID, List<DominionDTO>> entry : world_dominions_sector_b.entrySet()) {
|
||||||
world_dominion_tree_sector_b.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
world_dominion_tree_sector_b.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, List<DominionDTO>> entry : world_dominions_sector_c.entrySet()) {
|
for (Map.Entry<UUID, List<DominionDTO>> entry : world_dominions_sector_c.entrySet()) {
|
||||||
world_dominion_tree_sector_c.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
world_dominion_tree_sector_c.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, List<DominionDTO>> entry : world_dominions_sector_d.entrySet()) {
|
for (Map.Entry<UUID, List<DominionDTO>> entry : world_dominions_sector_d.entrySet()) {
|
||||||
world_dominion_tree_sector_d.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
world_dominion_tree_sector_d.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,20 +55,16 @@ public class DominionNode {
|
|||||||
return node;
|
return node;
|
||||||
} else {
|
} else {
|
||||||
DominionNode childDominion = getLocInDominionNode(node.children, loc);
|
DominionNode childDominion = getLocInDominionNode(node.children, loc);
|
||||||
if (childDominion == null) {
|
return Objects.requireNonNullElse(childDominion, node);
|
||||||
return node;
|
|
||||||
} else {
|
|
||||||
return childDominion;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInDominion(@Nullable DominionDTO dominion, Location location) {
|
public static boolean isInDominion(@Nullable DominionDTO dominion, @NotNull Location location) {
|
||||||
if (dominion == null) return false;
|
if (dominion == null) return false;
|
||||||
if (!Objects.equals(dominion.getWorld(), location.getWorld().getName())) return false;
|
if (!Objects.equals(dominion.getWorldUid(), location.getWorld().getUID())) return false;
|
||||||
double x = location.getX();
|
double x = location.getX();
|
||||||
double y = location.getY();
|
double y = location.getY();
|
||||||
double z = location.getZ();
|
double z = location.getZ();
|
||||||
|
@ -391,9 +391,9 @@ public class DominionOperate {
|
|||||||
if (location == null) {
|
if (location == null) {
|
||||||
int x = (dominionDTO.getX1() + dominionDTO.getX2()) / 2;
|
int x = (dominionDTO.getX1() + dominionDTO.getX2()) / 2;
|
||||||
int z = (dominionDTO.getZ1() + dominionDTO.getZ2()) / 2;
|
int z = (dominionDTO.getZ1() + dominionDTO.getZ2()) / 2;
|
||||||
World world = Dominion.instance.getServer().getWorld(dominionDTO.getWorld());
|
World world = dominionDTO.getWorld();
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
Notification.error(sender, "领地所在世界 %s 不存在", dominionDTO.getWorld());
|
Notification.error(sender, "领地所在世界不存在");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
location = new Location(world, x, player.getLocation().getY(), z);
|
location = new Location(world, x, player.getLocation().getY(), z);
|
||||||
@ -463,9 +463,9 @@ public class DominionOperate {
|
|||||||
Location location = dominionDTO.getTpLocation();
|
Location location = dominionDTO.getTpLocation();
|
||||||
int center_x = (dominionDTO.getX1() + dominionDTO.getX2()) / 2;
|
int center_x = (dominionDTO.getX1() + dominionDTO.getX2()) / 2;
|
||||||
int center_z = (dominionDTO.getZ1() + dominionDTO.getZ2()) / 2;
|
int center_z = (dominionDTO.getZ1() + dominionDTO.getZ2()) / 2;
|
||||||
World world = Dominion.instance.getServer().getWorld(dominionDTO.getWorld());
|
World world = dominionDTO.getWorld();
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
Notification.error(player, "领地所在世界 %s 不存在", dominionDTO.getWorld());
|
Notification.error(player, "领地所在世界不存在");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
|
@ -52,8 +52,11 @@ public class Operator {
|
|||||||
Map<String, List<String>> mca_cords = new HashMap<>();
|
Map<String, List<String>> mca_cords = new HashMap<>();
|
||||||
List<DominionDTO> doms = Cache.instance.getDominions();
|
List<DominionDTO> doms = Cache.instance.getDominions();
|
||||||
for (DominionDTO dom : doms) {
|
for (DominionDTO dom : doms) {
|
||||||
if (!mca_cords.containsKey(dom.getWorld())) {
|
if (dom.getWorld() == null) {
|
||||||
mca_cords.put(dom.getWorld(), new ArrayList<>());
|
continue;
|
||||||
|
}
|
||||||
|
if (!mca_cords.containsKey(dom.getWorld().getName())) {
|
||||||
|
mca_cords.put(dom.getWorld().getName(), new ArrayList<>());
|
||||||
}
|
}
|
||||||
Integer world_x1 = dom.getX1();
|
Integer world_x1 = dom.getX1();
|
||||||
Integer world_x2 = dom.getX2();
|
Integer world_x2 = dom.getX2();
|
||||||
@ -66,10 +69,10 @@ public class Operator {
|
|||||||
for (int x = mca_x1; x <= mca_x2; x++) {
|
for (int x = mca_x1; x <= mca_x2; x++) {
|
||||||
for (int z = mca_z1; z <= mca_z2; z++) {
|
for (int z = mca_z1; z <= mca_z2; z++) {
|
||||||
String file_name = "r." + x + "." + z + ".mca";
|
String file_name = "r." + x + "." + z + ".mca";
|
||||||
if (mca_cords.get(dom.getWorld()).contains(file_name)) {
|
if (mca_cords.get(dom.getWorld().getName()).contains(file_name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mca_cords.get(dom.getWorld()).add(file_name);
|
mca_cords.get(dom.getWorld().getName()).add(file_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class DominionController {
|
|||||||
operator.setResponse(FAIL.addMessage("已经存在名称为 %s 的领地", name));
|
operator.setResponse(FAIL.addMessage("已经存在名称为 %s 的领地", name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!loc1.getWorld().equals(loc2.getWorld())) {
|
if (!loc1.getWorld().getUID().equals(loc2.getWorld().getUID())) {
|
||||||
operator.setResponse(FAIL.addMessage("选点世界不一致"));
|
operator.setResponse(FAIL.addMessage("选点世界不一致"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -137,10 +137,10 @@ public class DominionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 创建 dominion (此步骤不会写入数据)
|
// 创建 dominion (此步骤不会写入数据)
|
||||||
DominionDTO dominion = DominionDTO.create(parent_dominion.getId() == -1 ? operator.getUniqueId() : parent_dominion.getOwner(), name, loc1.getWorld().getName(),
|
DominionDTO dominion = DominionDTO.create(parent_dominion.getId() == -1 ? operator.getUniqueId() : parent_dominion.getOwner(), name, loc1.getWorld(),
|
||||||
minX, minY, minZ, maxX, maxY, maxZ, parent_dominion);
|
minX, minY, minZ, maxX, maxY, maxZ, parent_dominion);
|
||||||
// 如果parent_dominion不为-1 检查是否在同一世界
|
// 如果parent_dominion不为-1 检查是否在同一世界
|
||||||
if (parent_dominion.getId() != -1 && !parent_dominion.getWorld().equals(dominion.getWorld())) {
|
if (parent_dominion.getId() != -1 && !parent_dominion.getWorldUid().equals(dominion.getWorldUid())) {
|
||||||
operator.setResponse(FAIL.addMessage("父领地与子领地不在同一世界。"));
|
operator.setResponse(FAIL.addMessage("父领地与子领地不在同一世界。"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ public class DominionController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 获取此领地的所有同级领地
|
// 获取此领地的所有同级领地
|
||||||
List<DominionDTO> sub_dominions = DominionDTO.selectByParentId(dominion.getWorld(), parent_dominion.getId());
|
List<DominionDTO> sub_dominions = DominionDTO.selectByParentId(dominion.getWorldUid(), parent_dominion.getId());
|
||||||
// 检查是否与出生点保护冲突
|
// 检查是否与出生点保护冲突
|
||||||
if (isIntersectSpawn(operator, dominion)) {
|
if (isIntersectSpawn(operator, dominion)) {
|
||||||
operator.setResponse(FAIL.addMessage("与出生点保护冲突"));
|
operator.setResponse(FAIL.addMessage("与出生点保护冲突"));
|
||||||
@ -191,7 +191,7 @@ public class DominionController {
|
|||||||
if (radius == -1) {
|
if (radius == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
World world = Dominion.instance.getServer().getWorld(dominion.getWorld());
|
World world = dominion.getWorld();
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ public class DominionController {
|
|||||||
, spawn.getBlockX() + radius, spawn.getBlockY() + radius, spawn.getBlockZ() + radius);
|
, spawn.getBlockX() + radius, spawn.getBlockY() + radius, spawn.getBlockZ() + radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isIntersectSpawn(AbstractOperator operator, String world, int[] cords) {
|
private static boolean isIntersectSpawn(AbstractOperator operator, @NotNull World world, int[] cords) {
|
||||||
if (operator.isOp() && Dominion.config.getLimitOpBypass()) {
|
if (operator.isOp() && Dominion.config.getLimitOpBypass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ public class DominionController {
|
|||||||
if (radius == -1) {
|
if (radius == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location spawn = Objects.requireNonNull(Dominion.instance.getServer().getWorld(world)).getSpawnLocation();
|
Location spawn = world.getSpawnLocation();
|
||||||
return isIntersect(cords, spawn.getBlockX() - radius, spawn.getBlockY() - radius, spawn.getBlockZ() - radius
|
return isIntersect(cords, spawn.getBlockX() - radius, spawn.getBlockY() - radius, spawn.getBlockZ() - radius
|
||||||
, spawn.getBlockX() + radius, spawn.getBlockY() + radius, spawn.getBlockZ() + radius);
|
, spawn.getBlockX() + radius, spawn.getBlockY() + radius, spawn.getBlockZ() + radius);
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ public class DominionController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 获取同世界下的所有同级领地
|
// 获取同世界下的所有同级领地
|
||||||
List<DominionDTO> exist_dominions = DominionDTO.selectByParentId(dominion.getWorld(), dominion.getParentDomId());
|
List<DominionDTO> exist_dominions = DominionDTO.selectByParentId(dominion.getWorldUid(), dominion.getParentDomId());
|
||||||
for (DominionDTO exist_dominion : exist_dominions) {
|
for (DominionDTO exist_dominion : exist_dominions) {
|
||||||
if (isIntersect(exist_dominion, newCords)) {
|
if (isIntersect(exist_dominion, newCords)) {
|
||||||
// 如果是自己,跳过
|
// 如果是自己,跳过
|
||||||
@ -317,7 +317,7 @@ public class DominionController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 获取所有的子领地
|
// 获取所有的子领地
|
||||||
List<DominionDTO> sub_dominions = DominionDTO.selectByParentId(dominion.getWorld(), dominion.getId());
|
List<DominionDTO> sub_dominions = DominionDTO.selectByParentId(dominion.getWorldUid(), dominion.getId());
|
||||||
for (DominionDTO sub_dominion : sub_dominions) {
|
for (DominionDTO sub_dominion : sub_dominions) {
|
||||||
if (!isContained(sub_dominion, newCords)) {
|
if (!isContained(sub_dominion, newCords)) {
|
||||||
operator.setResponse(FAIL.addMessage("缩小后的领地无法包含子领地 %s", sub_dominion.getName()));
|
operator.setResponse(FAIL.addMessage("缩小后的领地无法包含子领地 %s", sub_dominion.getName()));
|
||||||
@ -478,9 +478,9 @@ public class DominionController {
|
|||||||
operator.setResponse(new AbstractOperator.Result(AbstractOperator.Result.FAILURE, "领地 %s 不存在", dominion_name));
|
operator.setResponse(new AbstractOperator.Result(AbstractOperator.Result.FAILURE, "领地 %s 不存在", dominion_name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
World world = Dominion.instance.getServer().getWorld(dominion.getWorld());
|
World world = dominion.getWorld();
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
operator.setResponse(new AbstractOperator.Result(AbstractOperator.Result.FAILURE, "世界 %s 不存在", dominion.getWorld()));
|
operator.setResponse(new AbstractOperator.Result(AbstractOperator.Result.FAILURE, "领地所在世界不存在"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location loc = new Location(world, x, y, z);
|
Location loc = new Location(world, x, y, z);
|
||||||
@ -679,7 +679,7 @@ public class DominionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static List<DominionDTO> getSubDominionsRecursive(DominionDTO dominion) {
|
private static List<DominionDTO> getSubDominionsRecursive(DominionDTO dominion) {
|
||||||
List<DominionDTO> sub_dominions = DominionDTO.selectByParentId(dominion.getWorld(), dominion.getId());
|
List<DominionDTO> sub_dominions = DominionDTO.selectByParentId(dominion.getWorldUid(), dominion.getId());
|
||||||
List<DominionDTO> sub_sub_dominions = new ArrayList<>();
|
List<DominionDTO> sub_sub_dominions = new ArrayList<>();
|
||||||
for (DominionDTO sub_dominion : sub_dominions) {
|
for (DominionDTO sub_dominion : sub_dominions) {
|
||||||
sub_sub_dominions.addAll(getSubDominionsRecursive(sub_dominion));
|
sub_sub_dominions.addAll(getSubDominionsRecursive(sub_dominion));
|
||||||
@ -777,11 +777,11 @@ public class DominionController {
|
|||||||
return Cache.instance.getPlayerDominionCount(operator.getUniqueId()) >= Dominion.config.getLimitAmount(operator.getPlayer()) && Dominion.config.getLimitAmount(operator.getPlayer()) != -1;
|
return Cache.instance.getPlayerDominionCount(operator.getUniqueId()) >= Dominion.config.getLimitAmount(operator.getPlayer()) && Dominion.config.getLimitAmount(operator.getPlayer()) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean worldNotValid(AbstractOperator operator, String world) {
|
private static boolean worldNotValid(AbstractOperator operator, String worldName) {
|
||||||
if (operator.isOp() && Dominion.config.getLimitOpBypass()) {
|
if (operator.isOp() && Dominion.config.getLimitOpBypass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Dominion.config.getWorldBlackList(operator.getPlayer()).contains(world);
|
return Dominion.config.getWorldBlackList(operator.getPlayer()).contains(worldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DominionDTO getExistDomAndIsOwner(AbstractOperator operator, String dominion_name) {
|
private static DominionDTO getExistDomAndIsOwner(AbstractOperator operator, String dominion_name) {
|
||||||
@ -854,7 +854,7 @@ public class DominionController {
|
|||||||
operator.setResponse(FAIL.addMessage("无法获取你的位置"));
|
operator.setResponse(FAIL.addMessage("无法获取你的位置"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!operator.getLocation().getWorld().getName().equals(dominion.getWorld())) {
|
if (!operator.getLocation().getWorld().getUID().equals(dominion.getWorldUid())) {
|
||||||
operator.setResponse(FAIL.addMessage("禁止跨世界操作"));
|
operator.setResponse(FAIL.addMessage("禁止跨世界操作"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -929,7 +929,7 @@ public class DominionController {
|
|||||||
for (DominionDTO sub_dominion : sub_dominions) {
|
for (DominionDTO sub_dominion : sub_dominions) {
|
||||||
sub_names = sub_dominion.getName() + ", ";
|
sub_names = sub_dominion.getName() + ", ";
|
||||||
}
|
}
|
||||||
if (sub_dominions.size() > 0) {
|
if (!sub_dominions.isEmpty()) {
|
||||||
sub_names = sub_names.substring(0, sub_names.length() - 2);
|
sub_names = sub_names.substring(0, sub_names.length() - 2);
|
||||||
WARNING.addMessage("(子领地:%s)", sub_names);
|
WARNING.addMessage("(子领地:%s)", sub_names);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ import cn.lunadeer.minecraftpluginutils.databse.syntax.InsertRow;
|
|||||||
import cn.lunadeer.minecraftpluginutils.databse.syntax.UpdateRow;
|
import cn.lunadeer.minecraftpluginutils.databse.syntax.UpdateRow;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -89,6 +91,10 @@ public class DominionDTO {
|
|||||||
return dominions.getFirst();
|
return dominions.getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<DominionDTO> selectByParentId(World world, Integer parentId){
|
||||||
|
return selectByParentId(world.getUID(), parentId);
|
||||||
|
}
|
||||||
|
|
||||||
public static List<DominionDTO> selectByParentId(UUID world_uid, Integer parentId) {
|
public static List<DominionDTO> selectByParentId(UUID world_uid, Integer parentId) {
|
||||||
String sql = "SELECT * FROM dominion WHERE world_uid = ? AND parent_dom_id = ? AND id > 0;";
|
String sql = "SELECT * FROM dominion WHERE world_uid = ? AND parent_dom_id = ? AND id > 0;";
|
||||||
return query(sql, world_uid.toString(), parentId);
|
return query(sql, world_uid.toString(), parentId);
|
||||||
@ -181,14 +187,14 @@ public class DominionDTO {
|
|||||||
this.parentDomId.value = parentDomId;
|
this.parentDomId.value = parentDomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DominionDTO(UUID owner, String name, UUID world_uid,
|
public DominionDTO(UUID owner, String name, @NotNull World world,
|
||||||
Integer x1, Integer y1, Integer z1, Integer x2, Integer y2, Integer z2) {
|
Integer x1, Integer y1, Integer z1, Integer x2, Integer y2, Integer z2) {
|
||||||
this(null, owner, name, world_uid, x1, y1, z1, x2, y2, z2, -1);
|
this(null, owner, name, world.getUID(), x1, y1, z1, x2, y2, z2, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DominionDTO create(UUID owner, String name, UUID world_uid,
|
public static DominionDTO create(UUID owner, String name, @NotNull World world,
|
||||||
Integer x1, Integer y1, Integer z1, Integer x2, Integer y2, Integer z2, DominionDTO parent) {
|
Integer x1, Integer y1, Integer z1, Integer x2, Integer y2, Integer z2, DominionDTO parent) {
|
||||||
return new DominionDTO(null, owner, name, world_uid, x1, y1, z1, x2, y2, z2, parent == null ? -1 : parent.getId());
|
return new DominionDTO(null, owner, name, world.getUID(), x1, y1, z1, x2, y2, z2, parent == null ? -1 : parent.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Field id = new Field("id", FieldType.INT);
|
private final Field id = new Field("id", FieldType.INT);
|
||||||
@ -247,7 +253,7 @@ public class DominionDTO {
|
|||||||
return doUpdate(new UpdateRow().field(this.name));
|
return doUpdate(new UpdateRow().field(this.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public World getWorld() {
|
public @Nullable World getWorld() {
|
||||||
return Dominion.instance.getServer().getWorld(getWorldUid());
|
return Dominion.instance.getServer().getWorld(getWorldUid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package cn.lunadeer.dominion.managers;
|
package cn.lunadeer.dominion.managers;
|
||||||
|
|
||||||
|
import cn.lunadeer.dominion.Dominion;
|
||||||
import cn.lunadeer.dominion.dtos.Flag;
|
import cn.lunadeer.dominion.dtos.Flag;
|
||||||
import cn.lunadeer.minecraftpluginutils.databse.*;
|
import cn.lunadeer.minecraftpluginutils.databse.*;
|
||||||
import cn.lunadeer.minecraftpluginutils.databse.syntax.AddColumn;
|
import cn.lunadeer.minecraftpluginutils.databse.syntax.AddColumn;
|
||||||
import cn.lunadeer.minecraftpluginutils.databse.syntax.CreateTable;
|
import cn.lunadeer.minecraftpluginutils.databse.syntax.CreateTable;
|
||||||
import cn.lunadeer.minecraftpluginutils.databse.syntax.InsertRow;
|
import cn.lunadeer.minecraftpluginutils.databse.syntax.InsertRow;
|
||||||
|
import cn.lunadeer.minecraftpluginutils.databse.syntax.RemoveColumn;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class DatabaseTables {
|
public class DatabaseTables {
|
||||||
public static void migrate() {
|
public static void migrate() {
|
||||||
@ -242,5 +246,18 @@ public class DatabaseTables {
|
|||||||
TableColumn player_name_using_group_title_id = new TableColumn("using_group_title_id", FieldType.INT, false, false, true, false, -1);
|
TableColumn player_name_using_group_title_id = new TableColumn("using_group_title_id", FieldType.INT, false, false, true, false, -1);
|
||||||
new AddColumn(player_name_using_group_title_id).table("player_name").ifNotExists().execute();
|
new AddColumn(player_name_using_group_title_id).table("player_name").ifNotExists().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2.3.0 change world name to world uid
|
||||||
|
if (!Common.IsFieldExist("dominion", "world_uid")) {
|
||||||
|
TableColumn dominion_world_uid = new TableColumn("world_uid", FieldType.STRING, false, false, true, false, "'00000000-0000-0000-0000-000000000000'");
|
||||||
|
new AddColumn(dominion_world_uid).table("dominion").ifNotExists().execute();
|
||||||
|
List<World> worlds = Dominion.instance.getServer().getWorlds();
|
||||||
|
for (World world : worlds) {
|
||||||
|
String sql = String.format("UPDATE dominion SET world_uid = '%s' WHERE world = '%s';", world.getUID().toString(), world.getName());
|
||||||
|
DatabaseManager.instance.query(sql);
|
||||||
|
}
|
||||||
|
DatabaseManager.instance.query("UPDATE dominion SET world_uid = '00000000-0000-0000-0000-000000000000' WHERE world = 'all';");
|
||||||
|
new RemoveColumn("world").table("dominion").IfExists().execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,13 @@ public class BlueMapConnect {
|
|||||||
BlueMapAPI.getInstance().ifPresent(api -> {
|
BlueMapAPI.getInstance().ifPresent(api -> {
|
||||||
Map<String, List<DominionDTO>> world_dominions = new HashMap<>();
|
Map<String, List<DominionDTO>> world_dominions = new HashMap<>();
|
||||||
for (DominionDTO dominion : Cache.instance.getDominions()) {
|
for (DominionDTO dominion : Cache.instance.getDominions()) {
|
||||||
if (!world_dominions.containsKey(dominion.getWorld())) {
|
if (dominion.getWorld() == null) {
|
||||||
world_dominions.put(dominion.getWorld(), new ArrayList<>());
|
continue;
|
||||||
}
|
}
|
||||||
world_dominions.get(dominion.getWorld()).add(dominion);
|
if (!world_dominions.containsKey(dominion.getWorld().getName())) {
|
||||||
|
world_dominions.put(dominion.getWorld().getName(), new ArrayList<>());
|
||||||
|
}
|
||||||
|
world_dominions.get(dominion.getWorld().getName()).add(dominion);
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, List<DominionDTO>> d : world_dominions.entrySet()) {
|
for (Map.Entry<String, List<DominionDTO>> d : world_dominions.entrySet()) {
|
||||||
api.getWorld(d.getKey()).ifPresent(world -> {
|
api.getWorld(d.getKey()).ifPresent(world -> {
|
||||||
|
@ -42,11 +42,14 @@ public class DynmapConnect extends DynmapCommonAPIListener {
|
|||||||
String nameLabel = "<div>" + dominion.getName() + "</div>";
|
String nameLabel = "<div>" + dominion.getName() + "</div>";
|
||||||
double[] xx = {dominion.getX1(), dominion.getX2()};
|
double[] xx = {dominion.getX1(), dominion.getX2()};
|
||||||
double[] zz = {dominion.getZ1(), dominion.getZ2()};
|
double[] zz = {dominion.getZ1(), dominion.getZ2()};
|
||||||
|
if (dominion.getWorld() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
AreaMarker marker = this.markerSet_dominion.createAreaMarker(
|
AreaMarker marker = this.markerSet_dominion.createAreaMarker(
|
||||||
dominion.getId().toString(),
|
dominion.getId().toString(),
|
||||||
nameLabel,
|
nameLabel,
|
||||||
true,
|
true,
|
||||||
dominion.getWorld(),
|
dominion.getWorld().getName(),
|
||||||
xx,
|
xx,
|
||||||
zz,
|
zz,
|
||||||
false
|
false
|
||||||
|
@ -78,7 +78,7 @@ public class SelectPointEvents implements Listener {
|
|||||||
int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX()) + 1;
|
int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX()) + 1;
|
||||||
int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY()) + 1;
|
int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY()) + 1;
|
||||||
int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ()) + 1;
|
int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ()) + 1;
|
||||||
DominionDTO dominion = new DominionDTO(player.getUniqueId(), "", loc1.getWorld().getName(),
|
DominionDTO dominion = new DominionDTO(player.getUniqueId(), "", loc1.getWorld(),
|
||||||
minX, minY, minZ, maxX, maxY, maxZ);
|
minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
if (Dominion.config.getEconomyEnable()) {
|
if (Dominion.config.getEconomyEnable()) {
|
||||||
if (!VaultConnect.instance.economyAvailable()) {
|
if (!VaultConnect.instance.economyAvailable()) {
|
||||||
|
@ -78,7 +78,7 @@ public class SelectPointEvents implements Listener {
|
|||||||
int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX()) + 1;
|
int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX()) + 1;
|
||||||
int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY()) + 1;
|
int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY()) + 1;
|
||||||
int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ()) + 1;
|
int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ()) + 1;
|
||||||
DominionDTO dominion = new DominionDTO(player.getUniqueId(), "", loc1.getWorld().getName(),
|
DominionDTO dominion = new DominionDTO(player.getUniqueId(), "", loc1.getWorld(),
|
||||||
minX, minY, minZ, maxX, maxY, maxZ);
|
minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
if (Dominion.config.getEconomyEnable()) {
|
if (Dominion.config.getEconomyEnable()) {
|
||||||
if (!VaultConnect.instance.economyAvailable()) {
|
if (!VaultConnect.instance.economyAvailable()) {
|
||||||
|
Reference in New Issue
Block a user