mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
plot
This commit is contained in:
parent
aefd148bcd
commit
96d2688035
@ -63,7 +63,7 @@ public class Claim extends SubCommand {
|
|||||||
if (teleport) {
|
if (teleport) {
|
||||||
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
||||||
}
|
}
|
||||||
World world = plot.getWorld();
|
World world = plot.world;
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
|
|
||||||
final Plot plot2 = PlotSquared.getPlots(player.getWorld()).get(plot.id);
|
final Plot plot2 = PlotSquared.getPlots(player.getWorld()).get(plot.id);
|
||||||
@ -102,7 +102,7 @@ public class Claim extends SubCommand {
|
|||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||||
}
|
}
|
||||||
final PlotWorld world = PlotSquared.getWorldSettings(plot.getWorld());
|
final PlotWorld world = PlotSquared.getWorldSettings(plot.world);
|
||||||
if (PlotSquared.useEconomy && world.USE_ECONOMY) {
|
if (PlotSquared.useEconomy && world.USE_ECONOMY) {
|
||||||
final double cost = world.PLOT_PRICE;
|
final double cost = world.PLOT_PRICE;
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
|
@ -53,7 +53,7 @@ public class Delete extends SubCommand {
|
|||||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.getWorld());
|
final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.world);
|
||||||
if (PlotSquared.useEconomy && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
|
if (PlotSquared.useEconomy && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
|
||||||
final double c = pWorld.SELL_PRICE;
|
final double c = pWorld.SELL_PRICE;
|
||||||
if (c > 0d) {
|
if (c > 0d) {
|
||||||
|
@ -54,7 +54,7 @@ public class Unclaim extends SubCommand {
|
|||||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.getWorld());
|
final PlotWorld pWorld = PlotSquared.getWorldSettings(plot.world);
|
||||||
if (PlotSquared.useEconomy && pWorld.USE_ECONOMY) {
|
if (PlotSquared.useEconomy && pWorld.USE_ECONOMY) {
|
||||||
final double c = pWorld.SELL_PRICE;
|
final double c = pWorld.SELL_PRICE;
|
||||||
if (c > 0d) {
|
if (c > 0d) {
|
||||||
|
@ -1078,7 +1078,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
String comparison = below ? ">=" : "=";
|
String comparison = below ? ">=" : "=";
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?");
|
statement = this.connection.prepareStatement("SELECT * FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` " + comparison + " ?");
|
||||||
statement.setInt(1, getId(plot.getWorld().getName(), plot.id));
|
statement.setInt(1, getId(plot.world.getName(), plot.id));
|
||||||
statement.setInt(2, tier);
|
statement.setInt(2, tier);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1284,7 +1284,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
public double getRatings(final Plot plot) {
|
public double getRatings(final Plot plot) {
|
||||||
try {
|
try {
|
||||||
final PreparedStatement statement = this.connection.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `" + this.prefix + "plot_ratings` WHERE `plot_plot_id` = ? ");
|
final PreparedStatement statement = this.connection.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `" + this.prefix + "plot_ratings` WHERE `plot_plot_id` = ? ");
|
||||||
statement.setInt(1, getId(plot.getWorld().getName(), plot.id));
|
statement.setInt(1, getId(plot.world.getName(), plot.id));
|
||||||
final ResultSet set = statement.executeQuery();
|
final ResultSet set = statement.executeQuery();
|
||||||
double rating = 0;
|
double rating = 0;
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
|
@ -711,9 +711,9 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
final Set<Plot> plots = PlotSquared.getPlots(event.getPlayer());
|
final Set<Plot> plots = PlotSquared.getPlots(event.getPlayer());
|
||||||
for (final Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world);
|
PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world);
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(plot.getWorld());
|
final PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
||||||
manager.clearPlot(null, plotworld, plot, true, null);
|
manager.clearPlot(null, plotworld, plot, true, null);
|
||||||
DBFunc.delete(plot.getWorld().getName(), plot);
|
DBFunc.delete(plot.world.getName(), plot);
|
||||||
PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
|
PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,13 +192,13 @@ public class WorldGuardListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final Plot plot = event.getPlot();
|
final Plot plot = event.getPlot();
|
||||||
final RegionManager manager = PlotSquared.worldGuard.getRegionManager(plot.getWorld());
|
final RegionManager manager = PlotSquared.worldGuard.getRegionManager(plot.world);
|
||||||
|
|
||||||
final Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId());
|
final Location location1 = PlotHelper.getPlotBottomLoc(plot.world, plot.getId());
|
||||||
final Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId());
|
final Location location2 = PlotHelper.getPlotTopLoc(plot.world, plot.getId());
|
||||||
|
|
||||||
final BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
final BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
||||||
final BlockVector vector2 = new BlockVector(location2.getBlockX(), plot.getWorld().getMaxHeight(), location2.getBlockZ());
|
final BlockVector vector2 = new BlockVector(location2.getBlockX(), plot.world.getMaxHeight(), location2.getBlockZ());
|
||||||
|
|
||||||
final ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2);
|
final ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2);
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ import com.intellectualcrafters.plot.util.PlotHelper;
|
|||||||
* @return biome at plot loc
|
* @return biome at plot loc
|
||||||
*/
|
*/
|
||||||
public Biome getBiome() {
|
public Biome getBiome() {
|
||||||
return PlotHelper.getPlotBottomLoc(this.plot.getWorld(), this.plot.getId()).add(1, 0, 1).getBlock().getBiome();
|
return PlotHelper.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1).getBlock().getBiome();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockLoc getPosition() {
|
public BlockLoc getPosition() {
|
||||||
|
@ -452,7 +452,7 @@ 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.getWorld();
|
final World 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.getName());
|
||||||
PlotSquared.updatePlot(p);
|
PlotSquared.updatePlot(p);
|
||||||
DBFunc.createPlotAndSettings(p);
|
DBFunc.createPlotAndSettings(p);
|
||||||
@ -553,9 +553,9 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
*/
|
*/
|
||||||
public static void clear(final Player requester, final Plot plot, final boolean isDelete) {
|
public static void clear(final Player requester, final Plot plot, final boolean isDelete) {
|
||||||
if (requester == null) {
|
if (requester == null) {
|
||||||
clearAllEntities(plot.getWorld(), plot, false);
|
clearAllEntities(plot.world, plot, false);
|
||||||
clear(requester, plot.getWorld(), plot, isDelete);
|
clear(requester, plot.world, plot, isDelete);
|
||||||
removeSign(plot.getWorld(), plot);
|
removeSign(plot.world, plot);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (runners.containsKey(plot)) {
|
if (runners.containsKey(plot)) {
|
||||||
@ -571,376 +571,376 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
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++) {
|
// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||||
for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
// for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
||||||
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
// for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
// final Block block = world.getBlockAt(x, y, z);
|
||||||
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
// if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
||||||
setBlock(world, x, y, z, newblock.id, newblock.data);
|
// setBlock(world, x, y, z, newblock.id, newblock.data);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
|
// public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
|
||||||
|
//
|
||||||
if (blocks.length == 1) {
|
// if (blocks.length == 1) {
|
||||||
setCuboid(world, pos1, pos2, blocks[0]);
|
// setCuboid(world, pos1, pos2, blocks[0]);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||||
for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
// for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
||||||
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
// for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
||||||
final int i = random(blocks.length);
|
// final int i = random(blocks.length);
|
||||||
final PlotBlock newblock = blocks[i];
|
// final PlotBlock newblock = blocks[i];
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
// final Block block = world.getBlockAt(x, y, z);
|
||||||
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
// if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
||||||
setBlock(world, x, y, z, newblock.id, newblock.data);
|
// setBlock(world, x, y, z, newblock.id, newblock.data);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) {
|
// 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++) {
|
// for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||||
for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
// for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
||||||
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
// for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
// final Block block = world.getBlockAt(x, y, z);
|
||||||
if (!((block.getTypeId() == newblock.id))) {
|
// if (!((block.getTypeId() == newblock.id))) {
|
||||||
setBlock(world, x, y, z, newblock.id, (byte) 0);
|
// setBlock(world, x, y, z, newblock.id, (byte) 0);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static void setBiome(final String world, final Plot plot, final Biome b) {
|
// public static void setBiome(final String world, final Plot plot, final Biome b) {
|
||||||
|
//
|
||||||
final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
// final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
||||||
final int topX = getPlotTopLoc(world, plot.id).getX() + 1;
|
// final int topX = getPlotTopLoc(world, plot.id).getX() + 1;
|
||||||
final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
// final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
||||||
final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1;
|
// final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1;
|
||||||
|
//
|
||||||
final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1));
|
// final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1));
|
||||||
final Biome biome = block.getBiome();
|
// final Biome biome = block.getBiome();
|
||||||
|
//
|
||||||
if (biome.equals(b)) {
|
// if (biome.equals(b)) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (int x = bottomX; x <= topX; x++) {
|
// for (int x = bottomX; x <= topX; x++) {
|
||||||
for (int z = bottomZ; z <= topZ; z++) {
|
// for (int z = bottomZ; z <= topZ; z++) {
|
||||||
final Block blk = world.getBlockAt(x, 0, z);
|
// final Block blk = world.getBlockAt(x, 0, z);
|
||||||
final Biome c = blk.getBiome();
|
// final Biome c = blk.getBiome();
|
||||||
if (c.equals(b)) {
|
// if (c.equals(b)) {
|
||||||
x += 15;
|
// x += 15;
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
blk.setBiome(b);
|
// blk.setBiome(b);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static int getHeighestBlock(final String world, final int x, final int z) {
|
// public static int getHeighestBlock(final String world, final int x, final int z) {
|
||||||
|
//
|
||||||
boolean safe = false;
|
// boolean safe = false;
|
||||||
int id;
|
// int id;
|
||||||
for (int i = 1; i < world.getMaxHeight(); i++) {
|
// for (int i = 1; i < world.getMaxHeight(); i++) {
|
||||||
id = world.getBlockAt(x, i, z).getTypeId();
|
// id = world.getBlockAt(x, i, z).getTypeId();
|
||||||
if (id == 0) {
|
// if (id == 0) {
|
||||||
if (safe) {
|
// if (safe) {
|
||||||
return i;
|
// return i;
|
||||||
}
|
// }
|
||||||
safe = true;
|
// safe = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return 64;
|
// return 64;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Get plot home
|
// * Get plot home
|
||||||
*
|
// *
|
||||||
* @param w World in which the plot is located
|
// * @param w World in which the plot is located
|
||||||
* @param plotid Plot ID
|
// * @param plotid Plot ID
|
||||||
*
|
// *
|
||||||
* @return Home Location
|
// * @return Home Location
|
||||||
*/
|
// */
|
||||||
public static Location getPlotHome(final World w, final PlotId plotid) {
|
// public static Location getPlotHome(final World w, final PlotId plotid) {
|
||||||
Plot plot = getPlot(w, plotid);
|
// Plot plot = getPlot(w, plotid);
|
||||||
BlockLoc home = plot.settings.getPosition();
|
// BlockLoc home = plot.settings.getPosition();
|
||||||
final Location bot = getPlotBottomLoc(w, plotid);
|
// final Location bot = getPlotBottomLoc(w, plotid);
|
||||||
PlotManager manager = PlotSquared.getPlotManager(w);
|
// PlotManager manager = PlotSquared.getPlotManager(w);
|
||||||
if (home == null || (home.x == 0 && home.z == 0)) {
|
// if (home == null || (home.x == 0 && home.z == 0)) {
|
||||||
final Location top = getPlotTopLoc(w, plotid);
|
// final Location top = getPlotTopLoc(w, plotid);
|
||||||
final int x = ((top.getX() - bot.getX())/2) + bot.getX();
|
// final int x = ((top.getX() - bot.getX())/2) + bot.getX();
|
||||||
final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ();
|
// 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());
|
// final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getBlockY());
|
||||||
return new Location(w, x, y, z);
|
// return new Location(w, x, y, z);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y);
|
// final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y);
|
||||||
return bot.add(home.x, y, home.z);
|
// return bot.add(home.x, y, home.z);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Retrieve the location of the default plot home position
|
// * Retrieve the location of the default plot home position
|
||||||
*
|
// *
|
||||||
* @param plot Plot
|
// * @param plot Plot
|
||||||
*
|
// *
|
||||||
* @return the location
|
// * @return the location
|
||||||
*/
|
// */
|
||||||
public static Location getPlotHomeDefault(final Plot plot) {
|
// public static Location getPlotHomeDefault(final Plot plot) {
|
||||||
final Location l = getPlotBottomLoc(plot.getWorld(), plot.getId()).subtract(0, 0, 0);
|
// final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0);
|
||||||
l.setY(getHeighestBlock(plot.getWorld(), l.getX(), l.getZ()));
|
// l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ()));
|
||||||
return l;
|
// return l;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Get the plot home
|
// * Get the plot home
|
||||||
*
|
// *
|
||||||
* @param w World
|
// * @param w World
|
||||||
* @param plot Plot Object
|
// * @param plot Plot Object
|
||||||
*
|
// *
|
||||||
* @return Plot Home Location
|
// * @return Plot Home Location
|
||||||
*
|
// *
|
||||||
* @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
// * @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
||||||
*/
|
// */
|
||||||
public static Location getPlotHome(final World w, final Plot plot) {
|
// public static Location getPlotHome(final World w, final Plot plot) {
|
||||||
return getPlotHome(w, plot.id);
|
// return getPlotHome(w, plot.id);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Refresh the plot chunks
|
// * Refresh the plot chunks
|
||||||
*
|
// *
|
||||||
* @param world World in which the plot is located
|
// * @param world World in which the plot is located
|
||||||
* @param plot Plot Object
|
// * @param plot Plot Object
|
||||||
*/
|
// */
|
||||||
public static void refreshPlotChunks(final String world, final Plot plot) {
|
// public static void refreshPlotChunks(final String world, final Plot plot) {
|
||||||
|
//
|
||||||
final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
// final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
||||||
final int topX = getPlotTopLoc(world, plot.id).getX();
|
// final int topX = getPlotTopLoc(world, plot.id).getX();
|
||||||
final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
// final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
||||||
final int topZ = getPlotTopLoc(world, plot.id).getZ();
|
// final int topZ = getPlotTopLoc(world, plot.id).getZ();
|
||||||
|
//
|
||||||
final int minChunkX = (int) Math.floor((double) bottomX / 16);
|
// final int minChunkX = (int) Math.floor((double) bottomX / 16);
|
||||||
final int maxChunkX = (int) Math.floor((double) topX / 16);
|
// final int maxChunkX = (int) Math.floor((double) topX / 16);
|
||||||
final int minChunkZ = (int) Math.floor((double) bottomZ / 16);
|
// final int minChunkZ = (int) Math.floor((double) bottomZ / 16);
|
||||||
final int maxChunkZ = (int) Math.floor((double) topZ / 16);
|
// final int maxChunkZ = (int) Math.floor((double) topZ / 16);
|
||||||
|
//
|
||||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
// final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
|
//
|
||||||
for (int x = minChunkX; x <= maxChunkX; x++) {
|
// for (int x = minChunkX; x <= maxChunkX; x++) {
|
||||||
for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
// for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
||||||
if (canSendChunk) {
|
// if (canSendChunk) {
|
||||||
final Chunk chunk = world.getChunkAt(x, z);
|
// final Chunk chunk = world.getChunkAt(x, z);
|
||||||
chunks.add(chunk);
|
// chunks.add(chunk);
|
||||||
} else {
|
// } else {
|
||||||
world.refreshChunk(x, z);
|
// world.refreshChunk(x, z);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
try {
|
// try {
|
||||||
SendChunk.sendChunk(chunks);
|
// SendChunk.sendChunk(chunks);
|
||||||
} catch (final Throwable e) {
|
// } catch (final Throwable e) {
|
||||||
canSendChunk = false;
|
// canSendChunk = false;
|
||||||
for (int x = minChunkX; x <= maxChunkX; x++) {
|
// for (int x = minChunkX; x <= maxChunkX; x++) {
|
||||||
for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
// for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
||||||
world.refreshChunk(x, z);
|
// world.refreshChunk(x, z);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot
|
// * Gets the top plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega plot
|
||||||
* use getPlotTopLoc(...)
|
// * use getPlotTopLoc(...)
|
||||||
*
|
// *
|
||||||
* @param world
|
// * @param world
|
||||||
* @param id
|
// * @param id
|
||||||
*
|
// *
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public static Location getPlotTopLocAbs(final String world, final PlotId id) {
|
// public static Location getPlotTopLocAbs(final String world, final PlotId id) {
|
||||||
|
//
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
// final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
// final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
return manager.getPlotTopLocAbs(plotworld, id);
|
// return manager.getPlotTopLocAbs(plotworld, id);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Gets the bottom plot location of a plot (all plots are treated as small plots) - To get the top loc of a mega
|
// * 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(...)
|
// * plot use getPlotBottomLoc(...)
|
||||||
*
|
// *
|
||||||
* @param world
|
// * @param world
|
||||||
* @param id
|
// * @param id
|
||||||
*
|
// *
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public static Location getPlotBottomLocAbs(final String world, final PlotId id) {
|
// public static Location getPlotBottomLocAbs(final String world, final PlotId id) {
|
||||||
|
//
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
// final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
// final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
// return manager.getPlotBottomLocAbs(plotworld, id);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Obtains the width of a plot (x width)
|
// * Obtains the width of a plot (x width)
|
||||||
*
|
// *
|
||||||
* @param world
|
// * @param world
|
||||||
* @param id
|
// * @param id
|
||||||
*
|
// *
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public static int getPlotWidth(final String world, final PlotId id) {
|
// public static int getPlotWidth(final String world, final PlotId id) {
|
||||||
|
//
|
||||||
return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX();
|
// return getPlotTopLoc(world, id).getX() - getPlotBottomLoc(world, id).getX();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as
|
// * Gets the top loc of a plot (if mega, returns top loc of that mega plot) - If you would like each plot treated as
|
||||||
* a small plot use getPlotTopLocAbs(...)
|
// * a small plot use getPlotTopLocAbs(...)
|
||||||
*
|
// *
|
||||||
* @param world
|
// * @param world
|
||||||
* @param id
|
// * @param id
|
||||||
*
|
// *
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public static Location getPlotTopLoc(final String world, PlotId id) {
|
// public static Location getPlotTopLoc(final String world, PlotId id) {
|
||||||
|
//
|
||||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
// final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||||
if (plot != null) {
|
// if (plot != null) {
|
||||||
id = PlayerFunctions.getTopPlot(world, plot).id;
|
// id = PlayerFunctions.getTopPlot(world, plot).id;
|
||||||
}
|
// }
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
// final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
// final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
return manager.getPlotTopLocAbs(plotworld, id);
|
// return manager.getPlotTopLocAbs(plotworld, id);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot) - If you would like each plot
|
// * 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(...)
|
// * treated as a small plot use getPlotBottomLocAbs(...)
|
||||||
*
|
// *
|
||||||
* @param world
|
// * @param world
|
||||||
* @param id
|
// * @param id
|
||||||
*
|
// *
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public static Location getPlotBottomLoc(final String world, PlotId id) {
|
// public static Location getPlotBottomLoc(final String world, PlotId id) {
|
||||||
|
//
|
||||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
// final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||||
if (plot != null) {
|
// if (plot != null) {
|
||||||
id = PlayerFunctions.getBottomPlot(world, plot).id;
|
// id = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||||
}
|
// }
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
// final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
// final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
// return manager.getPlotBottomLocAbs(plotworld, id);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) {
|
// public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) {
|
||||||
|
//
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
// for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
// for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
final PlotId id = new PlotId(x, y);
|
// final PlotId id = new PlotId(x, y);
|
||||||
if (PlotSquared.getPlots(world).get(id) != null) {
|
// if (PlotSquared.getPlots(world).get(id) != null) {
|
||||||
if (PlotSquared.getPlots(world).get(id).owner != null) {
|
// if (PlotSquared.getPlots(world).get(id).owner != null) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) {
|
// public static boolean move(final String world, final PlotId current, PlotId newPlot, final Runnable whenDone) {
|
||||||
String worldname = world.getName();
|
// String worldname = world.getName();
|
||||||
final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current);
|
// final com.intellectualcrafters.plot.object.Location bot1 = PlotHelper.getPlotBottomLoc(worldname, current);
|
||||||
com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(worldname, newPlot);
|
// com.intellectualcrafters.plot.object.Location bot2 = PlotHelper.getPlotBottomLoc(worldname, newPlot);
|
||||||
final Location top = PlotHelper.getPlotTopLoc(worldname, current);
|
// final Location top = PlotHelper.getPlotTopLoc(worldname, current);
|
||||||
final Plot currentPlot = PlotHelper.getPlot(worldname, current);
|
// final Plot currentPlot = PlotHelper.getPlot(worldname, current);
|
||||||
if (currentPlot.owner == null) {
|
// if (currentPlot.owner == null) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot);
|
// Plot pos1 = PlayerFunctions.getBottomPlot(worldname, currentPlot);
|
||||||
Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot);
|
// Plot pos2 = PlayerFunctions.getTopPlot(worldname, currentPlot);
|
||||||
|
//
|
||||||
PlotId size = PlotHelper.getSize(world, currentPlot);
|
// PlotId size = PlotHelper.getSize(world, currentPlot);
|
||||||
if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) {
|
// if (!PlotHelper.isUnowned(world, newPlot, new PlotId(newPlot.x + size.x - 1, newPlot.y + size.y - 1))) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
int offset_x = newPlot.x - pos1.id.x;
|
// int offset_x = newPlot.x - pos1.id.x;
|
||||||
int offset_y = newPlot.y - pos1.id.y;
|
// int offset_y = newPlot.y - pos1.id.y;
|
||||||
final ArrayList<PlotId> selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id);
|
// final ArrayList<PlotId> selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id);
|
||||||
String worldname = world.getName();
|
// String worldname = world.getName();
|
||||||
for (PlotId id : selection) {
|
// for (PlotId id : selection) {
|
||||||
DBFunc.movePlot(world.getName(), new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y));
|
// 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);
|
// Plot plot = PlotSquared.getPlots(worldname).get(id);
|
||||||
PlotSquared.getPlots(worldname).remove(id);
|
// PlotSquared.getPlots(worldname).remove(id);
|
||||||
plot.id.x += offset_x;
|
// plot.id.x += offset_x;
|
||||||
plot.id.y += offset_y;
|
// plot.id.y += offset_y;
|
||||||
PlotSquared.getPlots(worldname).put(plot.id, plot);
|
// PlotSquared.getPlots(worldname).put(plot.id, plot);
|
||||||
}
|
// }
|
||||||
ChunkManager.copyRegion(bot1, top, bot2, new Runnable() {
|
// ChunkManager.copyRegion(bot1, top, bot2, new Runnable() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
Location bot = bot1.clone().add(1, 0, 1);
|
// Location bot = bot1.clone().add(1, 0, 1);
|
||||||
ChunkManager.regenerateRegion(bot, top, null);
|
// ChunkManager.regenerateRegion(bot, top, null);
|
||||||
TaskManager.runTaskLater(whenDone, 1);
|
// TaskManager.runTaskLater(whenDone, 1);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static PlotId getSize(String world, Plot plot) {
|
// public static PlotId getSize(String world, Plot plot) {
|
||||||
|
//
|
||||||
PlotSettings settings = plot.settings;
|
// PlotSettings settings = plot.settings;
|
||||||
if (!settings.isMerged()) {
|
// if (!settings.isMerged()) {
|
||||||
return new PlotId(1,1);
|
// return new PlotId(1,1);
|
||||||
}
|
// }
|
||||||
Plot top = PlayerFunctions.getTopPlot(world, plot);
|
// Plot top = PlayerFunctions.getTopPlot(world, plot);
|
||||||
Plot bot = PlayerFunctions.getBottomPlot(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 new PlotId(top.id.x - bot.id.x + 1, top.id.y - bot.id.y + 1);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Fetches the plot from the main class
|
// * Fetches the plot from the main class
|
||||||
*
|
// *
|
||||||
* @param world
|
// * @param world
|
||||||
* @param id
|
// * @param id
|
||||||
*
|
// *
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public static Plot getPlot(final String world, final PlotId id) {
|
// public static Plot getPlot(final String world, final PlotId id) {
|
||||||
|
//
|
||||||
if (id == null) {
|
// if (id == null) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
if (PlotSquared.getPlots(world).containsKey(id)) {
|
// if (PlotSquared.getPlots(world).containsKey(id)) {
|
||||||
return PlotSquared.getPlots(world).get(id);
|
// return PlotSquared.getPlots(world).get(id);
|
||||||
}
|
// }
|
||||||
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
|
// return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Returns the plot at a given location
|
// * Returns the plot at a given location
|
||||||
*
|
// *
|
||||||
* @param loc
|
// * @param loc
|
||||||
*
|
// *
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public static Plot getCurrentPlot(final Location loc) {
|
// public static Plot getCurrentPlot(final Location loc) {
|
||||||
final PlotId id = PlayerFunctions.getPlot(loc);
|
// final PlotId id = PlayerFunctions.getPlot(loc);
|
||||||
if (id == null) {
|
// if (id == null) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
if (PlotSquared.getPlots(loc.getWorld()).containsKey(id)) {
|
// if (PlotSquared.getPlots(loc.getWorld()).containsKey(id)) {
|
||||||
return PlotSquared.getPlots(loc.getWorld()).get(id);
|
// return PlotSquared.getPlots(loc.getWorld()).get(id);
|
||||||
}
|
// }
|
||||||
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld().getName());
|
// return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld().getName());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user