mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 11:38:29 +01:00
CraftSign changes. Addresses BUKKIT-824
- Removed the useless world field. - Made it so changes to a CraftSign (which is a Block*State*) no longer reflect into the world without calling sign.update().
This commit is contained in:
parent
57bd84510f
commit
f2d9d4174f
@ -6,26 +6,28 @@ import org.bukkit.block.Sign;
|
|||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
|
||||||
public class CraftSign extends CraftBlockState implements Sign {
|
public class CraftSign extends CraftBlockState implements Sign {
|
||||||
private final CraftWorld world;
|
|
||||||
private final TileEntitySign sign;
|
private final TileEntitySign sign;
|
||||||
|
private final String[] lines;
|
||||||
|
|
||||||
public CraftSign(final Block block) {
|
public CraftSign(final Block block) {
|
||||||
super(block);
|
super(block);
|
||||||
|
|
||||||
world = (CraftWorld) block.getWorld();
|
CraftWorld world = (CraftWorld) block.getWorld();
|
||||||
sign = (TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ());
|
sign = (TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ());
|
||||||
|
lines = new String[sign.lines.length];
|
||||||
|
System.arraycopy(sign.lines, 0, lines, 0, lines.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getLines() {
|
public String[] getLines() {
|
||||||
return sign.lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLine(int index) throws IndexOutOfBoundsException {
|
public String getLine(int index) throws IndexOutOfBoundsException {
|
||||||
return sign.lines[index];
|
return lines[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLine(int index, String line) throws IndexOutOfBoundsException {
|
public void setLine(int index, String line) throws IndexOutOfBoundsException {
|
||||||
sign.lines[index] = line;
|
lines[index] = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,6 +35,7 @@ public class CraftSign extends CraftBlockState implements Sign {
|
|||||||
boolean result = super.update(force);
|
boolean result = super.update(force);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
|
System.arraycopy(lines, 0, sign.lines, 0, lines.length);
|
||||||
sign.update();
|
sign.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user