mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-30 00:56:45 +01:00
PlotPlayer
This commit is contained in:
parent
fa6b78f117
commit
16f5cc1f36
@ -15,7 +15,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ConsoleColors;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.*;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
@ -43,83 +43,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
public static BukkitMain THIS = null;
|
||||
public static PlotSquared MAIN = null;
|
||||
|
||||
// TODO restructure this
|
||||
public static boolean hasPermission(final PlotPlayer p, final String perm) {
|
||||
final Player player = Bukkit.getPlayer(p + "");
|
||||
if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) {
|
||||
return true;
|
||||
}
|
||||
if (player.hasPermission(perm)) {
|
||||
return true;
|
||||
}
|
||||
final String[] nodes = perm.split("\\.");
|
||||
final StringBuilder n = new StringBuilder();
|
||||
for (int i = 0; i < (nodes.length - 1); i++) {
|
||||
n.append(nodes[i] + ("."));
|
||||
if (player.hasPermission(n + "*")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO restructure this
|
||||
public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) {
|
||||
if ((player == null) || player.isOp() || player.hasPermission(PlotSquared.ADMIN_PERMISSION)) {
|
||||
return Byte.MAX_VALUE;
|
||||
}
|
||||
if (player.hasPermission(stub + ".*")) {
|
||||
return Byte.MAX_VALUE;
|
||||
}
|
||||
for (int i = range; i > 0; i--) {
|
||||
if (player.hasPermission(stub + "." + i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO restructure this
|
||||
public static boolean teleportPlayer(final Player player, final Location from, final Plot plot) {
|
||||
final Plot bot = PlotHelper.getBottomPlot(player.getWorld().getName(), plot);
|
||||
final PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, bot);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
final Location location = PlotHelper.getPlotHome(bot.world, bot);
|
||||
final int x = location.getX();
|
||||
final int z = location.getZ();
|
||||
if ((x >= 29999999) || (x <= -29999999) || (z >= 299999999) || (z <= -29999999)) {
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
if ((Settings.TELEPORT_DELAY == 0) || hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||
PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
BukkitUtil.teleportPlayer(player, location);
|
||||
return true;
|
||||
}
|
||||
PlayerFunctions.sendMessage(player, C.TELEPORT_IN_SECONDS, Settings.TELEPORT_DELAY + "");
|
||||
final String name = player.getName();
|
||||
TaskManager.TELEPORT_QUEUE.add(name);
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!TaskManager.TELEPORT_QUEUE.contains(name)) {
|
||||
PlayerFunctions.sendMessage(player, C.TELEPORT_FAILED);
|
||||
return;
|
||||
}
|
||||
TaskManager.TELEPORT_QUEUE.remove(name);
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
BukkitUtil.teleportPlayer(player, location);
|
||||
}
|
||||
}, Settings.TELEPORT_DELAY * 20);
|
||||
return true;
|
||||
}
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public static void worldLoad(final WorldLoadEvent event) {
|
||||
UUIDHandler.cacheAll();
|
||||
@ -253,7 +176,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
final Entity[] entities = chunk.getEntities();
|
||||
Entity entity;
|
||||
for (int i = entities.length - 1; i >= 0; i--) {
|
||||
if (!((entity = entities[i]) instanceof Player) && (PlotHelper.getPlot(BukkitUtil.getLocation(entity)) == null)) {
|
||||
if (!((entity = entities[i]) instanceof Player) && (MainUtil.getPlot(BukkitUtil.getLocation(entity)) == null)) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
@ -346,9 +269,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
}
|
||||
try {
|
||||
new SendChunk();
|
||||
PlotHelper.canSendChunk = true;
|
||||
MainUtil.canSendChunk = true;
|
||||
} catch (final Throwable e) {
|
||||
PlotHelper.canSendChunk = false;
|
||||
MainUtil.canSendChunk = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.Logger;
|
||||
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
@ -184,12 +184,12 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
plots.get(world).remove(id);
|
||||
if (PlotHelper.lastPlot.containsKey(world)) {
|
||||
final PlotId last = PlotHelper.lastPlot.get(world);
|
||||
if (MainUtil.lastPlot.containsKey(world)) {
|
||||
final PlotId last = MainUtil.lastPlot.get(world);
|
||||
final int last_max = Math.max(last.x, last.y);
|
||||
final int this_max = Math.max(id.x, id.y);
|
||||
if (this_max < last_max) {
|
||||
PlotHelper.lastPlot.put(world, id);
|
||||
MainUtil.lastPlot.put(world, id);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -226,7 +226,7 @@ public class PlotSquared {
|
||||
}
|
||||
// Now add it
|
||||
addPlotWorld(world, plotWorld, plotManager);
|
||||
PlotHelper.setupBorder(world);
|
||||
MainUtil.setupBorder(world);
|
||||
} else {
|
||||
if (!worlds.contains(world)) {
|
||||
return;
|
||||
|
@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
|
||||
@ -163,7 +163,7 @@ public class Auto extends SubCommand {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(worldname);
|
||||
if (plotworld.TYPE == 2) {
|
||||
final Location loc = BukkitUtil.getLocation(plr);
|
||||
final Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
final Plot plot = MainUtil.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
if (plot == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -182,7 +182,7 @@ public class Auto extends SubCommand {
|
||||
//
|
||||
for (int i = 0; i <= max; i++) {
|
||||
final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
||||
final Plot current = PlotHelper.getPlot(worldname, currentId);
|
||||
final Plot current = MainUtil.getPlot(worldname, currentId);
|
||||
if ((current != null) && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
|
||||
Claim.claimPlot(plr, current, true, true);
|
||||
return true;
|
||||
@ -196,19 +196,19 @@ public class Auto extends SubCommand {
|
||||
boolean br = false;
|
||||
if ((size_x == 1) && (size_z == 1)) {
|
||||
while (!br) {
|
||||
final Plot plot = PlotHelper.getPlot(worldname, getLastPlot(worldname));
|
||||
final Plot plot = MainUtil.getPlot(worldname, getLastPlot(worldname));
|
||||
if ((plot.owner == null)) {
|
||||
Claim.claimPlot(plr, plot, true, true);
|
||||
br = true;
|
||||
}
|
||||
PlotHelper.lastPlot.put(worldname, getNextPlot(getLastPlot(worldname), 1));
|
||||
MainUtil.lastPlot.put(worldname, getNextPlot(getLastPlot(worldname), 1));
|
||||
}
|
||||
} else {
|
||||
boolean lastPlot = true;
|
||||
while (!br) {
|
||||
final PlotId start = getNextPlot(getLastPlot(worldname), 1);
|
||||
// Checking if the current set of plots is a viable option.
|
||||
PlotHelper.lastPlot.put(worldname, start);
|
||||
MainUtil.lastPlot.put(worldname, start);
|
||||
if (lastPlot) {
|
||||
}
|
||||
if ((PlotSquared.getPlots(worldname).get(start) != null) && (PlotSquared.getPlots(worldname).get(start).owner != null)) {
|
||||
@ -217,29 +217,29 @@ public class Auto extends SubCommand {
|
||||
lastPlot = false;
|
||||
}
|
||||
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
||||
if (PlotHelper.isUnowned(worldname, start, end)) {
|
||||
if (MainUtil.isUnowned(worldname, start, end)) {
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
final Plot plot = PlotHelper.getPlot(worldname, new PlotId(i, j));
|
||||
final Plot plot = MainUtil.getPlot(worldname, new PlotId(i, j));
|
||||
final boolean teleport = ((i == end.x) && (j == end.y));
|
||||
Claim.claimPlot(plr, plot, teleport, true);
|
||||
}
|
||||
}
|
||||
if (!PlotHelper.mergePlots(plr, worldname, PlayerFunctions.getPlotSelectionIds(start, end))) {
|
||||
if (!MainUtil.mergePlots(plr, worldname, PlayerFunctions.getPlotSelectionIds(start, end))) {
|
||||
return false;
|
||||
}
|
||||
br = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
PlotHelper.lastPlot.put(worldname, new PlotId(0, 0));
|
||||
MainUtil.lastPlot.put(worldname, new PlotId(0, 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
public PlotId getLastPlot(final String world) {
|
||||
if ((PlotHelper.lastPlot == null) || !PlotHelper.lastPlot.containsKey(world)) {
|
||||
PlotHelper.lastPlot.put(world, new PlotId(0, 0));
|
||||
if ((MainUtil.lastPlot == null) || !MainUtil.lastPlot.containsKey(world)) {
|
||||
MainUtil.lastPlot.put(world, new PlotId(0, 0));
|
||||
}
|
||||
return PlotHelper.lastPlot.get(world);
|
||||
return MainUtil.lastPlot.get(world);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -59,7 +59,7 @@ public class Buy extends SubCommand {
|
||||
try {
|
||||
final String[] split = args[0].split(";");
|
||||
final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
plot = PlotHelper.getPlot(world, id);
|
||||
plot = MainUtil.getPlot(world, id);
|
||||
} catch (final Exception e) {
|
||||
return sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
|
||||
@ -55,8 +55,8 @@ public class Claim extends SubCommand {
|
||||
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
PlotHelper.createPlot(player, plot);
|
||||
PlotHelper.setSign(player, plot);
|
||||
MainUtil.createPlot(player, plot);
|
||||
MainUtil.setSign(player, plot);
|
||||
PlayerFunctions.sendMessage(player, C.CLAIMED);
|
||||
if (teleport) {
|
||||
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
||||
@ -77,7 +77,7 @@ public class Claim extends SubCommand {
|
||||
SchematicHandler.paste(BukkitUtil.getLocation(entity), sch, plot2, 0, 0);
|
||||
}
|
||||
PlotSquared.getPlotManager(plot.world).claimPlot(world, plotworld, plot);
|
||||
PlotHelper.update(BukkitUtil.getLocation(entity));
|
||||
MainUtil.update(BukkitUtil.getLocation(entity));
|
||||
}
|
||||
return event.isCancelled();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -52,7 +52,7 @@ public class Clear extends SubCommand {
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
PlotSquared.log("Invalid plot world: " + world);
|
||||
} else {
|
||||
final Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id);
|
||||
final Plot plot = MainUtil.getPlot(Bukkit.getWorld(world), id);
|
||||
if (plot == null) {
|
||||
PlotSquared.log("Could not find plot " + args[0] + " in world " + world);
|
||||
} else {
|
||||
|
@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.object.PlotClusterId;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -100,8 +100,8 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
// check pos1 / pos2
|
||||
final PlotId pos1 = PlotHelper.parseId(args[2]);
|
||||
final PlotId pos2 = PlotHelper.parseId(args[3]);
|
||||
final PlotId pos1 = MainUtil.parseId(args[2]);
|
||||
final PlotId pos2 = MainUtil.parseId(args[3]);
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
@ -219,8 +219,8 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
// check pos1 / pos2
|
||||
final PlotId pos1 = PlotHelper.parseId(args[1]);
|
||||
final PlotId pos2 = PlotHelper.parseId(args[2]);
|
||||
final PlotId pos1 = MainUtil.parseId(args[1]);
|
||||
final PlotId pos2 = MainUtil.parseId(args[2]);
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
|
@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
|
||||
public class Condense extends SubCommand {
|
||||
@ -91,13 +91,13 @@ public class Condense extends SubCommand {
|
||||
final List<PlotId> free = new ArrayList<>();
|
||||
PlotId start = new PlotId(0, 0);
|
||||
while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) {
|
||||
final Plot plot = PlotHelper.getPlot(world, start);
|
||||
final Plot plot = MainUtil.getPlot(world, start);
|
||||
if (!plot.hasOwner()) {
|
||||
free.add(plot.id);
|
||||
}
|
||||
start = Auto.getNextPlot(start, 1);
|
||||
}
|
||||
PlotHelper.move(world, to_move.get(0), free.get(0), new Runnable() {
|
||||
MainUtil.move(world, to_move.get(0), free.get(0), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!TASK) {
|
||||
@ -108,7 +108,7 @@ public class Condense extends SubCommand {
|
||||
free.remove(0);
|
||||
int index = 0;
|
||||
for (final PlotId id : to_move) {
|
||||
final Plot plot = PlotHelper.getPlot(world, id);
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
if (plot.hasOwner()) {
|
||||
break;
|
||||
}
|
||||
@ -119,7 +119,7 @@ public class Condense extends SubCommand {
|
||||
}
|
||||
index = 0;
|
||||
for (final PlotId id : free) {
|
||||
final Plot plot = PlotHelper.getPlot(world, id);
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
if (!plot.hasOwner()) {
|
||||
break;
|
||||
}
|
||||
@ -139,7 +139,7 @@ public class Condense extends SubCommand {
|
||||
return;
|
||||
}
|
||||
sendMessage("MOVING " + to_move.get(0) + " to " + free.get(0));
|
||||
PlotHelper.move(world, to_move.get(0), free.get(0), this);
|
||||
MainUtil.move(world, to_move.get(0), free.get(0), this);
|
||||
}
|
||||
});
|
||||
TASK = true;
|
||||
|
@ -25,7 +25,7 @@ import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.BukkitMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -50,7 +50,7 @@ public class Copy extends SubCommand {
|
||||
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
return false;
|
||||
}
|
||||
final int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
|
||||
final int size = (MainUtil.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - MainUtil.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
|
||||
final PlotSelection selection = new PlotSelection(size, plr.getWorld(), plot);
|
||||
if (PlotSelection.currentSelection.containsKey(plr.getName())) {
|
||||
PlotSelection.currentSelection.remove(plr.getName());
|
||||
|
@ -27,7 +27,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
|
||||
public class CreateRoadSchematic extends SubCommand {
|
||||
@ -47,7 +47,7 @@ public class CreateRoadSchematic extends SubCommand {
|
||||
final Plot plot = PlayerFunctions.getCurrentPlot(player);
|
||||
final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
|
||||
manager.setupRoadSchematic(plot);
|
||||
PlotHelper.update(BukkitUtil.getLocation(entity));
|
||||
MainUtil.update(BukkitUtil.getLocation(entity));
|
||||
PlayerFunctions.sendMessage(player, "&6Saved new road schematic");
|
||||
return true;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.util.Lag;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.RUtils;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
|
||||
@ -71,10 +71,10 @@ public class Debug extends SubCommand {
|
||||
// PlotHelper.getWorldFolderSize() + "MB"));
|
||||
for (final String worldname : PlotSquared.getPlotWorlds()) {
|
||||
final World world = Bukkit.getWorld(worldname);
|
||||
information.append(getLine(line, "World: " + world.getName() + " size", PlotHelper.getWorldFolderSize(world)));
|
||||
information.append(getLine(line, " - Entities", PlotHelper.getEntities(world)));
|
||||
information.append(getLine(line, " - Loaded Tile Entities", PlotHelper.getTileEntities(world)));
|
||||
information.append(getLine(line, " - Loaded Chunks", PlotHelper.getLoadedChunks(world)));
|
||||
information.append(getLine(line, "World: " + world.getName() + " size", MainUtil.getWorldFolderSize(world)));
|
||||
information.append(getLine(line, " - Entities", MainUtil.getEntities(world)));
|
||||
information.append(getLine(line, " - Loaded Tile Entities", MainUtil.getTileEntities(world)));
|
||||
information.append(getLine(line, " - Loaded Chunks", MainUtil.getLoadedChunks(world)));
|
||||
}
|
||||
information.append(getSection(section, "RAM"));
|
||||
information.append(getLine(line, "Free Ram", RUtils.getFreeRam() + "MB"));
|
||||
|
@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -62,8 +62,8 @@ public class DebugClaimTest extends SubCommand {
|
||||
final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, true);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
PlotHelper.createPlot(player, plot);
|
||||
PlotHelper.setSign(player, plot);
|
||||
MainUtil.createPlot(player, plot);
|
||||
MainUtil.setSign(player, plot);
|
||||
PlayerFunctions.sendMessage(player, C.CLAIMED);
|
||||
if (teleport) {
|
||||
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
||||
@ -97,7 +97,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final ArrayList<Plot> plots = new ArrayList<>();
|
||||
for (final PlotId id : PlayerFunctions.getPlotSelectionIds(min, max)) {
|
||||
final Plot plot = PlotHelper.getPlot(world, id);
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id);
|
||||
if (contains) {
|
||||
PlayerFunctions.sendMessage(null, " - &cDB Already contains: " + plot.id);
|
||||
|
@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
@ -56,22 +56,22 @@ public class DebugClear extends SubCommand {
|
||||
if (!PlotSquared.isPlotWorld(world) || !(PlotSquared.getPlotWorld(world) instanceof SquarePlotWorld)) {
|
||||
PlotSquared.log("Invalid plot world: " + world);
|
||||
} else {
|
||||
final Plot plot = PlotHelper.getPlot(Bukkit.getWorld(world), id);
|
||||
final Plot plot = MainUtil.getPlot(Bukkit.getWorld(world), id);
|
||||
if (plot == null) {
|
||||
PlotSquared.log("Could not find plot " + args[0] + " in world " + world);
|
||||
} else {
|
||||
final World bukkitWorld = Bukkit.getWorld(world);
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id);
|
||||
if (PlotHelper.runners.containsKey(plot)) {
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id);
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
PlotHelper.runners.put(plot, 1);
|
||||
MainUtil.runners.put(plot, 1);
|
||||
ChunkManager.regenerateRegion(pos1, pos2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.runners.remove(plot);
|
||||
MainUtil.runners.remove(plot);
|
||||
PlotSquared.log("Plot " + plot.getId().toString() + " cleared.");
|
||||
PlotSquared.log("&aDone!");
|
||||
}
|
||||
@ -94,17 +94,17 @@ public class DebugClear extends SubCommand {
|
||||
}
|
||||
assert plot != null;
|
||||
final World bukkitWorld = plr.getWorld();
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(bukkitWorld, plot.id);
|
||||
if (PlotHelper.runners.containsKey(plot)) {
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(bukkitWorld, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(bukkitWorld, plot.id);
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
PlotHelper.runners.put(plot, 1);
|
||||
MainUtil.runners.put(plot, 1);
|
||||
ChunkManager.regenerateRegion(pos1, pos2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.runners.remove(plot);
|
||||
MainUtil.runners.remove(plot);
|
||||
PlayerFunctions.sendMessage(plr, "&aDone!");
|
||||
}
|
||||
});
|
||||
|
@ -38,7 +38,7 @@ import com.intellectualcrafters.plot.object.InfoInventory;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -79,7 +79,7 @@ public class Info extends SubCommand {
|
||||
try {
|
||||
final String[] split = args[1].split(";");
|
||||
final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
plot = PlotHelper.getPlot(Bukkit.getWorld(plotworld.worldname), id);
|
||||
plot = MainUtil.getPlot(Bukkit.getWorld(plotworld.worldname), id);
|
||||
if (plot == null) {
|
||||
PlayerFunctions.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
@ -227,7 +227,7 @@ public class Info extends SubCommand {
|
||||
|
||||
private Biome getBiomeAt(final Plot plot) {
|
||||
final World w = Bukkit.getWorld(plot.world);
|
||||
final Location bl = PlotHelper.getPlotTopLoc(w, plot.id);
|
||||
final Location bl = MainUtil.getPlotTopLoc(w, plot.id);
|
||||
return bl.getBlock().getBiome();
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -128,10 +128,10 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
final PlotId botId = plots.get(0);
|
||||
final PlotId topId = plots.get(plots.size() - 1);
|
||||
final PlotId bot1 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, botId)).id;
|
||||
final PlotId bot2 = PlayerFunctions.getBottomPlot(world, PlotHelper.getPlot(world, topId)).id;
|
||||
final PlotId top1 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, topId)).id;
|
||||
final PlotId top2 = PlayerFunctions.getTopPlot(world, PlotHelper.getPlot(world, botId)).id;
|
||||
final PlotId bot1 = PlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, botId)).id;
|
||||
final PlotId bot2 = PlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, topId)).id;
|
||||
final PlotId top1 = PlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, topId)).id;
|
||||
final PlotId top2 = PlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, botId)).id;
|
||||
bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y));
|
||||
top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y));
|
||||
plots = PlayerFunctions.getMaxPlotSelectionIds(world, bot, top);
|
||||
@ -164,9 +164,9 @@ public class Merge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
PlayerFunctions.sendMessage(plr, "&cPlots have been merged");
|
||||
PlotHelper.mergePlots(world, plots, true);
|
||||
PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot);
|
||||
PlotHelper.update(plr.getLocation());
|
||||
MainUtil.mergePlots(world, plots, true);
|
||||
MainUtil.setSign(world, UUIDHandler.getName(plot.owner), plot);
|
||||
MainUtil.update(plr.getLocation());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
|
||||
/**
|
||||
@ -47,8 +47,8 @@ public class Move extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final World world = plr.getWorld();
|
||||
final PlotId plot1 = PlotHelper.parseId(args[0]);
|
||||
final PlotId plot2 = PlotHelper.parseId(args[1]);
|
||||
final PlotId plot1 = MainUtil.parseId(args[0]);
|
||||
final PlotId plot2 = MainUtil.parseId(args[1]);
|
||||
if ((plot1 == null) || (plot2 == null)) {
|
||||
PlayerFunctions.sendMessage(plr, "INVALID PLOT ID\n/plot move <pos1> <pos2>");
|
||||
return false;
|
||||
@ -57,7 +57,7 @@ public class Move extends SubCommand {
|
||||
PlayerFunctions.sendMessage(plr, "DUPLICATE ID");
|
||||
return false;
|
||||
}
|
||||
if (PlotHelper.move(world, plot1, plot2, new Runnable() {
|
||||
if (MainUtil.move(world, plot1, plot2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlayerFunctions.sendMessage(plr, "MOVE SUCCESS");
|
||||
|
@ -25,7 +25,7 @@ import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.BukkitMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -50,7 +50,7 @@ public class Paste extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
assert plot != null;
|
||||
final int size = (PlotHelper.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - PlotHelper.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
|
||||
final int size = (MainUtil.getPlotTopLocAbs(plr.getWorld(), plot.getId()).getBlockX() - MainUtil.getPlotBottomLocAbs(plr.getWorld(), plot.getId()).getBlockX());
|
||||
if (PlotSelection.currentSelection.containsKey(plr.getName())) {
|
||||
final PlotSelection selection = PlotSelection.currentSelection.get(plr.getName());
|
||||
if (size != selection.getWidth()) {
|
||||
|
@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.DataCollection;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
||||
@ -101,8 +101,8 @@ public class Schematic extends SubCommand {
|
||||
final int z;
|
||||
final Plot plot2 = PlayerFunctions.getCurrentPlot(plr);
|
||||
final Dimension dem = schematic.getSchematicDimension();
|
||||
final Location bot = PlotHelper.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1);
|
||||
final int length2 = PlotHelper.getPlotWidth(plr.getWorld(), plot2.id);
|
||||
final Location bot = MainUtil.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1);
|
||||
final int length2 = MainUtil.getPlotWidth(plr.getWorld(), plot2.id);
|
||||
if ((dem.getX() > length2) || (dem.getZ() > length2)) {
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", dem.getX(), dem.getZ(), length2));
|
||||
Schematic.this.running = false;
|
||||
@ -131,7 +131,7 @@ public class Schematic extends SubCommand {
|
||||
final int start = Schematic.this.counter * 5000;
|
||||
if (start > blen) {
|
||||
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
PlotHelper.update(plr.getLocation());
|
||||
MainUtil.update(plr.getLocation());
|
||||
Schematic.this.running = false;
|
||||
Bukkit.getScheduler().cancelTask(Schematic.this.task);
|
||||
return;
|
||||
@ -167,7 +167,7 @@ public class Schematic extends SubCommand {
|
||||
final int l1 = schematic.getSchematicDimension().getX();
|
||||
final int l2 = schematic.getSchematicDimension().getZ();
|
||||
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
final int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id);
|
||||
final int length = MainUtil.getPlotWidth(plr.getWorld(), plot.id);
|
||||
if ((l1 < length) || (l2 < length)) {
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
||||
break;
|
||||
|
@ -46,7 +46,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
@ -177,7 +177,7 @@ public class Set extends SubCommand {
|
||||
}
|
||||
//set to current location
|
||||
final World world = plr.getWorld();
|
||||
final Location base = PlotHelper.getPlotBottomLoc(world, plot.id);
|
||||
final Location base = MainUtil.getPlotBottomLoc(world, plot.id);
|
||||
base.setY(0);
|
||||
final Location relative = plr.getLocation().subtract(base);
|
||||
final BlockLoc blockloc = new BlockLoc(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ());
|
||||
@ -231,7 +231,7 @@ public class Set extends SubCommand {
|
||||
PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values())));
|
||||
return true;
|
||||
}
|
||||
PlotHelper.setBiome(plr.getWorld(), plot, biome);
|
||||
MainUtil.setBiome(plr.getWorld(), plot, biome);
|
||||
PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase());
|
||||
return true;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -83,7 +83,7 @@ public class SetOwner extends SubCommand {
|
||||
PlotSquared.worldGuardListener.changeOwner(plr, current.owner, plr.getWorld(), current);
|
||||
}
|
||||
}
|
||||
PlotHelper.setSign(world, args[0], plot);
|
||||
MainUtil.setSign(world, args[0], plot);
|
||||
PlayerFunctions.sendMessage(plr, C.SET_OWNER);
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -86,10 +86,10 @@ public class Swap extends SubCommand {
|
||||
}
|
||||
PlotSelection.swap(world, plot.id, plotid);
|
||||
// TODO Requires testing!!
|
||||
DBFunc.dbManager.swapPlots(plot, PlotHelper.getPlot(world, plotid));
|
||||
DBFunc.dbManager.swapPlots(plot, MainUtil.getPlot(world, plotid));
|
||||
// TODO Requires testing!!
|
||||
PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS);
|
||||
PlotHelper.update(plr.getLocation());
|
||||
MainUtil.update(plr.getLocation());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
|
||||
/**
|
||||
@ -65,7 +65,7 @@ public class TP extends SubCommand {
|
||||
}
|
||||
try {
|
||||
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
|
||||
PlotSquared.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid));
|
||||
PlotSquared.teleportPlayer(plr, plr.getLocation(), MainUtil.getPlot(world, plotid));
|
||||
return true;
|
||||
} catch (final Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
|
@ -26,7 +26,7 @@ import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
|
||||
public class Target extends SubCommand {
|
||||
@ -41,12 +41,12 @@ public class Target extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
final PlotId id = PlotHelper.parseId(args[1]);
|
||||
final PlotId id = MainUtil.parseId(args[1]);
|
||||
if (id == null) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
}
|
||||
final Location loc = PlotHelper.getPlotHome(plr.getWorld(), id);
|
||||
final Location loc = MainUtil.getPlotHome(plr.getWorld(), id);
|
||||
plr.setCompassTarget(loc);
|
||||
PlayerFunctions.sendMessage(plr, C.COMPASS_TARGET);
|
||||
return true;
|
||||
|
@ -38,7 +38,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
@ -190,8 +190,8 @@ public class Trim extends SubCommand {
|
||||
}
|
||||
final Plot plot = plots.get(0);
|
||||
plots.remove(0);
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
final Location pos3 = new Location(world, pos1.getBlockX(), 64, pos2.getBlockZ());
|
||||
final Location pos4 = new Location(world, pos2.getBlockX(), 64, pos1.getBlockZ());
|
||||
chunks.remove(ChunkManager.getChunkChunk(pos1));
|
||||
|
@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -67,7 +67,7 @@ public class Unlink extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
PlotHelper.update(plr.getLocation());
|
||||
MainUtil.update(plr.getLocation());
|
||||
} catch (final Exception e) {
|
||||
// execute(final Player plr, final String... args) {
|
||||
try {
|
||||
@ -112,7 +112,7 @@ public class Unlink extends SubCommand {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final boolean lx = x < pos2.x;
|
||||
final boolean ly = y < pos2.y;
|
||||
final Plot p = PlotHelper.getPlot(world, new PlotId(x, y));
|
||||
final Plot p = MainUtil.getPlot(world, new PlotId(x, y));
|
||||
if (lx) {
|
||||
manager.createRoadEast(plotworld, p);
|
||||
if (ly) {
|
||||
@ -122,16 +122,16 @@ public class Unlink extends SubCommand {
|
||||
if (ly) {
|
||||
manager.createRoadSouth(plotworld, p);
|
||||
}
|
||||
PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot);
|
||||
MainUtil.setSign(world, UUIDHandler.getName(plot.owner), plot);
|
||||
}
|
||||
}
|
||||
manager.finishPlotUnlink(world, plotworld, ids);
|
||||
for (final PlotId id : ids) {
|
||||
final Plot myPlot = PlotHelper.getPlot(world, id);
|
||||
final Plot myPlot = MainUtil.getPlot(world, id);
|
||||
if (plot.hasOwner()) {
|
||||
final String name = UUIDHandler.getName(myPlot.owner);
|
||||
if (name != null) {
|
||||
PlotHelper.setSign(world, name, myPlot);
|
||||
MainUtil.setSign(world, name, myPlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.AChunkManager;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.SetBlockManager;
|
||||
|
@ -10,7 +10,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
/**
|
||||
* A plot manager with square plots which tesselate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot)
|
||||
@ -37,9 +37,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
|
||||
public boolean setFloor(final World world, final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid);
|
||||
PlotHelper.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), blocks);
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, plotid);
|
||||
MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), blocks);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -48,31 +48,31 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
final Location bottom = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid);
|
||||
final Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||
final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid);
|
||||
final Location top = MainUtil.getPlotTopLoc(w, plotid);
|
||||
int x, z;
|
||||
z = bottom.getBlockZ();
|
||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
PlotHelper.setBlock(w, x, y, z, blocks);
|
||||
MainUtil.setBlock(w, x, y, z, blocks);
|
||||
}
|
||||
}
|
||||
x = top.getBlockX() + 1;
|
||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
PlotHelper.setBlock(w, x, y, z, blocks);
|
||||
MainUtil.setBlock(w, x, y, z, blocks);
|
||||
}
|
||||
}
|
||||
z = top.getBlockZ() + 1;
|
||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
PlotHelper.setBlock(w, x, y, z, blocks);
|
||||
MainUtil.setBlock(w, x, y, z, blocks);
|
||||
}
|
||||
}
|
||||
x = bottom.getBlockX();
|
||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
PlotHelper.setBlock(w, x, y, z, blocks);
|
||||
MainUtil.setBlock(w, x, y, z, blocks);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -83,24 +83,24 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
final Location bottom = PlotHelper.getPlotBottomLoc(plotworld.worldname, plotid);
|
||||
final Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||
final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid);
|
||||
final Location top = MainUtil.getPlotTopLoc(w, plotid);
|
||||
int x, z;
|
||||
z = bottom.getBlockZ();
|
||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
x = top.getBlockX() + 1;
|
||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
z = top.getBlockZ() + 1;
|
||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
x = bottom.getBlockX();
|
||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
||||
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
MainUtil.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, blocks);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -118,13 +118,13 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos1.getBlockZ() - 1;
|
||||
final int ez = pos2.getBlockZ() + 2;
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK);
|
||||
PlotHelper.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(w, new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK);
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
||||
MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
||||
MainUtil.setCuboid(w, new Location(w, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK);
|
||||
MainUtil.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
||||
MainUtil.setCuboid(w, new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK);
|
||||
MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -138,13 +138,13 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int sx = pos1.getBlockX() - 1;
|
||||
final int ex = pos2.getBlockX() + 2;
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK);
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING);
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK);
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
||||
MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz), new Location(w, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
|
||||
MainUtil.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK);
|
||||
MainUtil.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING);
|
||||
MainUtil.setCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK);
|
||||
MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -157,9 +157,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos2.getBlockZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
||||
MainUtil.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboid(w, new Location(w, sx + 1, 0, sz + 1), new Location(w, ex, 1, ez), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -173,9 +173,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = pos1.getBlockZ();
|
||||
final int ez = pos2.getBlockZ() + 1;
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK);
|
||||
MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -189,9 +189,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int sx = pos1.getBlockX();
|
||||
final int ex = pos2.getBlockX() + 1;
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK);
|
||||
MainUtil.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -204,9 +204,9 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int sz = loc.getBlockZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
PlotHelper.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK);
|
||||
PlotHelper.setCuboid(world, new Location(world, sx + 1, dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK);
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboid(world, new Location(world, sx + 1, dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
||||
@Override
|
||||
public com.intellectualcrafters.plot.object.Location getSignLoc(final PlotWorld plotworld, final Plot plot) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location bot = PlotHelper.getPlotBottomLoc(plotworld.worldname, plot.id);
|
||||
final Location bot = MainUtil.getPlotBottomLoc(plotworld.worldname, plot.id);
|
||||
return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getBlockX(), dpw.ROAD_HEIGHT + 1, bot.getBlockZ() - 1);
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
||||
@ -54,8 +54,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
|
||||
public static boolean checkModified(final Plot plot, int requiredChanges) {
|
||||
final World world = Bukkit.getWorld(plot.world);
|
||||
final Location bottom = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final Location top = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||
final Location bottom = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final Location top = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
final int botx = bottom.getBlockX();
|
||||
final int botz = bottom.getBlockZ();
|
||||
final int topx = top.getBlockX();
|
||||
@ -109,8 +109,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
|
||||
public boolean setupRoadSchematic(final Plot plot) {
|
||||
final World world = Bukkit.getWorld(plot.world);
|
||||
final Location bot = PlotHelper.getPlotBottomLoc(world, plot.id);
|
||||
final Location top = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||
final Location bot = MainUtil.getPlotBottomLoc(world, plot.id);
|
||||
final Location top = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
final HybridPlotWorld plotworld = (HybridPlotWorld) PlotSquared.getPlotWorld(world);
|
||||
final int sx = (bot.getBlockX() - plotworld.ROAD_WIDTH) + 1;
|
||||
final int sz = bot.getBlockZ() + 1;
|
||||
@ -231,13 +231,13 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
chunk.load(false);
|
||||
}
|
||||
if (id1 != null) {
|
||||
final Plot p1 = PlotHelper.getPlot(world, id1);
|
||||
final Plot p1 = MainUtil.getPlot(world, id1);
|
||||
if ((p1 != null) && p1.hasOwner() && p1.settings.isMerged()) {
|
||||
toCheck = true;
|
||||
}
|
||||
}
|
||||
if ((id2 != null) && !toCheck) {
|
||||
final Plot p2 = PlotHelper.getPlot(world, id2);
|
||||
final Plot p2 = MainUtil.getPlot(world, id2);
|
||||
if ((p2 != null) && p2.hasOwner() && p2.settings.isMerged()) {
|
||||
toCheck = true;
|
||||
}
|
||||
@ -269,13 +269,13 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
final ChunkLoc loc = new ChunkLoc(absX, absZ);
|
||||
final HashMap<Short, Short> blocks = plotworld.G_SCH.get(loc);
|
||||
for (short y = (short) (plotworld.ROAD_HEIGHT + 1); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT); y++) {
|
||||
PlotHelper.setBlock(world, x + X, sy + y, z + Z, 0, (byte) 0);
|
||||
MainUtil.setBlock(world, x + X, sy + y, z + Z, 0, (byte) 0);
|
||||
}
|
||||
if (blocks != null) {
|
||||
final HashMap<Short, Byte> datas = plotworld.G_SCH_DATA.get(loc);
|
||||
if (datas == null) {
|
||||
for (final Short y : blocks.keySet()) {
|
||||
PlotHelper.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), (byte) 0);
|
||||
MainUtil.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), (byte) 0);
|
||||
}
|
||||
} else {
|
||||
for (final Short y : blocks.keySet()) {
|
||||
@ -283,7 +283,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
if (data == null) {
|
||||
data = 0;
|
||||
}
|
||||
PlotHelper.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), data);
|
||||
MainUtil.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -310,7 +310,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
final HashMap<Short, Byte> datas = hpw.G_SCH_DATA.get(loc);
|
||||
if (datas == null) {
|
||||
for (final Short y : blocks.keySet()) {
|
||||
PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), (byte) 0);
|
||||
MainUtil.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), (byte) 0);
|
||||
}
|
||||
} else {
|
||||
for (final Short y : blocks.keySet()) {
|
||||
@ -318,7 +318,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
if (data == null) {
|
||||
data = 0;
|
||||
}
|
||||
PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), data);
|
||||
MainUtil.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -328,11 +328,11 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
if (block.id != 0) {
|
||||
for (final PlotId id : plotIds) {
|
||||
setWall(world, plotworld, id, new PlotBlock[] { ((ClassicPlotWorld) plotworld).WALL_BLOCK });
|
||||
final Plot plot = PlotHelper.getPlot(world, id);
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
if (plot.hasOwner()) {
|
||||
final String name = UUIDHandler.getName(plot.owner);
|
||||
if (name != null) {
|
||||
PlotHelper.setSign(world, name, plot);
|
||||
MainUtil.setSign(world, name, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -348,17 +348,17 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
*/
|
||||
@Override
|
||||
public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
||||
PlotHelper.runners.put(plot, 1);
|
||||
MainUtil.runners.put(plot, 1);
|
||||
final Plugin plugin = PlotSquared.getMain();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.runners.remove(plot);
|
||||
MainUtil.runners.remove(plot);
|
||||
}
|
||||
}, 90L);
|
||||
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
|
||||
final Location pos1 = PlotHelper.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLocAbs(world, plot.id);
|
||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id);
|
||||
final PlotBlock[] plotfloor = dpw.TOP_BLOCK;
|
||||
final PlotBlock[] filling = dpw.MAIN_BLOCK;
|
||||
// PlotBlock wall = dpw.WALL_BLOCK;
|
||||
@ -384,19 +384,19 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
@Override
|
||||
public void run() {
|
||||
if ((pos2.getBlockX() - pos1.getBlockX()) < 48) {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling);
|
||||
MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor);
|
||||
MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor);
|
||||
}
|
||||
}, 5L);
|
||||
}
|
||||
@ -409,8 +409,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
final int startZ = (pos1.getBlockZ() / 16) * 16;
|
||||
final int chunkX = 16 + pos2.getBlockX();
|
||||
final int chunkZ = 16 + pos2.getBlockZ();
|
||||
final Location l1 = PlotHelper.getPlotBottomLoc(world, plot.id);
|
||||
final Location l2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||
final Location l1 = MainUtil.getPlotBottomLoc(world, plot.id);
|
||||
final Location l2 = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
final int plotMinX = l1.getBlockX() + 1;
|
||||
final int plotMinZ = l1.getBlockZ() + 1;
|
||||
final int plotMaxX = l2.getBlockX();
|
||||
@ -419,23 +419,23 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Location mx = null;
|
||||
for (int i = startX; i < chunkX; i += 16) {
|
||||
for (int j = startZ; j < chunkZ; j += 16) {
|
||||
final Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j));
|
||||
final Plot plot1 = MainUtil.getCurrentPlot(new Location(world, i, 0, j));
|
||||
if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) {
|
||||
break;
|
||||
}
|
||||
final Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j));
|
||||
final Plot plot2 = MainUtil.getCurrentPlot(new Location(world, i + 15, 0, j));
|
||||
if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) {
|
||||
break;
|
||||
}
|
||||
final Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
||||
final Plot plot3 = MainUtil.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
||||
if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) {
|
||||
break;
|
||||
}
|
||||
final Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15));
|
||||
final Plot plot4 = MainUtil.getCurrentPlot(new Location(world, i, 0, j + 15));
|
||||
if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) {
|
||||
break;
|
||||
}
|
||||
final Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
||||
final Plot plot5 = MainUtil.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
||||
if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) {
|
||||
break;
|
||||
}
|
||||
@ -451,19 +451,19 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
final Location max = mx;
|
||||
final Location min = mn;
|
||||
if (min == null) {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling);
|
||||
MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor);
|
||||
MainUtil.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor);
|
||||
}
|
||||
}, 5L);
|
||||
}
|
||||
@ -487,19 +487,19 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling);
|
||||
MainUtil.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor);
|
||||
MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
@ -511,19 +511,19 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
|
||||
MainUtil.setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor);
|
||||
MainUtil.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
@ -535,19 +535,19 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
|
||||
MainUtil.setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor);
|
||||
MainUtil.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
@ -559,19 +559,19 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
|
||||
MainUtil.setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor);
|
||||
MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
@ -583,19 +583,19 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||
MainUtil.setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||
MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
@ -607,19 +607,19 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||
MainUtil.setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||
MainUtil.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
@ -631,19 +631,19 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
|
||||
MainUtil.setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor);
|
||||
MainUtil.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
@ -655,19 +655,19 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||
MainUtil.setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||
MainUtil.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
}, 1L);
|
||||
|
@ -10,7 +10,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
|
||||
@ -20,8 +20,8 @@ import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
public abstract class SquarePlotManager extends GridPlotManager {
|
||||
@Override
|
||||
public boolean clearPlot(final World world, final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whendone) {
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
ChunkManager.regenerateRegion(pos1, pos2, whendone);
|
||||
return true;
|
||||
}
|
||||
@ -170,11 +170,11 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
*/
|
||||
@Override
|
||||
public boolean setBiome(final World world, final Plot plot, final Biome biome) {
|
||||
final int bottomX = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX() - 1;
|
||||
final int topX = PlotHelper.getPlotTopLoc(world, plot.id).getBlockX() + 1;
|
||||
final int bottomZ = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1;
|
||||
final int topZ = PlotHelper.getPlotTopLoc(world, plot.id).getBlockZ() + 1;
|
||||
final Block block = world.getBlockAt(PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 1, 1));
|
||||
final int bottomX = MainUtil.getPlotBottomLoc(world, plot.id).getBlockX() - 1;
|
||||
final int topX = MainUtil.getPlotTopLoc(world, plot.id).getBlockX() + 1;
|
||||
final int bottomZ = MainUtil.getPlotBottomLoc(world, plot.id).getBlockZ() - 1;
|
||||
final int topZ = MainUtil.getPlotTopLoc(world, plot.id).getBlockZ() + 1;
|
||||
final Block block = world.getBlockAt(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 1, 1));
|
||||
final Biome current = block.getBiome();
|
||||
if (biome.equals(current)) {
|
||||
return false;
|
||||
|
@ -99,7 +99,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
@ -127,8 +127,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
public static void onChunkLoad(final ChunkLoadEvent event) {
|
||||
final String worldname = event.getWorld().getName();
|
||||
final Chunk chunk = event.getChunk();
|
||||
if (PlotHelper.worldBorder.containsKey(worldname)) {
|
||||
final int border = PlotHelper.getBorder(worldname);
|
||||
if (MainUtil.worldBorder.containsKey(worldname)) {
|
||||
final int border = MainUtil.getBorder(worldname);
|
||||
final int x = Math.abs(chunk.getX() << 4);
|
||||
final int z = Math.abs(chunk.getZ() << 4);
|
||||
if ((x > border) || (z > border)) {
|
||||
@ -148,12 +148,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
final UUID uuid = UUIDHandler.getUUID(player);
|
||||
UUIDHandler.add(name, uuid);
|
||||
final Location loc = BukkitUtil.getLocation(player.getLocation());
|
||||
final Plot plot = PlotHelper.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (Settings.TELEPORT_ON_LOGIN) {
|
||||
BukkitUtil.teleportPlayer(player, PlotHelper.getPlotHomeDefault(plot));
|
||||
BukkitUtil.teleportPlayer(player, MainUtil.getPlotHomeDefault(plot));
|
||||
PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD);
|
||||
}
|
||||
plotEntry(player, plot);
|
||||
@ -172,8 +172,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
if (!isPlotWorld(worldname)) {
|
||||
return;
|
||||
}
|
||||
if (PlotHelper.worldBorder.containsKey(worldname)) {
|
||||
final int border = PlotHelper.getBorder(worldname);
|
||||
if (MainUtil.worldBorder.containsKey(worldname)) {
|
||||
final int border = MainUtil.getBorder(worldname);
|
||||
boolean passed = true;
|
||||
if (t.getX() > border) {
|
||||
event.getTo().setX(border);
|
||||
@ -585,6 +585,28 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public static void onBlockIgnite(final BlockIgniteEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
final Block b = e.getBlock();
|
||||
final Location loc;
|
||||
if (b != null) {
|
||||
loc = BukkitUtil.getLocation(b.getLocation());
|
||||
}
|
||||
else {
|
||||
Entity ent = e.getIgnitingEntity();
|
||||
if (ent != null) {
|
||||
loc = BukkitUtil.getLocation(ent);
|
||||
}
|
||||
else {
|
||||
if (player != null) {
|
||||
loc = BukkitUtil.getLocation(player);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final String world;
|
||||
if (e.getBlock() != null) {
|
||||
world = e.getBlock().getWorld().getName();
|
||||
@ -602,10 +624,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
final Block b = e.getBlock();
|
||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (b != null) {
|
||||
if (e.getPlayer() != null) {
|
||||
Player player = e.getPlayer();
|
||||
if (player == null) {
|
||||
if (isPlotArea(loc)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
final Player p = e.getPlayer();
|
||||
if (!isInPlot(loc)) {
|
||||
if (!BukkitMain.hasPermission(p, "plots.admin.build.road")) {
|
||||
@ -623,8 +648,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
} else {
|
||||
UUID uuid = UUIDHandler.getUUID(p);
|
||||
if (!plot.isAdded(uuid))
|
||||
if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) {
|
||||
if (!plot.isAdded(uuid)) if (!BukkitMain.hasPermission(p, "plots.admin.build.other")) {
|
||||
if (isPlotArea(loc)) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.build.other");
|
||||
e.setCancelled(true);
|
||||
@ -634,13 +658,6 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isPlotArea(loc)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public static void onTeleport(final PlayerTeleportEvent event) {
|
||||
@ -650,7 +667,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
if (isPlotWorld(q)) {
|
||||
if (isInPlot(q)) {
|
||||
final Plot plot = getCurrentPlot(q);
|
||||
if (plot.deny_entry(event.getPlayer())) {
|
||||
|
||||
if (plot.isDenied(event.getPlayer())) {
|
||||
PlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -12,7 +12,7 @@ import com.intellectualcrafters.plot.BukkitMain;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
@ -29,7 +29,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
final Plot plot = PlotHelper.getPlot(l);
|
||||
final Plot plot = MainUtil.getPlot(l);
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
if (!BukkitMain.hasPermission(p, "plots.admin.interact.unowned")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION, "plots.admin.interact.unowned");
|
||||
|
@ -43,7 +43,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
/**
|
||||
@ -70,7 +70,7 @@ public class PlotListener {
|
||||
}
|
||||
|
||||
public static boolean isInPlot(final String world, final int x, final int y, final int z) {
|
||||
return (PlotHelper.getPlot(new Location(world, x, y, z)) != null);
|
||||
return (MainUtil.getPlot(new Location(world, x, y, z)) != null);
|
||||
}
|
||||
|
||||
public static boolean isPlotWorld(final String world) {
|
||||
@ -101,14 +101,14 @@ public class PlotListener {
|
||||
}
|
||||
|
||||
public static boolean enteredPlot(final Location l1, final Location l2) {
|
||||
final PlotId p1 = PlotHelper.getPlotId(l1);
|
||||
final PlotId p2 = PlotHelper.getPlotId(l2);
|
||||
final PlotId p1 = MainUtil.getPlotId(l1);
|
||||
final PlotId p2 = MainUtil.getPlotId(l2);
|
||||
return (p2 != null) && ((p1 == null) || !p1.equals(p2));
|
||||
}
|
||||
|
||||
public static boolean leftPlot(final Location l1, final Location l2) {
|
||||
final PlotId p1 = PlotHelper.getPlotId(l1);
|
||||
final PlotId p2 = PlotHelper.getPlotId(l2);
|
||||
final PlotId p1 = MainUtil.getPlotId(l1);
|
||||
final PlotId p2 = MainUtil.getPlotId(l2);
|
||||
return (p1 != null) && ((p2 == null) || !p1.equals(p2));
|
||||
}
|
||||
|
||||
@ -121,11 +121,11 @@ public class PlotListener {
|
||||
}
|
||||
|
||||
public static Plot getCurrentPlot(final Location loc) {
|
||||
final PlotId id = PlotHelper.getPlotId(loc);
|
||||
final PlotId id = MainUtil.getPlotId(loc);
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return PlotHelper.getPlot(loc.getWorld(), id);
|
||||
return MainUtil.getPlot(loc.getWorld(), id);
|
||||
}
|
||||
|
||||
private static WeatherType getWeatherType(String str) {
|
||||
|
@ -52,7 +52,7 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
||||
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
@ -106,7 +106,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player));
|
||||
final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player));
|
||||
if (plot == null) {
|
||||
PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return;
|
||||
@ -118,7 +118,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
}
|
||||
final Set<Player> plotPlayers = new HashSet<>();
|
||||
for (final Player p : player.getWorld().getPlayers()) {
|
||||
Plot newPlot = PlotHelper.getPlot(BukkitUtil.getLocation(player));
|
||||
Plot newPlot = MainUtil.getPlot(BukkitUtil.getLocation(player));
|
||||
if (plot.equals(newPlot)) {
|
||||
plotPlayers.add(p);
|
||||
}
|
||||
@ -145,7 +145,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
if (player.getGameMode() != GameMode.SURVIVAL) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player));
|
||||
final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player));
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
@ -160,7 +160,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) event.getEntity();
|
||||
final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player));
|
||||
final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player));
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
@ -172,7 +172,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
@EventHandler
|
||||
public void onItemPickup(final PlayerPickupItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player));
|
||||
final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player));
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
@ -185,7 +185,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
@EventHandler
|
||||
public void onItemDrop(final PlayerDropItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(player));
|
||||
final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player));
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PWE;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
@ -107,7 +107,7 @@ public class WorldEditListener implements Listener {
|
||||
return;
|
||||
}
|
||||
com.intellectualcrafters.plot.object.Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
final Plot plot = PlotHelper.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot != null) {
|
||||
if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) {
|
||||
PWE.setMask(p, loc, false);
|
||||
@ -126,7 +126,7 @@ public class WorldEditListener implements Listener {
|
||||
cmd = cmd.substring(0, cmd.indexOf(" "));
|
||||
}
|
||||
if (this.restrictedcmds.contains(cmd)) {
|
||||
final Plot plot = PlotHelper.getPlot(BukkitUtil.getLocation(p));
|
||||
final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(p));
|
||||
if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@ -198,8 +198,8 @@ public class WorldEditListener implements Listener {
|
||||
com.intellectualcrafters.plot.object.Location locf = BukkitUtil.getLocation(f);
|
||||
com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t);
|
||||
if ((locf.getX() != loct.getX()) || (locf.getZ() != loct.getZ())) {
|
||||
final PlotId idF = PlotHelper.getPlotId(locf);
|
||||
final PlotId idT = PlotHelper.getPlotId(loct);
|
||||
final PlotId idF = MainUtil.getPlotId(locf);
|
||||
final PlotId idT = MainUtil.getPlotId(loct);
|
||||
if ((idT != null) && !(idF == idT)) {
|
||||
PWE.setMask(p, loct, false);
|
||||
}
|
||||
|
@ -0,0 +1,73 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
public class BukkitPlayer implements PlotPlayer {
|
||||
|
||||
public final Player player;
|
||||
UUID uuid;
|
||||
String name;
|
||||
|
||||
public BukkitPlayer(Player player, String name, UUID uuid) {
|
||||
this.player = player;
|
||||
this.name = name;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public BukkitPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return BukkitUtil.getLocation(this.player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
if (this.uuid == null) {
|
||||
this.uuid = UUIDHandler.getUUID(this.player);
|
||||
}
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
this.player.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location loc) {
|
||||
this.player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX(), loc.getY(), loc.getZ()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return this.player.isOp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (this.name == null) {
|
||||
this.name = player.getName();
|
||||
}
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return this.player.isOnline();
|
||||
}
|
||||
|
||||
}
|
@ -10,34 +10,20 @@ import java.util.UUID;
|
||||
*
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public class PlotPlayer {
|
||||
public interface PlotPlayer {
|
||||
public Location getLocation();
|
||||
|
||||
private final String name;
|
||||
private final Location location;
|
||||
public UUID getUUID();
|
||||
|
||||
public PlotPlayer(final String name, final Location location) {
|
||||
this.name = name;
|
||||
this.location = location;
|
||||
}
|
||||
public boolean hasPermission(final String perm);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
public void sendMessage(final String message);
|
||||
|
||||
public Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
public void teleport(final Location loc);
|
||||
|
||||
public UUID getUUID() {
|
||||
return UUIDHandler.getUUID(name);
|
||||
}
|
||||
public boolean isOp();
|
||||
|
||||
public boolean hasPermission(final String perm) {
|
||||
return BukkitMain.hasPermission(this, perm);
|
||||
}
|
||||
public boolean isOnline();
|
||||
|
||||
public void sendMessage(final String message) {
|
||||
return BukkitMain.sendMessage( final PlotPlayer player);
|
||||
}
|
||||
public String getName();
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.bukkit.block.Biome;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
|
||||
/**
|
||||
@ -107,7 +107,7 @@ public class PlotSettings {
|
||||
* @return biome at plot loc
|
||||
*/
|
||||
public Biome getBiome() {
|
||||
final Location loc = PlotHelper.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1);
|
||||
final Location loc = MainUtil.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1);
|
||||
return BukkitUtil.getBiome(loc);
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
@ -57,11 +58,11 @@ public class ClusterManager {
|
||||
if (home.y == 0) {
|
||||
// default pos
|
||||
final PlotId center = getCenterPlot(cluster);
|
||||
toReturn = PlotHelper.getPlotHome(cluster.world, center);
|
||||
toReturn = MainUtil.getPlotHome(cluster.world, center);
|
||||
if (toReturn.getY() == 0) {
|
||||
final PlotManager manager = PlotSquared.getPlotManager(cluster.world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(cluster.world);
|
||||
final Location loc = manager.getSignLoc(plotworld, PlotHelper.getPlot(cluster.world, center));
|
||||
final Location loc = manager.getSignLoc(plotworld, MainUtil.getPlot(cluster.world, center));
|
||||
toReturn.setY(loc.getY());
|
||||
}
|
||||
} else {
|
||||
@ -261,7 +262,7 @@ public class ClusterManager {
|
||||
ClusterManager.regenerating.remove(cluster.world + ":" + cluster.getName());
|
||||
final Player owner = UUIDHandler.uuidWrapper.getPlayer(cluster.owner);
|
||||
if (owner != null) {
|
||||
PlayerFunctions.sendMessage(owner, C.CLEARING_DONE);
|
||||
MainUtil.sendMessage(new BukkitPlayer(owner), C.CLEARING_DONE);
|
||||
}
|
||||
}
|
||||
}, (interval * chunks.size()) + 20);
|
||||
|
@ -19,6 +19,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
@ -104,7 +105,7 @@ public class ExpireManager {
|
||||
for (final UUID helper : plot.helpers) {
|
||||
final Player player = UUIDHandler.uuidWrapper.getPlayer(helper);
|
||||
if (player != null) {
|
||||
PlayerFunctions.sendMessage(player, C.PLOT_REMOVED_HELPER, plot.id.toString());
|
||||
MainUtil.sendMessage(new BukkitPlayer(player), C.PLOT_REMOVED_HELPER, plot.id.toString());
|
||||
}
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
@ -113,7 +114,7 @@ public class ExpireManager {
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
manager.clearPlot(plotworld, plot, false, null);
|
||||
PlotHelper.removeSign(plot);
|
||||
MainUtil.removeSign(plot);
|
||||
DBFunc.delete(world, plot);
|
||||
PlotSquared.removePlot(world, plot.id, true);
|
||||
expiredPlots.get(world).remove(plot);
|
||||
|
@ -0,0 +1,964 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.util.ChatPaginator;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
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.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.SendChunk;
|
||||
|
||||
/**
|
||||
* plot functions
|
||||
*
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public class MainUtil {
|
||||
public final static HashMap<Plot, Integer> runners = new HashMap<>();
|
||||
public static boolean canSendChunk = false;
|
||||
public static ArrayList<String> runners_p = new ArrayList<>();
|
||||
static long state = 1;
|
||||
public static HashMap<String, PlotId> lastPlot = new HashMap<>();
|
||||
public static HashMap<String, Integer> worldBorder = new HashMap<>();
|
||||
|
||||
public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) {
|
||||
final Plot bot = MainUtil.getBottomPlot(plot);
|
||||
|
||||
// TODO
|
||||
// boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot);
|
||||
boolean result = true;
|
||||
// TOOD ^ remove that
|
||||
|
||||
if (!result) {
|
||||
final Location location = MainUtil.getPlotHome(bot.world, bot);
|
||||
if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||
sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
player.teleport(location);
|
||||
return true;
|
||||
}
|
||||
sendMessage(player, C.TELEPORT_IN_SECONDS, Settings.TELEPORT_DELAY + "");
|
||||
final String name = player.getName();
|
||||
TaskManager.TELEPORT_QUEUE.add(name);
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!TaskManager.TELEPORT_QUEUE.contains(name)) {
|
||||
sendMessage(player, C.TELEPORT_FAILED);
|
||||
return;
|
||||
}
|
||||
TaskManager.TELEPORT_QUEUE.remove(name);
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
player.teleport(location);
|
||||
}
|
||||
}, Settings.TELEPORT_DELAY * 20);
|
||||
return true;
|
||||
}
|
||||
return !result;
|
||||
}
|
||||
|
||||
public static int getBorder(final String worldname) {
|
||||
if (worldBorder.containsKey(worldname)) {
|
||||
PlotSquared.getPlotWorld(worldname);
|
||||
return worldBorder.get(worldname) + 16;
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public static void setupBorder(final String world) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
if (!plotworld.WORLD_BORDER) {
|
||||
return;
|
||||
}
|
||||
if (!worldBorder.containsKey(world)) {
|
||||
worldBorder.put(world, 0);
|
||||
}
|
||||
for (final Plot plot : PlotSquared.getPlots(world).values()) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
}
|
||||
|
||||
public static void update(final Location loc) {
|
||||
final String world = loc.getWorld();
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
final int distance = BukkitUtil.getViewDistance();
|
||||
for (int cx = -distance; cx < distance; cx++) {
|
||||
for (int cz = -distance; cz < distance; cz++) {
|
||||
final ChunkLoc chunk = new ChunkLoc(cx, cz);
|
||||
chunks.add(chunk);
|
||||
}
|
||||
}
|
||||
AbstractSetBlock.setBlockManager.update(world, chunks);
|
||||
}
|
||||
|
||||
public static void createWorld(final String world, final String generator) {
|
||||
}
|
||||
|
||||
public static PlotId parseId(final String arg) {
|
||||
try {
|
||||
final String[] split = arg.split(";");
|
||||
return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
} catch (final Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* direction 0 = north, 1 = south, etc:
|
||||
*
|
||||
* @param id
|
||||
* @param direction
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static PlotId getPlotIdRelative(final PlotId id, final int direction) {
|
||||
switch (direction) {
|
||||
case 0:
|
||||
return new PlotId(id.x, id.y - 1);
|
||||
case 1:
|
||||
return new PlotId(id.x + 1, id.y);
|
||||
case 2:
|
||||
return new PlotId(id.x, id.y + 1);
|
||||
case 3:
|
||||
return new PlotId(id.x - 1, id.y);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public static ArrayList<PlotId> getPlotSelectionIds(final PlotId pos1, final PlotId pos2) {
|
||||
final ArrayList<PlotId> myplots = new ArrayList<>();
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
myplots.add(new PlotId(x, y));
|
||||
}
|
||||
}
|
||||
return myplots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completely merges a set of plots<br> <b>(There are no checks to make sure you supply the correct
|
||||
* arguments)</b><br> - Misuse of this method can result in unusable plots<br> - the set of plots must belong to one
|
||||
* owner and be rectangular<br> - the plot array must be sorted in ascending order<br> - Road will be removed where
|
||||
* required<br> - changes will be saved to DB<br>
|
||||
*
|
||||
* @param world
|
||||
* @param plotIds
|
||||
*
|
||||
* @return boolean (success)
|
||||
*/
|
||||
public static boolean mergePlots(final String world, final ArrayList<PlotId> plotIds, final boolean removeRoads) {
|
||||
if (plotIds.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
final PlotId pos1 = plotIds.get(0);
|
||||
final PlotId pos2 = plotIds.get(plotIds.size() - 1);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
manager.startPlotMerge(plotworld, plotIds);
|
||||
final boolean result = false;
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final boolean lx = x < pos2.x;
|
||||
final boolean ly = y < pos2.y;
|
||||
final PlotId id = new PlotId(x, y);
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
Plot plot2 = null;
|
||||
if (removeRoads) {
|
||||
removeSign(plot);
|
||||
}
|
||||
if (lx) {
|
||||
if (ly) {
|
||||
if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) {
|
||||
if (removeRoads) {
|
||||
manager.removeRoadSouthEast(plotworld, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.settings.getMerged(1)) {
|
||||
plot2 = PlotSquared.getPlots(world).get(new PlotId(x + 1, y));
|
||||
mergePlot(world, plot, plot2, removeRoads);
|
||||
plot.settings.setMerged(1, true);
|
||||
plot2.settings.setMerged(3, true);
|
||||
}
|
||||
}
|
||||
if (ly) {
|
||||
if (!plot.settings.getMerged(2)) {
|
||||
plot2 = PlotSquared.getPlots(world).get(new PlotId(x, y + 1));
|
||||
mergePlot(world, plot, plot2, removeRoads);
|
||||
plot.settings.setMerged(2, true);
|
||||
plot2.settings.setMerged(0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
DBFunc.setMerged(world, plot, plot.settings.getMerged());
|
||||
}
|
||||
}
|
||||
manager.finishPlotMerge(plotworld, plotIds);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges 2 plots Removes the road inbetween <br> - Assumes the first plot parameter is lower <br> - Assumes neither
|
||||
* are a Mega-plot <br> - Assumes plots are directly next to each other <br> - Saves to DB
|
||||
*
|
||||
* @param world
|
||||
* @param lesserPlot
|
||||
* @param greaterPlot
|
||||
*/
|
||||
public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, final boolean removeRoads) {
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
if (lesserPlot.id.x.equals(greaterPlot.id.x)) {
|
||||
if (!lesserPlot.settings.getMerged(2)) {
|
||||
lesserPlot.settings.setMerged(2, true);
|
||||
greaterPlot.settings.setMerged(0, true);
|
||||
if (removeRoads) {
|
||||
manager.removeRoadSouth(plotworld, lesserPlot);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!lesserPlot.settings.getMerged(1)) {
|
||||
lesserPlot.settings.setMerged(1, true);
|
||||
greaterPlot.settings.setMerged(3, true);
|
||||
if (removeRoads) {
|
||||
manager.removeRoadEast(plotworld, lesserPlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeSign(final Plot p) {
|
||||
final String world = p.world;
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final Location loc = manager.getSignLoc(plotworld, p);
|
||||
BlockManager.setBlocks(world, new int[] { loc.getX() }, new int[] { loc.getY() }, new int[] { loc.getZ() }, new int[] { 0 }, new byte[] { 0 });
|
||||
}
|
||||
|
||||
public static void setSign(String name, final Plot p) {
|
||||
if (name == null) {
|
||||
name = "unknown";
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(p.world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(p.world);
|
||||
final Location loc = manager.getSignLoc(plotworld, p);
|
||||
final String id = p.id.x + ";" + p.id.y;
|
||||
final String[] lines = new String[] { C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id), C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", name), C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", name) };
|
||||
BlockManager.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines);
|
||||
}
|
||||
|
||||
public static String getStringSized(final int max, final String string) {
|
||||
if (string.length() > max) {
|
||||
return string.substring(0, max);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static void autoMerge(final String world, final Plot plot, final UUID uuid) {
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (plot.owner == null) {
|
||||
return;
|
||||
}
|
||||
if (!plot.owner.equals(uuid)) {
|
||||
return;
|
||||
}
|
||||
ArrayList<PlotId> plots;
|
||||
boolean merge = true;
|
||||
int count = 0;
|
||||
while (merge) {
|
||||
if (count > 16) {
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
final PlotId bot = getBottomPlot(plot).id;
|
||||
final PlotId top = getTopPlot(world, plot).id;
|
||||
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||
if (ownsPlots(world, plots, uuid, 0)) {
|
||||
final boolean result = mergePlots(world, plots, true);
|
||||
if (result) {
|
||||
merge = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||
if (ownsPlots(world, plots, uuid, 1)) {
|
||||
final boolean result = mergePlots(world, plots, true);
|
||||
if (result) {
|
||||
merge = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||
if (ownsPlots(world, plots, uuid, 2)) {
|
||||
final boolean result = mergePlots(world, plots, true);
|
||||
if (result) {
|
||||
merge = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
plots = getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||
if (ownsPlots(world, plots, uuid, 3)) {
|
||||
final boolean result = mergePlots(world, plots, true);
|
||||
if (result) {
|
||||
merge = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
merge = false;
|
||||
}
|
||||
update(getPlotHome(world, plot));
|
||||
}
|
||||
|
||||
private static boolean ownsPlots(final String world, final ArrayList<PlotId> plots, final UUID uuid, final int dir) {
|
||||
final PlotId id_min = plots.get(0);
|
||||
final PlotId id_max = plots.get(plots.size() - 1);
|
||||
for (final PlotId myid : plots) {
|
||||
final Plot myplot = PlotSquared.getPlots(world).get(myid);
|
||||
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(uuid))) {
|
||||
return false;
|
||||
}
|
||||
final PlotId top = getTopPlot(world, myplot).id;
|
||||
if (((top.x > id_max.x) && (dir != 1)) || ((top.y > id_max.y) && (dir != 2))) {
|
||||
return false;
|
||||
}
|
||||
final PlotId bot = getBottomPlot(myplot).id;
|
||||
if (((bot.x < id_min.x) && (dir != 3)) || ((bot.y < id_min.y) && (dir != 0))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void updateWorldBorder(final Plot plot) {
|
||||
if (!worldBorder.containsKey(plot.world)) {
|
||||
return;
|
||||
}
|
||||
final String world = plot.world;
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id);
|
||||
final Location top = manager.getPlotTopLocAbs(plotworld, plot.id);
|
||||
final int border = worldBorder.get(plot.world);
|
||||
final int botmax = Math.max(Math.abs(bot.getX()), Math.abs(bot.getZ()));
|
||||
final int topmax = Math.max(Math.abs(top.getX()), Math.abs(top.getZ()));
|
||||
final int max = Math.max(botmax, topmax);
|
||||
if (max > border) {
|
||||
worldBorder.put(plot.world, max);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plot and notify the world border and plot merger
|
||||
*/
|
||||
public static boolean createPlot(final UUID uuid, final Plot plot) {
|
||||
if (MainUtil.worldBorder.containsKey(plot.world)) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
final Plot p = createPlotAbs(uuid, plot);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||
if (plotworld.AUTO_MERGE) {
|
||||
autoMerge(plot.world, p, uuid);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plot without notifying the merge function or world border manager
|
||||
*/
|
||||
public static Plot createPlotAbs(final UUID uuid, final Plot plot) {
|
||||
final String w = plot.world;
|
||||
final Plot p = new Plot(plot.id, uuid, new ArrayList<UUID>(), new ArrayList<UUID>(), w);
|
||||
PlotSquared.updatePlot(p);
|
||||
DBFunc.createPlotAndSettings(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
public static String createId(final int x, final int z) {
|
||||
return x + ";" + z;
|
||||
}
|
||||
|
||||
public static int square(final int x) {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
public static short[] getBlock(final String block) {
|
||||
if (block.contains(":")) {
|
||||
final String[] split = block.split(":");
|
||||
return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) };
|
||||
}
|
||||
return new short[] { Short.parseShort(block), 0 };
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear a plot and associated sections: [sign, entities, border]
|
||||
*
|
||||
* @param requester
|
||||
* @param plot
|
||||
*/
|
||||
public static boolean clearAsPlayer(final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
||||
if (runners.containsKey(plot)) {
|
||||
return false;
|
||||
}
|
||||
AChunkManager.manager.clearAllEntities(plot);
|
||||
clear(plot.world, plot, isDelete, whenDone);
|
||||
removeSign(plot);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final int prime = 31;
|
||||
int h = 1;
|
||||
h = (prime * h) + pos1.getX();
|
||||
h = (prime * h) + pos1.getZ();
|
||||
state = h;
|
||||
System.currentTimeMillis();
|
||||
final Location location = MainUtil.getPlotHomeDefault(plot);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
runners.put(plot, 1);
|
||||
if (plotworld.TERRAIN != 0) {
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runners.remove(plot);
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
final Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.setBiome(world, plot, "FOREST");
|
||||
runners.remove(plot);
|
||||
TaskManager.runTask(whenDone);
|
||||
update(location);
|
||||
}
|
||||
};
|
||||
manager.clearPlot(plotworld, plot, isDelete, run);
|
||||
}
|
||||
|
||||
public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
|
||||
if (blocks.length == 1) {
|
||||
setSimpleCuboid(world, pos1, pos2, blocks[0]);
|
||||
return;
|
||||
}
|
||||
final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ());
|
||||
final int[] xl = new int[length];
|
||||
final int[] yl = new int[length];
|
||||
final int[] zl = new int[length];
|
||||
final int[] ids = new int[length];
|
||||
final byte[] data = new byte[length];
|
||||
int index = 0;
|
||||
for (int y = pos1.getY(); y < pos2.getY(); y++) {
|
||||
for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
||||
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
||||
final int i = BlockManager.random(blocks.length);
|
||||
xl[index] = x;
|
||||
yl[index] = y;
|
||||
zl[index] = z;
|
||||
final PlotBlock block = blocks[i];
|
||||
ids[index] = block.id;
|
||||
data[index] = block.data;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
BlockManager.setBlocks(world, xl, yl, zl, ids, data);
|
||||
}
|
||||
|
||||
public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) {
|
||||
final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ());
|
||||
final int[] xl = new int[length];
|
||||
final int[] yl = new int[length];
|
||||
final int[] zl = new int[length];
|
||||
final int[] ids = new int[length];
|
||||
final byte[] data = new byte[length];
|
||||
int index = 0;
|
||||
for (int y = pos1.getY(); y < pos2.getY(); y++) {
|
||||
for (int x = pos1.getX(); x < pos2.getX(); x++) {
|
||||
for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
|
||||
xl[index] = x;
|
||||
yl[index] = y;
|
||||
zl[index] = z;
|
||||
ids[index] = newblock.id;
|
||||
data[index] = newblock.data;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
BlockManager.setBlocks(world, xl, yl, zl, ids, data);
|
||||
}
|
||||
|
||||
public static void setBiome(final String world, final Plot plot, final String biome) {
|
||||
final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1;
|
||||
final int topX = getPlotTopLoc(world, plot.id).getX();
|
||||
final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1;
|
||||
final int topZ = getPlotTopLoc(world, plot.id).getZ();
|
||||
BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, biome);
|
||||
}
|
||||
|
||||
public static int getHeighestBlock(final String world, final int x, final int z) {
|
||||
final int result = BukkitUtil.getHeighestBlock(world, x, z);
|
||||
if (result == 0) {
|
||||
return 64;
|
||||
}
|
||||
return result;
|
||||
// for (int i = 1; i < world.getMaxHeight(); i++) {
|
||||
// id = world.getBlockAt(x, i, z).getTypeId();
|
||||
// if (id == 0) {
|
||||
// if (safe) {
|
||||
// return i;
|
||||
// }
|
||||
// safe = true;
|
||||
// }
|
||||
// }
|
||||
// return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plot home
|
||||
*
|
||||
* @param w World in which the plot is located
|
||||
* @param plotid Plot ID
|
||||
*
|
||||
* @return Home Location
|
||||
*/
|
||||
public static Location getPlotHome(final String w, final PlotId plotid) {
|
||||
final Plot plot = getPlot(w, plotid);
|
||||
final BlockLoc home = plot.settings.getPosition();
|
||||
final Location bot = getPlotBottomLoc(w, plotid);
|
||||
final 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();
|
||||
final int z = ((top.getZ() - bot.getZ()) / 2) + bot.getZ();
|
||||
final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(w), plot).getY());
|
||||
return new Location(w, x, y, z);
|
||||
} else {
|
||||
final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y);
|
||||
return bot.add(home.x, y, home.z);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the location of the default plot home position
|
||||
*
|
||||
* @param plot Plot
|
||||
*
|
||||
* @return the location
|
||||
*/
|
||||
public static Location getPlotHomeDefault(final Plot plot) {
|
||||
final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0);
|
||||
l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ()));
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot home
|
||||
*
|
||||
* @param w World
|
||||
* @param plot Plot Object
|
||||
*
|
||||
* @return Plot Home Location
|
||||
*
|
||||
* @see #getPlotHome(org.bukkit.World, com.intellectualcrafters.plot.object.PlotId)
|
||||
*/
|
||||
public static Location getPlotHome(final String w, final Plot plot) {
|
||||
return getPlotHome(w, plot.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the plot chunks
|
||||
*
|
||||
* @param world World in which the plot is located
|
||||
* @param plot Plot Object
|
||||
*/
|
||||
public static void refreshPlotChunks(final String world, final Plot plot) {
|
||||
final int bottomX = getPlotBottomLoc(world, plot.id).getX();
|
||||
final int topX = getPlotTopLoc(world, plot.id).getX();
|
||||
final int bottomZ = getPlotBottomLoc(world, plot.id).getZ();
|
||||
final int topZ = getPlotTopLoc(world, plot.id).getZ();
|
||||
final int minChunkX = (int) Math.floor((double) bottomX / 16);
|
||||
final int maxChunkX = (int) Math.floor((double) topX / 16);
|
||||
final int minChunkZ = (int) Math.floor((double) bottomZ / 16);
|
||||
final int maxChunkZ = (int) Math.floor((double) topZ / 16);
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
for (int x = minChunkX; x <= maxChunkX; x++) {
|
||||
for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
||||
if (canSendChunk) {
|
||||
final ChunkLoc chunk = new ChunkLoc(x, z);
|
||||
chunks.add(chunk);
|
||||
} else {
|
||||
BukkitUtil.refreshChunk(world, x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
SendChunk.sendChunk(world, chunks);
|
||||
} catch (final Throwable e) {
|
||||
canSendChunk = false;
|
||||
for (int x = minChunkX; x <= maxChunkX; x++) {
|
||||
for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
||||
BukkitUtil.refreshChunk(world, 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
|
||||
* use getPlotTopLoc(...)
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Location getPlotTopLocAbs(final String world, final PlotId id) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
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
|
||||
* plot use getPlotBottomLoc(...)
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Location getPlotBottomLocAbs(final String world, final PlotId id) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the width of a plot (x width)
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int getPlotWidth(final String world, final PlotId id) {
|
||||
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
|
||||
* a small plot use getPlotTopLocAbs(...)
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Location getPlotTopLoc(final String world, PlotId id) {
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
if (plot != null) {
|
||||
id = getTopPlot(world, plot).id;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
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
|
||||
* treated as a small plot use getPlotBottomLocAbs(...)
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Location getPlotBottomLoc(final String world, PlotId id) {
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
if (plot != null) {
|
||||
id = getBottomPlot(plot).id;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) {
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
final PlotId id = new PlotId(x, y);
|
||||
if (PlotSquared.getPlots(world).get(id) != null) {
|
||||
if (PlotSquared.getPlots(world).get(id).owner != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||
final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(world, current);
|
||||
final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot);
|
||||
final Location top = MainUtil.getPlotTopLoc(world, current);
|
||||
final Plot currentPlot = MainUtil.getPlot(world, current);
|
||||
if (currentPlot.owner == null) {
|
||||
return false;
|
||||
}
|
||||
final Plot pos1 = getBottomPlot(currentPlot);
|
||||
final Plot pos2 = getTopPlot(world, currentPlot);
|
||||
final PlotId size = MainUtil.getSize(world, currentPlot);
|
||||
if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) {
|
||||
return false;
|
||||
}
|
||||
final int offset_x = newPlot.x - pos1.id.x;
|
||||
final int offset_y = newPlot.y - pos1.id.y;
|
||||
final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
|
||||
for (final PlotId id : selection) {
|
||||
DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y));
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
PlotSquared.getPlots(world).remove(id);
|
||||
plot.id.x += offset_x;
|
||||
plot.id.y += offset_y;
|
||||
PlotSquared.getPlots(world).put(plot.id, plot);
|
||||
}
|
||||
AChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Location bot = bot1.clone().add(1, 0, 1);
|
||||
AChunkManager.manager.regenerateRegion(bot, top, null);
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the player
|
||||
*
|
||||
* @param plr Player to recieve message
|
||||
* @param msg Message to send
|
||||
*
|
||||
* @return true Can be used in things such as commands (return PlayerFunctions.sendMessage(...))
|
||||
*/
|
||||
public static boolean sendMessage(final PlotPlayer plr, final String msg) {
|
||||
return sendMessage(plr, msg, true);
|
||||
}
|
||||
|
||||
public static boolean sendMessage(final PlotPlayer plr, final String msg, final boolean prefix) {
|
||||
if ((msg.length() > 0) && !msg.equals("")) {
|
||||
if (plr == null) {
|
||||
PlotSquared.log(C.PREFIX.s() + msg);
|
||||
} else {
|
||||
sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* \\previous\\
|
||||
*
|
||||
* @param plr
|
||||
* @param msg Was used to wrap the chat client length (Packets out--)
|
||||
*/
|
||||
public static void sendMessageWrapped(final PlotPlayer plr, String msg) {
|
||||
if (msg.length() > ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH) {
|
||||
final String[] ss = ChatPaginator.wordWrap(msg, ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH);
|
||||
final StringBuilder b = new StringBuilder();
|
||||
for (final String p : ss) {
|
||||
b.append(p).append(p.equals(ss[ss.length - 1]) ? "" : "\n ");
|
||||
}
|
||||
msg = b.toString();
|
||||
}
|
||||
if (msg.endsWith("\n")) {
|
||||
msg = msg.substring(0, msg.length() - 2);
|
||||
}
|
||||
plr.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the player
|
||||
*
|
||||
* @param plr Player to recieve message
|
||||
* @param c Caption to send
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
|
||||
if (c.s().length() > 1) {
|
||||
String msg = c.s();
|
||||
if ((args != null) && (args.length > 0)) {
|
||||
for (final String str : args) {
|
||||
if (msg.contains("%s")) {
|
||||
msg = msg.replaceFirst("%s", str);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plr == null) {
|
||||
PlotSquared.log(msg);
|
||||
} else {
|
||||
sendMessage(plr, msg, c.usePrefix());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Plot getBottomPlot(final Plot plot) {
|
||||
if (plot.settings.getMerged(0)) {
|
||||
final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y - 1));
|
||||
if (p == null) {
|
||||
return plot;
|
||||
}
|
||||
return getBottomPlot(p);
|
||||
}
|
||||
if (plot.settings.getMerged(3)) {
|
||||
final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x - 1, plot.id.y));
|
||||
if (p == null) {
|
||||
return plot;
|
||||
}
|
||||
return getBottomPlot(p);
|
||||
}
|
||||
return plot;
|
||||
}
|
||||
|
||||
public static Plot getTopPlot(final String world, final Plot plot) {
|
||||
if (plot.settings.getMerged(2)) {
|
||||
return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1)));
|
||||
}
|
||||
if (plot.settings.getMerged(1)) {
|
||||
return getTopPlot(world, PlotSquared.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y)));
|
||||
}
|
||||
return plot;
|
||||
}
|
||||
|
||||
public static PlotId getSize(final String world, final Plot plot) {
|
||||
final PlotSettings settings = plot.settings;
|
||||
if (!settings.isMerged()) {
|
||||
return new PlotId(1, 1);
|
||||
}
|
||||
final Plot top = getTopPlot(world, plot);
|
||||
final Plot bot = getBottomPlot(plot);
|
||||
return new PlotId((top.id.x - bot.id.x) + 1, (top.id.y - bot.id.y) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the plot from the main class
|
||||
*/
|
||||
public static Plot getPlot(final String world, final PlotId id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
if (PlotSquared.getPlots(world).containsKey(id)) {
|
||||
return PlotSquared.getPlots(world).get(id);
|
||||
}
|
||||
return new Plot(id, null, new ArrayList<UUID>(), new ArrayList<UUID>(), world);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the plot at a location (mega plots are not considered, all plots are treated as small plots)
|
||||
* @param loc
|
||||
* @return
|
||||
*/
|
||||
public static PlotId getPlotAbs(final Location loc) {
|
||||
final String world = loc.getWorld();
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
if (manager == null) {
|
||||
return null;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plot id at a location (mega plots are considered)
|
||||
* @param loc
|
||||
* @return
|
||||
*/
|
||||
public static PlotId getPlotId(final Location loc) {
|
||||
final String world = loc.getWorld();
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
if (manager == null) {
|
||||
return null;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotId id = manager.getPlotId(plotworld, loc.getX(), loc.getY(), loc.getZ());
|
||||
if ((id != null) && (plotworld.TYPE == 2)) {
|
||||
if (ClusterManager.getCluster(world, id) == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum number of plots a player is allowed
|
||||
*
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
public static int getAllowedPlots(final PlotPlayer p) {
|
||||
return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS);
|
||||
}
|
||||
|
||||
public static Plot getPlot(final Location loc) {
|
||||
PlotId id = getPlotId(loc);
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return getPlot(loc.getWorld(), id);
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
public class Permissions {
|
||||
// ADMIN
|
||||
public static String ADMIN = "plots.admin";
|
||||
// BUILD
|
||||
public static String BUILD_OTHER = "plots.admin.build.other";
|
||||
public static String BUILD_ROAD = "plots.admin.build.road";
|
||||
public static String BUILD_UNOWNED = "plots.admin.build.unowned";
|
||||
// INTERACT
|
||||
public static String INTERACT_OTHER = "plots.admin.interact.other";
|
||||
public static String INTERACT_ROAD = "plots.admin.interact.road";
|
||||
public static String INTERACT_UNOWNED = "plots.admin.interact.unowned";
|
||||
// BREAK
|
||||
public static String BREAK_OTHER = "plots.admin.break.other";
|
||||
public static String BREAK_ROAD = "plots.admin.break.road";
|
||||
public static String BREAK_UNOWNED = "plots.admin.break.unowned";
|
||||
|
||||
public static boolean hasPermission(final PlotPlayer player, final String perm) {
|
||||
if ((player == null) || player.isOp() || player.hasPermission(ADMIN)) {
|
||||
return true;
|
||||
}
|
||||
if (player.hasPermission(perm)) {
|
||||
return true;
|
||||
}
|
||||
final String[] nodes = perm.split("\\.");
|
||||
final StringBuilder n = new StringBuilder();
|
||||
for (int i = 0; i < (nodes.length - 1); i++) {
|
||||
n.append(nodes[i] + ("."));
|
||||
if (player.hasPermission(n + "*")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) {
|
||||
if ((player == null) || player.isOp() || player.hasPermission(ADMIN)) {
|
||||
return Byte.MAX_VALUE;
|
||||
}
|
||||
if (player.hasPermission(stub + ".*")) {
|
||||
return Byte.MAX_VALUE;
|
||||
}
|
||||
for (int i = range; i > 0; i--) {
|
||||
if (player.hasPermission(stub + "." + i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -77,7 +77,7 @@ public class SchematicHandler {
|
||||
final int LENGTH = demensions.getZ();
|
||||
final int HEIGHT = demensions.getY();
|
||||
final DataCollection[] blocks = schematic.getBlockCollection();
|
||||
Location l1 = PlotHelper.getPlotBottomLoc(plot.world, plot.getId());
|
||||
Location l1 = MainUtil.getPlotBottomLoc(plot.world, plot.getId());
|
||||
final int sy = BukkitUtil.getHeighestBlock(location.getWorld(), l1.getX() + 1, l1.getZ() + 1);
|
||||
l1 = l1.add(1, sy - 1, 1);
|
||||
if (HEIGHT == BukkitUtil.getMaxHeight(location.getWorld())) {
|
||||
@ -214,8 +214,8 @@ public class SchematicHandler {
|
||||
if (!PlotSquared.getPlots(world).containsKey(id)) {
|
||||
return null;
|
||||
}
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, id).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, id);
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(world, id).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, id);
|
||||
return getCompoundTag(world, pos1, pos2);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ import com.intellectualcrafters.plot.BukkitMain;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -52,7 +53,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.entity.EntityWrapper;
|
||||
import com.intellectualcrafters.plot.util.AChunkManager;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
public class ChunkManager extends AChunkManager {
|
||||
@ -110,12 +111,12 @@ public class ChunkManager extends AChunkManager {
|
||||
final int z2 = z1 + 15;
|
||||
final Location bot = new Location(world, x1, 0, z1);
|
||||
Plot plot;
|
||||
plot = PlotHelper.getPlot(bot);
|
||||
plot = MainUtil.getPlot(bot);
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return plot;
|
||||
}
|
||||
final Location top = new Location(world, x2, 0, z2);
|
||||
plot = PlotHelper.getPlot(top);
|
||||
plot = MainUtil.getPlot(top);
|
||||
if ((plot != null) && (plot.owner != null)) {
|
||||
return plot;
|
||||
}
|
||||
@ -743,11 +744,11 @@ public class ChunkManager extends AChunkManager {
|
||||
public void clearAllEntities(final Plot plot) {
|
||||
final List<Entity> entities = BukkitUtil.getEntities(plot.world);
|
||||
for (final Entity entity : entities) {
|
||||
final PlotId id = PlotHelper.getPlotId(BukkitUtil.getLocation(entity));
|
||||
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
|
||||
if (plot.id.equals(id)) {
|
||||
if (entity instanceof Player) {
|
||||
final Player player = (Player) entity;
|
||||
BukkitMain.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
||||
MainUtil.teleportPlayer(new BukkitPlayer(player), BukkitUtil.getLocation(entity), plot);
|
||||
PlotListener.plotExit(player, plot);
|
||||
} else {
|
||||
entity.remove();
|
||||
|
@ -26,15 +26,16 @@ import com.intellectualcrafters.plot.BukkitMain;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
@ -44,32 +45,30 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
* @author Empire92
|
||||
*/
|
||||
public class PWE {
|
||||
public static void setMask(final Player p, final Location l, final boolean force) {
|
||||
public static void setMask(final PlotPlayer p, final Location l, final boolean force) {
|
||||
try {
|
||||
LocalSession s;
|
||||
if (PlotSquared.worldEdit == null) {
|
||||
s = WorldEdit.getInstance().getSession(p.getName());
|
||||
} else {
|
||||
s = PlotSquared.worldEdit.getSession(p);
|
||||
}
|
||||
if (!PlotSquared.isPlotWorld(p.getWorld().getName())) {
|
||||
LocalSession s = WorldEdit.getInstance().getSession(p.getName());
|
||||
if (!PlotSquared.isPlotWorld(l.getWorld())) {
|
||||
removeMask(p);
|
||||
}
|
||||
final PlotId id = PlotHelper.getPlotId(l);
|
||||
final PlotId id = MainUtil.getPlotId(l);
|
||||
if (id != null) {
|
||||
final Plot plot = PlotSquared.getPlots(l.getWorld()).get(id);
|
||||
if (plot != null) {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "no-worldedit")) {
|
||||
return;
|
||||
}
|
||||
final boolean r = ((plot.getOwner() != null) && plot.getOwner().equals(UUIDHandler.getUUID(p))) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p));
|
||||
final boolean r = ((plot.getOwner() != null) && plot.getOwner().equals(p.getUUID())) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUUID());
|
||||
if (r) {
|
||||
final String w = l.getWorld();
|
||||
final Location bloc = PlotHelper.getPlotBottomLoc(w, plot.id);
|
||||
final Location tloc = PlotHelper.getPlotTopLoc(w, plot.id);
|
||||
final Location bloc = MainUtil.getPlotBottomLoc(w, plot.id);
|
||||
final Location tloc = MainUtil.getPlotTopLoc(w, plot.id);
|
||||
final Vector bvec = new Vector(bloc.getX() + 1, bloc.getY(), bloc.getZ() + 1);
|
||||
final Vector tvec = new Vector(tloc.getX(), tloc.getY(), tloc.getZ());
|
||||
final LocalWorld lw = PlotSquared.worldEdit.wrapPlayer(p).getWorld();
|
||||
|
||||
|
||||
// FIXME unchecked casting
|
||||
final LocalWorld lw = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player).getWorld();
|
||||
final CuboidRegion region = new CuboidRegion(lw, bvec, tvec);
|
||||
final RegionMask mask = new RegionMask(region);
|
||||
s.setMask(mask);
|
||||
@ -77,8 +76,8 @@ public class PWE {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (force ^ (noMask(s) && !BukkitMain.hasPermission(p, "plots.worldedit.bypass"))) {
|
||||
final BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(p);
|
||||
if (force ^ (noMask(s) && !p.hasPermission("plots.worldedit.bypass"))) {
|
||||
final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player);
|
||||
final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
|
||||
s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
|
||||
}
|
||||
@ -113,7 +112,7 @@ public class PWE {
|
||||
} else {
|
||||
s = PlotSquared.worldEdit.getSession(p);
|
||||
}
|
||||
final BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(p);
|
||||
final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player);
|
||||
final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
|
||||
s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
|
||||
} catch (final Exception e) {
|
||||
@ -121,19 +120,14 @@ public class PWE {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeMask(final Player p, final LocalSession s) {
|
||||
public static void removeMask(final PlotPlayer p, final LocalSession s) {
|
||||
final Mask mask = null;
|
||||
s.setMask(mask);
|
||||
}
|
||||
|
||||
public static void removeMask(final Player p) {
|
||||
public static void removeMask(final PlotPlayer p) {
|
||||
try {
|
||||
LocalSession s;
|
||||
if (PlotSquared.worldEdit == null) {
|
||||
s = WorldEdit.getInstance().getSession(p.getName());
|
||||
} else {
|
||||
s = PlotSquared.worldEdit.getSession(p);
|
||||
}
|
||||
LocalSession s = WorldEdit.getInstance().getSession(p.getName());
|
||||
removeMask(p, s);
|
||||
} catch (final Exception e) {
|
||||
// throw new
|
||||
|
@ -24,12 +24,16 @@ import com.intellectualcrafters.plot.BukkitMain;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -57,12 +61,12 @@ public class PlayerFunctions {
|
||||
@Override
|
||||
public void run() {
|
||||
if ((player != null) && player.isOnline()) {
|
||||
PlayerFunctions.sendMessage(player, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||
MainUtil.sendMessage(new BukkitPlayer(player), C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!PlotHelper.clearAsPlayer(plot, isDelete, whenDone)) {
|
||||
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
|
||||
if (!MainUtil.clearAsPlayer(plot, isDelete, whenDone)) {
|
||||
MainUtil.sendMessage(null, C.WAIT_FOR_TIMER);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,14 +86,14 @@ public class PlayerFunctions {
|
||||
if (cost > 0d) {
|
||||
final Economy economy = PlotSquared.economy;
|
||||
if (economy.getBalance(plr) < cost) {
|
||||
PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" + cost);
|
||||
MainUtil.sendMessage(new BukkitPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost);
|
||||
return false;
|
||||
}
|
||||
economy.withdrawPlayer(plr, cost);
|
||||
PlayerFunctions.sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
MainUtil.sendMessage(new BukkitPlayer(plr), C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
return PlotHelper.mergePlots(world, plotIds, true);
|
||||
return MainUtil.mergePlots(world, plotIds, true);
|
||||
}
|
||||
|
||||
public static String getPlayerName(final UUID uuid) {
|
||||
@ -116,10 +120,10 @@ public class PlayerFunctions {
|
||||
final Plot plot1 = PlotSquared.getPlots(world).get(pos1);
|
||||
final Plot plot2 = PlotSquared.getPlots(world).get(pos2);
|
||||
if (plot1 != null) {
|
||||
pos1 = PlotHelper.getBottomPlot(world, plot1).id;
|
||||
pos1 = MainUtil.getBottomPlot(plot1).id;
|
||||
}
|
||||
if (plot2 != null) {
|
||||
pos2 = PlotHelper.getTopPlot(world, plot2).id;
|
||||
pos2 = MainUtil.getTopPlot(world, plot2).id;
|
||||
}
|
||||
final ArrayList<PlotId> myplots = new ArrayList<>();
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
@ -141,7 +145,7 @@ public class PlayerFunctions {
|
||||
if (!PlotSquared.isPlotWorld(player.getWorld().getName())) {
|
||||
return null;
|
||||
}
|
||||
final PlotId id = PlotHelper.getPlotId(BukkitUtil.getLocation(player));
|
||||
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(player));
|
||||
final String world = player.getWorld().getName();
|
||||
if (id == null) {
|
||||
return null;
|
||||
@ -184,86 +188,4 @@ public class PlayerFunctions {
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum number of plots a player is allowed
|
||||
*
|
||||
* @param p
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int getAllowedPlots(final PlotPlayer p) {
|
||||
return BukkitMain.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS);
|
||||
}
|
||||
|
||||
/**
|
||||
* \\previous\\
|
||||
*
|
||||
* @param plr
|
||||
* @param msg Was used to wrap the chat client length (Packets out--)
|
||||
*/
|
||||
public static void sendMessageWrapped(final PlotPlayer plr, String msg) {
|
||||
if (msg.length() > ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH) {
|
||||
final String[] ss = ChatPaginator.wordWrap(msg, ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH);
|
||||
final StringBuilder b = new StringBuilder();
|
||||
for (final String p : ss) {
|
||||
b.append(p).append(p.equals(ss[ss.length - 1]) ? "" : "\n ");
|
||||
}
|
||||
msg = b.toString();
|
||||
}
|
||||
if (msg.endsWith("\n")) {
|
||||
msg = msg.substring(0, msg.length() - 2);
|
||||
}
|
||||
plr.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the player
|
||||
*
|
||||
* @param plr Player to recieve message
|
||||
* @param msg Message to send
|
||||
*
|
||||
* @return true Can be used in things such as commands (return PlayerFunctions.sendMessage(...))
|
||||
*/
|
||||
public static boolean sendMessage(final PlotPlayer plr, final String msg) {
|
||||
return sendMessage(plr, msg, true);
|
||||
}
|
||||
|
||||
public static boolean sendMessage(final PlotPlayer plr, final String msg, final boolean prefix) {
|
||||
if ((msg.length() > 0) && !msg.equals("")) {
|
||||
if (plr == null) {
|
||||
PlotSquared.log(C.PREFIX.s() + msg);
|
||||
} else {
|
||||
sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the player
|
||||
*
|
||||
* @param plr Player to recieve message
|
||||
* @param c Caption to send
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
|
||||
if (c.s().length() > 1) {
|
||||
String msg = c.s();
|
||||
if ((args != null) && (args.length > 0)) {
|
||||
for (final String str : args) {
|
||||
if (msg.contains("%s")) {
|
||||
msg = msg.replaceFirst("%s", str);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plr == null) {
|
||||
PlotSquared.log(msg);
|
||||
} else {
|
||||
sendMessage(plr, msg, c.usePrefix());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import java.util.List;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
|
||||
@ -88,7 +88,7 @@ public class SetBlockFast extends SetBlockManager {
|
||||
if (chunks.size() == 0) {
|
||||
return;
|
||||
}
|
||||
if (!PlotHelper.canSendChunk) {
|
||||
if (!MainUtil.canSendChunk) {
|
||||
final World world = chunks.get(0).getWorld();
|
||||
for (final Chunk chunk : chunks) {
|
||||
world.refreshChunk(chunk.getX(), chunk.getZ());
|
||||
@ -98,7 +98,7 @@ public class SetBlockFast extends SetBlockManager {
|
||||
try {
|
||||
SendChunk.sendChunk(chunks);
|
||||
} catch (final Throwable e) {
|
||||
PlotHelper.canSendChunk = false;
|
||||
MainUtil.canSendChunk = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
@ -128,7 +128,7 @@ public class SetBlockFast_1_8 extends SetBlockManager {
|
||||
if (chunks.size() == 0) {
|
||||
return;
|
||||
}
|
||||
if (!PlotHelper.canSendChunk) {
|
||||
if (!MainUtil.canSendChunk) {
|
||||
final World world = chunks.get(0).getWorld();
|
||||
for (final Chunk chunk : chunks) {
|
||||
world.refreshChunk(chunk.getX(), chunk.getZ());
|
||||
@ -138,7 +138,7 @@ public class SetBlockFast_1_8 extends SetBlockManager {
|
||||
try {
|
||||
SendChunk.sendChunk(chunks);
|
||||
} catch (final Throwable e) {
|
||||
PlotHelper.canSendChunk = false;
|
||||
MainUtil.canSendChunk = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user