mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Check teleportation on command location prefix
This commit is contained in:
@ -206,13 +206,18 @@ public class MainCommand extends Command {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
Plot newPlot = Plot.fromString(area, args[0]);
|
||||
if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea().equals(area) || Permissions.hasPermission(player, C.PERMISSION_ADMIN)) && !newPlot.isDenied(player.getUUID())) {
|
||||
// Save meta
|
||||
loc = player.getMeta("location");
|
||||
plot = player.getMeta("lastplot");
|
||||
tp = true;
|
||||
// Set loc
|
||||
player.setMeta("location", newPlot.getBottomAbs());
|
||||
player.setMeta("lastplot", newPlot);
|
||||
Location newLoc = newPlot.getCenter();
|
||||
if (player.canTeleport(newLoc)) {
|
||||
// Save meta
|
||||
loc = player.getMeta("location");
|
||||
plot = player.getMeta("lastplot");
|
||||
tp = true;
|
||||
// Set loc
|
||||
player.setMeta("location", newLoc);
|
||||
player.setMeta("lastplot", newPlot);
|
||||
} else {
|
||||
C.BORDER.send(player);
|
||||
}
|
||||
// Trim command
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
|
@ -250,6 +250,17 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
||||
*/
|
||||
public abstract UUID getUUID();
|
||||
|
||||
public boolean canTeleport(Location loc) {
|
||||
Location current = getLocationFull();
|
||||
teleport(loc);
|
||||
boolean result = true;
|
||||
if (!getLocation().equals(loc)) {
|
||||
result = false;
|
||||
}
|
||||
teleport(current);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleport the player to a location.
|
||||
* @param location the target location
|
||||
|
Reference in New Issue
Block a user