mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Add task complete + plot nearest targeting
This commit is contained in:
parent
0d03e9a1d9
commit
5ea7403d2e
@ -23,15 +23,17 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
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.StringMan;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "target",
|
||||
usage = "/plot target <X;Z>",
|
||||
usage = "/plot target <X;Z|nearest>",
|
||||
description = "Target a plot with your compass",
|
||||
permission = "plots.target",
|
||||
requiredType = RequiredType.NONE,
|
||||
@ -52,10 +54,24 @@ public class Target extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
final PlotId id = MainUtil.parseId(args[0]);
|
||||
PlotId id = MainUtil.parseId(args[0]);
|
||||
if (id == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
||||
Plot closest = null;
|
||||
int distance = Integer.MAX_VALUE;
|
||||
for (Plot plot : PS.get().getPlots(ploc.getWorld()).values()) {
|
||||
double current = plot.getBottom().getEuclideanDistanceSquared(ploc);
|
||||
if (current < distance) {
|
||||
distance = (int) current;
|
||||
closest = plot;
|
||||
}
|
||||
}
|
||||
id = closest.id;
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final Location loc = MainUtil.getPlotHome(ploc.getWorld(), id);
|
||||
plr.setCompassTarget(loc);
|
||||
|
@ -212,6 +212,7 @@ public class Trim extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
deleteChunks(world, empty);
|
||||
PS.log("$1Trim task complete!");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user