feat(bukkit): 添加新API

This commit is contained in:
2023-05-24 12:54:23 +08:00
parent bbfbd817b0
commit f301e18c83
2 changed files with 41 additions and 1 deletions

View File

@@ -20,9 +20,16 @@ public class BukkitBlockPos extends BallBlockPos {
}
public BukkitBlockPos(@NotNull Block block) {
this(block.getLocation());
super(
BallAPI.getInstance().getLocalServerId(),
block.getWorld().getName(),
block.getX(),
block.getY(),
block.getZ()
);
}
@SuppressWarnings("DataFlowIssue")
public BukkitBlockPos(@NotNull Location location) {
super(
BallAPI.getInstance().getLocalServerId(),
@@ -56,4 +63,20 @@ public class BukkitBlockPos extends BallBlockPos {
public BukkitLocation toServiceLocation() {
return new BukkitLocation(getServerID(), getWorldName(), getX(), getY(), getZ());
}
public boolean equals(@NotNull Block block) {
if (!BallAPI.getInstance().isLocalServer(getServerID())) {
return false;
}
if (!getWorldName().equals(block.getWorld().getName())) {
return false;
}
if (getX() != block.getX()) {
return false;
}
if (getY() != block.getY()) {
return false;
}
return getZ() == block.getZ();
}
}

View File

@@ -27,6 +27,7 @@ public class BukkitLocation extends BallLocation {
this(block.getLocation());
}
@SuppressWarnings("DataFlowIssue")
public BukkitLocation(@NotNull Location location) {
super(
BallAPI.getInstance().getLocalServerId(),
@@ -64,4 +65,20 @@ public class BukkitLocation extends BallLocation {
public BukkitBlockPos toBukkitBlockPos() {
return new BukkitBlockPos(getServerID(), getWorldName(), getBlockX(), getBlockY(), getBlockZ());
}
public boolean equals(@NotNull Block block) {
if (!BallAPI.getInstance().isLocalServer(getServerID())) {
return false;
}
if (!getWorldName().equals(block.getWorld().getName())) {
return false;
}
if (getX() != block.getX()) {
return false;
}
if (getY() != block.getY()) {
return false;
}
return getZ() == block.getZ();
}
}