mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-09-10 14:27:59 +02:00
Uses newer API for signs.
This commit is contained in:
parent
c463ad0ea0
commit
eeb3e64a97
@ -12,10 +12,12 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.block.data.type.Sign;
|
||||||
|
import org.bukkit.block.data.type.WallSign;
|
||||||
import org.bukkit.entity.AbstractHorse;
|
import org.bukkit.entity.AbstractHorse;
|
||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.ChestedHorse;
|
import org.bukkit.entity.ChestedHorse;
|
||||||
@ -221,7 +223,7 @@ public class BlueprintPaster {
|
|||||||
// Get the block state
|
// Get the block state
|
||||||
BlockState bs = block.getState();
|
BlockState bs = block.getState();
|
||||||
// Signs
|
// Signs
|
||||||
if (bs instanceof Sign) {
|
if (bs instanceof org.bukkit.block.Sign) {
|
||||||
writeSign(island, block, bpBlock.getSignLines());
|
writeSign(island, block, bpBlock.getSignLines());
|
||||||
}
|
}
|
||||||
// Chests, in general
|
// Chests, in general
|
||||||
@ -322,14 +324,20 @@ public class BlueprintPaster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeSign(final Island island, final Block block, final List<String> lines) {
|
private void writeSign(final Island island, final Block block, final List<String> lines) {
|
||||||
Sign sign = (Sign) block.getState();
|
BlockFace bf = null;
|
||||||
org.bukkit.material.Sign s = (org.bukkit.material.Sign) sign.getData();
|
if (block.getType().name().contains("WALL_SIGN")) {
|
||||||
|
WallSign wallSign = (WallSign)block.getBlockData();
|
||||||
|
bf = wallSign.getFacing();
|
||||||
|
} else {
|
||||||
|
Sign sign = (Sign)block.getBlockData();
|
||||||
|
bf = sign.getRotation();
|
||||||
|
}
|
||||||
// Handle spawn sign
|
// Handle spawn sign
|
||||||
if (island != null && !lines.isEmpty() && lines.get(0).equalsIgnoreCase(TextVariables.SPAWN_HERE)) {
|
if (island != null && !lines.isEmpty() && lines.get(0).equalsIgnoreCase(TextVariables.SPAWN_HERE)) {
|
||||||
block.setType(Material.AIR);
|
block.setType(Material.AIR);
|
||||||
// Orient to face same direction as sign
|
// Orient to face same direction as sign
|
||||||
Location spawnPoint = new Location(block.getWorld(), block.getX() + 0.5D, block.getY(),
|
Location spawnPoint = new Location(block.getWorld(), block.getX() + 0.5D, block.getY(),
|
||||||
block.getZ() + 0.5D, Util.blockFaceToFloat(s.getFacing().getOppositeFace()), 30F);
|
block.getZ() + 0.5D, Util.blockFaceToFloat(bf.getOppositeFace()), 30F);
|
||||||
island.setSpawnPoint(block.getWorld().getEnvironment(), spawnPoint);
|
island.setSpawnPoint(block.getWorld().getEnvironment(), spawnPoint);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -339,22 +347,23 @@ public class BlueprintPaster {
|
|||||||
name = plugin.getPlayers().getName(island.getOwner());
|
name = plugin.getPlayers().getName(island.getOwner());
|
||||||
}
|
}
|
||||||
// Handle locale text for starting sign
|
// Handle locale text for starting sign
|
||||||
|
org.bukkit.block.Sign s = (org.bukkit.block.Sign)block.getState();
|
||||||
// Sign text must be stored under the addon's name.sign.line0,1,2,3 in the yaml file
|
// Sign text must be stored under the addon's name.sign.line0,1,2,3 in the yaml file
|
||||||
if (island != null && !lines.isEmpty() && lines.get(0).equalsIgnoreCase(TextVariables.START_TEXT)) {
|
if (island != null && !lines.isEmpty() && lines.get(0).equalsIgnoreCase(TextVariables.START_TEXT)) {
|
||||||
// Get the addon that is operating in this world
|
// Get the addon that is operating in this world
|
||||||
String addonName = plugin.getIWM().getAddon(island.getWorld()).map(addon -> addon.getDescription().getName().toLowerCase()).orElse("");
|
String addonName = plugin.getIWM().getAddon(island.getWorld()).map(addon -> addon.getDescription().getName().toLowerCase()).orElse("");
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
sign.setLine(i, ChatColor.translateAlternateColorCodes('&', plugin.getLocalesManager().getOrDefault(User.getInstance(island.getOwner()),
|
s.setLine(i, ChatColor.translateAlternateColorCodes('&', plugin.getLocalesManager().getOrDefault(User.getInstance(island.getOwner()),
|
||||||
addonName + ".sign.line" + i,"").replace(TextVariables.NAME, name)));
|
addonName + ".sign.line" + i,"").replace(TextVariables.NAME, name)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Just paste
|
// Just paste
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
sign.setLine(i, lines.get(i));
|
s.setLine(i, lines.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update the sign
|
// Update the sign
|
||||||
sign.update();
|
s.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user