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:
Erik Broes
2011-04-25 18:14:06 +02:00
parent 6940f56d4d
commit 88ebcc8db5
5 changed files with 103 additions and 40 deletions

View File

@@ -5,7 +5,6 @@ import java.net.SocketAddress;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.ItemInWorldManager;
import net.minecraft.server.Packet;
import net.minecraft.server.Packet200Statistic;
import net.minecraft.server.Packet3Chat;
import net.minecraft.server.Packet6SpawnPosition;
@@ -17,7 +16,6 @@ import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.TextWrapper;
import org.bukkit.entity.Player;
public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -84,9 +82,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public void sendMessage(String message) {
for (final String line: TextWrapper.wrapText(message)) {
getHandle().netServerHandler.sendPacket(new Packet3Chat(line));
}
this.sendRawMessage(message);
}
public String getDisplayName() {
@@ -256,7 +252,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (!material.isBlock()) {
mat -= 255;
}
sendStatistic(statistic.getId() + mat, amount);
}
@@ -265,7 +261,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
sendStatistic(id, Byte.MAX_VALUE);
amount -= Byte.MAX_VALUE;
}
getHandle().netServerHandler.sendPacket(new Packet200Statistic(id, amount));
}
}