1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-30 20:29:19 +00:00

Merge remote-tracking branch 'upstream/master' into feature/configurate

# Conflicts:
#	bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java
#	build-logic/src/main/kotlin/geyser.base-conventions.gradle.kts
#	core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java
#	core/src/main/java/org/geysermc/geyser/pack/GeyserResourcePackManifest.java
#	core/src/main/java/org/geysermc/geyser/registry/loader/SoundRegistryLoader.java
#	core/src/main/java/org/geysermc/geyser/util/WebUtils.java
#	gradle/libs.versions.toml
This commit is contained in:
onebeastchris
2025-04-26 01:08:15 +02:00
292 changed files with 33826 additions and 18032 deletions

View File

@@ -75,4 +75,11 @@ public class GeyserBungeeLogger implements GeyserLogger {
info(message);
}
}
@Override
public void debug(String message, Object... arguments) {
if (debug) {
info(String.format(message, arguments));
}
}
}

View File

@@ -25,6 +25,6 @@
"depends": {
"fabricloader": ">=0.16.7",
"fabric-api": "*",
"minecraft": ">=1.21.4"
"minecraft": ">=1.21.5"
}
}

View File

@@ -16,12 +16,12 @@ config = "geyser_neoforge.mixins.json"
[[dependencies.geyser_neoforge]]
modId="neoforge"
type="required"
versionRange="[21.0.0-beta,)"
versionRange="[21.5.0-beta,)"
ordering="NONE"
side="BOTH"
[[dependencies.geyser_neoforge]]
modId="minecraft"
type="required"
versionRange="[1.21,)"
versionRange="[1.21.5,)"
ordering="NONE"
side="BOTH"
side="BOTH"

View File

@@ -84,6 +84,13 @@ public class GeyserModLogger implements GeyserLogger {
}
}
@Override
public void debug(String message, Object... arguments) {
if (debug) {
logger.info(String.format(message, arguments));
}
}
@Override
public void setDebug(boolean debug) {
this.debug = debug;

View File

@@ -25,15 +25,13 @@
package org.geysermc.geyser.platform.mod.mixin.server;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.data.SoundEvent;
@@ -44,13 +42,13 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(BlockItem.class)
public class BlockPlaceMixin {
@Inject(method = "place", locals = LocalCapture.CAPTURE_FAILSOFT, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;playSound(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/core/BlockPos;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FF)V"))
private void geyser$hijackPlaySound(BlockPlaceContext blockPlaceContext, CallbackInfoReturnable<InteractionResult> cir, BlockPlaceContext blockPlaceContext2, BlockState blockState, BlockPos blockPos, Level level, Player player, ItemStack itemStack, BlockState blockState2, SoundType soundType) {
@Inject(method = "place", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;playSound(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/core/BlockPos;Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FF)V"))
private void geyser$hijackPlaySound(BlockPlaceContext blockPlaceContext, CallbackInfoReturnable<InteractionResult> callbackInfoReturnable,
@Local BlockPos pos, @Local Player player, @Local(ordinal = 1) BlockState placedState) {
if (player == null) {
return;
}
@@ -61,16 +59,16 @@ public class BlockPlaceMixin {
}
Vector3f position = Vector3f.from(
blockPos.getX(),
blockPos.getY(),
blockPos.getZ()
pos.getX(),
pos.getY(),
pos.getZ()
);
LevelSoundEventPacket placeBlockSoundPacket = new LevelSoundEventPacket();
placeBlockSoundPacket.setSound(SoundEvent.PLACE);
placeBlockSoundPacket.setPosition(position);
placeBlockSoundPacket.setBabySound(false);
placeBlockSoundPacket.setExtraData(session.getBlockMappings().getBedrockBlockId(Block.BLOCK_STATE_REGISTRY.getId(blockState2)));
placeBlockSoundPacket.setExtraData(session.getBlockMappings().getBedrockBlockId(Block.BLOCK_STATE_REGISTRY.getId(placedState)));
placeBlockSoundPacket.setIdentifier(":");
session.sendUpstreamPacket(placeBlockSoundPacket);
session.setLastBlockPlacePosition(null);

View File

@@ -37,6 +37,7 @@ import org.geysermc.geyser.ping.GeyserPingInfo;
import org.geysermc.geyser.ping.IGeyserPingPassthrough;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
/**
@@ -44,7 +45,10 @@ import java.net.InetSocketAddress;
* applied.
*/
public final class GeyserPaperPingPassthrough implements IGeyserPingPassthrough {
private static final Constructor<PaperServerListPingEvent> OLD_CONSTRUCTOR = ReflectedNames.getOldPaperPingConstructor();
private static final Constructor<PaperServerListPingEvent> EVENT_CONSTRUCTOR = ReflectedNames.paperServerListPingEventConstructor();
// https://jd.papermc.io/paper/1.19.2/com/destroystokyo/paper/event/server/PaperServerListPingEvent.html
private static final boolean CHAT_PREVIEWS = EVENT_CONSTRUCTOR.getParameters()[2].getType() == boolean.class;
private static final Method MOTD_COMPONENT_GETTER = ReflectedNames.motdGetter();
private final GeyserSpigotLogger logger;
@@ -57,18 +61,15 @@ public final class GeyserPaperPingPassthrough implements IGeyserPingPassthrough
@Override
public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) {
try {
// We'd rather *not* use deprecations here, but unfortunately any Adventure class would be relocated at
// runtime because we still have to shade in our own Adventure class. For now.
PaperServerListPingEvent event;
if (OLD_CONSTRUCTOR != null) {
// 1.19, removed in 1.19.4
event = OLD_CONSTRUCTOR.newInstance(new GeyserStatusClient(inetSocketAddress),
Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(),
Bukkit.getMaxPlayers(), Bukkit.getVersion(), GameProtocol.getJavaProtocolVersion(), null);
if (CHAT_PREVIEWS) {
event = EVENT_CONSTRUCTOR.newInstance(new GeyserStatusClient(inetSocketAddress),
MOTD_COMPONENT_GETTER.invoke(null), false, Bukkit.getOnlinePlayers().size(),
Bukkit.getMaxPlayers(), Bukkit.getVersion(), GameProtocol.getJavaProtocolVersion(), null);
} else {
event = new PaperServerListPingEvent(new GeyserStatusClient(inetSocketAddress),
Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(),
Bukkit.getMaxPlayers(), Bukkit.getVersion(), GameProtocol.getJavaProtocolVersion(), null);
event = EVENT_CONSTRUCTOR.newInstance(new GeyserStatusClient(inetSocketAddress),
MOTD_COMPONENT_GETTER.invoke(null), Bukkit.getOnlinePlayers().size(),
Bukkit.getMaxPlayers(), Bukkit.getVersion(), GameProtocol.getJavaProtocolVersion(), null);
}
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {

View File

@@ -75,4 +75,11 @@ public class GeyserSpigotLogger implements GeyserLogger {
info(message);
}
}
@Override
public void debug(String message, Object... arguments) {
if (debug) {
info(String.format(message, arguments));
}
}
}

View File

@@ -26,12 +26,12 @@
package org.geysermc.geyser.platform.spigot;
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
import com.destroystokyo.paper.network.StatusClient;
import org.bukkit.Bukkit;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.util.CachedServerIcon;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.InetAddress;
/**
@@ -42,8 +42,9 @@ public final class ReflectedNames {
static boolean checkPaperPingEvent() {
try {
Class.forName("com.destroystokyo.paper.event.server.PaperServerListPingEvent");
paperServerListPingEventConstructor();
return true;
} catch (ClassNotFoundException e) {
} catch (Throwable ignored) {
return false;
}
}
@@ -52,18 +53,27 @@ public final class ReflectedNames {
return getConstructor(ServerListPingEvent.class, InetAddress.class, String.class, boolean.class, int.class, int.class) != null;
}
static @Nullable Constructor<PaperServerListPingEvent> getOldPaperPingConstructor() {
if (getConstructor(PaperServerListPingEvent.class, StatusClient.class, String.class, int.class,
int.class, String.class, int.class, CachedServerIcon.class) != null) {
// @NotNull StatusClient client, @NotNull String motd, int numPlayers, int maxPlayers,
// @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon
// New constructor is present
return null;
// Ugly workaround that's necessary due to relocation of adventure components
static Method motdGetter() {
try {
return Bukkit.class.getMethod("motd");
} catch (Throwable e) {
throw new RuntimeException("Could not find component motd method! Please report this issue.", e);
}
// @NotNull StatusClient client, @NotNull String motd, boolean shouldSendChatPreviews, int numPlayers, int maxPlayers,
// @NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon
return getConstructor(PaperServerListPingEvent.class, StatusClient.class, String.class, boolean.class, int.class, int.class,
String.class, int.class, CachedServerIcon.class);
}
@SuppressWarnings("unchecked")
static Constructor<PaperServerListPingEvent> paperServerListPingEventConstructor() {
var constructors = PaperServerListPingEvent.class.getConstructors();
for (var constructor : constructors) {
// We want to get the constructor with the adventure component motd, but without referencing the
// component class as that's relocated
if (constructor.getParameters()[1].getType() != String.class) {
return (Constructor<PaperServerListPingEvent>) constructor;
}
}
throw new IllegalStateException("Could not find component motd method!");
}
/**

View File

@@ -121,6 +121,12 @@ public class GeyserStandaloneLogger extends SimpleTerminalConsole implements Gey
log.debug("{}", object);
}
@Override
public void debug(String message, Object... arguments) {
// We can't use the debug call that would format for us as we're using Java's string formatting
log.debug(ChatColor.GRAY + String.format(message, arguments));
}
@Override
public void setDebug(boolean debug) {
Configurator.setLevel(log.getName(), debug ? Level.DEBUG : Level.INFO);

View File

@@ -53,6 +53,13 @@ public class GeyserVelocityInjector extends GeyserInjector {
@Override
@SuppressWarnings("unchecked")
protected void initializeLocalChannel0(GeyserBootstrap bootstrap) throws Exception {
// TEMPORARY until Netty 4.2 is implemented with these changes in mind.
try {
Class.forName("io.netty.channel.MultiThreadIoEventLoopGroup");
return;
} catch (ClassNotFoundException ignored) {
}
Field cm = proxy.getClass().getDeclaredField("cm");
cm.setAccessible(true);
Object connectionManager = cm.get(proxy);

View File

@@ -73,4 +73,11 @@ public class GeyserVelocityLogger implements GeyserLogger {
info(message);
}
}
}
@Override
public void debug(String message, Object... arguments) {
if (debug) {
logger.info(String.format(message, arguments));
}
}
}

View File

@@ -83,6 +83,13 @@ public class GeyserViaProxyLogger implements GeyserLogger, GeyserCommandSource {
}
}
@Override
public void debug(String message, Object... arguments) {
if (this.debug) {
this.debug(String.format(message, arguments));
}
}
@Override
public void setDebug(boolean debug) {
this.debug = debug;