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 53 commits into
base: master
Choose a base branch
from
Open

Conversation

Camotoy
Copy link
Member

@Camotoy Camotoy commented Aug 31, 2024

The primary goal of this PR is to facilitate config changes required for the Floodgate merge, while also allowing for automatic config file generation and updates, as well as customizing configs depending on the features available to a platform.

We have also decided to remove usage of the Jackson library within Geyser. While it has its benefits over Gson, ultimately all platforms have Gson access (and our libraries utilize Gson alongside that) and Jackson is a hefty dependency to shade within Geyser.

User-facing changes

The config file is split into two files - config.yml and config-advanced.yml (name subject to change to something that will always place it below config.yml alphabetically). The primary config will consist of values that a typical user needs to change for a typical setup or other basic config values. The advanced config will consist of values that we don't want most users to change, while still being accessible to tech-savvy users.
The ultimate goal is to keep setup super-simple while still allowing Geyser to be customizable.

Metrics config options are now moved to platform global configs, if they currently exist.

Camotoy and others added 25 commits May 23, 2024 19:57
Improve node ordering when updating configs
Comment on lines 313 to 318
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean loadConfig() {
try {
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);
} catch (IOException ex) {
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.config.failed"), ex);
ex.printStackTrace();
return false;
}
return true;
this.geyserConfig = new ConfigLoader(this).createFolder().load(GeyserPluginConfig.class);
return this.geyserConfig != null;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth it to make this a default method in GeyserBootstrap - it's currently duplicated in every bootstrap impl

bootstrap/mod/fabric/build.gradle.kts Outdated Show resolved Hide resolved
}

private AdvancedConfig migrateToAdvancedConfig(File file, ConfigurationNode configRoot) throws IOException {
Stream<NodePath> copyFromOldConfig = Stream.of("max-visible-custom-skulls", "custom-skull-render-distance", "scoreboard-packet-threshold", "mtu",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other options that may be worth moving:

  • compression level
  • forward-player-ping
  • maybe debug-mode (and then with e.g. scoreboard/pack length warnings that are currently system properties being added there too?)
  • Maybe as hidden options that are not present by default: cookies, packet limit, threads

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug mode was intentionally kept in config.yml by me because we use it when debugging with users sometimes. Can be up for discussion though.

@Camotoy Camotoy added the PR: Needs Testing When a PR needs testing but is currently not under review label Sep 25, 2024
@Konicai Konicai linked an issue Sep 26, 2024 that may be closed by this pull request
Copy link
Member

@Konicai Konicai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

14 files left that are more closely related to config loading. can probably get to those on friday

Comment on lines +42 to +46
default boolean disableRelocateCheck() {
PlatformType platformType = GeyserImpl.getInstance().platformType();
return platformType == PlatformType.FABRIC ||
platformType == PlatformType.NEOFORGE ||
platformType == PlatformType.STANDALONE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment about using JIJ on modded, and not doing relocations on standalone?

Comment on lines 55 to 57

// Sorry Konicai...
forAllConfigs(type -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment can be removed now haha

Comment on lines 101 to 118
try {
// Workaround for JsonAdapter not being allowed on methods
ConfigurationOptions options = InterfaceDefaultOptions.addTo(ConfigurationOptions.defaults(), builder ->
builder.addProcessor(AsteriskSerializer.Asterisk.class, String.class, AsteriskSerializer.CONFIGURATE_SERIALIZER))
.shouldCopyDefaults(false);

ConfigurationNode configNode = CommentedConfigurationNode.root(options);
configNode.set(geyser.config());
this.config = configNode.get(geyser.config().getClass());

ConfigurationNode advancedConfigNode = CommentedConfigurationNode.root(options);
advancedConfigNode.set(geyser.config().advanced());
this.advancedConfig = advancedConfigNode.get(AdvancedConfig.class);
} catch (SerializationException e) {
if (geyser.config().debugMode()) {
e.printStackTrace();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use configurate-gson instead? Should only increase jar size by 6 classes at first glance

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did attempt that once... I think I can try again.

Comment on lines +212 to +221
private Path floodgateKeyPath;

public void loadFloodgate(Path floodgateDataFolder) {
floodgateKeyPath = FloodgateKeyLoader.getKeyPath(geyserConfig, floodgateDataFolder, dataFolder, geyserLogger);
}

@Override
public Path getFloodgateKeyPath() {
return floodgateKeyPath;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't the FloodgateKeyPath just calling FloodgateKeyLoader, like other implementations? and why is testFloodgatePluginPresent the one responsible for calling this loadFloodgate method (seems like it was like that before tho)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as it works, I'm not too concerned, as it will be yeeted sometime in the short term.

Comment on lines +65 to +67
// MinecraftAuth
maven("https://maven.lenni0451.net/snapshots")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed again, we're back to release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Needs Testing When a PR needs testing but is currently not under review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expired Discord CDN links
4 participants