3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

SPIGOT-5098: Add a method to allow colored sign changes

Dieser Commit ist enthalten in:
Yannick Lamprecht 2019-06-22 16:22:53 +02:00 committet von md_5
Ursprung 533290e290
Commit 8a3d3f4980

Datei anzeigen

@ -36,6 +36,7 @@ import net.minecraft.server.Entity;
import net.minecraft.server.EntityLiving; import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EnumChatFormat; import net.minecraft.server.EnumChatFormat;
import net.minecraft.server.EnumColor;
import net.minecraft.server.EnumGamemode; import net.minecraft.server.EnumGamemode;
import net.minecraft.server.IChatBaseComponent; import net.minecraft.server.IChatBaseComponent;
import net.minecraft.server.MapIcon; import net.minecraft.server.MapIcon;
@ -68,6 +69,7 @@ import org.apache.commons.lang.Validate;
import org.bukkit.Achievement; import org.bukkit.Achievement;
import org.bukkit.BanList; import org.bukkit.BanList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Instrument; import org.bukkit.Instrument;
@ -523,6 +525,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override @Override
public void sendSignChange(Location loc, String[] lines) { 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) { if (getHandle().playerConnection == null) {
return; return;
} }
@ -532,6 +539,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
Validate.notNull(loc, "Location can not be null"); Validate.notNull(loc, "Location can not be null");
Validate.notNull(dyeColor, "DyeColor can not be null");
if (lines.length < 4) { if (lines.length < 4) {
throw new IllegalArgumentException("Must have at least 4 lines"); 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); IChatBaseComponent[] components = CraftSign.sanitizeLines(lines);
TileEntitySign sign = new TileEntitySign(); TileEntitySign sign = new TileEntitySign();
sign.setPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); 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); System.arraycopy(components, 0, sign.lines, 0, sign.lines.length);
getHandle().playerConnection.sendPacket(sign.getUpdatePacket()); getHandle().playerConnection.sendPacket(sign.getUpdatePacket());