geforkt von Mirrors/Paper
Re-added TextWrapper, and fixed chat length issues (at cost of it looking not so nice sometimes!) This fixes BUKKIT-1275
Dieser Commit ist enthalten in:
Ursprung
ddaf3c84d3
Commit
904cf388b4
@ -15,13 +15,16 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.craftbukkit.ChunkCompressionThread;
|
import org.bukkit.craftbukkit.ChunkCompressionThread;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandException;
|
import org.bukkit.command.CommandException;
|
||||||
|
import org.bukkit.conversations.Conversable;
|
||||||
import org.bukkit.craftbukkit.CraftWorld;
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.inventory.CraftInventoryCustom;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.TextWrapper;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -715,7 +718,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
|||||||
this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.x, packet6.y, packet6.z);
|
this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.x, packet6.y, packet6.z);
|
||||||
} else if (packet instanceof Packet3Chat) {
|
} else if (packet instanceof Packet3Chat) {
|
||||||
String message = ((Packet3Chat) packet).message;
|
String message = ((Packet3Chat) packet).message;
|
||||||
for (final String line : message.split("\n")) {
|
boolean first = true;
|
||||||
|
for (String line : TextWrapper.wrapText(message)) {
|
||||||
|
if (!first) line = " " + line;
|
||||||
|
first = false;
|
||||||
this.networkManager.queue(new Packet3Chat(line));
|
this.networkManager.queue(new Packet3Chat(line));
|
||||||
}
|
}
|
||||||
packet = null;
|
packet = null;
|
||||||
|
20
src/main/java/org/bukkit/craftbukkit/TextWrapper.java
Normale Datei
20
src/main/java/org/bukkit/craftbukkit/TextWrapper.java
Normale Datei
@ -0,0 +1,20 @@
|
|||||||
|
package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
public class TextWrapper {
|
||||||
|
private static final int CHAT_STRING_LENGTH = 119;
|
||||||
|
|
||||||
|
public static String[] wrapText(final String text) {
|
||||||
|
return insertLineBreaks(text).split("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String insertLineBreaks(String input) {
|
||||||
|
if (input.length() <= CHAT_STRING_LENGTH) return input;
|
||||||
|
|
||||||
|
String head = input.substring(0, CHAT_STRING_LENGTH);
|
||||||
|
String tail = ChatColor.getLastColors(head) + input.substring(CHAT_STRING_LENGTH + (input.charAt(CHAT_STRING_LENGTH) == ' ' ? 1 : 0));
|
||||||
|
|
||||||
|
return head + "\n" + insertLineBreaks(tail);
|
||||||
|
}
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren