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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
--- a/net/minecraft/server/TileEntitySign.java
+++ b/net/minecraft/server/TileEntitySign.java
@@ -24,6 +24,12 @@
nbttagcompound.setString("Text" + (i + 1), s);
}
+ // CraftBukkit start
+ if (Boolean.getBoolean("convertLegacySigns")) {
+ nbttagcompound.setBoolean("Bukkit.isConverted", true);
+ }
+ // CraftBukkit end
+
return nbttagcompound;
}
@@ -31,18 +37,38 @@
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
+
+ boolean oldSign = Boolean.getBoolean("convertLegacySigns") && !nbttagcompound.getBoolean("Bukkit.isConverted");
+
for (int i = 0; i < 4; ++i) {
String s = nbttagcompound.getString("Text" + (i + 1));
- IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s);
+ if (s != null && s.length() > 2048) {
+ s = "\"\"";
+ }
- if (this.world instanceof WorldServer) {
- try {
- this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatbasecomponent, (Entity) null);
- } catch (CommandSyntaxException commandsyntaxexception) {
+ try {
+ IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s);
+
+ if (oldSign) {
+ lines[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0];
+ continue;
+ }
+ // CraftBukkit end
+
+ 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;
+ } catch (com.google.gson.JsonParseException jsonparseexception) {
+ this.lines[i] = new ChatComponentText(s);
}
this.h[i] = null;
@@ -102,6 +128,13 @@
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);
+ }
+ // 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();
|