mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-28 19:54:43 +02:00
restructure a couple things.
This commit is contained in:
@ -52,7 +52,7 @@ public class Add extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class Auto extends SubCommand {
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(worldname);
|
||||
if (plotworld.TYPE == 2) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(new Location(worldname, loc.getX(), loc.getY(), loc.getZ()));
|
||||
final Plot plot = MainUtil.getPlotAbs(new Location(worldname, loc.getX(), loc.getY(), loc.getZ()));
|
||||
if (plot == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -180,8 +180,8 @@ 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 = MainUtil.getPlot(worldname, currentId);
|
||||
if (MainUtil.canClaim(plr, current) && (current.getSettings().isMerged() == false) && cluster.equals(current.getCluster())) {
|
||||
final Plot current = MainUtil.getPlotAbs(worldname, currentId);
|
||||
if (MainUtil.canClaim(plr, current) && (current.isMerged() == false) && cluster.equals(current.getCluster())) {
|
||||
Claim.claimPlot(plr, current, true, true);
|
||||
return true;
|
||||
}
|
||||
@ -194,7 +194,7 @@ public class Auto extends SubCommand {
|
||||
boolean br = false;
|
||||
if ((size_x == 1) && (size_z == 1)) {
|
||||
while (!br) {
|
||||
final Plot plot = MainUtil.getPlot(worldname, getLastPlot(worldname));
|
||||
final Plot plot = MainUtil.getPlotAbs(worldname, getLastPlot(worldname));
|
||||
if (MainUtil.canClaim(plr, plot)) {
|
||||
Claim.claimPlot(plr, plot, true, true);
|
||||
br = true;
|
||||
@ -217,7 +217,7 @@ public class Auto extends SubCommand {
|
||||
if (MainUtil.canClaim(plr, worldname, start, end)) {
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
final Plot plot = MainUtil.getPlot(worldname, new PlotId(i, j));
|
||||
final Plot plot = MainUtil.getPlotAbs(worldname, new PlotId(i, j));
|
||||
final boolean teleport = ((i == end.x) && (j == end.y));
|
||||
Claim.claimPlot(plr, plot, teleport, true);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class BO3 extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -20,6 +20,9 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -58,64 +61,54 @@ public class Buy extends SubCommand {
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
Set<Plot> plots;
|
||||
Plot plot;
|
||||
if (args.length > 0) {
|
||||
try {
|
||||
final String[] split = args[0].split(";");
|
||||
final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
plot = MainUtil.getPlot(world, id);
|
||||
plot = MainUtil.getPlotAbs(world, id);
|
||||
plots = MainUtil.getConnectedPlots(plot);
|
||||
} catch (final Exception e) {
|
||||
return sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
}
|
||||
} else {
|
||||
plot = MainUtil.getPlot(loc);
|
||||
plot = MainUtil.getPlotAbs(loc);
|
||||
plots = MainUtil.getConnectedPlots(plot);
|
||||
}
|
||||
if (plot == null) {
|
||||
if (plots == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(world, plr);
|
||||
if (currentPlots >= MainUtil.getAllowedPlots(plr)) {
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
return sendMessage(plr, C.PLOT_UNOWNED);
|
||||
}
|
||||
if (PlotHandler.isOwner(plot, plr.getUUID())) {
|
||||
return sendMessage(plr, C.CANNOT_BUY_OWN);
|
||||
final int currentPlots = MainUtil.getPlayerPlotCount(plr) + plots.size();
|
||||
if (currentPlots > MainUtil.getAllowedPlots(plr)) {
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "price");
|
||||
if (flag == null) {
|
||||
return sendMessage(plr, C.NOT_FOR_SALE);
|
||||
}
|
||||
double initPrice = (double) flag.getValue();
|
||||
double price = initPrice;
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id2 = MainUtil.getTopPlot(plot).id;
|
||||
final int size = MainUtil.getPlotSelectionIds(id, id2).size();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
if (plotworld.USE_ECONOMY) {
|
||||
price += plotworld.PLOT_PRICE * size;
|
||||
initPrice += plotworld.SELL_PRICE * size;
|
||||
if (plot.isOwner(plr.getUUID())) {
|
||||
return sendMessage(plr, C.CANNOT_BUY_OWN);
|
||||
}
|
||||
double price = (double) flag.getValue();
|
||||
if ((EconHandler.manager != null) && (price > 0d)) {
|
||||
if (EconHandler.manager.getMoney(plr) < price) {
|
||||
return sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + price);
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||
EconHandler.manager.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), initPrice);
|
||||
EconHandler.manager.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
|
||||
final PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
||||
if (owner != null) {
|
||||
sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + "");
|
||||
sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), price + "");
|
||||
}
|
||||
FlagManager.removePlotFlag(plot, "price");
|
||||
}
|
||||
final Plot top = MainUtil.getTopPlot(plot);
|
||||
|
||||
for (final PlotId myId : MainUtil.getPlotSelectionIds(plot.id, top.id)) {
|
||||
final Plot myPlot = MainUtil.getPlot(plot.world, myId);
|
||||
myPlot.owner = plr.getUUID();
|
||||
DBFunc.setOwner(plot, myPlot.owner);
|
||||
for (final Plot current : plots) {
|
||||
plot.setOwner(plr.getUUID());
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.CLAIMED);
|
||||
return true;
|
||||
|
@ -51,7 +51,7 @@ public class Claim extends SubCommand {
|
||||
}
|
||||
|
||||
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) {
|
||||
if (plot.hasOwner() || plot.getSettings().isMerged()) {
|
||||
if (plot.hasOwner() || plot.isMerged()) {
|
||||
return false;
|
||||
}
|
||||
final boolean result = EventUtil.manager.callClaim(player, plot, false);
|
||||
@ -94,13 +94,12 @@ public class Claim extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
|
||||
String schematic = "";
|
||||
if (args.length >= 1) {
|
||||
schematic = args[0];
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
@ -59,10 +60,10 @@ public class Clear extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
plot = MainUtil.getPlot(loc.getWorld(), id);
|
||||
plot = MainUtil.getPlotAbs(loc.getWorld(), id);
|
||||
}
|
||||
} else {
|
||||
plot = MainUtil.getPlot(loc);
|
||||
plot = MainUtil.getPlotAbs(loc);
|
||||
}
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot clear [X;Z|mine]");
|
||||
@ -71,11 +72,10 @@ public class Clear extends SubCommand {
|
||||
// if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||
// return sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
// }
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) {
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) {
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
assert plot != null;
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
if (plot.getRunning() != 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
@ -91,19 +91,29 @@ public class Clear extends SubCommand {
|
||||
final boolean result = MainUtil.clearAsPlayer(plot, plot.owner == null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// If the state changes, then mark it as no longer done
|
||||
if (FlagManager.getPlotFlag(plot, "done") != null) {
|
||||
FlagManager.removePlotFlag(plot, "done");
|
||||
}
|
||||
if (FlagManager.getPlotFlag(plot, "analysis") != null) {
|
||||
FlagManager.removePlotFlag(plot, "analysis");
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||
plot.unlink();
|
||||
SetBlockQueue.addNotify(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
// If the state changes, then mark it as no longer done
|
||||
if (FlagManager.getPlotFlag(plot, "done") != null) {
|
||||
FlagManager.removePlotFlag(plot, "done");
|
||||
}
|
||||
if (FlagManager.getPlotFlag(plot, "analysis") != null) {
|
||||
FlagManager.removePlotFlag(plot, "analysis");
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
}
|
||||
else {
|
||||
plot.addRunning();
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_CLEAR && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
|
||||
|
@ -59,10 +59,10 @@ public class Comment extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
index = 2;
|
||||
plot = MainUtil.getPlot(loc.getWorld(), id);
|
||||
plot = MainUtil.getPlotAbs(loc.getWorld(), id);
|
||||
} else {
|
||||
index = 1;
|
||||
plot = MainUtil.getPlot(loc);
|
||||
plot = MainUtil.getPlotAbs(loc);
|
||||
}
|
||||
if (!inbox.canWrite(plot, player)) {
|
||||
sendMessage(player, C.NO_PERM_INBOX, "");
|
||||
|
@ -23,8 +23,10 @@ package com.intellectualcrafters.plot.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -33,6 +35,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "condense", permission = "plots.admin", description = "Condense a plotworld", category = CommandCategory.DEBUG, requiredType = RequiredType.CONSOLE)
|
||||
@ -70,18 +73,53 @@ public class Condense extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final int radius = Integer.parseInt(args[2]);
|
||||
final Collection<Plot> plots = PS.get().getPlotsInWorld(worldname);
|
||||
final int size = plots.size();
|
||||
ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlotsInWorld(worldname));
|
||||
// remove non base plots
|
||||
Iterator<Plot> iter = plots.iterator();
|
||||
int maxSize = 0;
|
||||
ArrayList<Integer> sizes = new ArrayList<>();
|
||||
while (iter.hasNext()) {
|
||||
Plot plot = iter.next();
|
||||
if (!plot.isBasePlot()) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
int size = plot.getConnectedPlots().size();
|
||||
if (size > maxSize) {
|
||||
maxSize = size;
|
||||
}
|
||||
sizes.add(size - 1);
|
||||
}
|
||||
// Sort plots by size (buckets?)]
|
||||
ArrayList<Plot>[] buckets = new ArrayList[maxSize];
|
||||
for (int i = 0; i < plots.size(); i++) {
|
||||
Plot plot = plots.get(i);
|
||||
int size = sizes.get(i);
|
||||
ArrayList<Plot> array = buckets[size];
|
||||
if (array == null) {
|
||||
array = new ArrayList<Plot>();
|
||||
buckets[size] = array;
|
||||
}
|
||||
array.add(plot);
|
||||
}
|
||||
final ArrayList<Plot> allPlots = new ArrayList<Plot>(plots.size());
|
||||
for (int i = buckets.length - 1; i >= 0; i--) {
|
||||
ArrayList<Plot> array = buckets[i];
|
||||
if (array != null) {
|
||||
allPlots.addAll(array);
|
||||
}
|
||||
}
|
||||
final int size = allPlots.size();
|
||||
final int minimum_radius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||
if (radius < minimum_radius) {
|
||||
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
||||
return false;
|
||||
}
|
||||
final List<PlotId> to_move = new ArrayList<>(getPlots(plots, radius));
|
||||
final List<PlotId> to_move = new ArrayList<>(getPlots(allPlots, radius));
|
||||
final List<PlotId> free = new ArrayList<>();
|
||||
PlotId start = new PlotId(0, 0);
|
||||
while ((start.x <= minimum_radius) && (start.y <= minimum_radius)) {
|
||||
final Plot plot = MainUtil.getPlot(worldname, start);
|
||||
final Plot plot = MainUtil.getPlotAbs(worldname, start);
|
||||
if (!plot.hasOwner()) {
|
||||
free.add(plot.id);
|
||||
}
|
||||
@ -91,53 +129,54 @@ public class Condense extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "NO FREE PLOTS FOUND");
|
||||
return false;
|
||||
}
|
||||
MainUtil.move(MainUtil.getPlot(worldname, to_move.get(0)), MainUtil.getPlot(worldname, free.get(0)), new Runnable() {
|
||||
MainUtil.sendMessage(plr, "TASK STARTED...");
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!TASK) {
|
||||
MainUtil.sendMessage(plr, "CONDENSE TASK CANCELLED");
|
||||
return;
|
||||
MainUtil.sendMessage(plr, "TASK CANCELLED.");
|
||||
}
|
||||
to_move.remove(0);
|
||||
free.remove(0);
|
||||
int index = 0;
|
||||
for (final PlotId id : to_move) {
|
||||
final Plot plot = MainUtil.getPlot(worldname, id);
|
||||
if (plot.hasOwner()) {
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
for (int i = 0; i < index; i++) {
|
||||
to_move.remove(0);
|
||||
}
|
||||
index = 0;
|
||||
for (final PlotId id : free) {
|
||||
final Plot plot = MainUtil.getPlot(worldname, id);
|
||||
if (!plot.hasOwner()) {
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
for (int i = 0; i < index; i++) {
|
||||
free.remove(0);
|
||||
}
|
||||
if (to_move.size() == 0) {
|
||||
MainUtil.sendMessage(plr, "TASK COMPLETE. PLEASE VERIFY THAT NO NEW PLOTS HAVE BEEN CLAIMED DURING TASK.");
|
||||
if (allPlots.size() == 0) {
|
||||
TASK = false;
|
||||
MainUtil.sendMessage(plr, "TASK COMPLETE. PLEASE VERIFY THAT NO NEW PLOTS HAVE BEEN CLAIMED DURING TASK.");
|
||||
return;
|
||||
}
|
||||
final Runnable task = this;
|
||||
final Plot origin = allPlots.remove(0);
|
||||
int i = 0;
|
||||
while (free.size() > i) {
|
||||
final Plot possible = MainUtil.getPlotAbs(origin.world, free.get(i));
|
||||
if (possible.owner != null) {
|
||||
free.remove(i);
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
final AtomicBoolean result = new AtomicBoolean(false);
|
||||
result.set(MainUtil.move(origin, possible, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (result.get()) {
|
||||
MainUtil.sendMessage(plr, "Moving: " + origin + " -> " + possible);
|
||||
TaskManager.runTaskLater(task, 1);
|
||||
}
|
||||
}
|
||||
}, false));
|
||||
if (result.get()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (free.size() == 0) {
|
||||
MainUtil.sendMessage(plr, "TASK FAILED. NO FREE PLOTS FOUND!");
|
||||
TASK = false;
|
||||
MainUtil.sendMessage(plr, "TASK FAILED. NO FREE PLOTS FOUND!");
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, "MOVING " + to_move.get(0) + " to " + free.get(0));
|
||||
MainUtil.move(MainUtil.getPlot(worldname, to_move.get(0)), MainUtil.getPlot(worldname, free.get(0)), this);
|
||||
if (i >= free.size()) {
|
||||
MainUtil.sendMessage(plr, "SKIPPING COMPLEX PLOT: " + origin);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
TASK = true;
|
||||
MainUtil.sendMessage(plr, "TASK STARTED...");
|
||||
TaskManager.runTaskAsync(run);
|
||||
return true;
|
||||
}
|
||||
case "stop": {
|
||||
|
@ -41,7 +41,7 @@ public class Continue extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class Continue extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (!plot.getSettings().flags.containsKey("done")) {
|
||||
if (!plot.getFlags().containsKey("done")) {
|
||||
MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
@ -57,7 +57,7 @@ public class Continue extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.continue");
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
@ -45,29 +44,30 @@ public class Copy extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot1 = MainUtil.getPlot(loc);
|
||||
final Plot plot1 = MainUtil.getPlotAbs(loc);
|
||||
if (plot1 == null) {
|
||||
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot1.isAdded(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
|
||||
if (!plot1.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
final String world = loc.getWorld();
|
||||
final PlotId plot2 = MainUtil.parseId(args[0]);
|
||||
final Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
if ((plot2 == null)) {
|
||||
return false;
|
||||
}
|
||||
if (plot1.equals(plot2)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (plot1.id.equals(plot2)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
if (!plot1.getWorld().equals(plot2.getWorld())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(plr);
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.copy(world, plot1.id, plot2, new Runnable() {
|
||||
if (MainUtil.copy(plot1, plot2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, C.COPY_SUCCESS);
|
||||
|
@ -43,7 +43,7 @@ public class CreateRoadSchematic extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
||||
final Location loc = player.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
final ArrayList<Plot> plots = new ArrayList<>();
|
||||
for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
final Plot plot = MainUtil.getPlotAbs(world, id);
|
||||
if (PS.get().getPlot(world, plot.id) != null) {
|
||||
MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
|
||||
continue;
|
||||
|
@ -1,67 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 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.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "debugclear", aliases = { "fastclear" }, description = "Clear a plot using a fast experiment algorithm", category = CommandCategory.DEBUG)
|
||||
public class DebugClear extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot == null) || !(PS.get().getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||
return sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
}
|
||||
if ((!plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) {
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(loc.getWorld(), plot.id).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(loc.getWorld(), plot.id);
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
MainUtil.runners.put(plot, 1);
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.runners.remove(plot);
|
||||
MainUtil.sendMessage(plr, "&aDone!");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
@ -160,7 +160,7 @@ public class DebugExec extends SubCommand {
|
||||
boolean async = false;
|
||||
switch (arg) {
|
||||
case "analyze": {
|
||||
final Plot plot = MainUtil.getPlot(player.getLocation());
|
||||
final Plot plot = MainUtil.getPlotAbs(player.getLocation());
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
@ -168,7 +168,7 @@ public class DebugExec extends SubCommand {
|
||||
final PlotAnalysis analysis = plot.getComplexity();
|
||||
if (analysis != null) {
|
||||
final int complexity = analysis.getComplexity();
|
||||
MainUtil.sendMessage(player, "Changes: " + analysis.changes);
|
||||
MainUtil.sendMessage(player, "Changes/column: " + (analysis.changes / 1.0));
|
||||
MainUtil.sendMessage(player, "Complexity: " + complexity);
|
||||
return true;
|
||||
}
|
||||
|
@ -1,166 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 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.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "fill",
|
||||
permission = "plots.fill",
|
||||
description = "Fill or surround a plot in bedrock",
|
||||
usage = "/plot fill",
|
||||
aliases = { "debugfill" },
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class DebugFill extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
||||
if ((args.length != 1) || (!args[0].equalsIgnoreCase("outline") && !args[0].equalsIgnoreCase("all"))) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot fill <outline|all>");
|
||||
return true;
|
||||
}
|
||||
final Location loc = player.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.fill")) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||
MainUtil.sendMessage(player, "&cPreparing task");
|
||||
MainUtil.runners.put(plot, 1);
|
||||
SetBlockQueue.addNotify(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(player, "&7 - Starting");
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
int height = 255;
|
||||
PlotBlock block = new PlotBlock((short) 7, (byte) 0);
|
||||
final PlotBlock air = new PlotBlock((short) 0, (byte) 0);
|
||||
if (args.length > 2) {
|
||||
try {
|
||||
block = new PlotBlock(Short.parseShort(args[1]), (byte) 0);
|
||||
if (args.length == 3) {
|
||||
height = Integer.parseInt(args[2]);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot fill all <id> <height>");
|
||||
MainUtil.runners.remove(plot);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int y = 0; y <= height; y++) {
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||
SetBlockQueue.setBlock(plot.world, x, y, z, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int y = height + 1; y <= 255; y++) {
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||
SetBlockQueue.setBlock(plot.world, x, y, z, air);
|
||||
}
|
||||
}
|
||||
}
|
||||
SetBlockQueue.addNotify(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.runners.remove(plot);
|
||||
MainUtil.sendMessage(player, "&aFill task complete!");
|
||||
}
|
||||
});
|
||||
} else if (args[0].equals("outline")) {
|
||||
int x, z;
|
||||
z = bottom.getZ();
|
||||
for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
|
||||
for (int y = 1; y <= 255; y++) {
|
||||
SetBlockQueue.setBlock(plot.world, x, y, z, 7);
|
||||
}
|
||||
}
|
||||
x = top.getX();
|
||||
for (z = bottom.getZ(); z <= (top.getZ() - 1); z++) {
|
||||
for (int y = 1; y <= 255; y++) {
|
||||
SetBlockQueue.setBlock(plot.world, x, y, z, 7);
|
||||
}
|
||||
}
|
||||
z = top.getZ();
|
||||
for (x = top.getX(); x >= (bottom.getX() + 1); x--) {
|
||||
for (int y = 1; y <= 255; y++) {
|
||||
SetBlockQueue.setBlock(plot.world, x, y, z, 7);
|
||||
}
|
||||
}
|
||||
x = bottom.getX();
|
||||
for (z = top.getZ(); z >= (bottom.getZ() + 1); z--) {
|
||||
for (int y = 1; y <= 255; y++) {
|
||||
SetBlockQueue.setBlock(plot.world, x, y, z, 7);
|
||||
}
|
||||
}
|
||||
SetBlockQueue.addNotify(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(player, "&aWalls complete! The ceiling will take a while :(");
|
||||
bottom.setY(255);
|
||||
top.add(1, 0, 1);
|
||||
SetBlockQueue.setSlow(true);
|
||||
MainUtil.setSimpleCuboidAsync(plot.world, bottom, top, new PlotBlock((short) 7, (byte) 0));
|
||||
SetBlockQueue.addNotify(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.runners.remove(plot);
|
||||
MainUtil.sendMessage(player, "&aFill task complete!");
|
||||
SetBlockQueue.setSlow(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ public class DebugFixFlags extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---");
|
||||
for (final Plot plot : PS.get().getPlotsInWorld(world)) {
|
||||
final HashMap<String, Flag> flags = plot.getSettings().flags;
|
||||
final HashMap<String, Flag> flags = plot.getFlags();
|
||||
final Iterator<Entry<String, Flag>> i = flags.entrySet().iterator();
|
||||
boolean changed = false;
|
||||
while (i.hasNext()) {
|
||||
@ -68,7 +68,7 @@ public class DebugFixFlags extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
DBFunc.setFlags(plot, plot.getSettings().flags.values());
|
||||
DBFunc.setFlags(plot, plot.getFlags().values());
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&aDone!");
|
||||
|
@ -20,6 +20,8 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -49,51 +51,52 @@ public class Delete extends SubCommand {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
if (!plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.PLOT_UNOWNED);
|
||||
}
|
||||
if (((!plot.hasOwner() || !plot.isOwner(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
|
||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
final PlotWorld pWorld = PS.get().getPlotWorld(plot.world);
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
final Runnable runnable = new Runnable() {
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
final HashSet<Plot> plots = MainUtil.getConnectedPlots(plot);
|
||||
final Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if ((EconHandler.manager != null) && pWorld.USE_ECONOMY && plot.hasOwner() && plot.isOwner(UUIDHandler.getUUID(plr))) {
|
||||
final double c = pWorld.SELL_PRICE;
|
||||
if (c > 0d) {
|
||||
EconHandler.manager.depositMoney(plr, c);
|
||||
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return;
|
||||
}
|
||||
if (plot.unclaim()) {
|
||||
final long start = System.currentTimeMillis();
|
||||
final boolean result = MainUtil.clearAsPlayer(plot, true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||
final long start = System.currentTimeMillis();
|
||||
boolean result = plot.deletePlot(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plot.removeRunning();
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY) {
|
||||
final double value = plotworld.SELL_PRICE * plots.size();
|
||||
if (value > 0d) {
|
||||
EconHandler.manager.depositMoney(plr, value);
|
||||
sendMessage(plr, C.ADDED_BALANCE, value + "");
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||
}
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.UNCLAIM_FAILED);
|
||||
});
|
||||
if (result) {
|
||||
plot.addRunning();
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_DELETE && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
|
||||
CmdConfirm.addPending(plr, "/plot delete " + plot.id, runnable);
|
||||
CmdConfirm.addPending(plr, "/plot delete " + plot.id, run);
|
||||
} else {
|
||||
TaskManager.runTask(runnable);
|
||||
TaskManager.runTask(run);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class Deny extends SubCommand {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -95,7 +95,7 @@ public class Deny extends SubCommand {
|
||||
|
||||
private void handleKick(final UUID uuid, final Plot plot) {
|
||||
final PlotPlayer pp = UUIDHandler.getPlayer(uuid);
|
||||
if ((pp != null) && plot.equals(MainUtil.getPlot(pp.getLocation()))) {
|
||||
if ((pp != null) && plot.equals(MainUtil.getPlotAbs(pp.getLocation()))) {
|
||||
pp.teleport(BlockManager.manager.getSpawn(pp.getLocation().getWorld()));
|
||||
MainUtil.sendMessage(pp, C.YOU_GOT_DENIED);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class Done extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -48,11 +48,11 @@ public class Done extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (plot.getSettings().flags.containsKey("done")) {
|
||||
if (plot.getFlags().containsKey("done")) {
|
||||
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class Download extends SubCommand {
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(plr.getLocation());
|
||||
final Plot plot = MainUtil.getPlotAbs(plr.getLocation());
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -42,7 +42,7 @@ public class Download extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class FlagCmd extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final Location loc = player.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
@ -172,7 +172,7 @@ public class FlagCmd extends SubCommand {
|
||||
if ((args.length == 3) && flag.getAbstractFlag().isList()) {
|
||||
final String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value);
|
||||
DBFunc.setFlags(plot, plot.getSettings().flags.values());
|
||||
DBFunc.setFlags(plot, plot.getFlags().values());
|
||||
} else {
|
||||
final boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
|
||||
if (!result) {
|
||||
@ -222,7 +222,7 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
DBFunc.setFlags(plot, plot.getSettings().flags.values());
|
||||
DBFunc.setFlags(plot, plot.getFlags().values());
|
||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||
return true;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class Inbox extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
|
||||
final Plot plot = MainUtil.getPlot(player.getLocation());
|
||||
final Plot plot = MainUtil.getPlotAbs(player.getLocation());
|
||||
if (args.length == 0) {
|
||||
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]");
|
||||
for (final CommentInbox inbox : CommentManager.inboxes.values()) {
|
||||
|
@ -32,10 +32,12 @@ import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
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.PlotInventory;
|
||||
import com.intellectualcrafters.plot.object.PlotItemStack;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
@ -139,14 +141,14 @@ public class Info extends SubCommand {
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", new String[] {
|
||||
"&cID: &6" + plot.getId().toString(),
|
||||
"&cOwner: &6" + name,
|
||||
"&cAlias: &6" + plot.getSettings().getAlias(),
|
||||
"&cAlias: &6" + plot.getAlias(),
|
||||
"&cBiome: &6" + plot.getBiome().toString().replaceAll("_", "").toLowerCase(),
|
||||
"&cCan Build: &6" + plot.isAdded(uuid),
|
||||
"&cIs Denied: &6" + plot.isDenied(uuid) }));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", new String[] { "&cAmount: &6" + plot.getTrusted().size(), "&8Click to view a list of the trusted users" }));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cMembers", new String[] { "&cAmount: &6" + plot.getMembers().size(), "&8Click to view a list of plot members" }));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cDenied", new String[] { "&cDenied", "&cAmount: &6" + plot.getDenied().size(), "&8Click to view a list of denied players" }));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cFlags", new String[] { "&cFlags", "&cAmount: &6" + plot.getSettings().flags.size(), "&8Click to view a list of plot flags" }));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cFlags", new String[] { "&cFlags", "&cAmount: &6" + plot.getFlags().size(), "&8Click to view a list of plot flags" }));
|
||||
inv.openInventory();
|
||||
return true;
|
||||
}
|
||||
@ -205,12 +207,10 @@ public class Info extends SubCommand {
|
||||
}
|
||||
|
||||
private void formatAndSend(String info, final String world, final Plot plot, final PlotPlayer player, final boolean full) {
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id2 = MainUtil.getTopPlot(plot).id;
|
||||
final int num = MainUtil.getPlotSelectionIds(id, id2).size();
|
||||
final String alias = plot.getSettings().getAlias().length() > 0 ? plot.getSettings().getAlias() : C.NONE.s();
|
||||
final Location top = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
final Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final int num = MainUtil.getConnectedPlots(plot).size();
|
||||
final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s();
|
||||
final Location top = MainUtil.getPlotTopLocAbs(world, plot.id);
|
||||
final Location bot = MainUtil.getPlotBottomLocAbs(world, plot.id);
|
||||
final String biome = BlockManager.manager.getBiome(plot.world, bot.getX() + ((top.getX() - bot.getX()) / 2), bot.getZ() + ((top.getZ() - bot.getZ()) / 2));
|
||||
final String trusted = getPlayerList(plot.getTrusted());
|
||||
final String members = getPlayerList(plot.getMembers());
|
||||
@ -227,9 +227,8 @@ public class Info extends SubCommand {
|
||||
|
||||
final String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
|
||||
|
||||
info = info.replaceAll("%id%", plot.id.toString());
|
||||
info = info.replaceAll("%alias%", alias);
|
||||
info = info.replaceAll("%id%", id.toString());
|
||||
info = info.replaceAll("%id2%", id2.toString());
|
||||
info = info.replaceAll("%num%", num + "");
|
||||
info = info.replaceAll("%desc%", description);
|
||||
info = info.replaceAll("%biome%", biome);
|
||||
|
@ -37,7 +37,7 @@ public class Kick extends SubCommand {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class Kick extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final Location otherLoc = player.getLocation();
|
||||
if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(MainUtil.getPlot(otherLoc))) {
|
||||
if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(MainUtil.getPlotAbs(otherLoc))) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class Load extends SubCommand {
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(plr.getLocation());
|
||||
final Plot plot = MainUtil.getPlotAbs(plr.getLocation());
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -51,14 +51,13 @@ public class Load extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length != 0) {
|
||||
if (args.length == 1) {
|
||||
// TODO load save here
|
||||
final List<String> schematics = (List<String>) plr.getMeta("plot_schematics");
|
||||
if (schematics == null) {
|
||||
// No schematics found:
|
||||
|
@ -72,13 +72,11 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
createCommand(new Download());
|
||||
createCommand(new Update());
|
||||
createCommand(new Template());
|
||||
createCommand(new Setup());
|
||||
createCommand(new Setup());
|
||||
createCommand(new DebugSaveTest());
|
||||
createCommand(new DebugLoadTest());
|
||||
createCommand(new CreateRoadSchematic());
|
||||
createCommand(new DebugAllowUnsafe());
|
||||
createCommand(new RegenAllRoads());
|
||||
createCommand(new RegenAllRoads());
|
||||
createCommand(new Claim());
|
||||
createCommand(new Auto());
|
||||
@ -294,9 +292,9 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
id = null;
|
||||
world = null;
|
||||
}
|
||||
if ((id != null) && PS.get().isPlotWorld(world)) {
|
||||
if ((id != null) && PS.get().isPlotWorld(world)) {
|
||||
final Plot plot = MainUtil.getPlotAbs(world, id);
|
||||
if (plot != null) {
|
||||
if (plot != null) {
|
||||
player.teleport(plot.getBottomAbs());
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ usage = "/plot merge [direction]",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Merge extends SubCommand {
|
||||
public final static String[] values = new String[] { "north", "east", "south", "west" };
|
||||
public final static String[] aliases = new String[] { "n", "e", "s", "w" };
|
||||
public final static String[] values = new String[] { "north", "east", "south", "west", "auto" };
|
||||
public final static String[] aliases = new String[] { "n", "e", "s", "w", "all" };
|
||||
|
||||
public static String direction(float yaw) {
|
||||
yaw = yaw / 90;
|
||||
@ -77,9 +77,8 @@ public class Merge extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocationFull();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -92,27 +91,46 @@ public class Merge extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d && EconHandler.manager.getMoney(plr) < plotworld.MERGE_PRICE) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, plotworld.MERGE_PRICE + "");
|
||||
return false;
|
||||
}
|
||||
int direction = -1;
|
||||
final int size = plot.getConnectedPlots().size();
|
||||
final int maxSize = Permissions.hasPermissionRange(plr, "plots.merge", Settings.MAX_PLOTS);
|
||||
if (size >= maxSize) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.merge." + size);
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
switch (direction(plr.getLocationFull().getYaw())) {
|
||||
case "NORTH":
|
||||
direction = 0;
|
||||
break;
|
||||
case "EAST":
|
||||
direction = 1;
|
||||
break;
|
||||
case "SOUTH":
|
||||
direction = 2;
|
||||
break;
|
||||
case "WEST":
|
||||
direction = 3;
|
||||
break;
|
||||
}
|
||||
// switch (direction(plr.getLocationFull().getYaw())) {
|
||||
// case "NORTH":
|
||||
// direction = 0;
|
||||
// break;
|
||||
// case "EAST":
|
||||
// direction = 1;
|
||||
// break;
|
||||
// case "SOUTH":
|
||||
// direction = 2;
|
||||
// break;
|
||||
// case "WEST":
|
||||
// direction = 3;
|
||||
// break;
|
||||
// }
|
||||
} else {
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
plot.autoMerge((args.length != 2) || !args[1].equalsIgnoreCase("false"));
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
return true;
|
||||
if (args[0].equalsIgnoreCase("all") || args[0].equalsIgnoreCase("auto")) {
|
||||
if (MainUtil.autoMerge(plot, -1, maxSize - size, plr.getUUID(), (args.length != 2) || !args[1].equalsIgnoreCase("false"))) {
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
|
||||
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
return true;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
|
||||
}
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (args[0].equalsIgnoreCase(values[i]) || args[0].equalsIgnoreCase(aliases[i])) {
|
||||
@ -122,135 +140,63 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (direction == -1) {
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(values, C.BLOCK_LIST_SEPARATER.s()));
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot merge <" + StringMan.join(values, "|") + ">");
|
||||
MainUtil.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw())));
|
||||
return false;
|
||||
}
|
||||
PlotId bot = MainUtil.getBottomPlot(plot).id;
|
||||
PlotId top = MainUtil.getTopPlot(plot).id;
|
||||
ArrayList<PlotId> selPlots;
|
||||
final String world = loc.getWorld();
|
||||
switch (direction) {
|
||||
case 0: // north = -y
|
||||
selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||
break;
|
||||
case 1: // east = +x
|
||||
selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||
break;
|
||||
case 2: // south = +y
|
||||
selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||
break;
|
||||
case 3: // west = -x
|
||||
selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
final int size = selPlots.size();
|
||||
if (Permissions.hasPermissionRange(plr, "plots.merge", Settings.MAX_PLOTS) < size) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.merge." + size);
|
||||
return false;
|
||||
}
|
||||
final PlotId botId = selPlots.get(0);
|
||||
final PlotId topId = selPlots.get(selPlots.size() - 1);
|
||||
final PlotId bot1 = MainUtil.getBottomPlot(MainUtil.getPlot(world, botId)).id;
|
||||
final PlotId bot2 = MainUtil.getBottomPlot(MainUtil.getPlot(world, topId)).id;
|
||||
final PlotId top1 = MainUtil.getTopPlot(MainUtil.getPlot(world, topId)).id;
|
||||
final PlotId top2 = MainUtil.getTopPlot(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));
|
||||
final ArrayList<PlotId> plots = MainUtil.getMaxPlotSelectionIds(world, bot, top);
|
||||
boolean multiMerge = false;
|
||||
final HashSet<UUID> multiUUID = new HashSet<UUID>();
|
||||
final HashSet<PlotId> multiPlots = new HashSet<>();
|
||||
final UUID u1 = plot.owner;
|
||||
for (final PlotId myid : plots) {
|
||||
final Plot myplot = PS.get().getPlot(world, myid);
|
||||
if ((myplot == null) || (myplot.owner == null)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
||||
return false;
|
||||
if (MainUtil.autoMerge(plot, direction, maxSize - size, plot.owner, (args.length != 2) || !args[1].equalsIgnoreCase("false"))) {
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
|
||||
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
|
||||
}
|
||||
final UUID u2 = myplot.owner;
|
||||
if (u2.equals(u1)) {
|
||||
continue;
|
||||
}
|
||||
final PlotPlayer p2 = UUIDHandler.getPlayer(u2);
|
||||
if (p2 == null) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
||||
return false;
|
||||
}
|
||||
multiMerge = true;
|
||||
multiPlots.add(myid);
|
||||
multiUUID.add(u2);
|
||||
}
|
||||
if (multiMerge) {
|
||||
if (!Permissions.hasPermission(plr, C.PERMISSION_MERGE_OTHER)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER.s());
|
||||
return false;
|
||||
}
|
||||
for (final UUID uuid : multiUUID) {
|
||||
final PlotPlayer accepter = UUIDHandler.getPlayer(uuid);
|
||||
CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PlotPlayer accepter = UUIDHandler.getPlayer(uuid);
|
||||
multiUUID.remove(uuid);
|
||||
if (multiUUID.size() == 0) {
|
||||
final PlotPlayer pp = UUIDHandler.getPlayer(u1);
|
||||
if (pp == null) {
|
||||
sendMessage(accepter, C.MERGE_NOT_VALID);
|
||||
return;
|
||||
}
|
||||
final PlotWorld plotWorld = PS.get().getPlotWorld(world);
|
||||
if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) {
|
||||
double cost = plotWorld.MERGE_PRICE;
|
||||
cost = plots.size() * cost;
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
||||
return;
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(plr, cost);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
final boolean result = EventUtil.manager.callMerge(world, plot, plots);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, "&cMerge has been cancelled");
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
MainUtil.mergePlots(world, plots, true, true);
|
||||
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
|
||||
}
|
||||
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
|
||||
}
|
||||
});
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.MERGE_REQUESTED);
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
return true;
|
||||
}
|
||||
final PlotWorld plotWorld = PS.get().getPlotWorld(world);
|
||||
if ((EconHandler.manager != null) && plotWorld.USE_ECONOMY) {
|
||||
double cost = plotWorld.MERGE_PRICE;
|
||||
cost = plots.size() * cost;
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < cost) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
||||
return false;
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(plr, cost);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
final boolean result = EventUtil.manager.callMerge(world, plot, plots);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(plr, "&cMerge has been cancelled");
|
||||
Plot adjacent = MainUtil.getPlotAbs(plot.world, MainUtil.getPlotIdRelative(plot.id, direction));
|
||||
if (adjacent == null || !adjacent.hasOwner() || adjacent.getMerged((direction + 2) % 4)) {
|
||||
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
MainUtil.mergePlots(world, plots, true, true);
|
||||
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
|
||||
if (!Permissions.hasPermission(plr, C.PERMISSION_MERGE_OTHER)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER.s());
|
||||
return false;
|
||||
}
|
||||
HashSet<UUID> uuids = adjacent.getOwners();
|
||||
boolean isOnline = false;
|
||||
for (final UUID uuid : uuids) {
|
||||
final PlotPlayer accepter = UUIDHandler.getPlayer(uuid);
|
||||
if (accepter == null) {
|
||||
continue;
|
||||
}
|
||||
isOnline = true;
|
||||
final int dir = direction;
|
||||
CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
|
||||
MainUtil.autoMerge(plot, dir, maxSize - size, uuid, true);
|
||||
final PlotPlayer pp = UUIDHandler.getPlayer(plr.getUUID());
|
||||
if (pp == null) {
|
||||
sendMessage(accepter, C.MERGE_NOT_VALID);
|
||||
return;
|
||||
}
|
||||
if ((EconHandler.manager != null) && plotworld.USE_ECONOMY && plotworld.MERGE_PRICE > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < plotworld.MERGE_PRICE) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, plotworld.MERGE_PRICE + "");
|
||||
return;
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(plr, plotworld.MERGE_PRICE);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, plotworld.MERGE_PRICE + "");
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isOnline == false) {
|
||||
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.MERGE_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -41,40 +41,26 @@ public class Move extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot1 = MainUtil.getPlot(loc);
|
||||
final Plot plot1 = MainUtil.getPlotAbs(loc);
|
||||
if (plot1 == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot1.isAdded(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
|
||||
if (!plot1.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
final String world = loc.getWorld();
|
||||
final PlotId plot2id = MainUtil.parseId(args[0]);
|
||||
if ((plot2id == null)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move <X;Z>");
|
||||
final Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
if ((plot2 == null)) {
|
||||
return false;
|
||||
}
|
||||
String world2;
|
||||
if (args.length == 2) {
|
||||
final PlotWorld other = PS.get().getPlotWorld(args[1]);
|
||||
final PlotWorld current = PS.get().getPlotWorld(loc.getWorld());
|
||||
if ((other == null) || (current == null) || !other.equals(current)) {
|
||||
MainUtil.sendMessage(plr, C.PLOTWORLD_INCOMPATIBLE);
|
||||
return false;
|
||||
}
|
||||
world2 = other.worldname;
|
||||
} else {
|
||||
world2 = world;
|
||||
}
|
||||
final Plot plot2 = MainUtil.getPlot(world2, plot2id);
|
||||
|
||||
if (plot1.equals(plot2)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move <X;Z>");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getWorld().equals(plot2.getWorld())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(plr);
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.move(plot1, plot2, new Runnable() {
|
||||
@ -82,11 +68,12 @@ public class Move extends SubCommand {
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, C.MOVE_SUCCESS);
|
||||
}
|
||||
})) {
|
||||
}, false)) {
|
||||
return true;
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.REQUIRES_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class MusicSubcommand extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
final Location loc = player.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class Purge extends SubCommand {
|
||||
final PlotId id = getId(arg);
|
||||
if (id != null) {
|
||||
final HashSet<Integer> ids = new HashSet<Integer>();
|
||||
final int DBid = DBFunc.getId(MainUtil.getPlot(worldname, id));
|
||||
final int DBid = DBFunc.getId(MainUtil.getPlotAbs(worldname, id));
|
||||
if (DBid != Integer.MAX_VALUE) {
|
||||
ids.add(DBid);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class Rate extends SubCommand {
|
||||
});
|
||||
final UUID uuid = player.getUUID();
|
||||
for (final Plot p : plots) {
|
||||
if ((!Settings.REQUIRE_DONE || p.getSettings().flags.containsKey("done"))
|
||||
if ((!Settings.REQUIRE_DONE || p.getFlags().containsKey("done"))
|
||||
&& p.isBasePlot()
|
||||
&& ((p.getSettings().ratings == null) || !p.getSettings().ratings.containsKey(uuid))
|
||||
&& !p.isAdded(uuid)) {
|
||||
@ -96,7 +96,7 @@ public class Rate extends SubCommand {
|
||||
}
|
||||
}
|
||||
final Location loc = player.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -108,7 +108,7 @@ public class Rate extends SubCommand {
|
||||
sendMessage(player, C.RATING_NOT_YOUR_OWN);
|
||||
return false;
|
||||
}
|
||||
if (Settings.REQUIRE_DONE && !plot.getSettings().flags.containsKey("done")) {
|
||||
if (Settings.REQUIRE_DONE && !plot.getFlags().containsKey("done")) {
|
||||
sendMessage(player, C.RATING_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -66,7 +67,7 @@ public class RegenAllRoads extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
final List<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
|
||||
final Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
|
||||
MainUtil.sendMessage(plr, "&cIf no schematic is set, the following will not do anything");
|
||||
MainUtil.sendMessage(plr, "&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
|
||||
MainUtil.sendMessage(plr, "&6Potential chunks to update: &7" + (chunks.size() * 1024));
|
||||
|
@ -56,7 +56,7 @@ public class Remove extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -32,7 +33,7 @@ public class Save extends SubCommand {
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(plr.getLocation());
|
||||
final Plot plot = MainUtil.getPlotAbs(plr.getLocation());
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -44,7 +45,7 @@ public class Save extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
@ -57,7 +58,8 @@ public class Save extends SubCommand {
|
||||
public void run() {
|
||||
final String time = (System.currentTimeMillis() / 1000) + "";
|
||||
final String name = PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "");
|
||||
final int size = (plot.getTop().getX() - plot.getBottom().getX()) + 1;
|
||||
Location[] corners = MainUtil.getCorners(plot);
|
||||
final int size = (corners[1].getX() - corners[0].getX()) + 1;
|
||||
final PlotId id = plot.id;
|
||||
final String world = plot.world.replaceAll("[^A-Za-z0-9]", "");
|
||||
final String file = time + "_" + world + "_" + id.x + "_" + id.y + "_" + size + "_" + name;
|
||||
|
@ -40,8 +40,6 @@ import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
// TODO Add sub-subcommands
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "schematic",
|
||||
permission = "plots.schematic",
|
||||
@ -73,7 +71,7 @@ public class SchematicCmd extends SubCommand {
|
||||
break;
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -130,37 +128,38 @@ public class SchematicCmd extends SubCommand {
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "test": {
|
||||
if (!Permissions.hasPermission(plr, "plots.schematic.test")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test");
|
||||
return false;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
return false;
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
file = args[1];
|
||||
schematic = SchematicHandler.manager.getSchematic(file);
|
||||
if (schematic == null) {
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||
return false;
|
||||
}
|
||||
final int l1 = schematic.getSchematicDimension().getX();
|
||||
final int l2 = schematic.getSchematicDimension().getZ();
|
||||
final int length = MainUtil.getPlotWidth(loc.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;
|
||||
}
|
||||
sendMessage(plr, C.SCHEMATIC_VALID);
|
||||
break;
|
||||
}
|
||||
// TODO test
|
||||
// case "test": {
|
||||
// if (!Permissions.hasPermission(plr, "plots.schematic.test")) {
|
||||
// MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test");
|
||||
// return false;
|
||||
// }
|
||||
// if (args.length < 2) {
|
||||
// sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
// return false;
|
||||
// }
|
||||
// final Location loc = plr.getLocation();
|
||||
// final Plot plot = MainUtil.getPlot(loc);
|
||||
// if (plot == null) {
|
||||
// sendMessage(plr, C.NOT_IN_PLOT);
|
||||
// return false;
|
||||
// }
|
||||
// file = args[1];
|
||||
// schematic = SchematicHandler.manager.getSchematic(file);
|
||||
// if (schematic == null) {
|
||||
// sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||
// return false;
|
||||
// }
|
||||
// final int l1 = schematic.getSchematicDimension().getX();
|
||||
// final int l2 = schematic.getSchematicDimension().getZ();
|
||||
// final int length = MainUtil.getPlotWidth(loc.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;
|
||||
// }
|
||||
// sendMessage(plr, C.SCHEMATIC_VALID);
|
||||
// break;
|
||||
// }
|
||||
case "saveall":
|
||||
case "exportall": {
|
||||
if (!ConsolePlayer.isConsole(plr)) {
|
||||
@ -203,7 +202,7 @@ public class SchematicCmd extends SubCommand {
|
||||
}
|
||||
final Plot p2;
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
// TODO Make sub-subcommands
|
||||
@CommandDeclaration(
|
||||
command = "set",
|
||||
description = "Set a plot value",
|
||||
@ -62,9 +61,8 @@ public class Set extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -93,7 +91,7 @@ public class Set extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("flag")) {
|
||||
List<String> arglist = Arrays.asList("flag", "set");
|
||||
List<String> arglist = new ArrayList<>(Arrays.asList("flag", "set"));
|
||||
for (String arg : Arrays.copyOfRange(args, 1, args.length)) {
|
||||
arglist.add(arg);
|
||||
}
|
||||
@ -113,7 +111,7 @@ public class Set extends SubCommand {
|
||||
}
|
||||
//set to current location
|
||||
final String world = plr.getLocation().getWorld();
|
||||
final Location base = MainUtil.getPlotBottomLoc(world, plot.id);
|
||||
final Location base = MainUtil.getPlotBottomLocAbs(world, plot.id).subtract(1, 0, 1);
|
||||
base.setY(0);
|
||||
final Location relative = plr.getLocation().subtract(base.getX(), base.getY(), base.getZ());
|
||||
final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ(), relative.getYaw(), relative.getPitch());
|
||||
@ -159,7 +157,7 @@ public class Set extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
for (final Plot p : PS.get().getPlotsInWorld(plr.getLocation().getWorld())) {
|
||||
if (p.getSettings().getAlias().equalsIgnoreCase(alias)) {
|
||||
if (p.getAlias().equalsIgnoreCase(alias)) {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
@ -179,26 +177,26 @@ public class Set extends SubCommand {
|
||||
}
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(plr, C.NEED_BIOME);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (args[1].length() < 2) {
|
||||
sendMessage(plr, C.NAME_LITTLE, "Biome", args[1].length() + "", "2");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
final int biome = BlockManager.manager.getBiomeFromString(args[1]);
|
||||
if (biome == -1) {
|
||||
MainUtil.sendMessage(plr, getBiomeList(BlockManager.manager.getBiomeList()));
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
MainUtil.runners.put(plot, 1);
|
||||
plot.addRunning();
|
||||
plot.setBiome(args[1].toUpperCase(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
MainUtil.sendMessage(plr, C.BIOME_SET_TO.s() + args[1].toLowerCase());
|
||||
}
|
||||
});
|
||||
@ -265,17 +263,19 @@ public class Set extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK, args[1]);
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
MainUtil.runners.put(plot, 1);
|
||||
manager.setComponent(plotworld, plot.id, component, blocks);
|
||||
plot.addRunning();
|
||||
for (Plot current : MainUtil.getConnectedPlots(plot)) {
|
||||
manager.setComponent(plotworld, current.id, component, blocks);
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
|
||||
SetBlockQueue.addNotify(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.runners.remove(plot);
|
||||
plot.removeRunning();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -21,6 +21,7 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
@ -58,7 +59,7 @@ public class SetOwner extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if ((plot == null) || ((plot.owner == null) && !Permissions.hasPermission(plr, "plots.admin.command.setowner"))) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
@ -67,14 +68,11 @@ public class SetOwner extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NEED_USER);
|
||||
return false;
|
||||
}
|
||||
|
||||
final PlotId bot = MainUtil.getBottomPlot(plot).id;
|
||||
final PlotId top = MainUtil.getTopPlot(plot).id;
|
||||
final ArrayList<PlotId> plots = MainUtil.getPlotSelectionIds(bot, top);
|
||||
|
||||
HashSet<Plot> plots = MainUtil.getConnectedPlots(plot);
|
||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||
final PlotPlayer other = UUIDHandler.getPlayer(args[0]);
|
||||
if (other == null) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||
if (uuid == null || !Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
@ -88,32 +86,13 @@ public class SetOwner extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!plot.isOwner(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final String world = loc.getWorld();
|
||||
final UUID uuid = getUUID(args[0]);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
for (final PlotId id : plots) {
|
||||
Plot current = PS.get().getPlot(world, id);
|
||||
if (current == null) {
|
||||
current = MainUtil.getPlot(world, id);
|
||||
current.owner = uuid;
|
||||
current.create();
|
||||
} else {
|
||||
current.owner = uuid;
|
||||
DBFunc.setOwner(current, current.owner);
|
||||
}
|
||||
PS.get().updatePlot(current);
|
||||
}
|
||||
plot.setOwner(uuid);
|
||||
MainUtil.setSign(args[0], plot);
|
||||
MainUtil.sendMessage(plr, C.SET_OWNER);
|
||||
if (other != null) {
|
||||
|
@ -40,91 +40,38 @@ public class Swap extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
MainUtil.sendMessage(plr, "&cThis command has not been optimized for large selections yet. Please bug me if this becomes an issue.");
|
||||
if (args.length < 1) {
|
||||
MainUtil.sendMessage(plr, C.NEED_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
final Plot plot1 = MainUtil.getPlotAbs(loc);
|
||||
if (plot1 == null) {
|
||||
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if ((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) {
|
||||
if (!plot1.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
||||
final Plot bot1 = MainUtil.getBottomPlot(plot);
|
||||
final Plot top1 = MainUtil.getTopPlot(plot);
|
||||
|
||||
final PlotId id2 = PlotId.fromString(args[0]);
|
||||
if (id2 == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
||||
final Plot plot2 = MainUtil.getPlotFromString(plr, args[0], true);
|
||||
if ((plot2 == null)) {
|
||||
return false;
|
||||
}
|
||||
final String world = loc.getWorld();
|
||||
final Plot plot2 = MainUtil.getPlot(world, id2);
|
||||
final PlotId id3 = new PlotId((id2.x + top1.id.x) - bot1.id.x, (id2.y + top1.id.y) - bot1.id.y);
|
||||
final Plot plot3 = MainUtil.getPlot(world, id3);
|
||||
|
||||
// Getting secon selection
|
||||
final Plot bot2 = MainUtil.getBottomPlot(plot2);
|
||||
final Plot top2 = MainUtil.getTopPlot(plot3);
|
||||
|
||||
// cancel swap if intersection
|
||||
final PlotCluster cluster1 = new PlotCluster(world, bot1.id, top1.id, null);
|
||||
final PlotClusterId cluster2id = new PlotClusterId(bot2.id, top2.id);
|
||||
if (ClusterManager.intersects(cluster1, cluster2id)) {
|
||||
if (plot1.equals(plot2)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getWorld().equals(plot2.getWorld())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(plr);
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.move(plot1, plot2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, C.SWAP_SUCCESS);
|
||||
}
|
||||
}, true)) {
|
||||
return true;
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.SWAP_OVERLAP);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check dimensions
|
||||
if (((top1.id.x - bot1.id.x) != (top2.id.x - bot2.id.x)) || ((top1.id.y - bot1.id.y) != (top2.id.y - bot2.id.y))) {
|
||||
MainUtil.sendMessage(plr, C.SWAP_DIMENSIONS, "1");
|
||||
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Getting selections as ids
|
||||
final ArrayList<PlotId> selection1 = MainUtil.getPlotSelectionIds(bot1.id, top1.id);
|
||||
final ArrayList<PlotId> selection2 = MainUtil.getPlotSelectionIds(bot2.id, top2.id);
|
||||
|
||||
// Getting selections as location coordinates
|
||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, bot1.id);
|
||||
final Location pos2 = MainUtil.getPlotTopLocAbs(world, top1.id).subtract(1, 0, 1);
|
||||
final Location pos3 = MainUtil.getPlotBottomLocAbs(world, bot2.id);
|
||||
final Location pos4 = MainUtil.getPlotTopLocAbs(world, top2.id).subtract(1, 0, 1);
|
||||
|
||||
if (MainUtil.getPlot(pos2) != null) {
|
||||
pos1.add(1, 0, 1);
|
||||
pos2.add(1, 0, 1);
|
||||
pos3.add(1, 0, 1);
|
||||
pos4.add(1, 0, 1);
|
||||
}
|
||||
|
||||
// Swapping the blocks, states and entites
|
||||
ChunkManager.manager.swap(world, pos1, pos2, pos3, pos4);
|
||||
|
||||
// Swapping the plot data
|
||||
for (int i = 0; i < selection1.size(); i++) {
|
||||
final boolean last = i == (selection1.size() - 1);
|
||||
final PlotId swaper = selection1.get(i);
|
||||
final PlotId swapee = selection2.get(i);
|
||||
MainUtil.swapData(world, swaper, swapee, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (last) {
|
||||
MainUtil.sendMessage(plr, C.SWAP_SUCCESS);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.STARTED_SWAP);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class TP extends SubCommand {
|
||||
}
|
||||
try {
|
||||
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
|
||||
MainUtil.teleportPlayer(plr, plr.getLocation(), MainUtil.getPlot(world, plotid));
|
||||
MainUtil.teleportPlayer(plr, plr.getLocation(), MainUtil.getPlotAbs(world, plotid));
|
||||
return true;
|
||||
} catch (final Exception e) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
@ -90,7 +90,7 @@ public class TP extends SubCommand {
|
||||
return null;
|
||||
}
|
||||
for (final Plot p : PS.get().getPlotsInWorld(world)) {
|
||||
if ((p.getSettings().getAlias().length() > 0) && p.getSettings().getAlias().equalsIgnoreCase(a)) {
|
||||
if ((p.getAlias().length() > 0) && p.getAlias().equalsIgnoreCase(a)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class Target extends SubCommand {
|
||||
Plot closest = null;
|
||||
int distance = Integer.MAX_VALUE;
|
||||
for (final Plot plot : PS.get().getPlotsInWorld(ploc.getWorld())) {
|
||||
final double current = plot.getBottom().getEuclideanDistanceSquared(ploc);
|
||||
final double current = plot.getBottomAbs().getEuclideanDistanceSquared(ploc);
|
||||
if (current < distance) {
|
||||
distance = (int) current;
|
||||
closest = plot;
|
||||
|
@ -133,8 +133,8 @@ public class Trim extends SubCommand {
|
||||
}
|
||||
final Plot plot = plots.remove(0);
|
||||
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id);
|
||||
final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id);
|
||||
|
||||
final int ccx1 = (pos1.getX() >> 9);
|
||||
final int ccz1 = (pos1.getZ() >> 9);
|
||||
@ -204,7 +204,7 @@ public class Trim extends SubCommand {
|
||||
sendMessage(C.TRIM_IN_PROGRESS.s());
|
||||
return false;
|
||||
}
|
||||
sendMessage(C.TRIM_START.s());
|
||||
sendMessage(C.TASK_START.s());
|
||||
final ArrayList<ChunkLoc> empty = new ArrayList<>();
|
||||
getTrimRegions(empty, world, new Runnable() {
|
||||
public void run() {
|
||||
|
@ -53,7 +53,7 @@ public class Trust extends SubCommand {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -31,33 +31,25 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "unclaim", usage = "/plot unclaim", requiredType = RequiredType.NONE, description = "Unclaim a plot", category = CommandCategory.ACTIONS)
|
||||
/**
|
||||
* Unclaiming a plot makes no changes to the terrain or plot border and only removes the owner and should be regarded as an admin command.
|
||||
*/
|
||||
@CommandDeclaration(command = "unclaim", usage = "/plot unclaim", requiredType = RequiredType.NONE, description = "Unclaim a plot (admin command)", category = CommandCategory.ACTIONS)
|
||||
public class Unclaim extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
}
|
||||
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
}
|
||||
if (((!plot.hasOwner() || !plot.isOwner(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) {
|
||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
final PlotWorld pWorld = PS.get().getPlotWorld(plot.world);
|
||||
if ((EconHandler.manager != null) && pWorld.USE_ECONOMY) {
|
||||
final double c = pWorld.SELL_PRICE;
|
||||
if (c > 0d) {
|
||||
EconHandler.manager.depositMoney(plr, c);
|
||||
sendMessage(plr, C.ADDED_BALANCE, c + "");
|
||||
}
|
||||
}
|
||||
if (plot.unclaim()) {
|
||||
MainUtil.sendMessage(plr, C.UNCLAIM_SUCCESS);
|
||||
} else {
|
||||
|
@ -51,7 +51,7 @@ public class Undeny extends SubCommand {
|
||||
public boolean onCommand(final PlotPlayer plr, final String... args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -38,20 +38,23 @@ public class Unlink extends SubCommand {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if ((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) {
|
||||
if (!plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.PLOT_UNOWNED);
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) {
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
if (MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||
if (!plot.isMerged()) {
|
||||
return sendMessage(plr, C.UNLINK_IMPOSSIBLE);
|
||||
}
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!MainUtil.unlinkPlot(plot, true)) {
|
||||
if (!MainUtil.unlinkPlot(plot, true, true)) {
|
||||
MainUtil.sendMessage(plr, "&cUnlink has been cancelled");
|
||||
return;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class Untrust extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
if (plot == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
@ -170,7 +171,7 @@ public class list extends SubCommand {
|
||||
match = null;
|
||||
}
|
||||
for (final Plot plot : PS.get().getPlots()) {
|
||||
final Flag flag = plot.getSettings().flags.get("done");
|
||||
final Flag flag = plot.getFlags().get("done");
|
||||
if (flag == null) {
|
||||
continue;
|
||||
}
|
||||
@ -189,8 +190,8 @@ public class list extends SubCommand {
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(final Plot a, final Plot b) {
|
||||
final String va = a.getSettings().flags.get("done").getValueString();
|
||||
final String vb = b.getSettings().flags.get("done").getValueString();
|
||||
final String va = a.getFlags().get("done").getValueString();
|
||||
final String vb = b.getFlags().get("done").getValueString();
|
||||
if (MathMan.isInteger(va)) {
|
||||
if (MathMan.isInteger(vb)) {
|
||||
return Integer.parseInt(vb) - Integer.parseInt(va);
|
||||
@ -332,6 +333,13 @@ public class list extends SubCommand {
|
||||
}
|
||||
|
||||
public void displayPlots(final PlotPlayer player, List<Plot> plots, final int pageSize, int page, final String world, final String[] args, final boolean sort) {
|
||||
int rawSize = plots.size();
|
||||
Iterator<Plot> iter = plots.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (!iter.next().isBasePlot()) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
if (sort) {
|
||||
plots = PS.get().sortPlots(plots, SortType.DISTANCE_FROM_ORIGIN, world);
|
||||
}
|
||||
@ -351,17 +359,12 @@ public class list extends SubCommand {
|
||||
final List<Plot> subList = plots.subList(page * pageSize, max);
|
||||
|
||||
// Header
|
||||
final String header = C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", plots.size() + "")
|
||||
final String header = C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", plots.size() + "/" + rawSize)
|
||||
.replaceAll("%word%", "all");
|
||||
MainUtil.sendMessage(player, header);
|
||||
|
||||
int i = page * pageSize;
|
||||
for (final Plot plot : subList) {
|
||||
if (plot.getSettings().isMerged()) {
|
||||
if (!MainUtil.getBottomPlot(plot).equals(plot)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
String color;
|
||||
if (plot.owner == null) {
|
||||
@ -379,7 +382,7 @@ public class list extends SubCommand {
|
||||
|
||||
final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", Info.getPlayerList(plot.getMembers())))).color("$1");
|
||||
|
||||
String strFlags = StringMan.join(plot.getSettings().flags.values(), ",");
|
||||
String strFlags = StringMan.join(plot.getFlags().values(), ",");
|
||||
if (strFlags.length() == 0) {
|
||||
strFlags = C.NONE.s();
|
||||
}
|
||||
|
Reference in New Issue
Block a user