mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-02-22 09:39:36 +01:00
Improve teleport behavior for home command (#4369)
This commit is contained in:
parent
8bb15d5c65
commit
1b9d0d5317
@ -262,6 +262,11 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSmallBlock(Location location) {
|
||||||
|
return adapt(location).getBlock().getBoundingBox().getHeight() < 0.25;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NonNegative
|
@NonNegative
|
||||||
public int getHighestBlockSynchronous(final @NonNull String world, final int x, final int z) {
|
public int getHighestBlockSynchronous(final @NonNull String world, final int x, final int z) {
|
||||||
|
@ -582,6 +582,8 @@ public class Settings extends Config {
|
|||||||
public static boolean PER_WORLD_VISIT = false;
|
public static boolean PER_WORLD_VISIT = false;
|
||||||
@Comment("Search merged plots for having multiple owners when using the visit command")
|
@Comment("Search merged plots for having multiple owners when using the visit command")
|
||||||
public static boolean VISIT_MERGED_OWNERS = true;
|
public static boolean VISIT_MERGED_OWNERS = true;
|
||||||
|
@Comment("Allows to teleport based on block size instead to spawn on the highest block at the home command")
|
||||||
|
public static boolean SIZED_BASED = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1407,6 +1407,9 @@ public class Plot {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
Location location = toHomeLocation(bottom, home);
|
Location location = toHomeLocation(bottom, home);
|
||||||
|
if (Settings.Teleport.SIZED_BASED && this.worldUtil.isSmallBlock(location) && this.worldUtil.isSmallBlock(location.add(0,1,0))) {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
if (!this.worldUtil.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
|
if (!this.worldUtil.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
|
||||||
location = location.withY(
|
location = location.withY(
|
||||||
Math.max(1 + this.worldUtil.getHighestBlockSynchronous(
|
Math.max(1 + this.worldUtil.getHighestBlockSynchronous(
|
||||||
@ -1440,7 +1443,11 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
Location bottom = this.getBottomAbs();
|
Location bottom = this.getBottomAbs();
|
||||||
Location location = toHomeLocation(bottom, home);
|
Location location = toHomeLocation(bottom, home);
|
||||||
|
if (Settings.Teleport.SIZED_BASED && this.worldUtil.isSmallBlock(location) && this.worldUtil.isSmallBlock(location.add(0,1,0))) {
|
||||||
|
result.accept(location);
|
||||||
|
} else {
|
||||||
this.worldUtil.getBlock(location, block -> {
|
this.worldUtil.getBlock(location, block -> {
|
||||||
|
|
||||||
if (!block.getBlockType().getMaterial().isAir()) {
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
this.worldUtil.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(),
|
this.worldUtil.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(),
|
||||||
y -> result.accept(location.withY(Math.max(1 + y, bottom.getY())))
|
y -> result.accept(location.withY(Math.max(1 + y, bottom.getY())))
|
||||||
@ -1450,6 +1457,8 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location toHomeLocation(Location bottom, BlockLoc relativeHome) {
|
private Location toHomeLocation(Location bottom, BlockLoc relativeHome) {
|
||||||
|
@ -177,6 +177,13 @@ public abstract class WorldUtil {
|
|||||||
*/
|
*/
|
||||||
public abstract void getBlock(@NonNull Location location, @NonNull Consumer<BlockState> result);
|
public abstract void getBlock(@NonNull Location location, @NonNull Consumer<BlockState> result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the block smaller as a slab
|
||||||
|
* @param location Block location
|
||||||
|
* @return true if it smaller as a slab
|
||||||
|
*/
|
||||||
|
public abstract boolean isSmallBlock(@NonNull Location location);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the block at a given location (synchronously)
|
* Get the block at a given location (synchronously)
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user