13
0
geforkt von Mirrors/Paper

Apply sign limits to signs text content

Dieser Commit ist enthalten in:
Shane Freeder 2019-02-28 18:07:14 +00:00
Ursprung 8c3f760f3c
Commit 245e2d1061
2 geänderte Dateien mit 23 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Fix sign edit memory leak
when a player edits a sign, a reference to their Entity is never cleand up.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 9b857a8d1d..53ef6bf175 100644
index 9b857a8d1..53ef6bf17 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@ -19,7 +19,7 @@ index 9b857a8d1d..53ef6bf175 100644
this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit
return;
diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java
index 9dbdabeb0c..0a5971d0ec 100644
index 05fb2eea5..ca80391d7 100644
--- a/src/main/java/net/minecraft/server/TileEntitySign.java
+++ b/src/main/java/net/minecraft/server/TileEntitySign.java
@@ -0,0 +0,0 @@ public class TileEntitySign extends TileEntity implements ICommandListener {

Datei anzeigen

@ -20,7 +20,7 @@ it only impacts data sent to and from the client.
Set -DPaper.maxSignLength=XX to change limit or -1 to disable
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 04344a3711..9b857a8d1d 100644
index 04344a371..9b857a8d1 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@ -36,9 +36,17 @@ index 04344a3711..9b857a8d1d 100644
}
SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines);
diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java
index c2bcbbbab9..9dbdabeb0c 100644
index c2bcbbbab..05fb2eea5 100644
--- a/src/main/java/net/minecraft/server/TileEntitySign.java
+++ b/src/main/java/net/minecraft/server/TileEntitySign.java
@@ -0,0 +0,0 @@
package net.minecraft.server;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
+
import javax.annotation.Nullable;
public class TileEntitySign extends TileEntity implements ICommandListener {
@@ -0,0 +0,0 @@ public class TileEntitySign extends TileEntity implements ICommandListener {
// Paper start - Strip invalid unicode from signs on load
private static final boolean keepInvalidUnicode = Boolean.getBoolean("Paper.keepInvalidUnicode"); // Allow people to keep their bad unicode if they really want it
@ -59,13 +67,19 @@ index c2bcbbbab9..9dbdabeb0c 100644
super.save(nbttagcompound);
for (int i = 0; i < 4; ++i) {
String s = IChatBaseComponent.ChatSerializer.a(this.lines[i]);
- String s = IChatBaseComponent.ChatSerializer.a(this.lines[i]);
+ // Paper start
+ String component = org.bukkit.craftbukkit.util.CraftChatMessage.fromComponent(lines[i]);
+
+ if (filterLines && MAX_SIGN_LINE_LENGTH > 0 && component.length() > MAX_SIGN_LINE_LENGTH) {
+ component = component.substring(0, MAX_SIGN_LINE_LENGTH);
+ }
+
+ String s = org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(component)[0]);
+ // Paper end
- nbttagcompound.setString("Text" + (i + 1), s);
+ nbttagcompound.setString("Text" + (i + 1), filterLines && MAX_SIGN_LINE_LENGTH > 0 && s.length() > MAX_SIGN_LINE_LENGTH ? s.substring(0, MAX_SIGN_LINE_LENGTH): s); // Paper
nbttagcompound.setString("Text" + (i + 1), s);
}
// CraftBukkit start
@@ -0,0 +0,0 @@ public class TileEntitySign extends TileEntity implements ICommandListener {
}