13
0
geforkt von Mirrors/Velocity

A little more documentation.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-07-31 16:22:21 -04:00
Ursprung bbf861d3bc
Commit 8b1e1f20cf
2 geänderte Dateien mit 18 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -8,11 +8,15 @@ import java.util.regex.Pattern;
* LegacyChatColorUtils contains utilities for handling legacy Minecraft color codes. Generally, you should prefer * 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. * 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'; 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 * 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); 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. * Removes all Minecraft color codes from the string.
* @param text the text to remove color codes from * @param text the text to remove color codes from

Datei anzeigen

@ -134,11 +134,17 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
idRemapper = EntityIdRemapper.getMapper(joinGame.getEntityId(), player.getConnection().getProtocolVersion()); idRemapper = EntityIdRemapper.getMapper(joinGame.getEntityId(), player.getConnection().getProtocolVersion());
} else { } else {
// In order to handle switching to another server we will need send three packets: // In order to handle switching to another server we will need send three packets:
//
// - The join game packet from the backend server // - The join game packet from the backend server
// - A respawn packet with a different dimension // - A respawn packet with a different dimension
// - Another respawn with the correct 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 // We can't simply ignore the packet with the different dimension. If you try to be smart about it it doesn't
// work. // 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()); idRemapper.setServerEntityId(joinGame.getEntityId());
player.getConnection().delayedWrite(joinGame); player.getConnection().delayedWrite(joinGame);
int tempDim = joinGame.getDimension() == 0 ? -1 : 0; int tempDim = joinGame.getDimension() == 0 ? -1 : 0;