mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-12 10:24:07 +01:00
More efficient plot auto claim
This commit is contained in:
parent
fc72197f86
commit
c8d396a1a5
@ -36,9 +36,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation") public class Auto extends SubCommand {
|
public class Auto extends SubCommand {
|
||||||
public static PlotId lastPlot = new PlotId(0, 0);
|
|
||||||
|
|
||||||
public Auto() {
|
public Auto() {
|
||||||
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING, true);
|
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING, true);
|
||||||
}
|
}
|
||||||
@ -159,23 +157,22 @@ import com.intellectualcrafters.plot.util.PlotHelper;
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
boolean br = false;
|
boolean br = false;
|
||||||
|
String worldname = world.getName();
|
||||||
if ((size_x == 1) && (size_z == 1)) {
|
if ((size_x == 1) && (size_z == 1)) {
|
||||||
while (!br) {
|
while (!br) {
|
||||||
final Plot plot = PlotHelper.getPlot(world, Auto.lastPlot);
|
final Plot plot = PlotHelper.getPlot(world, getLastPlot(worldname));
|
||||||
if ((plot.owner == null)) {
|
if ((plot.owner == null)) {
|
||||||
Claim.claimPlot(plr, plot, true, true);
|
Claim.claimPlot(plr, plot, true, true);
|
||||||
br = true;
|
br = true;
|
||||||
final PlotWorld pw = PlotMain.getWorldSettings(world);
|
|
||||||
final Plot plot2 = PlotMain.getPlots(world).get(plot.id);
|
|
||||||
}
|
}
|
||||||
Auto.lastPlot = getNextPlot(Auto.lastPlot, 1);
|
PlotHelper.lastPlot.put(worldname, getNextPlot(getLastPlot(worldname), 1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boolean lastPlot = true;
|
boolean lastPlot = true;
|
||||||
while (!br) {
|
while (!br) {
|
||||||
final PlotId start = getNextPlot(Auto.lastPlot, 1);
|
final PlotId start = getNextPlot(getLastPlot(worldname), 1);
|
||||||
// Checking if the current set of plots is a viable option.
|
// Checking if the current set of plots is a viable option.
|
||||||
Auto.lastPlot = start;
|
PlotHelper.lastPlot.put(worldname, start);
|
||||||
if (lastPlot) {
|
if (lastPlot) {
|
||||||
}
|
}
|
||||||
if ((PlotMain.getPlots(world).get(start) != null) && (PlotMain.getPlots(world).get(start).owner != null)) {
|
if ((PlotMain.getPlots(world).get(start) != null) && (PlotMain.getPlots(world).get(start).owner != null)) {
|
||||||
@ -196,15 +193,20 @@ import com.intellectualcrafters.plot.util.PlotHelper;
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
br = true;
|
br = true;
|
||||||
final PlotWorld pw = PlotMain.getWorldSettings(world);
|
|
||||||
final Plot plot2 = PlotMain.getPlots(world).get(start);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Auto.lastPlot = new PlotId(0, 0);
|
PlotHelper.lastPlot.put(worldname, new PlotId(0, 0));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlotId getLastPlot(String world) {
|
||||||
|
if (PlotHelper.lastPlot == null) {
|
||||||
|
PlotHelper.lastPlot.put(world, new PlotId(0,0));
|
||||||
|
}
|
||||||
|
return PlotHelper.lastPlot.get(world);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isUnowned(final World world, final PlotId pos1, final PlotId pos2) {
|
public boolean isUnowned(final World world, final PlotId pos1, final PlotId pos2) {
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
|
@ -64,6 +64,8 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
public static boolean canSendChunk = false;
|
public static boolean canSendChunk = false;
|
||||||
public static ArrayList<String> runners_p = new ArrayList<>();
|
public static ArrayList<String> runners_p = new ArrayList<>();
|
||||||
static long state = 1;
|
static long state = 1;
|
||||||
|
public static HashMap<String, PlotId> lastPlot;
|
||||||
|
public static HashMap<String, Integer> worldBorder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* direction 0 = north, 1 = south, etc:
|
* direction 0 = north, 1 = south, etc:
|
||||||
|
Loading…
Reference in New Issue
Block a user