mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Prevent loading faraway chunks (#4370)
* Prevent loading faraway chunks * docs
This commit is contained in:
@ -268,6 +268,7 @@ public class MainCommand extends Command {
|
||||
tp = true;
|
||||
} else {
|
||||
player.sendMessage(TranslatableCaption.of("border.denied"));
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
// Trim command
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
@ -2574,6 +2574,12 @@ public class Plot {
|
||||
*/
|
||||
public void teleportPlayer(final PlotPlayer<?> player, TeleportCause cause, Consumer<Boolean> resultConsumer) {
|
||||
Plot plot = this.getBasePlot(false);
|
||||
if (!WorldUtil.isValidLocation(plot.getBottomAbs())) {
|
||||
// prevent from teleporting into unsafe regions
|
||||
player.sendMessage(TranslatableCaption.of("border.denied"));
|
||||
resultConsumer.accept(false);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerTeleportToPlotEvent event = this.eventDispatcher.callTeleport(player, player.getLocation(), plot, cause);
|
||||
if (event.getEventResult() == Result.DENY) {
|
||||
|
@ -62,6 +62,15 @@ import java.util.zip.ZipOutputStream;
|
||||
|
||||
public abstract class WorldUtil {
|
||||
|
||||
/**
|
||||
* {@return whether the given location is valid in the world}
|
||||
* @param location the location to check
|
||||
* @since TODO
|
||||
*/
|
||||
public static boolean isValidLocation(Location location) {
|
||||
return Math.abs(location.getX()) < 30000000 && Math.abs(location.getZ()) < 30000000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the biome in a region
|
||||
*
|
||||
|
Reference in New Issue
Block a user