3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00
Paper/nms-patches/TileEntitySign.patch

71 Zeilen
3.0 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/TileEntitySign.java
+++ b/net/minecraft/server/TileEntitySign.java
2016-05-10 13:47:39 +02:00
@@ -21,6 +21,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
+
this.i.b(nbttagcompound);
2016-05-10 13:47:39 +02:00
return nbttagcompound;
}
2016-06-09 03:43:49 +02:00
@@ -74,14 +80,34 @@
2016-02-29 22:32:46 +01:00
}
2015-02-26 23:41:06 +01:00
};
+ // 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 = "\"\"";
+ }
try {
2016-02-29 22:32:46 +01:00
- this.lines[i] = ChatComponentUtils.filterForDisplay(icommandlistener, ichatbasecomponent, (Entity) null);
- } catch (CommandException commandexception) {
- this.lines[i] = ichatbasecomponent;
+ 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
+
2016-02-29 22:32:46 +01:00
+ try {
+ this.lines[i] = ChatComponentUtils.filterForDisplay(icommandlistener, ichatbasecomponent, (Entity) null);
+ } catch (CommandException commandexception) {
+ this.lines[i] = ichatbasecomponent;
+ }
+ } catch (com.google.gson.JsonParseException jsonparseexception) {
+ this.lines[i] = new ChatComponentText(s);
}
}
2016-06-09 03:43:49 +02:00
@@ -171,7 +197,14 @@
ChatClickable chatclickable = chatmodifier.h();
2015-02-26 23:41:06 +01:00
if (chatclickable.a() == ChatClickable.EnumClickAction.RUN_COMMAND) {
2016-02-29 22:32:46 +01:00
- entityhuman.h().getCommandHandler().a(icommandlistener, chatclickable.b());
+ // CraftBukkit start
2016-02-29 22:32:46 +01:00
+ // entityhuman.h().getCommandHandler().a(icommandlistener, chatclickable.b());
+ CommandBlockListenerAbstract.executeCommand(icommandlistener, new org.bukkit.craftbukkit.command.ProxiedNativeCommandSender(
+ icommandlistener,
+ new org.bukkit.craftbukkit.command.CraftBlockCommandSender(icommandlistener),
+ entityhuman.getBukkitEntity()
+ ), chatclickable.b());
2015-02-26 23:41:06 +01:00
+ // CraftBukkit end
}
}
}