mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-20 06:43:49 -07:00
Fix TextWrapping issues; Now limits the packets send to the client to either: 119 chars or 320 width. This will strip disallowed characters, propagate colors properly to the next line and not 'eat' multiple color-codes.
This commit is contained in:
@@ -14,6 +14,7 @@ import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.TextWrapper;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.block.*;
|
||||
@@ -579,9 +580,15 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
if (packet instanceof Packet6SpawnPosition) {
|
||||
Packet6SpawnPosition packet6 = (Packet6SpawnPosition) packet;
|
||||
this.player.compassTarget = new Location(getPlayer().getWorld(), packet6.x, packet6.y, packet6.z);
|
||||
} else if (packet instanceof Packet3Chat) {
|
||||
String message = ((Packet3Chat) packet).a;
|
||||
for (final String line: TextWrapper.wrapText(message)) {
|
||||
this.networkManager.a(new Packet3Chat(line));
|
||||
}
|
||||
packet = null;
|
||||
}
|
||||
if (packet != null) this.networkManager.a(packet);
|
||||
// CraftBukkit
|
||||
this.networkManager.a(packet);
|
||||
this.g = this.f;
|
||||
}
|
||||
|
||||
|
@@ -150,9 +150,9 @@ public abstract class Packet {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void a(DataInputStream datainputstream);
|
||||
public abstract void a(DataInputStream datainputstream) throws IOException; // CraftBukkit
|
||||
|
||||
public abstract void a(DataOutputStream dataoutputstream);
|
||||
public abstract void a(DataOutputStream dataoutputstream) throws IOException; // CraftBukkit
|
||||
|
||||
public abstract void a(NetHandler nethandler);
|
||||
|
||||
|
38
src/main/java/net/minecraft/server/Packet3Chat.java
Normal file
38
src/main/java/net/minecraft/server/Packet3Chat.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Packet3Chat extends Packet {
|
||||
|
||||
public String a;
|
||||
|
||||
public Packet3Chat() {}
|
||||
|
||||
public Packet3Chat(String s) {
|
||||
// CraftBukkit start - handle this later
|
||||
//if (s.length() > 119) {
|
||||
// s = s.substring(0, 119);
|
||||
//}
|
||||
// CraftBukkit end
|
||||
|
||||
this.a = s;
|
||||
}
|
||||
|
||||
public void a(DataInputStream datainputstream) throws IOException { // CraftBukkit
|
||||
this.a = a(datainputstream, 119);
|
||||
}
|
||||
|
||||
public void a(DataOutputStream dataoutputstream) throws IOException { // CraftBukkit
|
||||
a(this.a, dataoutputstream);
|
||||
}
|
||||
|
||||
public void a(NetHandler nethandler) {
|
||||
nethandler.a(this);
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.a.length();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user