mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 03:35:11 +01:00
Fixes an error that can occur with sign pasting
This commit is contained in:
parent
5a6b1862a0
commit
390532adbc
@ -321,7 +321,7 @@ public class BlueprintPaster {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeSign(Island island, Block block, List<String> lines) {
|
private void writeSign(final Island island, final Block block, final List<String> lines) {
|
||||||
Sign sign = (Sign) block.getState();
|
Sign sign = (Sign) block.getState();
|
||||||
org.bukkit.material.Sign s = (org.bukkit.material.Sign) sign.getData();
|
org.bukkit.material.Sign s = (org.bukkit.material.Sign) sign.getData();
|
||||||
// Handle spawn sign
|
// Handle spawn sign
|
||||||
@ -333,25 +333,25 @@ public class BlueprintPaster {
|
|||||||
island.setSpawnPoint(block.getWorld().getEnvironment(), spawnPoint);
|
island.setSpawnPoint(block.getWorld().getEnvironment(), spawnPoint);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Get the name of the player
|
||||||
|
String name = "";
|
||||||
|
if (island != null) {
|
||||||
|
name = plugin.getPlayers().getName(island.getOwner());
|
||||||
|
}
|
||||||
// Handle locale text for starting sign
|
// Handle locale text for starting sign
|
||||||
// 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("");
|
||||||
lines.clear();
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
lines.add(ChatColor.translateAlternateColorCodes('&', plugin.getLocalesManager().getOrDefault(User.getInstance(island.getOwner()),
|
sign.setLine(i, ChatColor.translateAlternateColorCodes('&', plugin.getLocalesManager().getOrDefault(User.getInstance(island.getOwner()),
|
||||||
addonName + ".sign.line" + i,"")));
|
addonName + ".sign.line" + i,"").replace(TextVariables.NAME, name)));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Just paste
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
sign.setLine(i, lines.get(i));
|
||||||
}
|
}
|
||||||
// Get the name of the player
|
|
||||||
String name = TextVariables.NAME;
|
|
||||||
if (island != null) {
|
|
||||||
name = plugin.getPlayers().getName(island.getOwner());
|
|
||||||
}
|
|
||||||
// Sub in player's name
|
|
||||||
for (int i = 0 ; i < lines.size(); i++) {
|
|
||||||
sign.setLine(i, lines.get(i).replace(TextVariables.NAME, name));
|
|
||||||
}
|
}
|
||||||
// Update the sign
|
// Update the sign
|
||||||
sign.update();
|
sign.update();
|
||||||
|
Loading…
Reference in New Issue
Block a user