mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2025-08-07 13:03:06 +00:00
A whole loads of rewritez
This commit is contained in:
parent
8e499dffb2
commit
ebe80350dc
64 changed files with 1536 additions and 1806 deletions
|
@ -20,31 +20,20 @@
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
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.object.*;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
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.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.PlotCluster;
|
||||
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.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
/**
|
||||
* plot functions
|
||||
*
|
||||
|
@ -55,13 +44,13 @@ public class MainUtil {
|
|||
public static boolean canSendChunk = false;
|
||||
public static boolean canSetFast = true;
|
||||
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<>();
|
||||
static long state = 1;
|
||||
static PseudoRandom random = new PseudoRandom();
|
||||
|
||||
public static boolean isPlotArea(final Location location) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(location.getWorld());
|
||||
if (plotworld.TYPE == 2) {
|
||||
return ClusterManager.getCluster(location) != null;
|
||||
}
|
||||
|
@ -101,21 +90,21 @@ public class MainUtil {
|
|||
}
|
||||
else {
|
||||
if (worldname == null) {
|
||||
if (PlotSquared.getPlotWorlds().size() == 0) {
|
||||
if (PlotSquared.getInstance().getPlotWorlds().size() == 0) {
|
||||
if (message) MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||
return null;
|
||||
}
|
||||
worldname = PlotSquared.getPlotWorlds().iterator().next();
|
||||
worldname = PlotSquared.getInstance().getPlotWorlds().iterator().next();
|
||||
}
|
||||
for (Plot p : PlotSquared.getPlots(worldname).values()) {
|
||||
for (Plot p : PlotSquared.getInstance().getPlots(worldname).values()) {
|
||||
String name = p.settings.getAlias();
|
||||
if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
for (String world : PlotSquared.getPlotWorlds()) {
|
||||
for (String world : PlotSquared.getInstance().getPlotWorlds()) {
|
||||
if (!world.endsWith(worldname)) {
|
||||
for (Plot p : PlotSquared.getPlots(world).values()) {
|
||||
for (Plot p : PlotSquared.getInstance().getPlots(world).values()) {
|
||||
String name = p.settings.getAlias();
|
||||
if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
|
||||
return p;
|
||||
|
@ -124,7 +113,7 @@ public class MainUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (worldname == null || !PlotSquared.isPlotWorld(worldname)) {
|
||||
if (worldname == null || !PlotSquared.getInstance().isPlotWorld(worldname)) {
|
||||
if (message) MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||
System.out.print("INVALID WORLD: ");
|
||||
return null;
|
||||
|
@ -148,7 +137,7 @@ public class MainUtil {
|
|||
* @return boolean
|
||||
*/
|
||||
public static boolean mergePlots(final PlotPlayer player, final String world, final ArrayList<PlotId> plotIds) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY) {
|
||||
final double cost = plotIds.size() * plotworld.MERGE_PRICE;
|
||||
if (cost > 0d) {
|
||||
|
@ -172,11 +161,11 @@ public class MainUtil {
|
|||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
manager.startPlotUnlink(plotworld, ids);
|
||||
for (final PlotId id : ids) {
|
||||
final Plot myplot = PlotSquared.getPlots(world).get(id);
|
||||
final Plot myplot = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
if (plot == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -223,7 +212,7 @@ public class MainUtil {
|
|||
}
|
||||
|
||||
public static boolean isPlotAreaAbs(final Location location) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(location.getWorld());
|
||||
if (plotworld.TYPE == 2) {
|
||||
return ClusterManager.getClusterAbs(location) != null;
|
||||
}
|
||||
|
@ -231,19 +220,19 @@ public class MainUtil {
|
|||
}
|
||||
|
||||
public static boolean isPlotRoad(final Location location) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(location.getWorld());
|
||||
if (plotworld.TYPE == 2) {
|
||||
PlotCluster cluster = ClusterManager.getCluster(location);
|
||||
if (cluster == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
PlotManager manager = PlotSquared.getPlotManager(location.getWorld());
|
||||
PlotManager manager = PlotSquared.getInstance().getPlotManager(location.getWorld());
|
||||
return manager.getPlotId(plotworld, location.getX(), location.getY(), location.getZ()) == null;
|
||||
}
|
||||
|
||||
public static boolean isPlotArea(final Plot plot) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
if (plotworld.TYPE == 2) {
|
||||
return ClusterManager.getCluster(plot) != null;
|
||||
}
|
||||
|
@ -263,9 +252,9 @@ public class MainUtil {
|
|||
}
|
||||
|
||||
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
||||
|
||||
final Plot plot1 = PlotSquared.getPlots(world).get(pos1);
|
||||
final Plot plot2 = PlotSquared.getPlots(world).get(pos2);
|
||||
|
||||
final Plot plot1 = PlotSquared.getInstance().getPlots(world).get(pos1);
|
||||
final Plot plot2 = PlotSquared.getInstance().getPlots(world).get(pos2);
|
||||
|
||||
if (plot1 != null) {
|
||||
pos1 = getBottomPlot(plot1).id;
|
||||
|
@ -304,7 +293,7 @@ public class MainUtil {
|
|||
public static int getPlayerPlotCount(final String world, final PlotPlayer plr) {
|
||||
final UUID uuid = plr.getUUID();
|
||||
int count = 0;
|
||||
for (final Plot plot : PlotSquared.getPlots(world).values()) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlots(world).values()) {
|
||||
if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) {
|
||||
count++;
|
||||
}
|
||||
|
@ -314,17 +303,17 @@ public class MainUtil {
|
|||
|
||||
public static int getPlayerPlotCount(final PlotPlayer plr) {
|
||||
int count = 0;
|
||||
for (final String world : PlotSquared.getPlotWorldsString()) {
|
||||
for (final String world : PlotSquared.getInstance().getPlotWorldsString()) {
|
||||
count += getPlayerPlotCount(world, plr);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static Location getDefaultHome(Plot plot) {
|
||||
PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||
PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
if (plotworld.DEFAULT_HOME != null) {
|
||||
final Location bot = getPlotBottomLoc(plot.world, plot.id);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(plot.world);
|
||||
final int x;
|
||||
final int z;
|
||||
if (plotworld.DEFAULT_HOME.x == Integer.MAX_VALUE && plotworld.DEFAULT_HOME.z == Integer.MAX_VALUE) {
|
||||
|
@ -336,15 +325,15 @@ public class MainUtil {
|
|||
x = bot.getX() + plotworld.DEFAULT_HOME.x;
|
||||
z = bot.getZ() + plotworld.DEFAULT_HOME.z;
|
||||
}
|
||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY());
|
||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getInstance().getPlotWorld(plot.world), plot).getY());
|
||||
return new Location(plot.world, x, y + 1, z);
|
||||
}
|
||||
final Location top = getPlotTopLoc(plot.world, plot.id);
|
||||
final Location bot = getPlotBottomLoc(plot.world, plot.id);
|
||||
final int x = ((top.getX() - bot.getX()) / 2) + bot.getX();
|
||||
final int z = bot.getZ();
|
||||
PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY());
|
||||
PlotManager manager = PlotSquared.getInstance().getPlotManager(plot.world);
|
||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getInstance().getPlotWorld(plot.world), plot).getY());
|
||||
return new Location(plot.world, x, y + 1, z);
|
||||
}
|
||||
|
||||
|
@ -355,7 +344,7 @@ public class MainUtil {
|
|||
|
||||
if (result) {
|
||||
final Location location;
|
||||
if (PlotSquared.getPlotWorld(plot.world).HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
||||
if (PlotSquared.getInstance().getPlotWorld(plot.world).HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
||||
location = MainUtil.getPlotHome(bot.world, bot);
|
||||
}
|
||||
else {
|
||||
|
@ -391,21 +380,21 @@ public class MainUtil {
|
|||
|
||||
public static int getBorder(final String worldname) {
|
||||
if (worldBorder.containsKey(worldname)) {
|
||||
PlotSquared.getPlotWorld(worldname);
|
||||
PlotSquared.getInstance().getPlotWorld(worldname);
|
||||
return worldBorder.get(worldname) + 16;
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public static void setupBorder(final String world) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (!plotworld.WORLD_BORDER) {
|
||||
return;
|
||||
}
|
||||
if (!worldBorder.containsKey(world)) {
|
||||
worldBorder.put(world, 0);
|
||||
}
|
||||
for (final Plot plot : PlotSquared.getPlots(world).values()) {
|
||||
for (final Plot plot : PlotSquared.getInstance().getPlots(world).values()) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
}
|
||||
|
@ -495,8 +484,8 @@ public class MainUtil {
|
|||
}
|
||||
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);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
|
||||
boolean result = EventUtil.manager.callMerge(world, getPlot(world, pos1), plotIds);
|
||||
if (!result) {
|
||||
|
@ -509,7 +498,7 @@ public class MainUtil {
|
|||
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);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
Plot plot2 = null;
|
||||
if (removeRoads) {
|
||||
removeSign(plot);
|
||||
|
@ -523,7 +512,7 @@ public class MainUtil {
|
|||
}
|
||||
}
|
||||
if (!plot.settings.getMerged(1)) {
|
||||
plot2 = PlotSquared.getPlots(world).get(new PlotId(x + 1, y));
|
||||
plot2 = PlotSquared.getInstance().getPlots(world).get(new PlotId(x + 1, y));
|
||||
mergePlot(world, plot, plot2, removeRoads);
|
||||
plot.settings.setMerged(1, true);
|
||||
plot2.settings.setMerged(3, true);
|
||||
|
@ -531,7 +520,7 @@ public class MainUtil {
|
|||
}
|
||||
if (ly) {
|
||||
if (!plot.settings.getMerged(2)) {
|
||||
plot2 = PlotSquared.getPlots(world).get(new PlotId(x, y + 1));
|
||||
plot2 = PlotSquared.getInstance().getPlots(world).get(new PlotId(x, y + 1));
|
||||
mergePlot(world, plot, plot2, removeRoads);
|
||||
plot.settings.setMerged(2, true);
|
||||
plot2.settings.setMerged(0, true);
|
||||
|
@ -542,7 +531,7 @@ public class MainUtil {
|
|||
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);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
DBFunc.setMerged(world, plot, plot.settings.getMerged());
|
||||
}
|
||||
}
|
||||
|
@ -564,7 +553,7 @@ public class MainUtil {
|
|||
ChunkManager.manager.regenerateRegion(pos1, pos2, null);
|
||||
}
|
||||
else {
|
||||
PlotSquared.getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot);
|
||||
PlotSquared.getInstance().getPlotManager(plot.world).removeRoadSouthEast(plotworld, plot);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -582,7 +571,7 @@ public class MainUtil {
|
|||
ChunkManager.manager.regenerateRegion(pos1, pos2, null);
|
||||
}
|
||||
else {
|
||||
PlotSquared.getPlotManager(plot.world).removeRoadEast(plotworld, plot);
|
||||
PlotSquared.getInstance().getPlotManager(plot.world).removeRoadEast(plotworld, plot);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -600,7 +589,7 @@ public class MainUtil {
|
|||
ChunkManager.manager.regenerateRegion(pos1, pos2, null);
|
||||
}
|
||||
else {
|
||||
PlotSquared.getPlotManager(plot.world).removeRoadSouth(plotworld, plot);
|
||||
PlotSquared.getInstance().getPlotManager(plot.world).removeRoadSouth(plotworld, plot);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -614,7 +603,7 @@ public class MainUtil {
|
|||
* @param greaterPlot
|
||||
*/
|
||||
public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, final boolean removeRoads) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (lesserPlot.id.x.equals(greaterPlot.id.x)) {
|
||||
if (!lesserPlot.settings.getMerged(2)) {
|
||||
lesserPlot.settings.setMerged(2, true);
|
||||
|
@ -636,8 +625,8 @@ public class MainUtil {
|
|||
|
||||
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 PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
if (!plotworld.ALLOW_SIGNS) {
|
||||
return;
|
||||
}
|
||||
|
@ -649,8 +638,8 @@ public class MainUtil {
|
|||
if (name == null) {
|
||||
name = "unknown";
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(p.world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(p.world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(p.world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(p.world);
|
||||
if (plotworld.ALLOW_SIGNS) {
|
||||
final Location loc = manager.getSignLoc(plotworld, p);
|
||||
final String id = p.id.x + ";" + p.id.y;
|
||||
|
@ -726,7 +715,7 @@ public class MainUtil {
|
|||
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);
|
||||
final Plot myplot = PlotSquared.getInstance().getPlots(world).get(myid);
|
||||
if ((myplot == null) || myplot.owner == null || !(myplot.owner.equals(uuid))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -747,8 +736,8 @@ public class MainUtil {
|
|||
return;
|
||||
}
|
||||
final String world = plot.world;
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().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);
|
||||
|
@ -768,7 +757,7 @@ public class MainUtil {
|
|||
updateWorldBorder(plot);
|
||||
}
|
||||
final Plot p = createPlotAbs(uuid, plot);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(plot.world);
|
||||
if (plotworld.AUTO_MERGE) {
|
||||
autoMerge(plot.world, p, uuid);
|
||||
}
|
||||
|
@ -781,7 +770,7 @@ public class MainUtil {
|
|||
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);
|
||||
PlotSquared.getInstance().updatePlot(p);
|
||||
DBFunc.createPlotAndSettings(p);
|
||||
return p;
|
||||
}
|
||||
|
@ -820,7 +809,7 @@ public class MainUtil {
|
|||
}
|
||||
|
||||
public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final int prime = 31;
|
||||
int h = 1;
|
||||
|
@ -828,7 +817,7 @@ public class MainUtil {
|
|||
h = (prime * h) + pos1.getZ();
|
||||
state = h;
|
||||
System.currentTimeMillis();
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
runners.put(plot, 1);
|
||||
if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) {
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
|
@ -959,7 +948,7 @@ public class MainUtil {
|
|||
final Plot plot = getPlot(w, plotid);
|
||||
final BlockLoc home = plot.settings.getPosition();
|
||||
final Location bot = getPlotBottomLoc(w, plotid);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(w);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(w);
|
||||
if ((home == null) || ((home.x == 0) && (home.z == 0))) {
|
||||
return getDefaultHome(plot);
|
||||
} else {
|
||||
|
@ -992,8 +981,8 @@ public class MainUtil {
|
|||
* @return Location top
|
||||
*/
|
||||
public static Location getPlotTopLocAbs(final String world, final PlotId id) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
return manager.getPlotTopLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
|
@ -1007,8 +996,8 @@ public class MainUtil {
|
|||
* @return Location bottom
|
||||
*/
|
||||
public static Location getPlotBottomLocAbs(final String world, final PlotId id) {
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
|
@ -1034,12 +1023,12 @@ public class MainUtil {
|
|||
* @return Location top of mega plot
|
||||
*/
|
||||
public static Location getPlotTopLoc(final String world, PlotId id) {
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
if (plot != null) {
|
||||
id = getTopPlot(plot).id;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
return manager.getPlotTopLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
|
@ -1053,12 +1042,12 @@ public class MainUtil {
|
|||
* @return Location bottom of mega plot
|
||||
*/
|
||||
public static Location getPlotBottomLoc(final String world, PlotId id) {
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(world).get(id);
|
||||
if (plot != null) {
|
||||
id = getBottomPlot(plot).id;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||
}
|
||||
|
||||
|
@ -1087,18 +1076,15 @@ public class MainUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (plot.owner != null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return plot.owner == null;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (PlotSquared.getInstance().getPlots(world).get(id) != null) {
|
||||
if (PlotSquared.getInstance().getPlots(world).get(id).owner != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1108,8 +1094,8 @@ public class MainUtil {
|
|||
}
|
||||
|
||||
public static boolean swap(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||
Plot p1 = PlotSquared.getPlots(world).get(current);
|
||||
Plot p2 = PlotSquared.getPlots(world).get(newPlot);
|
||||
Plot p1 = PlotSquared.getInstance().getPlots(world).get(current);
|
||||
Plot p2 = PlotSquared.getInstance().getPlots(world).get(newPlot);
|
||||
if (p1==null || p2 == null || p1.owner == null || !p1.owner.equals(p2.owner)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1121,20 +1107,20 @@ public class MainUtil {
|
|||
p1.id.y = p2.id.y.intValue();
|
||||
p2.id.x = temp.x;
|
||||
p2.id.y = temp.y;
|
||||
PlotSquared.getPlots(world).remove(p1.id);
|
||||
PlotSquared.getPlots(world).remove(p2.id);
|
||||
PlotSquared.getInstance().getPlots(world).remove(p1.id);
|
||||
PlotSquared.getInstance().getPlots(world).remove(p2.id);
|
||||
p1.id.recalculateHash();
|
||||
p2.id.recalculateHash();
|
||||
PlotSquared.getPlots(world).put(p1.id, p1);
|
||||
PlotSquared.getPlots(world).put(p2.id, p2);
|
||||
PlotSquared.getInstance().getPlots(world).put(p1.id, p1);
|
||||
PlotSquared.getInstance().getPlots(world).put(p2.id, p2);
|
||||
// Swap database
|
||||
DBFunc.dbManager.swapPlots(p2, p1);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean swapData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||
Plot p1 = PlotSquared.getPlots(world).get(current);
|
||||
Plot p2 = PlotSquared.getPlots(world).get(newPlot);
|
||||
Plot p1 = PlotSquared.getInstance().getPlots(world).get(current);
|
||||
Plot p2 = PlotSquared.getInstance().getPlots(world).get(newPlot);
|
||||
if (p1 == null || p1.owner == null) {
|
||||
if (p2 != null && p2.owner != null) {
|
||||
moveData(p2, p1, whenDone);
|
||||
|
@ -1155,12 +1141,12 @@ public class MainUtil {
|
|||
p1.id.y = p2.id.y.intValue();
|
||||
p2.id.x = temp.x;
|
||||
p2.id.y = temp.y;
|
||||
PlotSquared.getPlots(world).remove(p1.id);
|
||||
PlotSquared.getPlots(world).remove(p2.id);
|
||||
PlotSquared.getInstance().getPlots(world).remove(p1.id);
|
||||
PlotSquared.getInstance().getPlots(world).remove(p2.id);
|
||||
p1.id.recalculateHash();
|
||||
p2.id.recalculateHash();
|
||||
PlotSquared.getPlots(world).put(p1.id, p1);
|
||||
PlotSquared.getPlots(world).put(p2.id, p2);
|
||||
PlotSquared.getInstance().getPlots(world).put(p1.id, p1);
|
||||
PlotSquared.getInstance().getPlots(world).put(p2.id, p2);
|
||||
// Swap database
|
||||
DBFunc.dbManager.swapPlots(p2, p1);
|
||||
TaskManager.runTask(whenDone);
|
||||
|
@ -1184,12 +1170,12 @@ public class MainUtil {
|
|||
final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
|
||||
for (final PlotId id : selection) {
|
||||
DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
|
||||
final Plot plot = PlotSquared.getPlots(plot1.world).get(id);
|
||||
PlotSquared.getPlots(plot1.world).remove(id);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(plot1.world).get(id);
|
||||
PlotSquared.getInstance().getPlots(plot1.world).remove(id);
|
||||
plot.id.x += offset_x;
|
||||
plot.id.y += offset_y;
|
||||
plot.id.recalculateHash();
|
||||
PlotSquared.getPlots(plot2.world).put(plot.id, plot);
|
||||
PlotSquared.getInstance().getPlots(plot2.world).put(plot.id, plot);
|
||||
}
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return true;
|
||||
|
@ -1214,12 +1200,12 @@ public class MainUtil {
|
|||
for (final PlotId id : selection) {
|
||||
String worldOriginal = plot1.world;
|
||||
PlotId idOriginal = new PlotId(id.x, id.y);
|
||||
final Plot plot = PlotSquared.getPlots(plot1.world).get(id);
|
||||
PlotSquared.getPlots(plot1.world).remove(id);
|
||||
final Plot plot = PlotSquared.getInstance().getPlots(plot1.world).get(id);
|
||||
PlotSquared.getInstance().getPlots(plot1.world).remove(id);
|
||||
plot.id.x += offset_x;
|
||||
plot.id.y += offset_y;
|
||||
plot.id.recalculateHash();
|
||||
PlotSquared.getPlots(plot2.world).put(plot.id, plot);
|
||||
PlotSquared.getInstance().getPlots(plot2.world).put(plot.id, plot);
|
||||
DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
|
||||
}
|
||||
ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() {
|
||||
|
@ -1282,7 +1268,7 @@ public class MainUtil {
|
|||
DBFunc.setDenied(world, plot, denied);
|
||||
}
|
||||
}
|
||||
PlotSquared.getPlots(world).put(plot.id, plot);
|
||||
PlotSquared.getInstance().getPlots(world).put(plot.id, plot);
|
||||
}
|
||||
ChunkManager.manager.copyRegion(bot1, top, bot2, whenDone);
|
||||
return true;
|
||||
|
@ -1449,14 +1435,14 @@ public class MainUtil {
|
|||
|
||||
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));
|
||||
final Plot p = PlotSquared.getInstance().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));
|
||||
final Plot p = PlotSquared.getInstance().getPlots(plot.world).get(new PlotId(plot.id.x - 1, plot.id.y));
|
||||
if (p == null) {
|
||||
return plot;
|
||||
}
|
||||
|
@ -1467,14 +1453,14 @@ public class MainUtil {
|
|||
|
||||
public static Plot getTopPlot(final Plot plot) {
|
||||
if (plot.settings.getMerged(2)) {
|
||||
final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1));
|
||||
final Plot p = PlotSquared.getInstance().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1));
|
||||
if (p == null) {
|
||||
return plot;
|
||||
}
|
||||
return getTopPlot(p);
|
||||
}
|
||||
if (plot.settings.getMerged(1)) {
|
||||
final Plot p = PlotSquared.getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y));
|
||||
final Plot p = PlotSquared.getInstance().getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y));
|
||||
if (p == null) {
|
||||
return plot;
|
||||
}
|
||||
|
@ -1501,8 +1487,8 @@ public class MainUtil {
|
|||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
if (PlotSquared.getPlots(world).containsKey(id)) {
|
||||
return PlotSquared.getPlots(world).get(id);
|
||||
if (PlotSquared.getInstance().getPlots(world).containsKey(id)) {
|
||||
return PlotSquared.getInstance().getPlots(world).get(id);
|
||||
}
|
||||
return new Plot(id, null, new ArrayList<UUID>(), new ArrayList<UUID>(), world);
|
||||
}
|
||||
|
@ -1514,11 +1500,11 @@ public class MainUtil {
|
|||
*/
|
||||
public static PlotId getPlotAbs(final Location loc) {
|
||||
final String world = loc.getWorld();
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
if (manager == null) {
|
||||
return null;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().getPlotWorld(world);
|
||||
return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
|
@ -1529,11 +1515,11 @@ public class MainUtil {
|
|||
*/
|
||||
public static PlotId getPlotId(final Location loc) {
|
||||
final String world = loc.getWorld();
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotManager manager = PlotSquared.getInstance().getPlotManager(world);
|
||||
if (manager == null) {
|
||||
return null;
|
||||
}
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final PlotWorld plotworld = PlotSquared.getInstance().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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue