SPIGOT-4391: Sign editable API

This commit is contained in:
md_5 2018-09-24 15:01:10 +10:00
parent dcb43ef83d
commit 5cffeca21f

View file

@ -11,6 +11,7 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements Sign { public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements Sign {
private String[] lines; private String[] lines;
private boolean editable;
public CraftSign(final Block block) { public CraftSign(final Block block) {
super(block, TileEntitySign.class); super(block, TileEntitySign.class);
@ -26,6 +27,7 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements
lines = new String[sign.lines.length]; lines = new String[sign.lines.length];
System.arraycopy(revertComponents(sign.lines), 0, lines, 0, lines.length); System.arraycopy(revertComponents(sign.lines), 0, lines, 0, lines.length);
editable = sign.isEditable;
} }
@Override @Override
@ -43,12 +45,23 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements
lines[index] = line; lines[index] = line;
} }
@Override
public boolean isEditable() {
return this.editable;
}
@Override
public void setEditable(boolean editable) {
this.editable = editable;
}
@Override @Override
public void applyTo(TileEntitySign sign) { public void applyTo(TileEntitySign sign) {
super.applyTo(sign); super.applyTo(sign);
IChatBaseComponent[] newLines = sanitizeLines(lines); IChatBaseComponent[] newLines = sanitizeLines(lines);
System.arraycopy(newLines, 0, sign.lines, 0, 4); System.arraycopy(newLines, 0, sign.lines, 0, 4);
sign.isEditable = editable;
} }
public static IChatBaseComponent[] sanitizeLines(String[] lines) { public static IChatBaseComponent[] sanitizeLines(String[] lines) {