mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 14:34:59 +01:00
Merge remote-tracking branch 'refs/remotes/upstream/master' into feature/1.21.4
# Conflicts: # core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java # core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java # gradle/libs.versions.toml
This commit is contained in:
commit
abf14e6ef9
22 changed files with 52 additions and 96 deletions
|
@ -178,9 +178,8 @@ public class GeyserSpigotInjector extends GeyserInjector {
|
||||||
MinecraftProtocol protocol = new MinecraftProtocol();
|
MinecraftProtocol protocol = new MinecraftProtocol();
|
||||||
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().address(),
|
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().address(),
|
||||||
bootstrap.getGeyserConfig().getRemote().port(), this.serverSocketAddress,
|
bootstrap.getGeyserConfig().getRemote().port(), this.serverSocketAddress,
|
||||||
InetAddress.getLoopbackAddress().getHostAddress(), protocol, protocol.createHelper());
|
InetAddress.getLoopbackAddress().getHostAddress(), protocol, Runnable::run);
|
||||||
session.connect();
|
session.connect();
|
||||||
session.disconnect("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -414,9 +414,6 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that PacketLib does not create an event loop for handling packets; we'll do that ourselves
|
|
||||||
TcpSession.USE_EVENT_LOOP_FOR_PACKETS = false;
|
|
||||||
|
|
||||||
pendingMicrosoftAuthentication = new PendingMicrosoftAuthentication(config.getPendingAuthenticationTimeout());
|
pendingMicrosoftAuthentication = new PendingMicrosoftAuthentication(config.getPendingAuthenticationTimeout());
|
||||||
|
|
||||||
this.newsHandler = new NewsHandler(BRANCH, this.buildNumber());
|
this.newsHandler = new NewsHandler(BRANCH, this.buildNumber());
|
||||||
|
|
|
@ -28,7 +28,7 @@ package org.geysermc.geyser.network;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
|
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;
|
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.v765.Bedrock_v765;
|
import org.cloudburstmc.protocol.bedrock.codec.v766.Bedrock_v766;
|
||||||
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
|
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
|
||||||
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodec;
|
import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodec;
|
||||||
import org.geysermc.mcprotocollib.protocol.codec.PacketCodec;
|
import org.geysermc.mcprotocollib.protocol.codec.PacketCodec;
|
||||||
|
@ -46,9 +46,8 @@ public final class GameProtocol {
|
||||||
* Default Bedrock codec that should act as a fallback. Should represent the latest available
|
* Default Bedrock codec that should act as a fallback. Should represent the latest available
|
||||||
* release of the game that Geyser supports.
|
* release of the game that Geyser supports.
|
||||||
*/
|
*/
|
||||||
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = CodecProcessor.processCodec(Bedrock_v765.CODEC.toBuilder()
|
public static final BedrockCodec DEFAULT_BEDROCK_CODEC = CodecProcessor.processCodec(Bedrock_v766.CODEC.toBuilder()
|
||||||
.minecraftVersion("1.21.50")
|
.minecraftVersion("1.21.50")
|
||||||
.protocolVersion(766)
|
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private PacketSignal translateAndDefault(BedrockPacket packet) {
|
private PacketSignal translateAndDefault(BedrockPacket packet) {
|
||||||
Registries.BEDROCK_PACKET_TRANSLATORS.translate(packet.getClass(), packet, session);
|
Registries.BEDROCK_PACKET_TRANSLATORS.translate(packet.getClass(), packet, session, false);
|
||||||
return PacketSignal.HANDLED; // PacketSignal.UNHANDLED will log a WARN publicly
|
return PacketSignal.HANDLED; // PacketSignal.UNHANDLED will log a WARN publicly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ import java.net.Inet4Address;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,11 +73,11 @@ public final class LocalSession extends TcpSession {
|
||||||
private final String clientIp;
|
private final String clientIp;
|
||||||
private final PacketCodecHelper codecHelper;
|
private final PacketCodecHelper codecHelper;
|
||||||
|
|
||||||
public LocalSession(String host, int port, SocketAddress targetAddress, String clientIp, PacketProtocol protocol, MinecraftCodecHelper codecHelper) {
|
public LocalSession(String host, int port, SocketAddress targetAddress, String clientIp, PacketProtocol protocol, Executor packetHandlerExecutor) {
|
||||||
super(host, port, protocol);
|
super(host, port, protocol, packetHandlerExecutor);
|
||||||
this.targetAddress = targetAddress;
|
this.targetAddress = targetAddress;
|
||||||
this.clientIp = clientIp;
|
this.clientIp = clientIp;
|
||||||
this.codecHelper = codecHelper;
|
this.codecHelper = protocol.createHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -56,15 +56,15 @@ public class PacketTranslatorRegistry<T> extends AbstractMappedRegistry<Class<?
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <P extends T> boolean translate(Class<? extends P> clazz, P packet, GeyserSession session) {
|
public <P extends T> boolean translate(Class<? extends P> clazz, P packet, GeyserSession session, boolean canRunImmediately) {
|
||||||
if (session.getUpstream().isClosed() || session.isClosed()) {
|
if (session.getUpstream().isClosed() || session.isClosed()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketTranslator<P> translator = (PacketTranslator<P>) this.mappings.get(clazz);
|
PacketTranslator<P> translator = (PacketTranslator<P>) this.mappings.get(clazz);
|
||||||
if (translator != null) {
|
if (translator != null) {
|
||||||
EventLoop eventLoop = session.getEventLoop();
|
EventLoop eventLoop = session.getTickEventLoop();
|
||||||
if (!translator.shouldExecuteInEventLoop() || eventLoop.inEventLoop()) {
|
if (canRunImmediately || !translator.shouldExecuteInEventLoop() || eventLoop.inEventLoop()) {
|
||||||
translate0(session, translator, packet);
|
translate0(session, translator, packet);
|
||||||
} else {
|
} else {
|
||||||
eventLoop.execute(() -> translate0(session, translator, packet));
|
eventLoop.execute(() -> translate0(session, translator, packet));
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||||
import org.cloudburstmc.nbt.NbtType;
|
import org.cloudburstmc.nbt.NbtType;
|
||||||
import org.cloudburstmc.nbt.NbtUtils;
|
import org.cloudburstmc.nbt.NbtUtils;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;
|
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.v765.Bedrock_v765;
|
import org.cloudburstmc.protocol.bedrock.codec.v766.Bedrock_v766;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.BlockPropertyData;
|
import org.cloudburstmc.protocol.bedrock.data.BlockPropertyData;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
|
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
|
@ -124,7 +124,7 @@ public final class BlockRegistryPopulator {
|
||||||
private static void registerBedrockBlocks() {
|
private static void registerBedrockBlocks() {
|
||||||
var blockMappers = ImmutableMap.<ObjectIntPair<String>, Remapper>builder()
|
var blockMappers = ImmutableMap.<ObjectIntPair<String>, Remapper>builder()
|
||||||
.put(ObjectIntPair.of("1_21_40", Bedrock_v748.CODEC.getProtocolVersion()), Conversion766_748::remapBlock)
|
.put(ObjectIntPair.of("1_21_40", Bedrock_v748.CODEC.getProtocolVersion()), Conversion766_748::remapBlock)
|
||||||
.put(ObjectIntPair.of("1_21_50", Bedrock_v765.CODEC.getProtocolVersion()), tag -> tag)
|
.put(ObjectIntPair.of("1_21_50", Bedrock_v766.CODEC.getProtocolVersion()), tag -> tag)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// We can keep this strong as nothing should be garbage collected
|
// We can keep this strong as nothing should be garbage collected
|
||||||
|
|
|
@ -46,7 +46,7 @@ import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||||
import org.cloudburstmc.nbt.NbtType;
|
import org.cloudburstmc.nbt.NbtType;
|
||||||
import org.cloudburstmc.nbt.NbtUtils;
|
import org.cloudburstmc.nbt.NbtUtils;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;
|
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.v765.Bedrock_v765;
|
import org.cloudburstmc.protocol.bedrock.codec.v766.Bedrock_v766;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
|
import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
|
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.definitions.SimpleItemDefinition;
|
import org.cloudburstmc.protocol.bedrock.data.definitions.SimpleItemDefinition;
|
||||||
|
@ -108,7 +108,6 @@ public class ItemRegistryPopulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void populate() {
|
public static void populate() {
|
||||||
|
|
||||||
Map<Item, Item> itemFallbacks = new HashMap<>();
|
Map<Item, Item> itemFallbacks = new HashMap<>();
|
||||||
itemFallbacks.put(Items.PALE_OAK_PLANKS, Items.BIRCH_PLANKS);
|
itemFallbacks.put(Items.PALE_OAK_PLANKS, Items.BIRCH_PLANKS);
|
||||||
itemFallbacks.put(Items.PALE_OAK_FENCE, Items.BIRCH_FENCE);
|
itemFallbacks.put(Items.PALE_OAK_FENCE, Items.BIRCH_FENCE);
|
||||||
|
@ -147,7 +146,7 @@ public class ItemRegistryPopulator {
|
||||||
|
|
||||||
List<PaletteVersion> paletteVersions = new ArrayList<>(2);
|
List<PaletteVersion> paletteVersions = new ArrayList<>(2);
|
||||||
paletteVersions.add(new PaletteVersion("1_21_40", Bedrock_v748.CODEC.getProtocolVersion(), itemFallbacks, (item, mapping) -> mapping));
|
paletteVersions.add(new PaletteVersion("1_21_40", Bedrock_v748.CODEC.getProtocolVersion(), itemFallbacks, (item, mapping) -> mapping));
|
||||||
paletteVersions.add(new PaletteVersion("1_21_50", Bedrock_v765.CODEC.getProtocolVersion()));
|
paletteVersions.add(new PaletteVersion("1_21_50", Bedrock_v766.CODEC.getProtocolVersion()));
|
||||||
|
|
||||||
GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();
|
GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectIntPair;
|
import it.unimi.dsi.fastutil.objects.ObjectIntPair;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;
|
import org.cloudburstmc.protocol.bedrock.codec.v748.Bedrock_v748;
|
||||||
import org.cloudburstmc.protocol.bedrock.codec.v765.Bedrock_v765;
|
import org.cloudburstmc.protocol.bedrock.codec.v766.Bedrock_v766;
|
||||||
import org.geysermc.geyser.GeyserBootstrap;
|
import org.geysermc.geyser.GeyserBootstrap;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
import org.geysermc.geyser.item.type.Item;
|
||||||
|
@ -68,7 +68,7 @@ public final class TagRegistryPopulator {
|
||||||
|
|
||||||
List<ObjectIntPair<String>> paletteVersions = List.of(
|
List<ObjectIntPair<String>> paletteVersions = List.of(
|
||||||
ObjectIntPair.of("1_21_40", Bedrock_v748.CODEC.getProtocolVersion()),
|
ObjectIntPair.of("1_21_40", Bedrock_v748.CODEC.getProtocolVersion()),
|
||||||
ObjectIntPair.of("1_21_50", Bedrock_v765.CODEC.getProtocolVersion())
|
ObjectIntPair.of("1_21_50", Bedrock_v766.CODEC.getProtocolVersion())
|
||||||
);
|
);
|
||||||
Type type = new TypeToken<Map<String, List<String>>>() {}.getType();
|
Type type = new TypeToken<Map<String, List<String>>>() {}.getType();
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||||
* The loop where all packets and ticking is processed to prevent concurrency issues.
|
* The loop where all packets and ticking is processed to prevent concurrency issues.
|
||||||
* If this is manually called, ensure that any exceptions are properly handled.
|
* If this is manually called, ensure that any exceptions are properly handled.
|
||||||
*/
|
*/
|
||||||
private final EventLoop eventLoop;
|
private final EventLoop tickEventLoop;
|
||||||
@Setter
|
@Setter
|
||||||
private AuthData authData;
|
private AuthData authData;
|
||||||
private BedrockClientData clientData;
|
private BedrockClientData clientData;
|
||||||
|
@ -658,10 +658,10 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||||
|
|
||||||
private MinecraftProtocol protocol;
|
private MinecraftProtocol protocol;
|
||||||
|
|
||||||
public GeyserSession(GeyserImpl geyser, BedrockServerSession bedrockServerSession, EventLoop eventLoop) {
|
public GeyserSession(GeyserImpl geyser, BedrockServerSession bedrockServerSession, EventLoop tickEventLoop) {
|
||||||
this.geyser = geyser;
|
this.geyser = geyser;
|
||||||
this.upstream = new UpstreamSession(bedrockServerSession);
|
this.upstream = new UpstreamSession(bedrockServerSession);
|
||||||
this.eventLoop = eventLoop;
|
this.tickEventLoop = tickEventLoop;
|
||||||
|
|
||||||
this.erosionHandler = new GeyserboundHandshakePacketHandler(this);
|
this.erosionHandler = new GeyserboundHandshakePacketHandler(this);
|
||||||
|
|
||||||
|
@ -952,17 +952,17 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||||
boolean floodgate = this.remoteServer.authType() == AuthType.FLOODGATE;
|
boolean floodgate = this.remoteServer.authType() == AuthType.FLOODGATE;
|
||||||
|
|
||||||
// Start ticking
|
// Start ticking
|
||||||
tickThread = eventLoop.scheduleAtFixedRate(this::tick, 50, 50, TimeUnit.MILLISECONDS);
|
tickThread = tickEventLoop.scheduleAtFixedRate(this::tick, 50, 50, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
TcpSession downstream;
|
TcpSession downstream;
|
||||||
if (geyser.getBootstrap().getSocketAddress() != null) {
|
if (geyser.getBootstrap().getSocketAddress() != null) {
|
||||||
// We're going to connect through the JVM and not through TCP
|
// We're going to connect through the JVM and not through TCP
|
||||||
downstream = new LocalSession(this.remoteServer.address(), this.remoteServer.port(),
|
downstream = new LocalSession(this.remoteServer.address(), this.remoteServer.port(),
|
||||||
geyser.getBootstrap().getSocketAddress(), upstream.getAddress().getAddress().getHostAddress(),
|
geyser.getBootstrap().getSocketAddress(), upstream.getAddress().getAddress().getHostAddress(),
|
||||||
this.protocol, this.protocol.createHelper());
|
this.protocol, tickEventLoop);
|
||||||
this.downstream = new DownstreamSession(downstream);
|
this.downstream = new DownstreamSession(downstream);
|
||||||
} else {
|
} else {
|
||||||
downstream = new TcpClientSession(this.remoteServer.address(), this.remoteServer.port(), this.protocol);
|
downstream = new TcpClientSession(this.remoteServer.address(), this.remoteServer.port(), "0.0.0.0", 0, this.protocol, null, tickEventLoop);
|
||||||
this.downstream = new DownstreamSession(downstream);
|
this.downstream = new DownstreamSession(downstream);
|
||||||
|
|
||||||
boolean resolveSrv = false;
|
boolean resolveSrv = false;
|
||||||
|
@ -1148,7 +1148,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void packetReceived(Session session, Packet packet) {
|
public void packetReceived(Session session, Packet packet) {
|
||||||
Registries.JAVA_PACKET_TRANSLATORS.translate(packet.getClass(), packet, GeyserSession.this);
|
Registries.JAVA_PACKET_TRANSLATORS.translate(packet.getClass(), packet, GeyserSession.this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1218,10 +1218,11 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||||
* Moves task to the session event loop if already not in it. Otherwise, the task is automatically ran.
|
* Moves task to the session event loop if already not in it. Otherwise, the task is automatically ran.
|
||||||
*/
|
*/
|
||||||
public void ensureInEventLoop(Runnable runnable) {
|
public void ensureInEventLoop(Runnable runnable) {
|
||||||
if (eventLoop.inEventLoop()) {
|
if (tickEventLoop.inEventLoop()) {
|
||||||
runnable.run();
|
executeRunnable(runnable);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
executeInEventLoop(runnable);
|
executeInEventLoop(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1229,15 +1230,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||||
* Executes a task and prints a stack trace if an error occurs.
|
* Executes a task and prints a stack trace if an error occurs.
|
||||||
*/
|
*/
|
||||||
public void executeInEventLoop(Runnable runnable) {
|
public void executeInEventLoop(Runnable runnable) {
|
||||||
eventLoop.execute(() -> {
|
tickEventLoop.execute(() -> executeRunnable(runnable));
|
||||||
try {
|
|
||||||
runnable.run();
|
|
||||||
} catch (ErosionCancellationException e) {
|
|
||||||
geyser.getLogger().debug("Caught ErosionCancellationException");
|
|
||||||
} catch (Throwable e) {
|
|
||||||
geyser.getLogger().error("Error thrown in " + this.bedrockUsername() + "'s event loop!", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1246,19 +1239,25 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||||
* The task will not run if the session is closed.
|
* The task will not run if the session is closed.
|
||||||
*/
|
*/
|
||||||
public ScheduledFuture<?> scheduleInEventLoop(Runnable runnable, long duration, TimeUnit timeUnit) {
|
public ScheduledFuture<?> scheduleInEventLoop(Runnable runnable, long duration, TimeUnit timeUnit) {
|
||||||
return eventLoop.schedule(() -> {
|
return tickEventLoop.schedule(() -> {
|
||||||
try {
|
executeRunnable(() -> {
|
||||||
if (!closed) {
|
if (!closed) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
}
|
}
|
||||||
} catch (ErosionCancellationException e) {
|
});
|
||||||
geyser.getLogger().debug("Caught ErosionCancellationException");
|
|
||||||
} catch (Throwable e) {
|
|
||||||
geyser.getLogger().error("Error thrown in " + this.bedrockUsername() + "'s event loop!", e);
|
|
||||||
}
|
|
||||||
}, duration, timeUnit);
|
}, duration, timeUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void executeRunnable(Runnable runnable) {
|
||||||
|
try {
|
||||||
|
runnable.run();
|
||||||
|
} catch (ErosionCancellationException e) {
|
||||||
|
geyser.getLogger().debug("Caught ErosionCancellationException");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
geyser.getLogger().error("Error thrown in " + this.bedrockUsername() + "'s event loop!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called every 50 milliseconds - one Minecraft tick.
|
* Called every 50 milliseconds - one Minecraft tick.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -131,11 +131,8 @@ public class SkullBlockEntityTranslator extends BlockEntityTranslator implements
|
||||||
session.getGeyser().getLogger().debug("Custom skull with invalid profile tag: " + blockPosition + " " + javaNbt);
|
session.getGeyser().getLogger().debug("Custom skull with invalid profile tag: " + blockPosition + " " + javaNbt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (session.getEventLoop().inEventLoop()) {
|
|
||||||
putSkull(session, blockPosition, uuid, texturesProperty, blockState);
|
session.ensureInEventLoop(() -> putSkull(session, blockPosition, uuid, texturesProperty, blockState));
|
||||||
} else {
|
|
||||||
session.executeInEventLoop(() -> putSkull(session, blockPosition, uuid, texturesProperty, blockState));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// We don't have the textures yet, so we can't determine if a custom block was defined for this skull
|
// We don't have the textures yet, so we can't determine if a custom block was defined for this skull
|
||||||
|
|
|
@ -34,6 +34,7 @@ public abstract class PacketTranslator<T> {
|
||||||
/**
|
/**
|
||||||
* Determines if this packet should be handled in the session's event loop. This should generally be true -
|
* Determines if this packet should be handled in the session's event loop. This should generally be true -
|
||||||
* only when the packet has to be executed immediately should it be false.
|
* only when the packet has to be executed immediately should it be false.
|
||||||
|
* This method is only used for bedrock packets, java packets have a more sophisticated system through MCProtocolLib.
|
||||||
*/
|
*/
|
||||||
public boolean shouldExecuteInEventLoop() {
|
public boolean shouldExecuteInEventLoop() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -61,11 +61,8 @@ public class BedrockEmoteTranslator extends PacketTranslator<EmotePacket> {
|
||||||
for (GeyserSession otherSession : session.getGeyser().getSessionManager().getSessions().values()) {
|
for (GeyserSession otherSession : session.getGeyser().getSessionManager().getSessions().values()) {
|
||||||
if (otherSession != session) {
|
if (otherSession != session) {
|
||||||
if (otherSession.isClosed()) continue;
|
if (otherSession.isClosed()) continue;
|
||||||
if (otherSession.getEventLoop().inEventLoop()) {
|
|
||||||
playEmote(otherSession, javaId, xuid, emote);
|
otherSession.ensureInEventLoop(() -> playEmote(otherSession, javaId, xuid, emote));
|
||||||
} else {
|
|
||||||
otherSession.executeInEventLoop(() -> playEmote(otherSession, javaId, xuid, emote));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,10 +140,4 @@ public class JavaCustomPayloadTranslator extends PacketTranslator<ClientboundCus
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldExecuteInEventLoop() {
|
|
||||||
// For Erosion packets
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,4 @@ public class JavaDisconnectTranslator extends PacketTranslator<ClientboundDiscon
|
||||||
public void translate(GeyserSession session, ClientboundDisconnectPacket packet) {
|
public void translate(GeyserSession session, ClientboundDisconnectPacket packet) {
|
||||||
session.disconnect(MessageTranslator.convertMessage(packet.getReason(), session.locale()));
|
session.disconnect(MessageTranslator.convertMessage(packet.getReason(), session.locale()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldExecuteInEventLoop() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,9 +67,4 @@ public class JavaKeepAliveTranslator extends PacketTranslator<ClientboundKeepAli
|
||||||
latencyPacket.setTimestamp(timestamp);
|
latencyPacket.setTimestamp(timestamp);
|
||||||
session.sendUpstreamPacketImmediately(latencyPacket);
|
session.sendUpstreamPacketImmediately(latencyPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldExecuteInEventLoop() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,9 +98,4 @@ public class JavaLoginDisconnectTranslator extends PacketTranslator<ClientboundL
|
||||||
private boolean testForMissingProfilePublicKey(Component disconnectReason) {
|
private boolean testForMissingProfilePublicKey(Component disconnectReason) {
|
||||||
return disconnectReason instanceof TranslatableComponent component && "multiplayer.disconnect.missing_public_key".equals(component.key());
|
return disconnectReason instanceof TranslatableComponent component && "multiplayer.disconnect.missing_public_key".equals(component.key());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldExecuteInEventLoop() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,10 +59,4 @@ public class JavaSelectKnownPacksTranslator extends PacketTranslator<Clientbound
|
||||||
}
|
}
|
||||||
session.sendDownstreamPacket(new ServerboundSelectKnownPacks(knownPacks));
|
session.sendDownstreamPacket(new ServerboundSelectKnownPacks(knownPacks));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldExecuteInEventLoop() {
|
|
||||||
// This technically isn't correct behavior, but it prevents race conditions between MCProtocolLib's packet handler and ours.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,4 @@ public class JavaStartConfigurationTranslator extends PacketTranslator<Clientbou
|
||||||
erosionHandler.close();
|
erosionHandler.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldExecuteInEventLoop() {
|
|
||||||
// Execute outside of event loop to cancel any pending erosion futures
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,6 @@ public class JavaTeleportEntityTranslator extends PacketTranslator<ClientboundTe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, ClientboundTeleportEntityPacket packet) {
|
public void translate(GeyserSession session, ClientboundTeleportEntityPacket packet) {
|
||||||
session.getGeyser().getLogger().info(packet.toString());
|
session.getGeyser().getLogger().debug(packet.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ package org.geysermc.geyser.translator.protocol.java.entity.player;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundCookieRequestPacket;
|
import org.geysermc.mcprotocollib.protocol.packet.cookie.clientbound.ClientboundCookieRequestPacket;
|
||||||
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ServerboundCookieResponsePacket;
|
import org.geysermc.mcprotocollib.protocol.packet.cookie.serverbound.ServerboundCookieResponsePacket;
|
||||||
|
|
||||||
@Translator(packet = ClientboundCookieRequestPacket.class)
|
@Translator(packet = ClientboundCookieRequestPacket.class)
|
||||||
public class JavaCookieRequestTranslator extends PacketTranslator<ClientboundCookieRequestPacket> {
|
public class JavaCookieRequestTranslator extends PacketTranslator<ClientboundCookieRequestPacket> {
|
||||||
|
|
|
@ -10,9 +10,9 @@ netty-io-uring = "0.0.25.Final-SNAPSHOT"
|
||||||
guava = "29.0-jre"
|
guava = "29.0-jre"
|
||||||
gson = "2.3.1" # Provided by Spigot 1.8.8
|
gson = "2.3.1" # Provided by Spigot 1.8.8
|
||||||
websocket = "1.5.1"
|
websocket = "1.5.1"
|
||||||
protocol-connection = "3.0.0.Beta5-20241121.192504-18"
|
protocol-connection = "3.0.0.Beta5-20241203.200249-19"
|
||||||
protocol-common = "3.0.0.Beta5-20241121.192504-18"
|
protocol-common = "3.0.0.Beta5-20241203.200249-19"
|
||||||
protocol-codec = "3.0.0.Beta5-20241121.192504-18"
|
protocol-codec = "3.0.0.Beta5-20241203.200249-19"
|
||||||
raknet = "1.0.0.CR3-20240416.144209-1"
|
raknet = "1.0.0.CR3-20240416.144209-1"
|
||||||
minecraftauth = "4.1.1"
|
minecraftauth = "4.1.1"
|
||||||
mcprotocollib = "1.21.4-SNAPSHOT"
|
mcprotocollib = "1.21.4-SNAPSHOT"
|
||||||
|
|
Loading…
Reference in a new issue