diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java index 8c05d56647..761970797a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java @@ -2,46 +2,40 @@ package org.bukkit.craftbukkit.block; import com.google.common.base.Preconditions; import net.minecraft.network.chat.IChatBaseComponent; -import net.minecraft.world.item.EnumColor; import net.minecraft.world.level.block.entity.TileEntitySign; import org.bukkit.DyeColor; import org.bukkit.World; import org.bukkit.block.Sign; +import org.bukkit.block.sign.Side; +import org.bukkit.block.sign.SignSide; +import org.bukkit.craftbukkit.block.sign.CraftSignSide; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class CraftSign extends CraftBlockEntityState implements Sign { - // Lazily initialized only if requested: - private String[] originalLines = null; - private String[] lines = null; + private final CraftSignSide front; public CraftSign(World world, T tileEntity) { super(world, tileEntity); + this.front = new CraftSignSide(this.getSnapshot()); } @Override public String[] getLines() { - if (lines == null) { - // Lazy initialization: - TileEntitySign sign = this.getSnapshot(); - lines = new String[sign.messages.length]; - System.arraycopy(revertComponents(sign.messages), 0, lines, 0, lines.length); - originalLines = new String[lines.length]; - System.arraycopy(lines, 0, originalLines, 0, originalLines.length); - } - return lines; + return front.getLines(); } @Override public String getLine(int index) throws IndexOutOfBoundsException { - return getLines()[index]; + return front.getLine(index); } @Override public void setLine(int index, String line) throws IndexOutOfBoundsException { - getLines()[index] = line; + front.setLine(index, line); } @Override @@ -56,37 +50,37 @@ public class CraftSign extends CraftBlockEntityState