mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
.
This commit is contained in:
parent
96d2688035
commit
f20a21c1c3
@ -452,8 +452,8 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
* Create a plot without notifying the merge function or world border manager
|
* Create a plot without notifying the merge function or world border manager
|
||||||
*/
|
*/
|
||||||
public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
|
public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
|
||||||
final World w = plot.world;
|
final String w = plot.world;
|
||||||
final Plot p = new Plot(plot.id, uuid, plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
final Plot p = new Plot(plot.id, uuid, plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w);
|
||||||
PlotSquared.updatePlot(p);
|
PlotSquared.updatePlot(p);
|
||||||
DBFunc.createPlotAndSettings(p);
|
DBFunc.createPlotAndSettings(p);
|
||||||
return p;
|
return p;
|
||||||
@ -478,7 +478,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
public static void clearAllEntities(final String world, final Plot plot, final boolean tile) {
|
public static void clearAllEntities(final String world, final Plot plot, final boolean tile) {
|
||||||
final List<Entity> entities = BukkitUtil.getEntities(world);
|
final List<Entity> entities = BukkitUtil.getEntities(world);
|
||||||
for (final Entity entity : entities) {
|
for (final Entity entity : entities) {
|
||||||
final PlotId id = PlayerFunctions.getPlot(entity.getLocation());
|
final PlotId id = PlayerFunctions.getPlot(BukkitUtil.getLocation(entity));
|
||||||
if (plot.id.equals(id)) {
|
if (plot.id.equals(id)) {
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
final Player player = (Player) entity;
|
final Player player = (Player) entity;
|
||||||
@ -565,382 +565,370 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
|
|
||||||
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
||||||
|
|
||||||
world = requester.getWorld();
|
String world = requester.getWorld().getName();
|
||||||
|
|
||||||
clearAllEntities(world, plot, false);
|
clearAllEntities(world, plot, false);
|
||||||
clear(requester, world, plot, isDelete);
|
clear(requester, world, plot, isDelete);
|
||||||
removeSign(world, plot);
|
removeSign(world, plot);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
|
||||||
// for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
|
||||||
// for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
if (blocks.length == 1) {
|
||||||
// final Block block = world.getBlockAt(x, y, z);
|
setCuboid(world, pos1, pos2, blocks[0]);
|
||||||
// if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
return;
|
||||||
// setBlock(world, x, y, z, newblock.id, newblock.data);
|
}
|
||||||
// }
|
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||||
// }
|
for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
||||||
// }
|
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
||||||
// }
|
final int i = random(blocks.length);
|
||||||
// }
|
final PlotBlock newblock = blocks[i];
|
||||||
//
|
final Block block = world.getBlockAt(x, y, z);
|
||||||
// public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
|
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
||||||
//
|
setBlock(world, x, y, z, newblock.id, newblock.data);
|
||||||
// if (blocks.length == 1) {
|
}
|
||||||
// setCuboid(world, pos1, pos2, blocks[0]);
|
}
|
||||||
// return;
|
}
|
||||||
// }
|
}
|
||||||
// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
}
|
||||||
// for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
|
||||||
// for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) {
|
||||||
// final int i = random(blocks.length);
|
|
||||||
// final PlotBlock newblock = blocks[i];
|
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||||
// final Block block = world.getBlockAt(x, y, z);
|
for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
||||||
// if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
||||||
// setBlock(world, x, y, z, newblock.id, newblock.data);
|
final Block block = world.getBlockAt(x, y, z);
|
||||||
// }
|
if (!((block.getTypeId() == newblock.id))) {
|
||||||
// }
|
setBlock(world, x, y, z, newblock.id, (byte) 0);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) {
|
}
|
||||||
//
|
|
||||||
// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
public static void setBiome(final String world, final Plot plot, final Biome b) {
|
||||||
// for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
|
||||||
// for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
||||||
// final Block block = world.getBlockAt(x, y, z);
|
final int topX = getPlotTopLoc(world, plot.id).getX() + 1;
|
||||||
// if (!((block.getTypeId() == newblock.id))) {
|
final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
||||||
// setBlock(world, x, y, z, newblock.id, (byte) 0);
|
final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1;
|
||||||
// }
|
|
||||||
// }
|
final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1));
|
||||||
// }
|
final Biome biome = block.getBiome();
|
||||||
// }
|
|
||||||
// }
|
if (biome.equals(b)) {
|
||||||
//
|
return;
|
||||||
// public static void setBiome(final String world, final Plot plot, final Biome b) {
|
}
|
||||||
//
|
|
||||||
// final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
for (int x = bottomX; x <= topX; x++) {
|
||||||
// final int topX = getPlotTopLoc(world, plot.id).getX() + 1;
|
for (int z = bottomZ; z <= topZ; z++) {
|
||||||
// final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
final Block blk = world.getBlockAt(x, 0, z);
|
||||||
// final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1;
|
final Biome c = blk.getBiome();
|
||||||
//
|
if (c.equals(b)) {
|
||||||
// final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1));
|
x += 15;
|
||||||
// final Biome biome = block.getBiome();
|
continue;
|
||||||
//
|
}
|
||||||
// if (biome.equals(b)) {
|
blk.setBiome(b);
|
||||||
// return;
|
}
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// for (int x = bottomX; x <= topX; x++) {
|
|
||||||
// for (int z = bottomZ; z <= topZ; z++) {
|
public static int getHeighestBlock(final String world, final int x, final int z) {
|
||||||
// final Block blk = world.getBlockAt(x, 0, z);
|
|
||||||
// final Biome c = blk.getBiome();
|
boolean safe = false;
|
||||||
// if (c.equals(b)) {
|
int id;
|
||||||
// x += 15;
|
for (int i = 1; i < world.getMaxHeight(); i++) {
|
||||||
// continue;
|
id = world.getBlockAt(x, i, z).getTypeId();
|
||||||
// }
|
if (id == 0) {
|
||||||
// blk.setBiome(b);
|
if (safe) {
|
||||||
// }
|
return i;
|
||||||
// }
|
}
|
||||||
// }
|
safe = true;
|
||||||
//
|
}
|
||||||
// public static int getHeighestBlock(final String world, final int x, final int z) {
|
}
|
||||||
//
|
return 64;
|
||||||
// boolean safe = false;
|
}
|
||||||
// int id;
|
|
||||||
// for (int i = 1; i < world.getMaxHeight(); i++) {
|
/**
|
||||||
// id = world.getBlockAt(x, i, z).getTypeId();
|
* Get plot home
|
||||||
// if (id == 0) {
|
*
|
||||||
// if (safe) {
|
* @param w World in which the plot is located
|
||||||
// return i;
|
* @param plotid Plot ID
|
||||||
// }
|
*
|
||||||
// safe = true;
|
* @return Home Location
|
||||||
// }
|
*/
|
||||||
// }
|
public static Location getPlotHome(final World w, final PlotId plotid) {
|
||||||
// return 64;
|
Plot plot = getPlot(w, plotid);
|
||||||
// }
|
BlockLoc home = plot.settings.getPosition();
|
||||||
//
|
final Location bot = getPlotBottomLoc(w, plotid);
|
||||||
// /**
|
PlotManager manager = PlotSquared.getPlotManager(w);
|
||||||
// * Get plot home
|
if (home == null || (home.x == 0 && home.z == 0)) {
|
||||||
// *
|
final Location top = getPlotTopLoc(w, plotid);
|
||||||
// * @param w World in which the plot is located
|
final int x = ((top.getX() - bot.getX())/2) + bot.getX();
|
||||||
// * @param plotid Plot ID
|
final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ();
|
||||||
// *
|
final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getBlockY());
|
||||||
// * @return Home Location
|
return new Location(w, x, y, z);
|
||||||
// */
|
}
|
||||||
// public static Location getPlotHome(final World w, final PlotId plotid) {
|
else {
|
||||||
// Plot plot = getPlot(w, plotid);
|
final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y);
|
||||||
// BlockLoc home = plot.settings.getPosition();
|
return bot.add(home.x, y, home.z);
|
||||||
// final Location bot = getPlotBottomLoc(w, plotid);
|
}
|
||||||
// PlotManager manager = PlotSquared.getPlotManager(w);
|
}
|
||||||
// if (home == null || (home.x == 0 && home.z == 0)) {
|
|
||||||
// final Location top = getPlotTopLoc(w, plotid);
|
/**
|
||||||
// final int x = ((top.getX() - bot.getX())/2) + bot.getX();
|
* Retrieve the location of the default plot home position
|
||||||
// final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ();
|
*
|
||||||
// final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getBlockY());
|
* @param plot Plot
|
||||||
// return new Location(w, x, y, z);
|
*
|
||||||
// }
|
* @return the location
|
||||||
// else {
|
*/
|
||||||
// final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y);
|
public static Location getPlotHomeDefault(final Plot plot) {
|
||||||
// return bot.add(home.x, y, home.z);
|
final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0);
|
||||||
// }
|
l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ()));
|
||||||
// }
|
return l;
|
||||||
//
|
}
|
||||||
// /**
|
|
||||||
// * Retrieve the location of the default plot home position
|
/**
|
||||||
// *
|
* Get the plot home
|
||||||
// * @param plot Plot
|
*
|
||||||
// *
|
* @param w World
|
||||||
// * @return the location
|
* @param plot Plot Object
|
||||||
// */
|
*
|
||||||
// public static Location getPlotHomeDefault(final Plot plot) {
|
* @return Plot Home Location
|
||||||
// final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0);
|
*
|
||||||
// l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ()));
|
* @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
||||||
// return l;
|
*/
|
||||||
// }
|
public static Location getPlotHome(final World w, final Plot plot) {
|
||||||
//
|
return getPlotHome(w, plot.id);
|
||||||
// /**
|
}
|
||||||
// * Get the plot home
|
|
||||||
// *
|
/**
|
||||||
// * @param w World
|
* Refresh the plot chunks
|
||||||
// * @param plot Plot Object
|
*
|
||||||
// *
|
* @param world World in which the plot is located
|
||||||
// * @return Plot Home Location
|
* @param plot Plot Object
|
||||||
// *
|
*/
|
||||||
// * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
public static void refreshPlotChunks(final String world, final Plot plot) {
|
||||||
// */
|
|
||||||
// public static Location getPlotHome(final World w, final Plot plot) {
|
final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
||||||
// return getPlotHome(w, plot.id);
|
final int topX = getPlotTopLoc(world, plot.id).getX();
|
||||||
// }
|
final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
||||||
//
|
final int topZ = getPlotTopLoc(world, plot.id).getZ();
|
||||||
// /**
|
|
||||||
// * Refresh the plot chunks
|
final int minChunkX = (int) Math.floor((double) bottomX / 16);
|
||||||
// *
|
final int maxChunkX = (int) Math.floor((double) topX / 16);
|
||||||
// * @param world World in which the plot is located
|
final int minChunkZ = (int) Math.floor((double) bottomZ / 16);
|
||||||
// * @param plot Plot Object
|
final int maxChunkZ = (int) Math.floor((double) topZ / 16);
|
||||||
// */
|
|
||||||
// public static void refreshPlotChunks(final String world, final Plot plot) {
|
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
//
|
|
||||||
// final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
for (int x = minChunkX; x <= maxChunkX; x++) {
|
||||||
// final int topX = getPlotTopLoc(world, plot.id).getX();
|
for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
||||||
// final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
if (canSendChunk) {
|
||||||
// final int topZ = getPlotTopLoc(world, plot.id).getZ();
|
final Chunk chunk = world.getChunkAt(x, z);
|
||||||
//
|
chunks.add(chunk);
|
||||||
// final int minChunkX = (int) Math.floor((double) bottomX / 16);
|
} else {
|
||||||
// final int maxChunkX = (int) Math.floor((double) topX / 16);
|
world.refreshChunk(x, z);
|
||||||
// final int minChunkZ = (int) Math.floor((double) bottomZ / 16);
|
}
|
||||||
// final int maxChunkZ = (int) Math.floor((double) topZ / 16);
|
}
|
||||||
//
|
}
|
||||||
// final ArrayList<Chunk> chunks = new ArrayList<>();
|
try {
|
||||||
//
|
SendChunk.sendChunk(chunks);
|
||||||
// for (int x = minChunkX; x <= maxChunkX; x++) {
|
} catch (final Throwable e) {
|
||||||
// for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
canSendChunk = false;
|
||||||
// if (canSendChunk) {
|
for (int x = minChunkX; x <= maxChunkX; x++) {
|
||||||
// final Chunk chunk = world.getChunkAt(x, z);
|
for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
||||||
// chunks.add(chunk);
|
world.refreshChunk(x, z);
|
||||||
// } else {
|
}
|
||||||
// world.refreshChunk(x, z);
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
// try {
|
/**
|
||||||
// SendChunk.sendChunk(chunks);
|
* Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot
|
||||||
// } catch (final Throwable e) {
|
* use getPlotTopLoc(...)
|
||||||
// canSendChunk = false;
|
*
|
||||||
// for (int x = minChunkX; x <= maxChunkX; x++) {
|
* @param world
|
||||||
// for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
* @param id
|
||||||
// world.refreshChunk(x, z);
|
*
|
||||||
// }
|
* @return
|
||||||
// }
|
*/
|
||||||
// }
|
public static Location getPlotTopLocAbs(final String world, final PlotId id) {
|
||||||
// }
|
|
||||||
//
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
// /**
|
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
// * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot
|
return manager.getPlotTopLocAbs(plotworld, id);
|
||||||
// * use getPlotTopLoc(...)
|
}
|
||||||
// *
|
|
||||||
// * @param world
|
/**
|
||||||
// * @param id
|
* Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega
|
||||||
// *
|
* plot use getPlotBottomLoc(...)
|
||||||
// * @return
|
*
|
||||||
// */
|
* @param world
|
||||||
// public static Location getPlotTopLocAbs(final String world, final PlotId id) {
|
* @param id
|
||||||
//
|
*
|
||||||
// final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
* @return
|
||||||
// final PlotManager manager = PlotSquared.getPlotManager(world);
|
*/
|
||||||
// return manager.getPlotTopLocAbs(plotworld, id);
|
public static Location getPlotBottomLocAbs(final String world, final PlotId id) {
|
||||||
// }
|
|
||||||
//
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
// /**
|
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
// * Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega
|
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||||
// * plot use getPlotBottomLoc(...)
|
}
|
||||||
// *
|
|
||||||
// * @param world
|
/**
|
||||||
// * @param id
|
* Obtains the width of a plot (x width)
|
||||||
// *
|
*
|
||||||
// * @return
|
* @param world
|
||||||
// */
|
* @param id
|
||||||
// public static Location getPlotBottomLocAbs(final String world, final PlotId id) {
|
*
|
||||||
//
|
* @return
|
||||||
// final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
*/
|
||||||
// final PlotManager manager = PlotSquared.getPlotManager(world);
|
public static int getPlotWidth(final String world, final PlotId id) {
|
||||||
// return manager.getPlotBottomLocAbs(plotworld, id);
|
|
||||||
// }
|
return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX();
|
||||||
//
|
}
|
||||||
// /**
|
|
||||||
// * Obtains the width of a plot (x width)
|
/**
|
||||||
// *
|
* Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as
|
||||||
// * @param world
|
* a small plot use getPlotTopLocAbs(...)
|
||||||
// * @param id
|
*
|
||||||
// *
|
* @param world
|
||||||
// * @return
|
* @param id
|
||||||
// */
|
*
|
||||||
// public static int getPlotWidth(final String world, final PlotId id) {
|
* @return
|
||||||
//
|
*/
|
||||||
// return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX();
|
public static Location getPlotTopLoc(final String world, PlotId id) {
|
||||||
// }
|
|
||||||
//
|
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||||
// /**
|
if (plot != null) {
|
||||||
// * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as
|
id = PlayerFunctions.getTopPlot(world, plot).id;
|
||||||
// * a small plot use getPlotTopLocAbs(...)
|
}
|
||||||
// *
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
// * @param world
|
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
// * @param id
|
return manager.getPlotTopLocAbs(plotworld, id);
|
||||||
// *
|
}
|
||||||
// * @return
|
|
||||||
// */
|
/**
|
||||||
// public static Location getPlotTopLoc(final String world, PlotId id) {
|
* Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot
|
||||||
//
|
* treated as a small plot use getPlotBottomLocAbs(...)
|
||||||
// final Plot plot = PlotSquared.getPlots(world).get(id);
|
*
|
||||||
// if (plot != null) {
|
* @param world
|
||||||
// id = PlayerFunctions.getTopPlot(world, plot).id;
|
* @param id
|
||||||
// }
|
*
|
||||||
// final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
* @return
|
||||||
// final PlotManager manager = PlotSquared.getPlotManager(world);
|
*/
|
||||||
// return manager.getPlotTopLocAbs(plotworld, id);
|
public static Location getPlotBottomLoc(final String world, PlotId id) {
|
||||||
// }
|
|
||||||
//
|
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||||
// /**
|
if (plot != null) {
|
||||||
// * Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot
|
id = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||||
// * treated as a small plot use getPlotBottomLocAbs(...)
|
}
|
||||||
// *
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
// * @param world
|
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
// * @param id
|
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||||
// *
|
}
|
||||||
// * @return
|
|
||||||
// */
|
public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) {
|
||||||
// public static Location getPlotBottomLoc(final String world, PlotId id) {
|
|
||||||
//
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
// final Plot plot = PlotSquared.getPlots(world).get(id);
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
// if (plot != null) {
|
final PlotId id = new PlotId(x, y);
|
||||||
// id = PlayerFunctions.getBottomPlot(world, plot).id;
|
if (PlotSquared.getPlots(world).get(id) != null) {
|
||||||
// }
|
if (PlotSquared.getPlots(world).get(id).owner != null) {
|
||||||
// final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
return false;
|
||||||
// final PlotManager manager = PlotSquared.getPlotManager(world);
|
}
|
||||||
// return manager.getPlotBottomLocAbs(plotworld, id);
|
}
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) {
|
return true;
|
||||||
//
|
}
|
||||||
// for (int x = pos1.x; x <= pos2.x; x++) {
|
|
||||||
// for (int y = pos1.y; y <= pos2.y; y++) {
|
public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) {
|
||||||
// final PlotId id = new PlotId(x, y);
|
String worldname = world.getName();
|
||||||
// if (PlotSquared.getPlots(world).get(id) != null) {
|
final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current);
|
||||||
// if (PlotSquared.getPlots(world).get(id).owner != null) {
|
com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(worldname, newPlot);
|
||||||
// return false;
|
final Location top = PlotHelper.getPlotTopLoc(worldname, current);
|
||||||
// }
|
final Plot currentPlot = PlotHelper.getPlot(worldname, current);
|
||||||
// }
|
if (currentPlot.owner == null) {
|
||||||
// }
|
return false;
|
||||||
// }
|
}
|
||||||
// return true;
|
Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot);
|
||||||
// }
|
Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot);
|
||||||
//
|
|
||||||
// public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) {
|
PlotId size = PlotHelper.getSize(world, currentPlot);
|
||||||
// String worldname = world.getName();
|
if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) {
|
||||||
// final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current);
|
return false;
|
||||||
// com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(worldname, newPlot);
|
}
|
||||||
// final Location top = PlotHelper.getPlotTopLoc(worldname, current);
|
|
||||||
// final Plot currentPlot = PlotHelper.getPlot(worldname, current);
|
int offset_x = newPlot.x - pos1.id.x;
|
||||||
// if (currentPlot.owner == null) {
|
int offset_y = newPlot.y - pos1.id.y;
|
||||||
// return false;
|
final ArrayList<PlotId> selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id);
|
||||||
// }
|
String worldname = world.getName();
|
||||||
// Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot);
|
for (PlotId id : selection) {
|
||||||
// Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot);
|
DBFunc.movePlot(world.getName(), new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y));
|
||||||
//
|
Plot plot = PlotSquared.getPlots(worldname).get(id);
|
||||||
// PlotId size = PlotHelper.getSize(world, currentPlot);
|
PlotSquared.getPlots(worldname).remove(id);
|
||||||
// if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) {
|
plot.id.x += offset_x;
|
||||||
// return false;
|
plot.id.y += offset_y;
|
||||||
// }
|
PlotSquared.getPlots(worldname).put(plot.id, plot);
|
||||||
//
|
}
|
||||||
// int offset_x = newPlot.x - pos1.id.x;
|
ChunkManager.copyRegion(bot1, top, bot2, new Runnable() {
|
||||||
// int offset_y = newPlot.y - pos1.id.y;
|
@Override
|
||||||
// final ArrayList<PlotId> selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id);
|
public void run() {
|
||||||
// String worldname = world.getName();
|
Location bot = bot1.clone().add(1, 0, 1);
|
||||||
// for (PlotId id : selection) {
|
ChunkManager.regenerateRegion(bot, top, null);
|
||||||
// DBFunc.movePlot(world.getName(), new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y));
|
TaskManager.runTaskLater(whenDone, 1);
|
||||||
// Plot plot = PlotSquared.getPlots(worldname).get(id);
|
}
|
||||||
// PlotSquared.getPlots(worldname).remove(id);
|
});
|
||||||
// plot.id.x += offset_x;
|
return true;
|
||||||
// plot.id.y += offset_y;
|
}
|
||||||
// PlotSquared.getPlots(worldname).put(plot.id, plot);
|
|
||||||
// }
|
public static PlotId getSize(String world, Plot plot) {
|
||||||
// ChunkManager.copyRegion(bot1, top, bot2, new Runnable() {
|
|
||||||
// @Override
|
PlotSettings settings = plot.settings;
|
||||||
// public void run() {
|
if (!settings.isMerged()) {
|
||||||
// Location bot = bot1.clone().add(1, 0, 1);
|
return new PlotId(1,1);
|
||||||
// ChunkManager.regenerateRegion(bot, top, null);
|
}
|
||||||
// TaskManager.runTaskLater(whenDone, 1);
|
Plot top = PlayerFunctions.getTopPlot(world, plot);
|
||||||
// }
|
Plot bot = PlayerFunctions.getBottomPlot(world, plot);
|
||||||
// });
|
return new PlotId(top.id.x - bot.id.x + 1, top.id.y - bot.id.y + 1);
|
||||||
// return true;
|
}
|
||||||
// }
|
|
||||||
//
|
/**
|
||||||
// public static PlotId getSize(String world, Plot plot) {
|
* Fetches the plot from the main class
|
||||||
//
|
*
|
||||||
// PlotSettings settings = plot.settings;
|
* @param world
|
||||||
// if (!settings.isMerged()) {
|
* @param id
|
||||||
// return new PlotId(1,1);
|
*
|
||||||
// }
|
* @return
|
||||||
// Plot top = PlayerFunctions.getTopPlot(world, plot);
|
*/
|
||||||
// Plot bot = PlayerFunctions.getBottomPlot(world, plot);
|
public static Plot getPlot(final String world, final PlotId id) {
|
||||||
// return new PlotId(top.id.x - bot.id.x + 1, top.id.y - bot.id.y + 1);
|
|
||||||
// }
|
if (id == null) {
|
||||||
//
|
return null;
|
||||||
// /**
|
}
|
||||||
// * Fetches the plot from the main class
|
if (PlotSquared.getPlots(world).containsKey(id)) {
|
||||||
// *
|
return PlotSquared.getPlots(world).get(id);
|
||||||
// * @param world
|
}
|
||||||
// * @param id
|
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
|
||||||
// *
|
}
|
||||||
// * @return
|
|
||||||
// */
|
/**
|
||||||
// public static Plot getPlot(final String world, final PlotId id) {
|
* Returns the plot at a given location
|
||||||
//
|
*
|
||||||
// if (id == null) {
|
* @param loc
|
||||||
// return null;
|
*
|
||||||
// }
|
* @return
|
||||||
// if (PlotSquared.getPlots(world).containsKey(id)) {
|
*/
|
||||||
// return PlotSquared.getPlots(world).get(id);
|
public static Plot getCurrentPlot(final Location loc) {
|
||||||
// }
|
final PlotId id = PlayerFunctions.getPlot(loc);
|
||||||
// return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
|
if (id == null) {
|
||||||
// }
|
return null;
|
||||||
//
|
}
|
||||||
// /**
|
if (PlotSquared.getPlots(loc.getWorld()).containsKey(id)) {
|
||||||
// * Returns the plot at a given location
|
return PlotSquared.getPlots(loc.getWorld()).get(id);
|
||||||
// *
|
}
|
||||||
// * @param loc
|
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld().getName());
|
||||||
// *
|
}
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// public static Plot getCurrentPlot(final Location loc) {
|
|
||||||
// final PlotId id = PlayerFunctions.getPlot(loc);
|
|
||||||
// if (id == null) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// if (PlotSquared.getPlots(loc.getWorld()).containsKey(id)) {
|
|
||||||
// return PlotSquared.getPlots(loc.getWorld()).get(id);
|
|
||||||
// }
|
|
||||||
// return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld().getName());
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user