From 8a3d3f4980d4c0752be3c96ac67d1d40dde6c315 Mon Sep 17 00:00:00 2001 From: Yannick Lamprecht Date: Sat, 22 Jun 2019 16:22:53 +0200 Subject: [PATCH] SPIGOT-5098: Add a method to allow colored sign changes --- .../java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 8b5b22e923..220130fd20 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -36,6 +36,7 @@ import net.minecraft.server.Entity; import net.minecraft.server.EntityLiving; import net.minecraft.server.EntityPlayer; import net.minecraft.server.EnumChatFormat; +import net.minecraft.server.EnumColor; import net.minecraft.server.EnumGamemode; import net.minecraft.server.IChatBaseComponent; import net.minecraft.server.MapIcon; @@ -68,6 +69,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Achievement; import org.bukkit.BanList; import org.bukkit.Bukkit; +import org.bukkit.DyeColor; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Instrument; @@ -523,6 +525,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void sendSignChange(Location loc, String[] lines) { + sendSignChange(loc, lines, DyeColor.BLACK); + } + + @Override + public void sendSignChange(Location loc, String[] lines, DyeColor dyeColor) { if (getHandle().playerConnection == null) { return; } @@ -532,6 +539,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } Validate.notNull(loc, "Location can not be null"); + Validate.notNull(dyeColor, "DyeColor can not be null"); if (lines.length < 4) { throw new IllegalArgumentException("Must have at least 4 lines"); } @@ -539,6 +547,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { IChatBaseComponent[] components = CraftSign.sanitizeLines(lines); TileEntitySign sign = new TileEntitySign(); sign.setPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + sign.setColor(EnumColor.fromColorIndex(dyeColor.getWoolData())); System.arraycopy(components, 0, sign.lines, 0, sign.lines.length); getHandle().playerConnection.sendPacket(sign.getUpdatePacket());