mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-29 04:04:43 +02:00
Trying to reduce reliance on Bukkit
This commit is contained in:
@ -21,9 +21,11 @@ public abstract class BlockManager {
|
||||
|
||||
public abstract int getBlockIdFromString(String block);
|
||||
|
||||
public abstract int getHeighestBlock(Location loc);
|
||||
public abstract int getHeighestBlock(String world, int x, int z);
|
||||
|
||||
public abstract String getBiome(Location loc);
|
||||
public abstract String getBiome(String world, int x, int z);
|
||||
|
||||
public abstract PlotBlock getBlock(Location loc);
|
||||
|
||||
public abstract Location getSpawn(String world);
|
||||
|
||||
@ -37,9 +39,9 @@ public abstract class BlockManager {
|
||||
|
||||
public abstract void functionSetBlock(String worldname, int x, int y, int z, int id, byte data);
|
||||
|
||||
public abstract void functionSetBiomes(final String worldname, final int[] x, final int z[], final int[] biome);
|
||||
public abstract void functionSetBiomes(final String worldname, final int[] x, final int z[], final String biome);
|
||||
|
||||
public static void setBiomes(final String worldname, final int[] x, final int z[], final int[] biome) {
|
||||
public static void setBiomes(final String worldname, final int[] x, final int z[], final String biome) {
|
||||
manager.functionSetBiomes(worldname, x, z, biome);
|
||||
}
|
||||
|
||||
|
@ -92,9 +92,9 @@ public abstract class ChunkManager {
|
||||
|
||||
public abstract int[] countEntities(Plot plot);
|
||||
|
||||
public abstract boolean loadChunk(String world, ChunkLoc loc);
|
||||
public abstract boolean loadChunk(String world, ChunkLoc loc, boolean force);
|
||||
|
||||
public abstract boolean unloadChunk(String world, ChunkLoc loc);
|
||||
public abstract boolean unloadChunk(String world, ChunkLoc loc, boolean save, boolean safe);
|
||||
|
||||
public abstract List<ChunkLoc> getChunkChunks(String world);
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class ClusterManager {
|
||||
} else {
|
||||
toReturn = getClusterBottom(cluster).add(home.x, home.y, home.z);
|
||||
}
|
||||
final int max = BukkitUtil.getHeighestBlock(cluster.world, toReturn.getX(), toReturn.getZ());
|
||||
final int max = MainUtil.getHeighestBlock(cluster.world, toReturn.getX(), toReturn.getZ());
|
||||
if (max > toReturn.getY()) {
|
||||
toReturn.setY(max);
|
||||
}
|
||||
|
@ -54,6 +54,17 @@ public class MainUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getName(UUID owner) {
|
||||
if (owner == null) {
|
||||
return "unowned";
|
||||
}
|
||||
String name = UUIDHandler.getName(owner);
|
||||
if (name == null) {
|
||||
return "unknown";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public static List<PlotPlayer> getPlayersInPlot(Plot plot) {
|
||||
ArrayList<PlotPlayer> players = new ArrayList<>();
|
||||
for (PlotPlayer pp : UUIDHandler.getPlayers().values()) {
|
||||
@ -1032,9 +1043,10 @@ public class MainUtil {
|
||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
public void run() {
|
||||
BukkitUtil.loadChunkAt(plot.world, value[0], value[1], false);
|
||||
BukkitUtil.setBiome(plot.world, value[2], value[3], value[4], value[4], biome);
|
||||
BukkitUtil.unloadChunkAt(plot.world, value[0], value[1], true, true);
|
||||
ChunkLoc loc = new ChunkLoc(value[0], value[1]);
|
||||
ChunkManager.manager.loadChunk(plot.world, loc, false);
|
||||
setBiome(plot.world, value[2], value[3], value[4], value[4], biome);
|
||||
ChunkManager.manager.unloadChunk(plot.world, loc, true, true);
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
@ -1045,8 +1057,23 @@ public class MainUtil {
|
||||
}, 5);
|
||||
}
|
||||
|
||||
public static void setBiome(final String world, int p1x, int p1z, int p2x, int p2z, final String biome) {
|
||||
final int length = (p2x - p1x + 1) * (p2z - p1z + 1);
|
||||
final int[] xl = new int[length];
|
||||
final int[] zl = new int[length];
|
||||
int index = 0;
|
||||
for (int x = p1x; x <= p2x; x++) {
|
||||
for (int z = p1z; z <= p2z; z++) {
|
||||
xl[index] = x;
|
||||
zl[index] = z;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
BlockManager.setBiomes(world, xl, zl, biome);
|
||||
}
|
||||
|
||||
public static int getHeighestBlock(final String world, final int x, final int z) {
|
||||
final int result = BukkitUtil.getHeighestBlock(world, x, z);
|
||||
final int result = BlockManager.manager.getHeighestBlock(world, x, z);
|
||||
if (result == 0) {
|
||||
return 64;
|
||||
}
|
||||
@ -1070,7 +1097,7 @@ public class MainUtil {
|
||||
return getDefaultHome(plot);
|
||||
} else {
|
||||
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y, bot.getZ() + home.z);
|
||||
if (BukkitUtil.getBlock(loc).id != 0) {
|
||||
if (BlockManager.manager.getBlock(loc).id != 0) {
|
||||
// sendConsoleMessage("ID was " + BukkitUtil.getBlock(loc).id);
|
||||
loc.setY(Math.max(getHeighestBlock(w, bot.getX(), bot.getZ()), bot.getY()));
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public abstract class SchematicHandler {
|
||||
y_offset = 0;
|
||||
}
|
||||
else {
|
||||
y_offset = BukkitUtil.getHeighestBlock(plot.world, bottom.getX() + 1, bottom.getZ() + 1);
|
||||
y_offset = MainUtil.getHeighestBlock(plot.world, bottom.getX() + 1, bottom.getZ() + 1);
|
||||
}
|
||||
Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1 + x_offset, y_offset - 1, 1 + z_offset);
|
||||
Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
|
||||
@ -346,10 +346,10 @@ public abstract class SchematicHandler {
|
||||
return false;
|
||||
}
|
||||
Location l1 = MainUtil.getPlotBottomLoc(plot.world, plot.getId());
|
||||
final int sy = BukkitUtil.getHeighestBlock(plot.world, l1.getX() + 1, l1.getZ() + 1);
|
||||
final int sy = MainUtil.getHeighestBlock(plot.world, l1.getX() + 1, l1.getZ() + 1);
|
||||
final Dimension demensions = schematic.getSchematicDimension();
|
||||
final int HEIGHT = demensions.getY();
|
||||
if (!(HEIGHT == BukkitUtil.getMaxHeight(plot.world))) {
|
||||
if ((HEIGHT < 255)) {
|
||||
l1 = l1.add(1, sy - 1, 1);
|
||||
} else {
|
||||
l1 = l1.add(1, 0, 1);
|
||||
|
Reference in New Issue
Block a user