Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-08 17:20:20 +01:00
Merge branch 'floodgate-2.0' of https://github.com/Tim203/Geyser into floodgate-2.0
Dieser Commit ist enthalten in:
Commit
b0aceefd86
@ -76,7 +76,7 @@ public final class BedrockData {
|
||||
return new BedrockData(
|
||||
split[0], split[1], split[2], Integer.parseInt(split[3]), split[4],
|
||||
Integer.parseInt(split[5]), Integer.parseInt(split[6]), split[7],
|
||||
linkedPlayer, Boolean.parseBoolean(split[9]), split.length
|
||||
linkedPlayer, "1".equals(split[8]), split.length
|
||||
);
|
||||
}
|
||||
|
||||
@ -93,6 +93,7 @@ public final class BedrockData {
|
||||
// The format is the same as the order of the fields in this class
|
||||
return version + '\0' + username + '\0' + xuid + '\0' + deviceOs + '\0' +
|
||||
languageCode + '\0' + uiProfile + '\0' + inputMode + '\0' + ip + '\0' +
|
||||
fromProxy + '\0' + (linkedPlayer != null ? linkedPlayer.toString() : "null");
|
||||
(fromProxy ? 1 : 0) + '\0' +
|
||||
(linkedPlayer != null ? linkedPlayer.toString() : "null");
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
package org.geysermc.floodgate.util;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Base64;
|
||||
@ -34,7 +33,6 @@ import java.util.Base64;
|
||||
import static java.lang.String.format;
|
||||
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public final class RawSkin {
|
||||
public int width;
|
||||
public int height;
|
||||
@ -44,11 +42,20 @@ public final class RawSkin {
|
||||
private RawSkin() {
|
||||
}
|
||||
|
||||
public static RawSkin decode(byte[] data) throws InvalidFormatException {
|
||||
return decode(data, 0);
|
||||
public static RawSkin decode(byte[] data, int offset) throws InvalidFormatException {
|
||||
if (data == null || offset < 0 || data.length <= offset) {
|
||||
return null;
|
||||
}
|
||||
if (offset == 0) {
|
||||
return decode(data);
|
||||
}
|
||||
|
||||
byte[] rawSkin = new byte[data.length - offset];
|
||||
System.arraycopy(data, offset, rawSkin, 0, rawSkin.length);
|
||||
return decode(rawSkin);
|
||||
}
|
||||
|
||||
public static RawSkin decode(byte[] data, int offset) throws InvalidFormatException {
|
||||
public static RawSkin decode(byte[] data) throws InvalidFormatException {
|
||||
// offset is an amount of bytes before the Base64 starts
|
||||
if (data == null) {
|
||||
return null;
|
||||
@ -56,7 +63,7 @@ public final class RawSkin {
|
||||
|
||||
int maxEncodedLength = Base64Utils.getEncodedLength(64 * 64 * 4 + 9);
|
||||
// if the RawSkin is longer then the max Java Edition skin length
|
||||
if ((data.length - offset) > maxEncodedLength) {
|
||||
if (data.length > maxEncodedLength) {
|
||||
throw new InvalidFormatException(format(
|
||||
"Encoded data cannot be longer then %s bytes! Got %s",
|
||||
maxEncodedLength, data.length
|
||||
@ -64,7 +71,7 @@ public final class RawSkin {
|
||||
}
|
||||
|
||||
// if the encoded data doesn't even contain the width, height (8 bytes, 2 ints) and isAlex
|
||||
if ((data.length - offset) < Base64Utils.getEncodedLength(9)) {
|
||||
if (data.length < Base64Utils.getEncodedLength(9)) {
|
||||
throw new InvalidFormatException("Encoded data must be at least 16 bytes long!");
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,7 @@ public class PluginMessageUtils {
|
||||
.put(data)
|
||||
.array();
|
||||
|
||||
data = "floodgate:skin\0floodgate:form".getBytes(Charsets.UTF_8);
|
||||
FLOODGATE_REGISTER_DATA =
|
||||
ByteBuffer.allocate(data.length + getVarIntLength(data.length))
|
||||
.put(writeVarInt(data.length))
|
||||
.put(data)
|
||||
.array();
|
||||
FLOODGATE_REGISTER_DATA = "floodgate:skin\0floodgate:form".getBytes(Charsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren