blob: ae54e0f4925e6557c1f14d07d60dc49a98bb0d86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntitySign;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.craftbukkit.CraftWorld;
public class CraftSign extends CraftBlockState implements Sign {
private final TileEntitySign sign;
private final String[] lines;
public CraftSign(final Block block) {
super(block);
CraftWorld world = (CraftWorld) block.getWorld();
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() {
return lines;
}
public String getLine(int index) throws IndexOutOfBoundsException {
return lines[index];
}
public void setLine(int index, String line) throws IndexOutOfBoundsException {
lines[index] = line;
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
if (result) {
System.arraycopy(lines, 0, sign.lines, 0, lines.length);
sign.update();
}
return result;
}
}
|