Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch config system to Configurate #5010

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
25e7deb
Start implementing Configurate config system
Camotoy May 23, 2024
dedb592
Merge branch 'master' of https://github.com/GeyserMC/Geyser into feat…
Camotoy May 26, 2024
a135d3c
More development
Camotoy May 27, 2024
25a755f
Start migrating to Gson only
Camotoy May 27, 2024
10bf4ee
Merge branch 'master' of https://github.com/GeyserMC/Geyser into feat…
Camotoy Jun 15, 2024
cb4c5ad
Progress
Camotoy Jun 15, 2024
528de86
Merge branch 'master' of https://github.com/GeyserMC/Geyser into feat…
Camotoy Jun 24, 2024
8d24891
Update usage of WebUtils
Camotoy Jun 24, 2024
2d33cfd
Most things now use Gson for JSON
Camotoy Jun 26, 2024
0dadbc2
Allow tests to succeed by using new Gson version
Camotoy Jun 26, 2024
7eb5b53
Use slightly cleaner version for Version deserializer
Camotoy Jun 26, 2024
360350d
Work around older Gson versions without record support
Camotoy Jun 26, 2024
add02ca
GeyserCustomSkullConfiguration uses Configurate
Camotoy Jun 27, 2024
db9b951
Fix regression in properties get
Camotoy Jun 27, 2024
29f8e29
New config used in core
Camotoy Jul 6, 2024
c095c27
The configuration is gone. Long live the config.
Camotoy Jul 7, 2024
ab4cc97
More changes and migrations away from Jackson
Camotoy Jul 9, 2024
76ca326
Improve node ordering when updating configs
Konicai Aug 9, 2024
0952f79
typo
Konicai Aug 9, 2024
e506c14
Better check for ignoring non-configurate configs for considering com…
Konicai Aug 9, 2024
f7a677e
Merge branch 'master' of https://github.com/GeyserMC/Geyser into feat…
Camotoy Aug 21, 2024
85d63de
Merge pull request #4954 from Konicai/feature/configurate
Camotoy Aug 21, 2024
d9d78cd
Ensure metrics UUID is valid
Camotoy Aug 22, 2024
f113c89
Initial advanced config
Camotoy Aug 24, 2024
5870856
Remove Jackson; finish config value placements
Camotoy Aug 29, 2024
c4c8808
Merge branch 'master' of https://github.com/GeyserMC/Geyser into feat…
Camotoy Sep 1, 2024
f40cbca
Remove duplicate relocate declarations
Camotoy Sep 1, 2024
a2e9e70
Merge branch 'master' of https://github.com/GeyserMC/Geyser into feat…
Camotoy Sep 9, 2024
a6c21b1
Let annotations work
Camotoy Sep 10, 2024
b719278
Renaming to PluginSpecific
Camotoy Sep 10, 2024
1271505
Use global bStats config where possible
Camotoy Sep 12, 2024
e99759d
Fix test
Camotoy Sep 12, 2024
5551169
Re-introduce asterisk behavior in configs
Camotoy Sep 13, 2024
45f8baf
Remove GeyserPluginBootstrap as it's no longer necessary
Camotoy Sep 22, 2024
adee6a7
Remove old config.yml file
Camotoy Sep 22, 2024
869f7a8
Update Xbox achievement comment
Camotoy Sep 22, 2024
2034ffa
Merge branch 'master' of https://github.com/GeyserMC/Geyser into feat…
Camotoy Sep 23, 2024
3448c2f
Apply suggestions from code review
Camotoy Sep 23, 2024
d03e661
Merge branch 'feature/configurate' of https://github.com/GeyserMC/Gey…
Camotoy Sep 23, 2024
2ee488d
No need to remove values anymore
Camotoy Sep 23, 2024
a44edb3
Fix: disable bstats relocation on platforms where it is not needed
onebeastchris Sep 24, 2024
02a361e
ensure it builds
onebeastchris Sep 24, 2024
0d9b20a
Update custom unavailable slot comment
Camotoy Sep 24, 2024
bfd032d
Update cooldown image
Camotoy Sep 25, 2024
fc10ec2
Logger message for direct-compression still being enabled
Camotoy Sep 25, 2024
f42ee7d
Merge branch 'master' into feature/configurate
Camotoy Sep 25, 2024
8b43498
oops
Camotoy Sep 25, 2024
0a62562
More explicit RuntimeException message
Camotoy Sep 26, 2024
c4bed65
Constant for 'system' locale
Camotoy Sep 26, 2024
b2ea579
Better config JSON encoding (something is broken with Cloudflare; we'…
Camotoy Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bootstrap/bungeecord/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ dependencies {
}

platformRelocate("net.md_5.bungee.jni")
platformRelocate("com.fasterxml.jackson")
platformRelocate("io.netty.channel.kqueue") // This is not used because relocating breaks natives, but we must include it or else we get ClassDefNotFound
platformRelocate("net.kyori")
platformRelocate("org.incendo")
platformRelocate("io.leangen.geantyref") // provided by cloud, should also be relocated
platformRelocate("org.yaml") // Broken as of 1.20
platformRelocate("org.spongepowered")
platformRelocate("io.leangen.geantyref")
Camotoy marked this conversation as resolved.
Show resolved Hide resolved
platformRelocate("org.bstats")

// These dependencies are already present on the platform
provided(libs.bungeecord.proxy)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.netty.PipelineUtils;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserPluginBootstrap;
import org.geysermc.geyser.network.netty.GeyserInjector;
import org.geysermc.geyser.network.netty.LocalServerChannelWrapper;
import org.geysermc.geyser.network.netty.LocalSession;
Expand All @@ -67,7 +67,7 @@ public GeyserBungeeInjector(Plugin plugin) {

@Override
@SuppressWarnings("unchecked")
protected void initializeLocalChannel0(GeyserBootstrap bootstrap) throws Exception {
protected void initializeLocalChannel0(GeyserPluginBootstrap bootstrap) throws Exception {
// TODO - allow Geyser to specify its own listener info properties
if (proxy.getConfig().getListeners().size() != 1) {
throw new UnsupportedOperationException("Geyser does not currently support multiple listeners with injection! " +
Expand Down Expand Up @@ -108,7 +108,7 @@ protected void initializeLocalChannel0(GeyserBootstrap bootstrap) throws Excepti
listenerInfo.isPingPassthrough(),
listenerInfo.getQueryPort(),
listenerInfo.isQueryEnabled(),
bootstrap.getGeyserConfig().getRemote().isUseProxyProtocol() // If Geyser is expecting HAProxy, so should the Bungee end
bootstrap.config().java().useProxyProtocol() // If Geyser is expecting HAProxy, so should the Bungee end
);

// The field that stores all listeners in BungeeCord
Expand Down Expand Up @@ -142,7 +142,7 @@ protected void initChannel(@NonNull Channel ch) throws Exception {
}
initChannel.invoke(channelInitializer, ch);

if (bootstrap.getGeyserConfig().isDisableCompression()) {
if (bootstrap.config().advanced().disableCompression()) {
ch.pipeline().addAfter(PipelineUtils.PACKET_ENCODER, "geyser-compression-disabler",
new GeyserBungeeCompressionDisabler());
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public void onProxyReload(ProxyReloadEvent event) {
this.bungeeChannels = null;
if (this.localChannel != null) {
shutdown();
initializeLocalChannel(GeyserImpl.getInstance().getBootstrap());
initializeLocalChannel((GeyserPluginBootstrap) GeyserImpl.getInstance().getBootstrap());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) {
try {
event = future.get(100, TimeUnit.MILLISECONDS);
} catch (Throwable cause) {
String address = GeyserImpl.getInstance().getConfig().isLogPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
String address = GeyserImpl.getInstance().config().logPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
GeyserImpl.getInstance().getLogger().error("Failed to get ping information for " + address, cause);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@
import net.md_5.bungee.protocol.ProtocolConstants;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.FloodgateKeyLoader;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserPluginBootstrap;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.configuration.ConfigLoader;
import org.geysermc.geyser.configuration.GeyserPluginConfig;
import org.geysermc.geyser.command.CommandRegistry;
import org.geysermc.geyser.command.CommandSourceConverter;
import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.configuration.GeyserConfiguration;
import org.geysermc.geyser.dump.BootstrapDumpInfo;
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
import org.geysermc.geyser.ping.IGeyserPingPassthrough;
import org.geysermc.geyser.platform.bungeecord.command.BungeeCommandSource;
import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.FileUtils;
import org.incendo.cloud.CommandManager;
import org.incendo.cloud.bungee.BungeeCommandManager;
import org.incendo.cloud.execution.ExecutionCoordinator;
Expand All @@ -59,13 +60,12 @@
import java.nio.file.Paths;
import java.util.Collection;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
public class GeyserBungeePlugin extends Plugin implements GeyserPluginBootstrap {

private CommandRegistry commandRegistry;
private GeyserBungeeConfiguration geyserConfig;
private GeyserPluginConfig geyserConfig;
private GeyserBungeeInjector geyserInjector;
private final GeyserBungeeLogger geyserLogger = new GeyserBungeeLogger(getLogger());
private IGeyserPingPassthrough geyserBungeePingPassthrough;
Expand Down Expand Up @@ -97,8 +97,7 @@ public void onGeyserInitialize() {
if (!this.loadConfig()) {
return;
}
this.geyserLogger.setDebug(geyserConfig.isDebugMode());
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
this.geyserLogger.setDebug(geyserConfig.debugMode());
this.geyser = GeyserImpl.load(PlatformType.BUNGEECORD, this);
this.geyserInjector = new GeyserBungeeInjector(this);

Expand Down Expand Up @@ -148,8 +147,7 @@ public void onGeyserEnable() {
if (!loadConfig()) {
return;
}
this.geyserLogger.setDebug(geyserConfig.isDebugMode());
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
this.geyserLogger.setDebug(geyserConfig.debugMode());
} else {
var sourceConverter = new CommandSourceConverter<>(
CommandSender.class,
Expand All @@ -167,7 +165,7 @@ public void onGeyserEnable() {

// Force-disable query if enabled, or else Geyser won't enable
for (ListenerInfo info : getProxy().getConfig().getListeners()) {
if (info.isQueryEnabled() && info.getQueryPort() == geyserConfig.getBedrock().port()) {
if (info.isQueryEnabled() && info.getQueryPort() == geyserConfig.bedrock().port()) {
try {
Field queryField = ListenerInfo.class.getDeclaredField("queryEnabled");
queryField.setAccessible(true);
Expand All @@ -185,7 +183,7 @@ public void onGeyserEnable() {

GeyserImpl.start();

if (geyserConfig.isLegacyPingPassthrough()) {
if (!geyserConfig.integratedPingPassthrough()) {
this.geyserBungeePingPassthrough = GeyserLegacyPingPassthrough.init(geyser);
} else {
this.geyserBungeePingPassthrough = new GeyserBungeePingPassthrough(getProxy());
Expand Down Expand Up @@ -222,8 +220,8 @@ public void onDisable() {
}

@Override
public GeyserBungeeConfiguration getGeyserConfig() {
return geyserConfig;
public GeyserPluginConfig config() {
return this.geyserConfig;
}

@Override
Expand Down Expand Up @@ -275,11 +273,16 @@ public int getServerPort() {

@Override
public boolean testFloodgatePluginPresent() {
if (getProxy().getPluginManager().getPlugin("floodgate") != null) {
geyserConfig.loadFloodgate(this);
return true;
}
return false;
return getProxy().getPluginManager().getPlugin("floodgate") != null;
}

@Override
public Path getFloodgateKeyPath() {
Plugin floodgate = getProxy().getPluginManager().getPlugin("floodgate");
Path geyserDataFolder = getDataFolder().toPath();
Path floodgateDataFolder = floodgate != null ? floodgate.getDataFolder().toPath() : null;

return FloodgateKeyLoader.getKeyPath(geyserConfig, floodgateDataFolder, geyserDataFolder, geyserLogger);
}

private Optional<InetSocketAddress> findCompatibleListener() {
Expand All @@ -292,14 +295,13 @@ private Optional<InetSocketAddress> findCompatibleListener() {
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean loadConfig() {
try {
if (!getDataFolder().exists()) //noinspection ResultOfMethodCallIgnored
if (!getDataFolder().exists()) {
//noinspection ResultOfMethodCallIgnored
getDataFolder().mkdir();
File configFile = FileUtils.fileOrCopiedFromResource(new File(getDataFolder(), "config.yml"),
"config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()), this);
this.geyserConfig = FileUtils.loadConfig(configFile, GeyserBungeeConfiguration.class);
}
this.geyserConfig = ConfigLoader.load(new File(getDataFolder(), "config.yml"), GeyserPluginConfig.class);
} catch (IOException ex) {
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.config.failed"), ex);
ex.printStackTrace();
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class GeyserBungeeUpdateListener implements Listener {

@EventHandler
public void onPlayerJoin(final PostLoginEvent event) {
if (GeyserImpl.getInstance().getConfig().isNotifyOnNewBedrockUpdate()) {
if (GeyserImpl.getInstance().config().notifyOnNewBedrockUpdate()) {
final ProxiedPlayer player = event.getPlayer();
if (player.hasPermission(Permissions.CHECK_UPDATE)) {
VersionCheckUtils.checkForGeyserUpdate(() -> new BungeeCommandSource(player));
Expand Down
1 change: 1 addition & 0 deletions bootstrap/mod/fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ tasks.withType<Jar> {
relocate("org.cloudburstmc.netty")
relocate("org.cloudburstmc.protocol")
relocate("com.github.steveice10.mc.auth")
platformRelocate("org.bstats")
onebeastchris marked this conversation as resolved.
Show resolved Hide resolved

tasks {
remapJar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package org.geysermc.geyser.platform.fabric;

import com.google.gson.annotations.JsonAdapter;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.fabricmc.api.EnvType;
Expand All @@ -48,7 +49,7 @@ public class GeyserFabricDumpInfo extends BootstrapDumpInfo {
private final String minecraftVersion;
private final EnvType environmentType;

@AsteriskSerializer.Asterisk(isIp = true)
@JsonAdapter(value = AsteriskSerializer.class)
private final String serverIP;
private final int serverPort;
private final boolean onlineMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public boolean testFloodgatePluginPresent(@NonNull GeyserModBootstrap bootstrap)
Optional<ModContainer> floodgate = FabricLoader.getInstance().getModContainer("floodgate");
if (floodgate.isPresent()) {
Path floodgateDataFolder = FabricLoader.getInstance().getConfigDir().resolve("floodgate");
bootstrap.getGeyserConfig().loadFloodgate(bootstrap, floodgateDataFolder);
bootstrap.loadFloodgate(floodgateDataFolder);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package org.geysermc.geyser.platform.neoforge;

import com.google.gson.annotations.JsonAdapter;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.minecraft.server.MinecraftServer;
Expand All @@ -47,7 +48,7 @@ public class GeyserNeoForgeDumpInfo extends BootstrapDumpInfo {
private final String minecraftVersion;
private final Dist dist;

@AsteriskSerializer.Asterisk(isIp = true)
@JsonAdapter(value = AsteriskSerializer.class)
private final String serverIP;
private final int serverPort;
private final boolean onlineMode;
Expand Down Expand Up @@ -81,4 +82,4 @@ public static class ModInfo {
public String version;
public String url;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public GeyserNeoForgePlatform(ModContainer container) {
public boolean testFloodgatePluginPresent(@NonNull GeyserModBootstrap bootstrap) {
if (ModList.get().isLoaded("floodgate")) {
Path floodgateDataFolder = FMLPaths.CONFIGDIR.get().resolve("floodgate");
bootstrap.getGeyserConfig().loadFloodgate(bootstrap, floodgateDataFolder);
bootstrap.loadFloodgate(floodgateDataFolder);
return true;
}
return false;
Expand Down
Loading