mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Initial changes
This commit is contained in:
parent
eb7d71017c
commit
c0d605dd77
3 changed files with 7 additions and 32 deletions
|
@ -91,7 +91,7 @@ public final class AesCipher implements FloodgateCipher {
|
||||||
if (topping != null) {
|
if (topping != null) {
|
||||||
int mark = buffer.position();
|
int mark = buffer.position();
|
||||||
|
|
||||||
// we need the first index, the second is for the optional RawSkin
|
// we need the first index, the second is for the actual data
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
while (buffer.hasRemaining() && !found) {
|
while (buffer.hasRemaining() && !found) {
|
||||||
if (buffer.get() == 0x21) {
|
if (buffer.get() == 0x21) {
|
||||||
|
|
|
@ -130,25 +130,18 @@ public interface FloodgateCipher {
|
||||||
final int identifierLength = IDENTIFIER.length;
|
final int identifierLength = IDENTIFIER.length;
|
||||||
|
|
||||||
if (data.length <= HEADER_LENGTH) {
|
if (data.length <= HEADER_LENGTH) {
|
||||||
throw new InvalidFormatException("Data length is smaller then header." +
|
throw new InvalidFormatException(
|
||||||
"Needed " + HEADER_LENGTH + ", got " + data.length,
|
"Data length is smaller then header." +
|
||||||
true
|
"Needed " + HEADER_LENGTH + ", got " + data.length
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < identifierLength; i++) {
|
for (int i = 0; i < identifierLength; i++) {
|
||||||
if (IDENTIFIER[i] != data[i]) {
|
if (IDENTIFIER[i] != data[i]) {
|
||||||
StringBuilder receivedIdentifier = new StringBuilder();
|
String identifier = new String(IDENTIFIER, StandardCharsets.UTF_8);
|
||||||
for (byte b : IDENTIFIER) {
|
String received = new String(data, 0, IDENTIFIER.length, StandardCharsets.UTF_8);
|
||||||
receivedIdentifier.append(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new InvalidFormatException(
|
throw new InvalidFormatException(
|
||||||
String.format("Expected identifier %s, got %s",
|
"Expected identifier " + identifier + ", got " + received
|
||||||
new String(IDENTIFIER, StandardCharsets.UTF_8),
|
|
||||||
receivedIdentifier.toString()
|
|
||||||
),
|
|
||||||
true
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,26 +26,8 @@
|
||||||
|
|
||||||
package org.geysermc.floodgate.util;
|
package org.geysermc.floodgate.util;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class InvalidFormatException extends Exception {
|
public class InvalidFormatException extends Exception {
|
||||||
private boolean header = false;
|
|
||||||
|
|
||||||
public InvalidFormatException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public InvalidFormatException(String message) {
|
public InvalidFormatException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvalidFormatException(String message, boolean header) {
|
|
||||||
super(message);
|
|
||||||
this.header = header;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InvalidFormatException(String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue