3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Let annotations work

Dieser Commit ist enthalten in:
Camotoy 2024-09-09 20:07:18 -04:00
Ursprung a2e9e702b3
Commit a6c21b1f00
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
23 geänderte Dateien mit 262 neuen und 160 gelöschten Zeilen

Datei anzeigen

@ -37,11 +37,11 @@ import org.geysermc.geyser.FloodgateKeyLoader;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserPluginBootstrap; import org.geysermc.geyser.GeyserPluginBootstrap;
import org.geysermc.geyser.api.util.PlatformType; 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.CommandRegistry;
import org.geysermc.geyser.command.CommandSourceConverter; import org.geysermc.geyser.command.CommandSourceConverter;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.configuration.ConfigLoader;
import org.geysermc.geyser.configuration.GeyserPluginConfig;
import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo;
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough; import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
import org.geysermc.geyser.ping.IGeyserPingPassthrough; import org.geysermc.geyser.ping.IGeyserPingPassthrough;
@ -51,8 +51,6 @@ import org.incendo.cloud.CommandManager;
import org.incendo.cloud.bungee.BungeeCommandManager; import org.incendo.cloud.bungee.BungeeCommandManager;
import org.incendo.cloud.execution.ExecutionCoordinator; import org.incendo.cloud.execution.ExecutionCoordinator;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
@ -97,8 +95,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserPluginBootstrap
if (!this.loadConfig()) { if (!this.loadConfig()) {
return; return;
} }
this.geyserLogger.setDebug(geyserConfig.debugMode()); this.geyser = GeyserImpl.load(this);
this.geyser = GeyserImpl.load(PlatformType.BUNGEECORD, this);
this.geyserInjector = new GeyserBungeeInjector(this); this.geyserInjector = new GeyserBungeeInjector(this);
// Registration of listeners occurs only once // Registration of listeners occurs only once
@ -162,7 +159,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserPluginBootstrap
if (!loadConfig()) { if (!loadConfig()) {
return; return;
} }
this.geyserLogger.setDebug(geyserConfig.debugMode());
} }
// Force-disable query if enabled, or else Geyser won't enable // Force-disable query if enabled, or else Geyser won't enable
@ -221,6 +217,11 @@ public class GeyserBungeePlugin extends Plugin implements GeyserPluginBootstrap
this.onGeyserShutdown(); this.onGeyserShutdown();
} }
@Override
public PlatformType platformType() {
return PlatformType.BUNGEECORD;
}
@Override @Override
public GeyserPluginConfig config() { public GeyserPluginConfig config() {
return this.geyserConfig; return this.geyserConfig;
@ -296,16 +297,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserPluginBootstrap
@SuppressWarnings("BooleanMethodIsAlwaysInverted") @SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean loadConfig() { private boolean loadConfig() {
try { this.geyserConfig = new ConfigLoader(this).createFolder().load(GeyserPluginConfig.class);
if (!getDataFolder().exists()) { return this.geyserConfig != null;
//noinspection ResultOfMethodCallIgnored
getDataFolder().mkdir();
}
this.geyserConfig = ConfigLoader.load(new File(getDataFolder(), "config.yml"), GeyserPluginConfig.class);
} catch (IOException ex) {
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.config.failed"), ex);
return false;
}
return true;
} }
} }

Datei anzeigen

@ -35,9 +35,10 @@ import org.geysermc.geyser.FloodgateKeyLoader;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.GeyserPluginBootstrap; import org.geysermc.geyser.GeyserPluginBootstrap;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.CommandRegistry;
import org.geysermc.geyser.configuration.ConfigLoader; import org.geysermc.geyser.configuration.ConfigLoader;
import org.geysermc.geyser.configuration.GeyserPluginConfig; import org.geysermc.geyser.configuration.GeyserPluginConfig;
import org.geysermc.geyser.command.CommandRegistry;
import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo;
import org.geysermc.geyser.level.WorldManager; import org.geysermc.geyser.level.WorldManager;
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough; import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
@ -46,7 +47,6 @@ import org.geysermc.geyser.platform.mod.platform.GeyserModPlatform;
import org.geysermc.geyser.platform.mod.world.GeyserModWorldManager; import org.geysermc.geyser.platform.mod.world.GeyserModWorldManager;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.file.Path; import java.nio.file.Path;
@ -82,8 +82,7 @@ public abstract class GeyserModBootstrap implements GeyserPluginBootstrap {
if (!loadConfig()) { if (!loadConfig()) {
return; return;
} }
this.geyserLogger.setDebug(geyserConfig.debugMode()); this.geyser = GeyserImpl.load(this);
this.geyser = GeyserImpl.load(this.platform.platformType(), this);
} }
public void onGeyserEnable() { public void onGeyserEnable() {
@ -96,7 +95,6 @@ public abstract class GeyserModBootstrap implements GeyserPluginBootstrap {
if (!loadConfig()) { if (!loadConfig()) {
return; return;
} }
this.geyserLogger.setDebug(geyserConfig.debugMode());
} }
GeyserImpl.start(); GeyserImpl.start();
@ -141,6 +139,11 @@ public abstract class GeyserModBootstrap implements GeyserPluginBootstrap {
} }
} }
@Override
public PlatformType platformType() {
return this.platform.platformType();
}
@Override @Override
public GeyserPluginConfig config() { public GeyserPluginConfig config() {
return geyserConfig; return geyserConfig;
@ -226,17 +229,7 @@ public abstract class GeyserModBootstrap implements GeyserPluginBootstrap {
@SuppressWarnings("BooleanMethodIsAlwaysInverted") @SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean loadConfig() { private boolean loadConfig() {
try { this.geyserConfig = new ConfigLoader(this).createFolder().load(GeyserPluginConfig.class);
if (!dataFolder.toFile().exists()) { return this.geyserConfig != null;
//noinspection ResultOfMethodCallIgnored
dataFolder.toFile().mkdir();
}
this.geyserConfig = ConfigLoader.load(dataFolder.resolve("config.yml").toFile(), GeyserPluginConfig.class);
return true;
} catch (IOException ex) {
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.config.failed"), ex);
return false;
}
} }
} }

Datei anzeigen

@ -71,8 +71,6 @@ import org.incendo.cloud.bukkit.BukkitCommandManager;
import org.incendo.cloud.execution.ExecutionCoordinator; import org.incendo.cloud.execution.ExecutionCoordinator;
import org.incendo.cloud.paper.LegacyPaperCommandManager; import org.incendo.cloud.paper.LegacyPaperCommandManager;
import java.io.File;
import java.io.IOException;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
@ -165,12 +163,11 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserPluginBootst
if (!loadConfig()) { if (!loadConfig()) {
return; return;
} }
this.geyserLogger.setDebug(geyserConfig.debugMode());
// Turn "(MC: 1.16.4)" into 1.16.4. // Turn "(MC: 1.16.4)" into 1.16.4.
this.minecraftVersion = Bukkit.getServer().getVersion().split("\\(MC: ")[1].split("\\)")[0]; this.minecraftVersion = Bukkit.getServer().getVersion().split("\\(MC: ")[1].split("\\)")[0];
this.geyser = GeyserImpl.load(PlatformType.SPIGOT, this); this.geyser = GeyserImpl.load(this);
} }
@Override @Override
@ -229,7 +226,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserPluginBootst
if (!loadConfig()) { if (!loadConfig()) {
return; return;
} }
this.geyserLogger.setDebug(this.geyserConfig.debugMode());
} }
GeyserImpl.start(); GeyserImpl.start();
@ -361,6 +357,11 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserPluginBootst
this.onGeyserShutdown(); this.onGeyserShutdown();
} }
@Override
public PlatformType platformType() {
return PlatformType.SPIGOT;
}
@Override @Override
public GeyserPluginConfig config() { public GeyserPluginConfig config() {
return this.geyserConfig; return this.geyserConfig;
@ -463,20 +464,11 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserPluginBootst
@SuppressWarnings("BooleanMethodIsAlwaysInverted") @SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean loadConfig() { private boolean loadConfig() {
// This is manually done instead of using Bukkit methods to save the config because otherwise comments get removed this.geyserConfig = new ConfigLoader(this).createFolder().load(GeyserPluginConfig.class);
try { if (this.geyserConfig == null) {
if (!getDataFolder().exists()) {
//noinspection ResultOfMethodCallIgnored
getDataFolder().mkdir();
}
this.geyserConfig = ConfigLoader.load(new File(getDataFolder(), "config.yml"), GeyserPluginConfig.class);
} catch (IOException ex) {
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.config.failed"), ex);
ex.printStackTrace();
Bukkit.getPluginManager().disablePlugin(this); Bukkit.getPluginManager().disablePlugin(this);
return false; return false;
} }
return true; return true;
} }

Datei anzeigen

@ -37,11 +37,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.util.PlatformType; import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.CommandRegistry;
import org.geysermc.geyser.command.standalone.StandaloneCloudCommandManager;
import org.geysermc.geyser.configuration.ConfigLoader; import org.geysermc.geyser.configuration.ConfigLoader;
import org.geysermc.geyser.configuration.GeyserConfig; import org.geysermc.geyser.configuration.GeyserConfig;
import org.geysermc.geyser.configuration.GeyserRemoteConfig; import org.geysermc.geyser.configuration.GeyserRemoteConfig;
import org.geysermc.geyser.command.CommandRegistry;
import org.geysermc.geyser.command.standalone.StandaloneCloudCommandManager;
import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo;
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough; import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
import org.geysermc.geyser.ping.IGeyserPingPassthrough; import org.geysermc.geyser.ping.IGeyserPingPassthrough;
@ -53,7 +53,6 @@ import org.spongepowered.configurate.NodePath;
import org.spongepowered.configurate.serialize.SerializationException; import org.spongepowered.configurate.serialize.SerializationException;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -161,10 +160,10 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
@Override @Override
public void onGeyserEnable() { public void onGeyserEnable() {
try { this.geyserConfig = new ConfigLoader(this)
geyserConfig = ConfigLoader.load(new File(configFilename), GeyserRemoteConfig.class, this::handleArgsConfigOptions); .transformer(this::handleArgsConfigOptions)
} catch (IOException ex) { .load(GeyserRemoteConfig.class);
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), ex); if (this.geyserConfig == null) {
if (gui == null) { if (gui == null) {
System.exit(1); System.exit(1);
} else { } else {
@ -172,12 +171,11 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
return; return;
} }
} }
geyserLogger.setDebug(geyserConfig.debugMode());
// Allow libraries like Protocol to have their debug information passthrough // Allow libraries like Protocol to have their debug information passthrough
log4jLogger.get().setLevel(geyserConfig.debugMode() ? Level.DEBUG : Level.INFO); log4jLogger.get().setLevel(geyserConfig.debugMode() ? Level.DEBUG : Level.INFO);
geyser = GeyserImpl.load(PlatformType.STANDALONE, this); geyser = GeyserImpl.load(this);
boolean reloading = geyser.isReloading(); boolean reloading = geyser.isReloading();
if (!reloading) { if (!reloading) {
@ -232,6 +230,11 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
System.exit(0); System.exit(0);
} }
@Override
public PlatformType platformType() {
return PlatformType.STANDALONE;
}
@Override @Override
public GeyserConfig config() { public GeyserConfig config() {
return this.geyserConfig; return this.geyserConfig;

Datei anzeigen

@ -42,15 +42,12 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.FloodgateKeyLoader; import org.geysermc.geyser.FloodgateKeyLoader;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserPluginBootstrap; import org.geysermc.geyser.GeyserPluginBootstrap;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.extension.Extension;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.configuration.ConfigLoader;
import org.geysermc.geyser.configuration.GeyserPluginConfig;
import org.geysermc.geyser.api.util.PlatformType; import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.CommandRegistry; import org.geysermc.geyser.command.CommandRegistry;
import org.geysermc.geyser.command.CommandSourceConverter; import org.geysermc.geyser.command.CommandSourceConverter;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.configuration.ConfigLoader;
import org.geysermc.geyser.configuration.GeyserPluginConfig;
import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo;
import org.geysermc.geyser.network.GameProtocol; import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough; import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
@ -62,7 +59,6 @@ import org.incendo.cloud.execution.ExecutionCoordinator;
import org.incendo.cloud.velocity.VelocityCommandManager; import org.incendo.cloud.velocity.VelocityCommandManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.io.IOException;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -107,9 +103,8 @@ public class GeyserVelocityPlugin implements GeyserPluginBootstrap {
if (!loadConfig()) { if (!loadConfig()) {
return; return;
} }
this.geyserLogger.setDebug(geyserConfig.debugMode());
this.geyser = GeyserImpl.load(PlatformType.VELOCITY, this); this.geyser = GeyserImpl.load(this);
this.geyserInjector = new GeyserVelocityInjector(proxyServer); this.geyserInjector = new GeyserVelocityInjector(proxyServer);
// We need to register commands here, rather than in onGeyserEnable which is invoked during the appropriate ListenerBoundEvent. // We need to register commands here, rather than in onGeyserEnable which is invoked during the appropriate ListenerBoundEvent.
@ -139,7 +134,6 @@ public class GeyserVelocityPlugin implements GeyserPluginBootstrap {
if (!loadConfig()) { if (!loadConfig()) {
return; return;
} }
this.geyserLogger.setDebug(geyserConfig.debugMode());
} }
GeyserImpl.start(); GeyserImpl.start();
@ -173,6 +167,11 @@ public class GeyserVelocityPlugin implements GeyserPluginBootstrap {
} }
} }
@Override
public PlatformType platformType() {
return PlatformType.VELOCITY;
}
@Override @Override
public GeyserPluginConfig config() { public GeyserPluginConfig config() {
return geyserConfig; return geyserConfig;
@ -253,17 +252,7 @@ public class GeyserVelocityPlugin implements GeyserPluginBootstrap {
@SuppressWarnings("BooleanMethodIsAlwaysInverted") @SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean loadConfig() { private boolean loadConfig() {
try { this.geyserConfig = new ConfigLoader(this).createFolder().load(GeyserPluginConfig.class);
if (!configFolder.toFile().exists()) { return this.geyserConfig != null;
//noinspection ResultOfMethodCallIgnored
configFolder.toFile().mkdirs();
}
this.geyserConfig = ConfigLoader.load(configFolder.resolve("config.yml").toFile(), GeyserPluginConfig.class);
} catch (IOException ex) {
geyserLogger.error(GeyserLocale.getLocaleStringLog("geyser.config.failed"), ex);
ex.printStackTrace();
return false;
}
return true;
} }
} }

Datei anzeigen

@ -42,10 +42,10 @@ import org.geysermc.geyser.GeyserPluginBootstrap;
import org.geysermc.geyser.api.event.EventRegistrar; import org.geysermc.geyser.api.event.EventRegistrar;
import org.geysermc.geyser.api.network.AuthType; import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.api.util.PlatformType; 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.CommandRegistry;
import org.geysermc.geyser.command.standalone.StandaloneCloudCommandManager; import org.geysermc.geyser.command.standalone.StandaloneCloudCommandManager;
import org.geysermc.geyser.configuration.ConfigLoader;
import org.geysermc.geyser.configuration.GeyserPluginConfig;
import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo;
import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough; import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough;
import org.geysermc.geyser.ping.IGeyserPingPassthrough; import org.geysermc.geyser.ping.IGeyserPingPassthrough;
@ -56,7 +56,6 @@ import org.geysermc.geyser.util.LoopbackUtil;
import org.spongepowered.configurate.serialize.SerializationException; import org.spongepowered.configurate.serialize.SerializationException;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -127,7 +126,7 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserPlugin
return; return;
} }
this.geyser = GeyserImpl.load(PlatformType.VIAPROXY, this); this.geyser = GeyserImpl.load(this);
this.geyser.eventBus().register(this, new GeyserServerTransferListener()); this.geyser.eventBus().register(this, new GeyserServerTransferListener());
LoopbackUtil.checkAndApplyLoopback(this.logger); LoopbackUtil.checkAndApplyLoopback(this.logger);
} }
@ -176,6 +175,11 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserPlugin
this.geyser.shutdown(); this.geyser.shutdown();
} }
@Override
public PlatformType platformType() {
return PlatformType.VIAPROXY;
}
@Override @Override
public GeyserPluginConfig config() { public GeyserPluginConfig config() {
return this.config; return this.config;
@ -237,10 +241,10 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserPlugin
@SuppressWarnings("BooleanMethodIsAlwaysInverted") @SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean loadConfig() { private boolean loadConfig() {
try { this.config = new ConfigLoader(this)
this.config = ConfigLoader.load(new File(ROOT_FOLDER, "config.yml"), GeyserPluginConfig.class, node -> { .transformer(node -> {
try { try {
if (!ViaProxy.getConfig().getWildcardDomainHandling().equals(ViaProxyConfig.WildcardDomainHandling.NONE)) { // TODO if (!ViaProxy.getConfig().getWildcardDomainHandling().equals(ViaProxyConfig.WildcardDomainHandling.NONE)) {
node.node("java", "forward-host").set(true); node.node("java", "forward-host").set(true);
} }
@ -253,13 +257,13 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserPlugin
} catch (SerializationException e) { } catch (SerializationException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
}); })
} catch (IOException e) { .configFile(new File(ROOT_FOLDER, "config.yml"))
this.logger.severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e); .load(GeyserPluginConfig.class);
if (this.config == null) {
return false; return false;
} }
this.config.java().authType(Files.isRegularFile(getFloodgateKeyPath()) ? AuthType.FLOODGATE : AuthType.OFFLINE); this.config.java().authType(Files.isRegularFile(getFloodgateKeyPath()) ? AuthType.FLOODGATE : AuthType.OFFLINE);
this.logger.setDebug(this.config.debugMode());
return true; return true;
} }

Datei anzeigen

@ -27,6 +27,7 @@ package org.geysermc.geyser;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.command.CommandRegistry; import org.geysermc.geyser.command.CommandRegistry;
import org.geysermc.geyser.configuration.GeyserConfig; import org.geysermc.geyser.configuration.GeyserConfig;
import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo;
@ -67,6 +68,14 @@ public interface GeyserBootstrap {
*/ */
void onGeyserShutdown(); void onGeyserShutdown();
/**
* Returns the platform type this Geyser instance is running on.
*
* @return The current PlatformType
*/
@NonNull
PlatformType platformType();
/** /**
* Returns the current GeyserConfig * Returns the current GeyserConfig
* *

Datei anzeigen

@ -167,7 +167,6 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
private ScheduledExecutorService scheduledThread; private ScheduledExecutorService scheduledThread;
private GeyserServer geyserServer; private GeyserServer geyserServer;
private final PlatformType platformType;
private final GeyserBootstrap bootstrap; private final GeyserBootstrap bootstrap;
private final EventBus<EventRegistrar> eventBus; private final EventBus<EventRegistrar> eventBus;
@ -193,12 +192,11 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
@Setter @Setter
private boolean isEnabled; private boolean isEnabled;
private GeyserImpl(PlatformType platformType, GeyserBootstrap bootstrap) { private GeyserImpl(GeyserBootstrap bootstrap) {
instance = this; instance = this;
Geyser.set(this); Geyser.set(this);
this.platformType = platformType;
this.bootstrap = bootstrap; this.bootstrap = bootstrap;
/* Initialize event bus */ /* Initialize event bus */
@ -270,7 +268,7 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
message += " " + GeyserLocale.getLocaleStringLog("geyser.core.finish.console"); message += " " + GeyserLocale.getLocaleStringLog("geyser.core.finish.console");
logger.info(message); logger.info(message);
if (platformType == PlatformType.STANDALONE) { if (platformType() == PlatformType.STANDALONE) {
if (config.java().authType() != AuthType.FLOODGATE) { if (config.java().authType() != AuthType.FLOODGATE) {
// If the auth-type is Floodgate, then this Geyser instance is probably owned by the Java server // If the auth-type is Floodgate, then this Geyser instance is probably owned by the Java server
logger.warning(GeyserLocale.getLocaleStringLog("geyser.core.movement_warn")); logger.warning(GeyserLocale.getLocaleStringLog("geyser.core.movement_warn"));
@ -306,7 +304,7 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
boolean portPropertyApplied = false; boolean portPropertyApplied = false;
String pluginUdpAddress = System.getProperty("geyserUdpAddress", System.getProperty("pluginUdpAddress", "")); String pluginUdpAddress = System.getProperty("geyserUdpAddress", System.getProperty("pluginUdpAddress", ""));
if (platformType != PlatformType.STANDALONE) { if (platformType() != PlatformType.STANDALONE) {
int javaPort = bootstrap.getServerPort(); int javaPort = bootstrap.getServerPort();
String serverAddress = bootstrap.getServerBindAddress(); String serverAddress = bootstrap.getServerBindAddress();
if (!serverAddress.isEmpty() && !"0.0.0.0".equals(serverAddress)) { if (!serverAddress.isEmpty() && !"0.0.0.0".equals(serverAddress)) {
@ -360,7 +358,7 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
} }
if (platformType != PlatformType.VIAPROXY) { if (platformType() != PlatformType.VIAPROXY) {
boolean floodgatePresent = bootstrap.testFloodgatePluginPresent(); boolean floodgatePresent = bootstrap.testFloodgatePluginPresent();
if (config.java().authType() == AuthType.FLOODGATE && !floodgatePresent) { if (config.java().authType() == AuthType.FLOODGATE && !floodgatePresent) {
logger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " logger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
@ -496,7 +494,7 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
metrics.addCustomChart(new SingleLineChart("players", sessionManager::size)); metrics.addCustomChart(new SingleLineChart("players", sessionManager::size));
// Prevent unwanted words best we can // Prevent unwanted words best we can
metrics.addCustomChart(new SimplePie("authMode", () -> config.java().authType().toString().toLowerCase(Locale.ROOT))); metrics.addCustomChart(new SimplePie("authMode", () -> config.java().authType().toString().toLowerCase(Locale.ROOT)));
metrics.addCustomChart(new SimplePie("platform", platformType::platformName)); metrics.addCustomChart(new SimplePie("platform", platformType()::platformName));
metrics.addCustomChart(new SimplePie("defaultLocale", GeyserLocale::getDefaultLocale)); metrics.addCustomChart(new SimplePie("defaultLocale", GeyserLocale::getDefaultLocale));
metrics.addCustomChart(new SimplePie("version", () -> GeyserImpl.VERSION)); metrics.addCustomChart(new SimplePie("version", () -> GeyserImpl.VERSION));
metrics.addCustomChart(new AdvancedPie("playerPlatform", () -> { metrics.addCustomChart(new AdvancedPie("playerPlatform", () -> {
@ -532,7 +530,7 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
if (minecraftVersion != null) { if (minecraftVersion != null) {
Map<String, Map<String, Integer>> versionMap = new HashMap<>(); Map<String, Map<String, Integer>> versionMap = new HashMap<>();
Map<String, Integer> platformMap = new HashMap<>(); Map<String, Integer> platformMap = new HashMap<>();
platformMap.put(platformType.platformName(), 1); platformMap.put(platformType().platformName(), 1);
versionMap.put(minecraftVersion, platformMap); versionMap.put(minecraftVersion, platformMap);
metrics.addCustomChart(new DrilldownPie("minecraftServerVersion", () -> { metrics.addCustomChart(new DrilldownPie("minecraftServerVersion", () -> {
@ -840,7 +838,7 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
@Override @Override
@NonNull @NonNull
public PlatformType platformType() { public PlatformType platformType() {
return platformType; return bootstrap.platformType();
} }
@Override @Override
@ -871,9 +869,9 @@ public class GeyserImpl implements GeyserApi, EventRegistrar {
return Integer.parseInt(BUILD_NUMBER); return Integer.parseInt(BUILD_NUMBER);
} }
public static GeyserImpl load(PlatformType platformType, GeyserBootstrap bootstrap) { public static GeyserImpl load(GeyserBootstrap bootstrap) {
if (instance == null) { if (instance == null) {
return new GeyserImpl(platformType, bootstrap); return new GeyserImpl(bootstrap);
} }
return instance; return instance;

Datei anzeigen

@ -141,7 +141,7 @@ public class CommandRegistry implements EventRegistrar {
registerBuiltInCommand(new AdvancedTooltipsCommand("tooltips", "geyser.commands.advancedtooltips.desc", "geyser.command.tooltips")); registerBuiltInCommand(new AdvancedTooltipsCommand("tooltips", "geyser.commands.advancedtooltips.desc", "geyser.command.tooltips"));
registerBuiltInCommand(new ConnectionTestCommand(geyser, "connectiontest", "geyser.commands.connectiontest.desc", "geyser.command.connectiontest")); registerBuiltInCommand(new ConnectionTestCommand(geyser, "connectiontest", "geyser.commands.connectiontest.desc", "geyser.command.connectiontest"));
registerBuiltInCommand(new PingCommand("ping", "geyser.commands.ping.desc", "geyser.command.ping")); registerBuiltInCommand(new PingCommand("ping", "geyser.commands.ping.desc", "geyser.command.ping"));
if (this.geyser.getPlatformType() == PlatformType.STANDALONE) { if (this.geyser.platformType() == PlatformType.STANDALONE) {
registerBuiltInCommand(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop")); registerBuiltInCommand(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));
} }

Datei anzeigen

@ -73,7 +73,7 @@ public class VersionCommand extends GeyserCommand {
GeyserImpl.NAME, GeyserImpl.VERSION, javaVersions, bedrockVersions)); GeyserImpl.NAME, GeyserImpl.VERSION, javaVersions, bedrockVersions));
// Disable update checking in dev mode and for players in Geyser Standalone // Disable update checking in dev mode and for players in Geyser Standalone
if (!GeyserImpl.getInstance().isProductionEnvironment() || (!source.isConsole() && geyser.getPlatformType() == PlatformType.STANDALONE)) { if (!GeyserImpl.getInstance().isProductionEnvironment() || (!source.isConsole() && geyser.platformType() == PlatformType.STANDALONE)) {
return; return;
} }

Datei anzeigen

@ -81,22 +81,22 @@ public interface AdvancedConfig {
int mtu(); int mtu();
@Comment(""" @Comment("""
Only for plugin versions of Geyser.
Whether to connect directly into the Java server without creating a TCP connection. Whether to connect directly into the Java server without creating a TCP connection.
This should only be disabled if a plugin that interfaces with packets or the network does not work correctly with Geyser. This should only be disabled if a plugin that interfaces with packets or the network does not work correctly with Geyser.
If enabled on plugin versions, the remote address and port sections are ignored If enabled, the remote address and port sections are ignored
If disabled on plugin versions, expect performance decrease and latency increase If disabled, expect performance decrease and latency increase
""") """)
@DefaultBoolean(true) @DefaultBoolean(true)
@PlatformTypeSpecific
boolean useDirectConnection(); boolean useDirectConnection();
@Comment(""" @Comment("""
Only for plugin versions of Geyser.
Whether Geyser should attempt to disable compression for Bedrock players. This should be a benefit as there is no need to compress data Whether Geyser should attempt to disable compression for Bedrock players. This should be a benefit as there is no need to compress data
when Java packets aren't being handled over the network. when Java packets aren't being handled over the network.
This requires use-direct-connection to be true. This requires use-direct-connection to be true.
""") """)
@DefaultBoolean(true) @DefaultBoolean(true)
@PlatformTypeSpecific
boolean disableCompression(); boolean disableCompression();
@Comment("Do not touch!") @Comment("Do not touch!")

Datei anzeigen

@ -26,18 +26,23 @@
package org.geysermc.geyser.configuration; package org.geysermc.geyser.configuration;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
import org.geysermc.geyser.Constants; import org.geysermc.geyser.Constants;
import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.api.util.PlatformType;
import org.geysermc.geyser.text.GeyserLocale;
import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.NodePath; import org.spongepowered.configurate.NodePath;
import org.spongepowered.configurate.interfaces.InterfaceDefaultOptions; import org.spongepowered.configurate.interfaces.InterfaceDefaultOptions;
import org.spongepowered.configurate.objectmapping.meta.Processor;
import org.spongepowered.configurate.transformation.ConfigurationTransformation; import org.spongepowered.configurate.transformation.ConfigurationTransformation;
import org.spongepowered.configurate.yaml.NodeStyle; import org.spongepowered.configurate.yaml.NodeStyle;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader; import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.nio.file.Path;
import java.util.UUID; import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -70,15 +75,58 @@ public final class ConfigLoader {
-------------------------------- --------------------------------
"""; """;
public static <T extends GeyserConfig> T load(File file, Class<T> configClass) throws IOException { private final GeyserBootstrap bootstrap;
return load(file, configClass, null); private @Nullable Consumer<CommentedConfigurationNode> transformer;
private File configFile;
public ConfigLoader(GeyserBootstrap bootstrap) {
this.bootstrap = bootstrap;
configFile = new File(bootstrap.getConfigFolder().toFile(), "config.yml");
} }
public static <T extends GeyserConfig> T load(File file, Class<T> configClass, @Nullable Consumer<CommentedConfigurationNode> transformer) throws IOException { /**
var loader = createLoader(file, HEADER); * Creates the directory as indicated by {@link GeyserBootstrap#getConfigFolder()}
*/
@This
public ConfigLoader createFolder() {
Path dataFolder = this.bootstrap.getConfigFolder();
if (!dataFolder.toFile().exists()) {
//noinspection ResultOfMethodCallIgnored
dataFolder.toFile().mkdir();
}
return this;
}
@This
public ConfigLoader transformer(Consumer<CommentedConfigurationNode> transformer) {
this.transformer = transformer;
return this;
}
@This
public ConfigLoader configFile(File configFile) {
this.configFile = configFile;
return this;
}
/**
* @return null if the config failed to load.
*/
@Nullable
public <T extends GeyserConfig> T load(Class<T> configClass) {
try {
return load0(configClass);
} catch (IOException ex) {
bootstrap.getGeyserLogger().error(GeyserLocale.getLocaleStringLog("geyser.config.failed"), ex);
return null;
}
}
private <T extends GeyserConfig> T load0(Class<T> configClass) throws IOException {
var loader = createLoader(configFile, HEADER);
CommentedConfigurationNode node = loader.load(); CommentedConfigurationNode node = loader.load();
boolean originallyEmpty = !file.exists() || node.isNull(); boolean originallyEmpty = !configFile.exists() || node.isNull();
// Note for Tim? Needed or else Configurate breaks. // Note for Tim? Needed or else Configurate breaks.
var migrations = ConfigurationTransformation.versionedBuilder() var migrations = ConfigurationTransformation.versionedBuilder()
@ -157,8 +205,8 @@ public final class ConfigLoader {
newRoot.set(config); newRoot.set(config);
// Create the path in a way that Standalone changing the config name will be fine. // Create the path in a way that Standalone changing the config name will be fine.
int extensionIndex = file.getName().lastIndexOf("."); int extensionIndex = configFile.getName().lastIndexOf(".");
File advancedConfigPath = new File(file.getParent(), file.getName().substring(0, extensionIndex) + "_advanced" + file.getName().substring(extensionIndex)); File advancedConfigPath = new File(configFile.getParent(), configFile.getName().substring(0, extensionIndex) + "_advanced" + configFile.getName().substring(extensionIndex));
AdvancedConfig advancedConfig = null; AdvancedConfig advancedConfig = null;
if (originallyEmpty || currentVersion != newVersion) { if (originallyEmpty || currentVersion != newVersion) {
@ -188,13 +236,15 @@ public final class ConfigLoader {
config.advanced(advancedConfig); config.advanced(advancedConfig);
bootstrap.getGeyserLogger().setDebug(config.debugMode());
return config; return config;
} }
private static AdvancedConfig migrateToAdvancedConfig(File file, ConfigurationNode configRoot) throws IOException { private AdvancedConfig migrateToAdvancedConfig(File file, ConfigurationNode configRoot) throws IOException {
List<NodePath> copyFromOldConfig = Stream.of("max-visible-custom-skulls", "custom-skull-render-distance", "scoreboard-packet-threshold", "mtu", Stream<NodePath> copyFromOldConfig = Stream.of("max-visible-custom-skulls", "custom-skull-render-distance", "scoreboard-packet-threshold", "mtu",
"floodgate-key-file", "use-direct-connection", "disable-compression") "floodgate-key-file", "use-direct-connection", "disable-compression")
.map(NodePath::path).toList(); .map(NodePath::path);
var loader = createLoader(file, ADVANCED_HEADER); var loader = createLoader(file, ADVANCED_HEADER);
@ -222,7 +272,7 @@ public final class ConfigLoader {
return advancedConfig; return advancedConfig;
} }
private static AdvancedConfig loadAdvancedConfig(File file) throws IOException { private AdvancedConfig loadAdvancedConfig(File file) throws IOException {
var loader = createLoader(file, ADVANCED_HEADER); var loader = createLoader(file, ADVANCED_HEADER);
if (file.exists()) { if (file.exists()) {
ConfigurationNode node = loader.load(); ConfigurationNode node = loader.load();
@ -237,18 +287,38 @@ public final class ConfigLoader {
} }
} }
private static YamlConfigurationLoader createLoader(File file, String header) { private YamlConfigurationLoader createLoader(File file, String header) {
return YamlConfigurationLoader.builder() return YamlConfigurationLoader.builder()
.file(file) .file(file)
.indent(2) .indent(2)
.nodeStyle(NodeStyle.BLOCK) .nodeStyle(NodeStyle.BLOCK)
.defaultOptions(options -> InterfaceDefaultOptions.addTo(options) .defaultOptions(options -> InterfaceDefaultOptions.addTo(options, builder ->
builder.addProcessor(ExcludePlatform.class, excludePlatform(bootstrap.platformType().platformName()))
.addProcessor(PlatformTypeSpecific.class, platformTypeSpecific(bootstrap.platformType() != PlatformType.STANDALONE)))
.shouldCopyDefaults(false) // If we use ConfigurationNode#get(type, default), do not write the default back to the node. .shouldCopyDefaults(false) // If we use ConfigurationNode#get(type, default), do not write the default back to the node.
.header(header) .header(header)
.serializers(builder -> builder.register(new LowercaseEnumSerializer()))) .serializers(builder -> builder.register(new LowercaseEnumSerializer())))
.build(); .build();
} }
private static Processor.Factory<ExcludePlatform, Object> excludePlatform(String thisPlatform) {
return (data, fieldType) -> (value, destination) -> {
for (String platform : data.platforms()) {
if (thisPlatform.equals(platform)) {
//noinspection DataFlowIssue
destination.parent().removeChild(destination.key());
break;
}
}
};
}
private ConfigLoader() { private static Processor.Factory<PlatformTypeSpecific, Object> platformTypeSpecific(boolean thisConfigPlugin) {
return (data, fieldType) -> (value, destination) -> {
if (data.forPlugin() != thisConfigPlugin) {
//noinspection DataFlowIssue
destination.parent().removeChild(destination.key());
}
};
} }
} }

Datei anzeigen

@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.configuration;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface ExcludePlatform {
String[] platforms();
}

Datei anzeigen

@ -83,6 +83,11 @@ public interface GeyserConfig {
@DefaultBoolean(true) @DefaultBoolean(true)
boolean passthroughPlayerCounts(); boolean passthroughPlayerCounts();
@Comment("""
Use server API methods to determine the Java server's MOTD and ping passthrough.
There is no need to disable this unless your MOTD or player count does not appear properly.""")
@DefaultBoolean(true)
@PlatformTypeSpecific
boolean integratedPingPassthrough(); boolean integratedPingPassthrough();
@Comment("How often to ping the Java server to refresh MOTD and player count, in seconds.") @Comment("How often to ping the Java server to refresh MOTD and player count, in seconds.")
@ -214,6 +219,7 @@ public interface GeyserConfig {
Some hosting services change your Java port everytime you start the server and require the same port to be used for Bedrock. Some hosting services change your Java port everytime you start the server and require the same port to be used for Bedrock.
This option makes the Bedrock port the same as the Java port every time you start the server.""") This option makes the Bedrock port the same as the Java port every time you start the server.""")
@DefaultBoolean @DefaultBoolean
@PlatformTypeSpecific
boolean cloneRemotePort(); boolean cloneRemotePort();
void address(String address); void address(String address);

Datei anzeigen

@ -27,7 +27,6 @@ package org.geysermc.geyser.configuration;
import org.spongepowered.configurate.interfaces.meta.Exclude; import org.spongepowered.configurate.interfaces.meta.Exclude;
import org.spongepowered.configurate.interfaces.meta.Field; import org.spongepowered.configurate.interfaces.meta.Field;
import org.spongepowered.configurate.interfaces.meta.defaults.DefaultBoolean;
import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment; import org.spongepowered.configurate.objectmapping.meta.Comment;
@ -59,13 +58,6 @@ public interface GeyserPluginConfig extends GeyserConfig {
} }
} }
@Comment("""
Use server API methods to determine the Java server's MOTD and ping passthrough.
There is no need to disable this unless your MOTD or player count does not appear properly.""")
@DefaultBoolean(true)
@Override
boolean integratedPingPassthrough();
@Comment(""" @Comment("""
How often to ping the Java server to refresh MOTD and player count, in seconds. How often to ping the Java server to refresh MOTD and player count, in seconds.
Only relevant if integrated-ping-passthrough is disabled.""") Only relevant if integrated-ping-passthrough is disabled.""")

Datei anzeigen

@ -25,7 +25,6 @@
package org.geysermc.geyser.configuration; package org.geysermc.geyser.configuration;
import org.spongepowered.configurate.interfaces.meta.Exclude;
import org.spongepowered.configurate.interfaces.meta.defaults.DefaultNumeric; import org.spongepowered.configurate.interfaces.meta.defaults.DefaultNumeric;
import org.spongepowered.configurate.interfaces.meta.defaults.DefaultString; import org.spongepowered.configurate.interfaces.meta.defaults.DefaultString;
import org.spongepowered.configurate.interfaces.meta.range.NumericRange; import org.spongepowered.configurate.interfaces.meta.range.NumericRange;
@ -37,21 +36,9 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
*/ */
@ConfigSerializable @ConfigSerializable
public interface GeyserRemoteConfig extends GeyserConfig { public interface GeyserRemoteConfig extends GeyserConfig {
@Override
RemoteBedrock bedrock();
@Override @Override
RemoteConfig java(); RemoteConfig java();
@ConfigSerializable
interface RemoteBedrock extends BedrockConfig {
@Override
@Exclude // We can bring this back if there's a use-case but it's not really justified here.
default boolean cloneRemotePort() {
return false;
}
}
@ConfigSerializable @ConfigSerializable
interface RemoteConfig extends JavaConfig { interface RemoteConfig extends JavaConfig {
@Override @Override
@ -71,11 +58,4 @@ public interface GeyserRemoteConfig extends GeyserConfig {
This is designed to be used for forced hosts on proxies""") This is designed to be used for forced hosts on proxies""")
boolean forwardHostname(); boolean forwardHostname();
} }
@Exclude
@Override
default boolean integratedPingPassthrough() {
// Does nothing here.
return false;
}
} }

Datei anzeigen

@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.configuration;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface PlatformTypeSpecific {
boolean forPlugin() default true;
}

Datei anzeigen

@ -39,7 +39,7 @@ public class BootstrapDumpInfo {
private final PlatformType platform; private final PlatformType platform;
public BootstrapDumpInfo() { public BootstrapDumpInfo() {
this.platform = GeyserImpl.getInstance().getPlatformType(); this.platform = GeyserImpl.getInstance().platformType();
} }
@Getter @Getter

Datei anzeigen

@ -1084,7 +1084,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
disconnectMessage = GeyserLocale.getPlayerLocaleString("geyser.network.remote.authentication_type_mismatch", locale()); disconnectMessage = GeyserLocale.getPlayerLocaleString("geyser.network.remote.authentication_type_mismatch", locale());
// Explain that they may be looking for Floodgate. // Explain that they may be looking for Floodgate.
geyser.getLogger().warning(GeyserLocale.getLocaleStringLog( geyser.getLogger().warning(GeyserLocale.getLocaleStringLog(
geyser.getPlatformType() == PlatformType.STANDALONE ? geyser.platformType() == PlatformType.STANDALONE ?
"geyser.network.remote.floodgate_explanation_standalone" "geyser.network.remote.floodgate_explanation_standalone"
: "geyser.network.remote.floodgate_explanation_plugin", : "geyser.network.remote.floodgate_explanation_plugin",
Constants.FLOODGATE_DOWNLOAD_LOCATION Constants.FLOODGATE_DOWNLOAD_LOCATION
@ -1092,7 +1092,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
} else { } else {
// Likely that Floodgate is not configured correctly. // Likely that Floodgate is not configured correctly.
disconnectMessage = GeyserLocale.getPlayerLocaleString("geyser.network.remote.floodgate_login_error", locale()); disconnectMessage = GeyserLocale.getPlayerLocaleString("geyser.network.remote.floodgate_login_error", locale());
if (geyser.getPlatformType() == PlatformType.STANDALONE) { if (geyser.platformType() == PlatformType.STANDALONE) {
geyser.getLogger().warning(GeyserLocale.getLocaleStringLog("geyser.network.remote.floodgate_login_error_standalone")); geyser.getLogger().warning(GeyserLocale.getLocaleStringLog("geyser.network.remote.floodgate_login_error_standalone"));
} }
} }

Datei anzeigen

@ -44,8 +44,8 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
} }
static void handleCommand(GeyserSession session, String command) { static void handleCommand(GeyserSession session, String command) {
if (session.getGeyser().getPlatformType() == PlatformType.STANDALONE || if (session.getGeyser().platformType() == PlatformType.STANDALONE ||
session.getGeyser().getPlatformType() == PlatformType.VIAPROXY) { session.getGeyser().platformType() == PlatformType.VIAPROXY) {
// try to handle the command within the standalone/viaproxy command manager // try to handle the command within the standalone/viaproxy command manager
String[] args = command.split(" "); String[] args = command.split(" ");

Datei anzeigen

@ -50,7 +50,7 @@ public class JavaLoginDisconnectTranslator extends PacketTranslator<ClientboundL
String disconnectMessage; String disconnectMessage;
if (testForOutdatedServer(disconnectReason)) { if (testForOutdatedServer(disconnectReason)) {
String locale = session.locale(); String locale = session.locale();
PlatformType platform = session.getGeyser().getPlatformType(); PlatformType platform = session.getGeyser().platformType();
String outdatedType = (platform == PlatformType.BUNGEECORD || platform == PlatformType.VELOCITY || platform == PlatformType.VIAPROXY) ? String outdatedType = (platform == PlatformType.BUNGEECORD || platform == PlatformType.VELOCITY || platform == PlatformType.VIAPROXY) ?
"geyser.network.remote.outdated.proxy" : "geyser.network.remote.outdated.server"; "geyser.network.remote.outdated.proxy" : "geyser.network.remote.outdated.server";
disconnectMessage = GeyserLocale.getPlayerLocaleString(outdatedType, locale, GameProtocol.getJavaVersions().get(0)) + '\n' disconnectMessage = GeyserLocale.getPlayerLocaleString(outdatedType, locale, GameProtocol.getJavaVersions().get(0)) + '\n'

Datei anzeigen

@ -92,7 +92,7 @@ public class JavaBlockEventTranslator extends PacketTranslator<ClientboundBlockE
// Retracting sticky pistons is an exception, since the event is not called on Spigot from 1.13.2 - 1.17.1 // Retracting sticky pistons is an exception, since the event is not called on Spigot from 1.13.2 - 1.17.1
// See https://github.com/PaperMC/Paper/blob/6fa1983e9ce177a4a412d5b950fd978620174777/patches/server/0304-Fire-BlockPistonRetractEvent-for-all-empty-pistons.patch // See https://github.com/PaperMC/Paper/blob/6fa1983e9ce177a4a412d5b950fd978620174777/patches/server/0304-Fire-BlockPistonRetractEvent-for-all-empty-pistons.patch
boolean isSticky = isSticky(pistonBlock); boolean isSticky = isSticky(pistonBlock);
if (session.getGeyser().getPlatformType() == PlatformType.SPIGOT && !isSticky) { if (session.getGeyser().platformType() == PlatformType.SPIGOT && !isSticky) {
return; return;
} }

Datei anzeigen

@ -233,6 +233,6 @@ public class WebUtils {
} }
public static String getUserAgent() { public static String getUserAgent() {
return "Geyser-" + GeyserImpl.getInstance().getPlatformType().platformName() + "/" + GeyserImpl.VERSION; return "Geyser-" + GeyserImpl.getInstance().platformType().platformName() + "/" + GeyserImpl.VERSION;
} }
} }