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

Add option for disabling command suggestions; add config version (#598)

* Add option for disabling command suggestions; add config version

This commit adds an option for disabling command suggestions. If enabled, command suggestions will not be sent to the server so as to remove command freezing. This commit also adds a config version variable so users are notified when to regenerate their configs.

* Rename GeyserConfiguration.checkGeyserConfiguration()
Dieser Commit ist enthalten in:
Camotoy 2020-05-20 23:43:22 -04:00 committet von GitHub
Ursprung 83c7858a8c
Commit a7f363ec09
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
13 geänderte Dateien mit 79 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -86,6 +86,11 @@ public class GeyserBukkitConfiguration implements GeyserConfiguration {
return userAuthInfo;
}
@Override
public boolean isCommandSuggestions() {
return config.getBoolean("command-suggestions", true);
}
@Override
public boolean isPingPassthrough() {
return config.getBoolean("ping-passthrough", false);
@ -203,4 +208,9 @@ public class GeyserBukkitConfiguration implements GeyserConfiguration {
return config.getString("metrics.uuid", "generateduuid");
}
}
@Override
public int getConfigVersion() {
return config.getInt("config-version", 0);
}
}

Datei anzeigen

@ -28,6 +28,7 @@ package org.geysermc.platform.bukkit;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.geysermc.common.PlatformType;
import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.command.CommandManager;
@ -55,6 +56,7 @@ public class GeyserBukkitPlugin extends JavaPlugin implements GeyserBootstrap {
saveDefaultConfig();
this.geyserConfig = new GeyserBukkitConfiguration(getDataFolder(), getConfig());
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
if (geyserConfig.getMetrics().getUniqueId().equals("generateduuid")) {
getConfig().set("metrics.uuid", UUID.randomUUID().toString());
saveConfig();

Datei anzeigen

@ -85,6 +85,11 @@ public class GeyserBungeeConfiguration implements GeyserConfiguration {
return userAuthInfo;
}
@Override
public boolean isCommandSuggestions() {
return config.getBoolean("command-suggestions", true);
}
@Override
public boolean isPingPassthrough() {
return config.getBoolean("ping-passthrough", false);
@ -202,4 +207,9 @@ public class GeyserBungeeConfiguration implements GeyserConfiguration {
return config.getString("metrics.uuid", "generateduuid");
}
}
@Override
public int getConfigVersion() {
return config.getInt("config-version", 0);
}
}

Datei anzeigen

@ -31,6 +31,7 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import org.geysermc.common.PlatformType;
import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.command.CommandManager;
@ -116,6 +117,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
}
this.geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
geyserConfig.loadFloodgate(this);

Datei anzeigen

@ -79,6 +79,11 @@ public class GeyserSpongeConfiguration implements GeyserConfiguration {
return userAuthInfo;
}
@Override
public boolean isCommandSuggestions() {
return node.getNode("command-suggestions").getBoolean(true);
}
@Override
public boolean isPingPassthrough() {
return node.getNode("ping-passthrough").getBoolean(false);
@ -202,4 +207,9 @@ public class GeyserSpongeConfiguration implements GeyserConfiguration {
return node.getNode("metrics").getNode("uuid").getString("generateduuid");
}
}
@Override
public int getConfigVersion() {
return node.getNode("config-version").getInt(0);
}
}

Datei anzeigen

@ -30,6 +30,7 @@ import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
import org.geysermc.common.PlatformType;
import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.command.CommandManager;
@ -105,6 +106,7 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
}
this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode());
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
this.connector = GeyserConnector.start(PlatformType.SPONGE, this);
this.geyserCommandManager = new GeyserSpongeCommandManager(Sponge.getCommandManager(), connector);

Datei anzeigen

@ -62,6 +62,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
geyserLogger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex);
System.exit(0);
}
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
connector = GeyserConnector.start(PlatformType.STANDALONE, this);
geyserCommandManager = new GeyserCommandManager(connector);

Datei anzeigen

@ -47,6 +47,9 @@ public class GeyserStandaloneConfiguration implements GeyserConfiguration {
private Map<String, UserAuthenticationInfo> userAuths;
@JsonProperty("command-suggestions")
private boolean isCommandSuggestions;
@JsonProperty("ping-passthrough")
private boolean pingPassthrough;
@ -112,4 +115,7 @@ public class GeyserStandaloneConfiguration implements GeyserConfiguration {
@JsonProperty("uuid")
private String uniqueId;
}
@JsonProperty("config-version")
private int configVersion;
}

Datei anzeigen

@ -52,6 +52,9 @@ public class GeyserVelocityConfiguration implements GeyserConfiguration {
private Map<String, UserAuthenticationInfo> userAuths;
@JsonProperty("command-suggestions")
private boolean commandSuggestions;
@JsonProperty("ping-passthrough")
private boolean pingPassthrough;
@ -127,4 +130,7 @@ public class GeyserVelocityConfiguration implements GeyserConfiguration {
@JsonProperty("uuid")
private String uniqueId;
}
@JsonProperty("config-version")
private int configVersion;
}

Datei anzeigen

@ -35,6 +35,7 @@ import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ProxyServer;
import org.geysermc.common.PlatformType;
import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.utils.FileUtils;
@ -90,6 +91,7 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
geyserConfig.getRemote().setPort(javaAddr.getPort());
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
geyserConfig.loadFloodgate(this, proxyServer, configDir);

Datei anzeigen

@ -31,12 +31,17 @@ import java.util.Map;
public interface GeyserConfiguration {
// Modify this when you update the config
int CURRENT_CONFIG_VERSION = 1;
IBedrockConfiguration getBedrock();
IRemoteConfiguration getRemote();
Map<String, ? extends IUserAuthenticationInfo> getUserAuths();
boolean isCommandSuggestions();
boolean isPingPassthrough();
int getMaxPlayers();
@ -87,4 +92,14 @@ public interface GeyserConfiguration {
String getUniqueId();
}
int getConfigVersion();
static void checkGeyserConfiguration(GeyserConfiguration geyserConfig, GeyserLogger geyserLogger) {
if (geyserConfig.getConfigVersion() < CURRENT_CONFIG_VERSION) {
geyserLogger.warning("Your Geyser config is out of date! Please regenerate your config when possible.");
} else if (geyserConfig.getConfigVersion() > CURRENT_CONFIG_VERSION) {
geyserLogger.warning("Your Geyser config is too new! Errors may occur.");
}
}
}

Datei anzeigen

@ -43,9 +43,14 @@ import org.geysermc.connector.network.translators.Translator;
import java.util.*;
@Translator(packet = ServerDeclareCommandsPacket.class)
public class JavaServerDeclareCommandsTranslator extends PacketTranslator<ServerDeclareCommandsPacket> {
public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclareCommandsPacket> {
@Override
public void translate(ServerDeclareCommandsPacket packet, GeyserSession session) {
// Don't send command suggestions if they are disabled
if (!session.getConnector().getConfig().isCommandSuggestions()) {
session.getConnector().getLogger().debug("Not sending command suggestions as they are disabled.");
return;
}
List<CommandData> commandData = new ArrayList<>();
Int2ObjectMap<String> commands = new Int2ObjectOpenHashMap<>();
Int2ObjectMap<List<CommandNode>> commandArgs = new Int2ObjectOpenHashMap<>();

Datei anzeigen

@ -41,6 +41,10 @@ floodgate-key-file: public-key.pem
# email: herpderp@derpherp.com
# password: dooooo
# Bedrock clients can freeze when opening up the command prompt for the first time if given a lot of commands.
# Disabling this will prevent command suggestions from being sent and solve freezing for Bedrock clients.
command-suggestions: true
# Relay the MOTD, player count and max players from the remote server
ping-passthrough: false
@ -78,3 +82,6 @@ metrics:
enabled: true
# UUID of server, don't change!
uuid: generateduuid
# DO NOT TOUCH!
config-version: 1