Paper/nms-patches/TileEntitySign.patch

76 lines
3.2 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/TileEntitySign.java
+++ b/net/minecraft/server/TileEntitySign.java
2018-08-26 04:00:00 +02:00
@@ -24,6 +24,12 @@
nbttagcompound.setString("Text" + (i + 1), s);
}
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start
+ if (Boolean.getBoolean("convertLegacySigns")) {
+ nbttagcompound.setBoolean("Bukkit.isConverted", true);
+ }
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
+
2016-05-10 13:47:39 +02:00
return nbttagcompound;
}
2018-07-15 02:00:00 +02:00
2018-08-26 04:00:00 +02:00
@@ -31,18 +37,38 @@
2018-07-15 02:00:00 +02:00
this.isEditable = false;
super.load(nbttagcompound);
+ // CraftBukkit start - Add an option to convert signs correctly
+ // This is done with a flag instead of all the time because
+ // we have no way to tell whether a sign is from 1.7.10 or 1.8
2015-02-26 23:41:06 +01:00
+
+ boolean oldSign = Boolean.getBoolean("convertLegacySigns") && !nbttagcompound.getBoolean("Bukkit.isConverted");
2015-02-26 23:41:06 +01:00
+
for (int i = 0; i < 4; ++i) {
String s = nbttagcompound.getString("Text" + (i + 1));
2016-02-29 22:32:46 +01:00
- IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s);
+ if (s != null && s.length() > 2048) {
+ s = "\"\"";
+ }
2018-07-15 02:00:00 +02:00
- if (this.world instanceof WorldServer) {
- try {
- this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatbasecomponent, (Entity) null);
- } catch (CommandSyntaxException commandsyntaxexception) {
+ try {
2016-02-29 22:32:46 +01:00
+ IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s);
+
2015-02-26 23:41:06 +01:00
+ if (oldSign) {
+ lines[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0];
+ continue;
+ }
+ // CraftBukkit end
+
2018-07-15 02:00:00 +02:00
+ if (this.world instanceof WorldServer) {
+ try {
+ this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatbasecomponent, (Entity) null);
+ } catch (CommandSyntaxException commandsyntaxexception) {
+ this.lines[i] = ichatbasecomponent;
+ }
+ } else {
this.lines[i] = ichatbasecomponent;
}
- } else {
- this.lines[i] = ichatbasecomponent;
2016-02-29 22:32:46 +01:00
+ } catch (com.google.gson.JsonParseException jsonparseexception) {
+ this.lines[i] = new ChatComponentText(s);
}
2018-08-26 04:00:00 +02:00
this.h[i] = null;
@@ -102,6 +128,13 @@
2018-07-15 02:00:00 +02:00
public void sendMessage(IChatBaseComponent ichatbasecomponent) {}
+ // CraftBukkit start
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
+ return wrapper.f() != null ? wrapper.f().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this);
2018-07-15 02:00:00 +02:00
+ }
+ // CraftBukkit end
+
public CommandListenerWrapper a(@Nullable EntityPlayer entityplayer) {
String s = entityplayer == null ? "Sign" : entityplayer.getDisplayName().getString();
Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getScoreboardDisplayName();