Fix protocol detection on some versions of Spigot

Fixes #3263
This commit is contained in:
Nassim Jahnke 2023-03-17 18:36:48 +01:00
parent 2e59a51734
commit e298a7efac
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
3 changed files with 10 additions and 11 deletions

View File

@ -237,6 +237,6 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
@Override
public String toString() {
return "Type|" + typeName;
return typeName;
}
}

View File

@ -36,7 +36,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public class BukkitViaInjector extends LegacyViaInjector {
private static final boolean HAS_SHARED_CONSTANTS = PaperViaInjector.hasClass("net.minecraft.SharedConstants") && PaperViaInjector.hasClass("net.minecraft.WorldVersion");
private static final boolean HAS_WORLD_VERSION_PROTOCOL_VERSION = PaperViaInjector.hasClass("net.minecraft.SharedConstants")
&& PaperViaInjector.hasClass("net.minecraft.WorldVersion")
&& !PaperViaInjector.hasClass("com.mojang.bridge.game.GameVersion");
@Override
public void inject() throws ReflectiveOperationException {
@ -65,7 +67,7 @@ public class BukkitViaInjector extends LegacyViaInjector {
return Bukkit.getUnsafe().getProtocolVersion();
}
return HAS_SHARED_CONSTANTS ? cursedProtocolDetection() : veryCursedProtocolDetection();
return HAS_WORLD_VERSION_PROTOCOL_VERSION ? cursedProtocolDetection() : veryCursedProtocolDetection();
}
private int cursedProtocolDetection() throws ReflectiveOperationException {
@ -187,7 +189,7 @@ public class BukkitViaInjector extends LegacyViaInjector {
@Override
public boolean lateProtocolVersionSetting() {
return !(PaperViaInjector.PAPER_PROTOCOL_METHOD || HAS_SHARED_CONSTANTS);
return !(PaperViaInjector.PAPER_PROTOCOL_METHOD || HAS_WORLD_VERSION_PROTOCOL_VERSION);
}
public boolean isBinded() {

View File

@ -509,10 +509,10 @@ public class PacketWrapperImpl implements PacketWrapper {
@Override
public String toString() {
return "PacketWrapper{" +
"packetType=" + packetType +
"type=" + packetType +
", id=" + id +
", packetValues=" + packetValues +
", readableObjects=" + readableObjects +
", values=" + packetValues +
", readable=" + readableObjects +
'}';
}
@ -555,10 +555,7 @@ public class PacketWrapperImpl implements PacketWrapper {
@Override
public String toString() {
return "{"
+ type +
", " + value +
'}';
return "{" + type + ": " + value + "}";
}
}
}