mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-01 13:14:43 +02:00
restructure a couple things.
This commit is contained in:
@ -5,6 +5,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@ -17,8 +18,10 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
|
||||
public class BO3Handler {
|
||||
|
||||
@ -54,54 +57,60 @@ public class BO3Handler {
|
||||
return false;
|
||||
}
|
||||
final String alias = plot.toString();
|
||||
final Location pos1 = plot.getBottom();
|
||||
final Location pos2 = plot.getTop();
|
||||
Location[] corners = MainUtil.getCorners(plot);
|
||||
Location bot = corners[0];
|
||||
Location top = corners[1];
|
||||
final ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld;
|
||||
final int height = cpw.PLOT_HEIGHT;
|
||||
|
||||
final int cx = (pos1.getX() + pos2.getX()) / 2;
|
||||
final int cz = (pos1.getZ() + pos2.getZ()) / 2;
|
||||
final int cx = (bot.getX() + top.getX()) / 2;
|
||||
final int cz = (bot.getZ() + top.getZ()) / 2;
|
||||
|
||||
final HashMap<ChunkLoc, BO3> map = new HashMap<>();
|
||||
|
||||
HashSet<RegionWrapper> regions = MainUtil.getRegions(plot);
|
||||
boolean content = false;
|
||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||
final int X = ((x + 7) - cx) >> 4;
|
||||
final int xx = (x - cx) % 16;
|
||||
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
|
||||
final int Z = ((z + 7) - cz) >> 4;
|
||||
final int zz = (z - cz) % 16;
|
||||
final ChunkLoc loc = new ChunkLoc(X, Z);
|
||||
BO3 bo3 = map.get(loc);
|
||||
for (int y = 1; y < height; y++) {
|
||||
final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z));
|
||||
if ((block != null) && !contains(cpw.MAIN_BLOCK, block)) {
|
||||
for (RegionWrapper region : regions) {
|
||||
Location pos1 = new Location(plot.world, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.world, region.maxX, region.maxY, region.maxZ);
|
||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||
final int X = ((x + 7) - cx) >> 4;
|
||||
final int xx = (x - cx) % 16;
|
||||
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
|
||||
final int Z = ((z + 7) - cz) >> 4;
|
||||
final int zz = (z - cz) % 16;
|
||||
final ChunkLoc loc = new ChunkLoc(X, Z);
|
||||
BO3 bo3 = map.get(loc);
|
||||
for (int y = 1; y < height; y++) {
|
||||
final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z));
|
||||
if ((block != null) && !contains(cpw.MAIN_BLOCK, block)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, loc);
|
||||
map.put(loc, bo3);
|
||||
content = true;
|
||||
}
|
||||
bo3.addBlock(xx, y - height - 1, zz, block);
|
||||
}
|
||||
}
|
||||
final PlotBlock floor = BlockManager.manager.getBlock(new Location(plot.world, x, height, z));
|
||||
if ((floor != null) && !contains(cpw.TOP_BLOCK, floor)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, loc);
|
||||
map.put(loc, bo3);
|
||||
content = true;
|
||||
}
|
||||
bo3.addBlock(xx, y - height - 1, zz, block);
|
||||
bo3.addBlock(xx, -1, zz, floor);
|
||||
}
|
||||
}
|
||||
final PlotBlock floor = BlockManager.manager.getBlock(new Location(plot.world, x, height, z));
|
||||
if ((floor != null) && !contains(cpw.TOP_BLOCK, floor)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, loc);
|
||||
map.put(loc, bo3);
|
||||
content = true;
|
||||
}
|
||||
bo3.addBlock(xx, -1, zz, floor);
|
||||
}
|
||||
for (int y = height + 1; y < 256; y++) {
|
||||
final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z));
|
||||
if ((block != null) && (block.id != 0)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, loc);
|
||||
map.put(loc, bo3);
|
||||
content = true;
|
||||
for (int y = height + 1; y < 256; y++) {
|
||||
final PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z));
|
||||
if ((block != null) && (block.id != 0)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, loc);
|
||||
map.put(loc, bo3);
|
||||
content = true;
|
||||
}
|
||||
bo3.addBlock(xx, y - height - 1, zz, block);
|
||||
}
|
||||
bo3.addBlock(xx, y - height - 1, zz, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -102,7 +103,7 @@ public abstract class ChunkManager {
|
||||
|
||||
public abstract boolean unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe);
|
||||
|
||||
public abstract List<ChunkLoc> getChunkChunks(final String world);
|
||||
public abstract Set<ChunkLoc> getChunkChunks(final String world);
|
||||
|
||||
public abstract void regenerateChunk(final String world, final ChunkLoc loc);
|
||||
|
||||
@ -114,6 +115,9 @@ public abstract class ChunkManager {
|
||||
|
||||
public abstract Plot hasPlot(String world, ChunkLoc chunk);
|
||||
|
||||
/**
|
||||
* Copy a region to a new location (in the same world)
|
||||
*/
|
||||
public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone);
|
||||
|
||||
/**
|
||||
@ -129,7 +133,5 @@ public abstract class ChunkManager {
|
||||
|
||||
public abstract void clearAllEntities(final Location pos1, final Location pos2);
|
||||
|
||||
public abstract void swap(final String world, final PlotId id, final PlotId plotid);
|
||||
|
||||
public abstract void swap(final String worldname, final Location bot1, final Location top1, final Location bot2, final Location top2);
|
||||
public abstract void swap(final Location bot1, final Location top1, final Location bot2, final Location top2, Runnable whenDone);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class ClusterManager {
|
||||
if (clusters.containsKey(world)) {
|
||||
return clusters.get(world);
|
||||
}
|
||||
return new HashSet<>();
|
||||
return new HashSet<>(0);
|
||||
}
|
||||
|
||||
public static int getPlayerClusterCount(final String world, final PlotPlayer player) {
|
||||
@ -74,7 +74,7 @@ public class ClusterManager {
|
||||
if (toReturn.getY() == 0) {
|
||||
final PlotManager manager = PS.get().getPlotManager(cluster.world);
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(cluster.world);
|
||||
final Location loc = manager.getSignLoc(plotworld, MainUtil.getPlot(cluster.world, center));
|
||||
final Location loc = manager.getSignLoc(plotworld, MainUtil.getPlotAbs(cluster.world, center));
|
||||
toReturn.setY(loc.getY());
|
||||
}
|
||||
} else {
|
||||
@ -124,13 +124,13 @@ public class ClusterManager {
|
||||
final PlotManager manager = PS.get().getPlotManager(world);
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
final Location bot = manager.getPlotBottomLocAbs(plotworld, cluster.getP1());
|
||||
final Location top = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1, 0, 1);
|
||||
return (bot.getX() < loc.getX()) && (bot.getZ() < loc.getZ()) && (top.getX() > loc.getX()) && (top.getZ() > loc.getZ());
|
||||
final Location top = manager.getPlotTopLocAbs(plotworld, cluster.getP2());
|
||||
return (bot.getX() <= loc.getX()) && (bot.getZ() <= loc.getZ()) && (top.getX() >= loc.getX()) && (top.getZ() >= loc.getZ());
|
||||
}
|
||||
|
||||
public static HashSet<PlotCluster> getIntersects(final String world, final PlotClusterId id) {
|
||||
if (!clusters.containsKey(world)) {
|
||||
return new HashSet<>();
|
||||
return new HashSet<>(0);
|
||||
}
|
||||
final HashSet<PlotCluster> list = new HashSet<PlotCluster>();
|
||||
for (final PlotCluster cluster : clusters.get(world)) {
|
||||
@ -236,7 +236,7 @@ public class ClusterManager {
|
||||
}
|
||||
|
||||
public static PlotId estimatePlotId(final Location loc) {
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot != null) {
|
||||
return plot.id;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public abstract class EventUtil {
|
||||
public abstract void callMember(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added);
|
||||
|
||||
public boolean checkPlayerBlockEvent(final PlotPlayer pp, final PlayerBlockEventType type, final Location loc, final LazyBlock block, final boolean notifyPerms) {
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
final UUID uuid = pp.getUUID();
|
||||
if (plot == null) {
|
||||
if (!MainUtil.isPlotAreaAbs(loc)) {
|
||||
|
@ -129,7 +129,7 @@ public class ExpireManager {
|
||||
}
|
||||
}
|
||||
if (plot.isMerged()) {
|
||||
MainUtil.unlinkPlot(plot, true);
|
||||
MainUtil.unlinkPlot(plot, true, false);
|
||||
}
|
||||
plot.deletePlot(null);
|
||||
expiredPlots.get(world).remove(plot);
|
||||
@ -144,7 +144,7 @@ public class ExpireManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
if (plot.getRunning() > 0) {
|
||||
PS.debug("$2[&5Expire&dManager$2] &bSkipping plot in use: " + plot);
|
||||
expiredPlots.get(world).remove(plot);
|
||||
run();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,6 +24,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
@ -46,6 +47,7 @@ import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.plotsquared.object.schematic.StateWrapper;
|
||||
@ -92,15 +94,6 @@ public abstract class SchematicHandler {
|
||||
} else {
|
||||
directory = outputDir.getPath();
|
||||
}
|
||||
final Location top = plot.getTop();
|
||||
final Location bot = plot.getBottom();
|
||||
final int area = ((1 + top.getX()) - bot.getX()) * ((1 + top.getZ()) - bot.getZ());
|
||||
if (area > 4096) {
|
||||
PS.debug("The plot is > 64 x 64 - Fast lossy schematic saving will be used");
|
||||
}
|
||||
// if (area <= 4096 && PS.get().worldEdit != null) {
|
||||
// new WorldEditSchematic().saveSchematic(directory + File.separator + name + ".schematic", plot.world, plot.id);
|
||||
// }
|
||||
final Runnable THIS = this;
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
@ -162,9 +155,8 @@ public abstract class SchematicHandler {
|
||||
final int LENGTH = demensions.getZ();
|
||||
final int HEIGHT = demensions.getY();
|
||||
// Validate dimensions
|
||||
final Location bottom = plot.getBottom();
|
||||
final Location top = plot.getTop();
|
||||
if ((((top.getX() - bottom.getX()) + 1) < WIDTH) || (((top.getZ() - bottom.getZ()) + 1) < LENGTH) || (HEIGHT > 256)) {
|
||||
RegionWrapper region = MainUtil.getLargestRegion(plot);
|
||||
if ((((region.maxX - region.minX + x_offset) + 1) < WIDTH) || (((region.maxZ - region.minZ + z_offset) + 1) < LENGTH) || (HEIGHT > 256)) {
|
||||
PS.debug("Schematic is too large");
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
@ -177,9 +169,10 @@ public abstract class SchematicHandler {
|
||||
if (HEIGHT >= 256) {
|
||||
y_offset = 0;
|
||||
} else {
|
||||
y_offset = MainUtil.getHeighestBlock(plot.world, bottom.getX() + 1, bottom.getZ() + 1);
|
||||
y_offset = MainUtil.getHeighestBlock(plot.world, region.minX + 1, region.minZ + 1);
|
||||
}
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1 + x_offset, y_offset - 1, 1 + z_offset);
|
||||
final Location pos1 = new Location(plot.world, region.minX + x_offset, y_offset, region.minZ + z_offset);
|
||||
// Location pos2 = new Location(plot.world, region.maxX, region.maxY, region.maxZ);
|
||||
final Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
|
||||
// TODO switch to ChunkManager.chunkTask(pos1, pos2, task, whenDone, allocate);
|
||||
final int p1x = pos1.getX();
|
||||
@ -369,14 +362,14 @@ public abstract class SchematicHandler {
|
||||
if (items == null) {
|
||||
return false;
|
||||
}
|
||||
Location l1 = MainUtil.getPlotBottomLoc(plot.world, plot.getId());
|
||||
RegionWrapper region = MainUtil.getLargestRegion(plot);
|
||||
Location l1 = new Location(plot.world, region.minX + x_offset, 1, region.minZ + z_offset);
|
||||
// Location l1 = MainUtil.getPlotBottomLoc(plot.world, plot.getId());
|
||||
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 < 255)) {
|
||||
l1 = l1.add(1, sy - 1, 1);
|
||||
} else {
|
||||
l1 = l1.add(1, 0, 1);
|
||||
l1 = l1.add(0, sy - 1, 0);
|
||||
}
|
||||
final int X = l1.getX() + x_offset;
|
||||
final int Y = l1.getY();
|
||||
@ -675,25 +668,11 @@ public abstract class SchematicHandler {
|
||||
return new CompoundTag("Schematic", schematic);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the schematic of a plot
|
||||
*
|
||||
* @param world to check
|
||||
* @param id plot
|
||||
*
|
||||
* @return tag
|
||||
*/
|
||||
public void getCompoundTag(final String world, final PlotId id, final RunnableVal<CompoundTag> whenDone) {
|
||||
if (PS.get().getPlot(world, id) == null) {
|
||||
whenDone.run();
|
||||
return;
|
||||
}
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(world, id).add(1, -1, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, id);
|
||||
getCompoundTag(world, pos1, pos2, whenDone);
|
||||
}
|
||||
public abstract void getCompoundTag(final String world, Set<RegionWrapper> regions, final RunnableVal<CompoundTag> whenDone);
|
||||
|
||||
public abstract void getCompoundTag(final String world, final Location pos1, final Location pos2, final RunnableVal<CompoundTag> whenDone);
|
||||
public void getCompoundTag(final String world, PlotId id, final RunnableVal<CompoundTag> whenDone) {
|
||||
getCompoundTag(world, MainUtil.getRegions(MainUtil.getPlotAbs(world, id)), whenDone);
|
||||
}
|
||||
|
||||
public boolean pastePart(final String world, final DataCollection[] blocks, final Location l1, final int x_offset, final int z_offset, final int i1, final int i2, final int WIDTH, final int LENGTH) {
|
||||
int length = 0;
|
||||
|
Reference in New Issue
Block a user