Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
A little more documentation.
Dieser Commit ist enthalten in:
Ursprung
bbf861d3bc
Commit
8b1e1f20cf
@ -8,11 +8,15 @@ import java.util.regex.Pattern;
|
||||
* LegacyChatColorUtils contains utilities for handling legacy Minecraft color codes. Generally, you should prefer
|
||||
* JSON-based components, but for convenience Velocity provides a limited set of tools to handle Minecraft color codes.
|
||||
*/
|
||||
public enum LegacyChatColorUtils {
|
||||
;
|
||||
public class LegacyChatColorUtils {
|
||||
private LegacyChatColorUtils() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the legacy Minecraft format character, the section symbol.
|
||||
*/
|
||||
public static final char FORMAT_CHAR = '\u00a7';
|
||||
private static final Pattern CHAT_COLOR_MATCHER = Pattern.compile("(?i)" + Character.toString(FORMAT_CHAR) + "[0-9A-FL-OR]");
|
||||
|
||||
/**
|
||||
* Translates a string with Minecraft color codes prefixed with a different character than the section symbol into
|
||||
@ -44,6 +48,11 @@ public enum LegacyChatColorUtils {
|
||||
return new String(textChars);
|
||||
}
|
||||
|
||||
/**
|
||||
* A regex that matches all Minecraft color codes and removes them.
|
||||
*/
|
||||
private static final Pattern CHAT_COLOR_MATCHER = Pattern.compile("(?i)" + Character.toString(FORMAT_CHAR) + "[0-9A-FL-OR]");
|
||||
|
||||
/**
|
||||
* Removes all Minecraft color codes from the string.
|
||||
* @param text the text to remove color codes from
|
||||
|
@ -134,11 +134,17 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
idRemapper = EntityIdRemapper.getMapper(joinGame.getEntityId(), player.getConnection().getProtocolVersion());
|
||||
} else {
|
||||
// In order to handle switching to another server we will need send three packets:
|
||||
//
|
||||
// - The join game packet from the backend server
|
||||
// - A respawn packet with a different dimension
|
||||
// - Another respawn with the correct dimension
|
||||
//
|
||||
// We can't simply ignore the packet with the different dimension. If you try to be smart about it it doesn't
|
||||
// work.
|
||||
//
|
||||
// Most notably, by having the client accept the join game packet, we can work around the need to perform
|
||||
// entity ID rewrites, eliminating potential issues from rewriting packets and improving compatibility with
|
||||
// mods.
|
||||
idRemapper.setServerEntityId(joinGame.getEntityId());
|
||||
player.getConnection().delayedWrite(joinGame);
|
||||
int tempDim = joinGame.getDimension() == 0 ? -1 : 0;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren