Use configured unsafe blocks in height validator
This commit is contained in:
parent
3ecf194913
commit
4a77bf1519
|
@ -258,7 +258,7 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI {
|
|||
|
||||
private void initValidators() {
|
||||
locationValidators.add(new WorldborderValidator());
|
||||
locationValidators.add(new HeightValidator());
|
||||
locationValidators.add(new HeightValidator(unsafeBlocks));
|
||||
locationValidators.add(new ProtectionValidator());
|
||||
locationValidators.add(new BlockValidator(safeBlocks));
|
||||
}
|
||||
|
|
|
@ -20,13 +20,21 @@ package de.themoep.randomteleport.searcher.validators;
|
|||
|
||||
import de.themoep.randomteleport.searcher.RandomSearcher;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class HeightValidator extends LocationValidator {
|
||||
|
||||
public HeightValidator() {
|
||||
private final EnumSet<Material> unsafeBlocks;
|
||||
|
||||
public HeightValidator(Material[] unsafeBlocks) {
|
||||
super("height");
|
||||
this.unsafeBlocks = EnumSet.noneOf(Material.class);
|
||||
Collections.addAll(this.unsafeBlocks, unsafeBlocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,7 +57,7 @@ public class HeightValidator extends LocationValidator {
|
|||
return isSafe(block.getRelative(BlockFace.UP)) && isSafe(block.getRelative(BlockFace.UP, 2));
|
||||
}
|
||||
|
||||
private static boolean isSafe(Block block) {
|
||||
return block.isPassable() && !block.isLiquid();
|
||||
private boolean isSafe(Block block) {
|
||||
return block.isPassable() && !block.isLiquid() && !unsafeBlocks.contains(block.getType());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ safe-blocks:
|
|||
- end_stone
|
||||
- netherrack
|
||||
|
||||
# Blocks unsafe when in "--force blocks" mode
|
||||
# Blocks not to teleport on or into
|
||||
unsafe-blocks:
|
||||
- air
|
||||
- water
|
||||
|
@ -96,6 +96,7 @@ unsafe-blocks:
|
|||
- dark_oak_door
|
||||
- end_rod
|
||||
- end_gateway
|
||||
- powder_snow
|
||||
|
||||
sign-variables:
|
||||
- "[RTP]"
|
||||
|
|
Loading…
Reference in New Issue