mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-03-02 11:12:28 +01:00
Paste water at spawn_here sign location if sign is waterlogged
Prevents the air block around the user when they spawn.
This commit is contained in:
parent
3c9e5385ad
commit
8d89d622c9
@ -18,6 +18,7 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.block.data.type.WallSign;
|
||||
import org.bukkit.block.sign.Side;
|
||||
import org.bukkit.block.sign.SignSide;
|
||||
@ -26,6 +27,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.spawner.TrialSpawnerConfiguration;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
@ -141,6 +143,9 @@ public class DefaultPasteUtil {
|
||||
else if (bs instanceof CreatureSpawner spawner) {
|
||||
setSpawner(spawner, bpBlock.getCreatureSpawner());
|
||||
}
|
||||
else if (bs instanceof TrialSpawnerConfiguration spawner) {
|
||||
bpBlock.getTrialSpawner().configTrialSpawner(spawner);
|
||||
}
|
||||
// Banners
|
||||
else if (bs instanceof Banner banner && bpBlock.getBannerPatterns() != null) {
|
||||
bpBlock.getBannerPatterns().removeIf(Objects::isNull);
|
||||
@ -261,21 +266,20 @@ public class DefaultPasteUtil {
|
||||
* @param bpSign - BlueprintBlock that is the sign
|
||||
* @param side - the side being written
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void writeSign(Island island, final Block block, BlueprintBlock bpSign, Side side) {
|
||||
List<String> lines = bpSign.getSignLines(side);
|
||||
boolean glow = bpSign.isGlowingText(side);
|
||||
|
||||
BlockFace bf;
|
||||
if (block.getType().name().contains("WALL_SIGN")) {
|
||||
WallSign wallSign = (WallSign) block.getBlockData();
|
||||
bf = wallSign.getFacing();
|
||||
} else {
|
||||
org.bukkit.block.data.type.Sign sign = (org.bukkit.block.data.type.Sign) block.getBlockData();
|
||||
bf = sign.getRotation();
|
||||
}
|
||||
BlockData bd = block.getBlockData();
|
||||
BlockFace bf = (bd instanceof WallSign ws) ? ws.getFacing()
|
||||
: ((org.bukkit.block.data.type.Sign) bd).getRotation();
|
||||
// Handle spawn sign
|
||||
if (side == Side.FRONT && island != null && !lines.isEmpty() && lines.get(0).equalsIgnoreCase(TextVariables.SPAWN_HERE)) {
|
||||
block.setType(Material.AIR);
|
||||
if (bd instanceof Waterlogged wl && wl.isWaterlogged()) {
|
||||
block.setType(Material.WATER);
|
||||
} else {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
// Orient to face same direction as sign
|
||||
Location spawnPoint = new Location(block.getWorld(), block.getX() + 0.5D, block.getY(),
|
||||
block.getZ() + 0.5D, Util.blockFaceToFloat(bf.getOppositeFace()), 30F);
|
||||
|
Loading…
Reference in New Issue
Block a user