3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 22:40:18 +01:00

Merge branch 'feature/extensions' into feature/blockstuff-updated

# Conflicts:
#	core/src/main/java/org/geysermc/geyser/GeyserImpl.java
#	core/src/main/java/org/geysermc/geyser/registry/provider/GeyserBuilderProvider.java
Dieser Commit ist enthalten in:
davchoo 2022-07-26 18:50:30 -04:00
Commit 88725f89a3
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A0168C8E45799B7D
45 geänderte Dateien mit 245 neuen und 655 gelöschten Zeilen

Datei anzeigen

@ -35,7 +35,6 @@ import org.geysermc.geyser.api.event.EventBus;
import org.geysermc.geyser.api.extension.ExtensionManager; import org.geysermc.geyser.api.extension.ExtensionManager;
import org.geysermc.geyser.api.network.BedrockListener; import org.geysermc.geyser.api.network.BedrockListener;
import org.geysermc.geyser.api.network.RemoteServer; import org.geysermc.geyser.api.network.RemoteServer;
import org.geysermc.geyser.api.provider.ProviderManager;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -44,24 +43,6 @@ import java.util.UUID;
* Represents the API used in Geyser. * Represents the API used in Geyser.
*/ */
public interface GeyserApi extends GeyserApiBase { public interface GeyserApi extends GeyserApiBase {
/**
* Shuts down the current Geyser instance.
*/
void shutdown();
/**
* Reloads the current Geyser instance.
*/
void reload();
/**
* Gets if this Geyser instance is running in an IDE. This only needs to be used in cases where files
* expected to be in a jarfile are not present.
*
* @return if we are in a production environment
*/
boolean isProductionEnvironment();
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -101,11 +82,15 @@ public interface GeyserApi extends GeyserApiBase {
CommandManager commandManager(); CommandManager commandManager();
/** /**
* Gets the {@link ProviderManager}. * Provides an implementation for the specified API type.
* *
* @return the provider manager * @param apiClass the builder class
* @param <R> the implementation type
* @param <T> the API type
* @return the builder instance
*/ */
ProviderManager providerManager(); @NonNull
<R extends T, T> R provider(@NonNull Class<T> apiClass, @Nullable Object... args);
/** /**
* Gets the {@link EventBus} for handling * Gets the {@link EventBus} for handling
@ -131,15 +116,6 @@ public interface GeyserApi extends GeyserApiBase {
*/ */
BedrockListener bedrockListener(); BedrockListener bedrockListener();
/**
* Gets the maximum number of players that
* can join this Geyser instance.
*
* @return the maximum number of players that
* can join this Geyser instance
*/
int maxPlayers();
/** /**
* Gets the current {@link GeyserApiBase} instance. * Gets the current {@link GeyserApiBase} instance.
* *

Datei anzeigen

@ -105,7 +105,7 @@ public interface Command {
} }
static <T extends CommandSource> Command.Builder<T> builder(Class<T> sourceType) { static <T extends CommandSource> Command.Builder<T> builder(Class<T> sourceType) {
return GeyserApi.api().providerManager().builderProvider().provideBuilder(Builder.class, sourceType); return GeyserApi.api().provider(Builder.class, sourceType);
} }
interface Builder<T extends CommandSource> { interface Builder<T extends CommandSource> {

Datei anzeigen

@ -33,7 +33,9 @@ import org.geysermc.geyser.api.event.connection.ConnectionEvent;
import java.util.Set; import java.util.Set;
/** /**
* Called when the downstream server defines the commands available on the server. * Called when the Java server defines the commands available on the server.
* <br>
* This event is mapped to the existence of Brigadier on the server.
*/ */
public class ServerDefineCommandsEvent extends ConnectionEvent implements Cancellable { public class ServerDefineCommandsEvent extends ConnectionEvent implements Cancellable {
private final Set<? extends CommandInfo> commands; private final Set<? extends CommandInfo> commands;
@ -45,9 +47,10 @@ public class ServerDefineCommandsEvent extends ConnectionEvent implements Cancel
} }
/** /**
* A mutable collection of the commands sent over. * A collection of commands sent from the server. Any element in this collection can be removed, but no element can
* be added.
* *
* @return a mutable collection of the commands sent over * @return a collection of the commands sent over
*/ */
@NonNull @NonNull
public Set<? extends CommandInfo> commands() { public Set<? extends CommandInfo> commands() {
@ -65,7 +68,6 @@ public class ServerDefineCommandsEvent extends ConnectionEvent implements Cancel
} }
public interface CommandInfo { public interface CommandInfo {
/** /**
* Gets the name of the command. * Gets the name of the command.
* *

Datei anzeigen

@ -1,42 +0,0 @@
/*
* Copyright (c) 2019-2022 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.api.event.lifecycle;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.command.CommandManager;
import org.geysermc.geyser.api.event.Event;
import java.util.Map;
/**
* Called when commands are defined within Geyser.
*
* @param commandManager the command manager
* @param commands an immutable view of the default commands
*/
public record GeyserDefineCommandsEvent(@NonNull CommandManager commandManager, @NonNull Map<String, Command> commands) implements Event {
}

Datei anzeigen

@ -83,7 +83,7 @@ public interface CustomItemData {
@Nullable CustomRenderOffsets renderOffsets(); @Nullable CustomRenderOffsets renderOffsets();
static CustomItemData.Builder builder() { static CustomItemData.Builder builder() {
return GeyserApi.api().providerManager().builderProvider().provideBuilder(CustomItemData.Builder.class); return GeyserApi.api().provider(CustomItemData.Builder.class);
} }
interface Builder { interface Builder {

Datei anzeigen

@ -68,7 +68,7 @@ public interface CustomItemOptions {
} }
static CustomItemOptions.Builder builder() { static CustomItemOptions.Builder builder() {
return GeyserApi.api().providerManager().builderProvider().provideBuilder(CustomItemOptions.Builder.class); return GeyserApi.api().provider(CustomItemOptions.Builder.class);
} }
interface Builder { interface Builder {

Datei anzeigen

@ -137,7 +137,7 @@ public interface NonVanillaCustomItemData extends CustomItemData {
boolean isTool(); boolean isTool();
static NonVanillaCustomItemData.Builder builder() { static NonVanillaCustomItemData.Builder builder() {
return GeyserApi.api().providerManager().builderProvider().provideBuilder(NonVanillaCustomItemData.Builder.class); return GeyserApi.api().provider(NonVanillaCustomItemData.Builder.class);
} }
interface Builder extends CustomItemData.Builder { interface Builder extends CustomItemData.Builder {

Datei anzeigen

@ -25,16 +25,22 @@
package org.geysermc.geyser.api.network; package org.geysermc.geyser.api.network;
import java.util.Locale;
/**
* The authentication types that a Java server can be on connection.
*/
public enum AuthType { public enum AuthType {
OFFLINE, OFFLINE,
ONLINE, ONLINE,
/**
* The internal name for connecting to an online mode server without needing a Java account. The presence of this
* authentication type does not necessarily mean the Floodgate plugin is installed; it only means that this
* authentication type will be attempted.
*/
FLOODGATE; FLOODGATE;
public static final AuthType[] VALUES = values(); private static final AuthType[] VALUES = values();
public static AuthType getById(int id) {
return id < VALUES.length ? VALUES[id] : OFFLINE;
}
/** /**
* Convert the AuthType string (from config) to the enum, ONLINE on fail * Convert the AuthType string (from config) to the enum, ONLINE on fail
@ -44,7 +50,7 @@ public enum AuthType {
* @return The converted AuthType * @return The converted AuthType
*/ */
public static AuthType getByName(String name) { public static AuthType getByName(String name) {
String upperCase = name.toUpperCase(); String upperCase = name.toUpperCase(Locale.ROOT);
for (AuthType type : VALUES) { for (AuthType type : VALUES) {
if (type.name().equals(upperCase)) { if (type.name().equals(upperCase)) {
return type; return type;

Datei anzeigen

@ -48,7 +48,7 @@ public interface BedrockListener {
int port(); int port();
/** /**
* Gets the primary MOTD shown to Bedrock players. * Gets the primary MOTD shown to Bedrock players if a ping passthrough setting is not enabled.
* <p> * <p>
* This is the first line that will be displayed. * This is the first line that will be displayed.
* *
@ -57,7 +57,7 @@ public interface BedrockListener {
String primaryMotd(); String primaryMotd();
/** /**
* Gets the secondary MOTD shown to Bedrock players. * Gets the secondary MOTD shown to Bedrock players if a ping passthrough setting is not enabled.
* <p> * <p>
* This is the second line that will be displayed. * This is the second line that will be displayed.
* *

Datei anzeigen

@ -1,47 +0,0 @@
/*
* Copyright (c) 2019-2022 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.api.provider;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Allows for obtaining instances of a builder that are
* used for constructing various data.
*/
public interface BuilderProvider extends Provider {
/**
* Provides a builder for the specified builder type.
*
* @param builderClass the builder class
* @param <B> the resulting type
* @param <T> the builder type
* @return the builder instance
*/
@NonNull
<B extends T, T> B provideBuilder(@NonNull Class<T> builderClass, @Nullable Object... args);
}

Datei anzeigen

@ -1,29 +0,0 @@
/*
* Copyright (c) 2019-2022 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.api.provider;
public interface Provider {
}

Datei anzeigen

@ -1,41 +0,0 @@
/*
* Copyright (c) 2019-2022 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.api.provider;
/**
* Holds a record of every {@link Provider} available
* that allows for accessing various information throughout
* the API.
*/
public interface ProviderManager {
/**
* Returns the {@link BuilderProvider}.
*
* @return the builder provider
*/
BuilderProvider builderProvider();
}

Datei anzeigen

@ -86,7 +86,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
InetSocketAddress javaAddr = listener.getHost(); InetSocketAddress javaAddr = listener.getHost();
// By default this should be localhost but may need to be changed in some circumstances // By default this should be localhost but may need to be changed in some circumstances
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) { if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
this.geyserConfig.setAutoconfiguredRemote(true); this.geyserConfig.setAutoconfiguredRemote(true);
// Don't use localhost if not listening on all interfaces // Don't use localhost if not listening on all interfaces
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) { if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
@ -109,7 +109,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
return; return;
} }
if (geyserConfig.getRemote().getAuthType() == AuthType.FLOODGATE && getProxy().getPluginManager().getPlugin("floodgate") == null) { if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && getProxy().getPluginManager().getPlugin("floodgate") == null) {
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling")); geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
return; return;
} else if (geyserConfig.isAutoconfiguredRemote() && getProxy().getPluginManager().getPlugin("floodgate") != null) { } else if (geyserConfig.isAutoconfiguredRemote() && getProxy().getPluginManager().getPlugin("floodgate") != null) {
@ -134,7 +134,8 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
this.geyserBungeePingPassthrough = new GeyserBungeePingPassthrough(getProxy()); this.geyserBungeePingPassthrough = new GeyserBungeePingPassthrough(getProxy());
} }
this.getProxy().getPluginManager().registerCommand(this, new GeyserBungeeCommandExecutor(geyser)); this.getProxy().getPluginManager().registerCommand(this, new GeyserBungeeCommandExecutor("geyser", geyser, geyserCommandManager.getCommands()));
this.getProxy().getPluginManager().registerCommand(this, new GeyserBungeeCommandExecutor("geyserext", geyser, geyserCommandManager.commands()));
} }
@Override @Override

Datei anzeigen

@ -37,14 +37,15 @@ import org.geysermc.geyser.text.GeyserLocale;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Map;
public class GeyserBungeeCommandExecutor extends Command implements TabExecutor { public class GeyserBungeeCommandExecutor extends Command implements TabExecutor {
private final GeyserCommandExecutor commandExecutor; private final GeyserCommandExecutor commandExecutor;
public GeyserBungeeCommandExecutor(GeyserImpl geyser) { public GeyserBungeeCommandExecutor(String name, GeyserImpl geyser, Map<String, org.geysermc.geyser.api.command.Command> commands) {
super("geyser"); super(name);
this.commandExecutor = new GeyserCommandExecutor(geyser); this.commandExecutor = new GeyserCommandExecutor(geyser, commands);
} }
@Override @Override

Datei anzeigen

@ -170,8 +170,8 @@ public class GeyserSpigotInjector extends GeyserInjector {
*/ */
private void workAroundWeirdBug(GeyserBootstrap bootstrap) { private void workAroundWeirdBug(GeyserBootstrap bootstrap) {
MinecraftProtocol protocol = new MinecraftProtocol(); MinecraftProtocol protocol = new MinecraftProtocol();
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().getAddress(), LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().address(),
bootstrap.getGeyserConfig().getRemote().getPort(), this.serverSocketAddress, bootstrap.getGeyserConfig().getRemote().port(), this.serverSocketAddress,
InetAddress.getLoopbackAddress().getHostAddress(), protocol, protocol.createHelper()); InetAddress.getLoopbackAddress().getHostAddress(), protocol, protocol.createHelper());
session.connect(); session.connect();
} }

Datei anzeigen

@ -43,7 +43,6 @@ import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.adapters.spigot.SpigotAdapters; import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
import org.geysermc.geyser.api.command.Command; import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.network.AuthType; import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.command.GeyserCommand;
import org.geysermc.geyser.command.GeyserCommandManager; import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.configuration.GeyserConfiguration; import org.geysermc.geyser.configuration.GeyserConfiguration;
import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.dump.BootstrapDumpInfo;
@ -125,7 +124,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
} }
// By default this should be localhost but may need to be changed in some circumstances // By default this should be localhost but may need to be changed in some circumstances
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) { if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
geyserConfig.setAutoconfiguredRemote(true); geyserConfig.setAutoconfiguredRemote(true);
// Don't use localhost if not listening on all interfaces // Don't use localhost if not listening on all interfaces
if (!Bukkit.getIp().equals("0.0.0.0") && !Bukkit.getIp().equals("")) { if (!Bukkit.getIp().equals("0.0.0.0") && !Bukkit.getIp().equals("")) {
@ -148,7 +147,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
return; return;
} }
if (geyserConfig.getRemote().getAuthType() == AuthType.FLOODGATE && Bukkit.getPluginManager().getPlugin("floodgate") == null) { if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && Bukkit.getPluginManager().getPlugin("floodgate") == null) {
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling")); geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
this.getPluginLoader().disablePlugin(this); this.getPluginLoader().disablePlugin(this);
return; return;
@ -251,8 +250,10 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
geyserLogger.debug("Using default world manager: " + this.geyserWorldManager.getClass()); geyserLogger.debug("Using default world manager: " + this.geyserWorldManager.getClass());
} }
PluginCommand pluginCommand = this.getCommand("geyser"); PluginCommand geyserCommand = this.getCommand("geyser");
pluginCommand.setExecutor(new GeyserSpigotCommandExecutor(geyser)); geyserCommand.setExecutor(new GeyserSpigotCommandExecutor(geyser, geyserCommandManager.getCommands()));
PluginCommand geyserExtCommand = this.getCommand("geyserext");
geyserExtCommand.setExecutor(new GeyserSpigotCommandExecutor(geyser, geyserCommandManager.getCommands()));
if (!INITIALIZED) { if (!INITIALIZED) {
// Register permissions so they appear in, for example, LuckPerms' UI // Register permissions so they appear in, for example, LuckPerms' UI
@ -279,7 +280,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
boolean brigadierSupported = CommodoreProvider.isSupported(); boolean brigadierSupported = CommodoreProvider.isSupported();
geyserLogger.debug("Brigadier supported? " + brigadierSupported); geyserLogger.debug("Brigadier supported? " + brigadierSupported);
if (brigadierSupported) { if (brigadierSupported) {
GeyserBrigadierSupport.loadBrigadier(this, pluginCommand); GeyserBrigadierSupport.loadBrigadier(this, geyserCommand);
} }
// Check to ensure the current setup can support the protocol version Geyser uses // Check to ensure the current setup can support the protocol version Geyser uses

Datei anzeigen

@ -38,11 +38,12 @@ import org.geysermc.geyser.text.GeyserLocale;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
public class GeyserSpigotCommandExecutor extends GeyserCommandExecutor implements TabExecutor { public class GeyserSpigotCommandExecutor extends GeyserCommandExecutor implements TabExecutor {
public GeyserSpigotCommandExecutor(GeyserImpl geyser) { public GeyserSpigotCommandExecutor(GeyserImpl geyser, Map<String, org.geysermc.geyser.api.command.Command> commands) {
super(geyser); super(geyser, commands);
} }
@Override @Override

Datei anzeigen

@ -8,4 +8,7 @@ api-version: 1.13
commands: commands:
geyser: geyser:
description: The main command for Geyser. description: The main command for Geyser.
usage: /geyser <subcommand> usage: /geyser <subcommand>
geyserext:
description: The command any extensions can register to.
usage: /geyserext <subcommand>

Datei anzeigen

@ -99,14 +99,14 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
// Don't change the ip if its listening on all interfaces // Don't change the ip if its listening on all interfaces
// By default this should be 127.0.0.1 but may need to be changed in some circumstances // By default this should be 127.0.0.1 but may need to be changed in some circumstances
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) { if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
this.geyserConfig.setAutoconfiguredRemote(true); this.geyserConfig.setAutoconfiguredRemote(true);
geyserConfig.getRemote().setPort(javaAddr.getPort()); geyserConfig.getRemote().setPort(javaAddr.getPort());
} }
} }
if (geyserConfig.getBedrock().isCloneRemotePort()) { if (geyserConfig.getBedrock().isCloneRemotePort()) {
geyserConfig.getBedrock().setPort(geyserConfig.getRemote().getPort()); geyserConfig.getBedrock().setPort(geyserConfig.getRemote().port());
} }
this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode()); this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode());
@ -121,7 +121,8 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
this.geyserCommandManager = new GeyserSpongeCommandManager(Sponge.getCommandManager(), geyser); this.geyserCommandManager = new GeyserSpongeCommandManager(Sponge.getCommandManager(), geyser);
this.geyserCommandManager.init(); this.geyserCommandManager.init();
Sponge.getCommandManager().register(this, new GeyserSpongeCommandExecutor(geyser), "geyser"); Sponge.getCommandManager().register(this, new GeyserSpongeCommandExecutor(geyser, geyserCommandManager.getCommands()), "geyser");
Sponge.getCommandManager().register(this, new GeyserSpongeCommandExecutor(geyser, geyserCommandManager.commands()), "geyserext");
} }
@Override @Override

Datei anzeigen

@ -26,6 +26,7 @@
package org.geysermc.geyser.platform.sponge.command; package org.geysermc.geyser.platform.sponge.command;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.command.GeyserCommand; import org.geysermc.geyser.command.GeyserCommand;
import org.geysermc.geyser.command.GeyserCommandExecutor; import org.geysermc.geyser.command.GeyserCommandExecutor;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
@ -40,15 +41,12 @@ import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Arrays; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
public class GeyserSpongeCommandExecutor extends GeyserCommandExecutor implements CommandCallable { public class GeyserSpongeCommandExecutor extends GeyserCommandExecutor implements CommandCallable {
public GeyserSpongeCommandExecutor(GeyserImpl geyser) { public GeyserSpongeCommandExecutor(GeyserImpl geyser, Map<String, Command> commands) {
super(geyser); super(geyser, commands);
} }
@Override @Override

Datei anzeigen

@ -197,7 +197,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
handleArgsConfigOptions(); handleArgsConfigOptions();
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) { if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
geyserConfig.setAutoconfiguredRemote(true); // Doesn't really need to be set but /shrug geyserConfig.setAutoconfiguredRemote(true); // Doesn't really need to be set but /shrug
geyserConfig.getRemote().setAddress("127.0.0.1"); geyserConfig.getRemote().setAddress("127.0.0.1");
} }

Datei anzeigen

@ -102,7 +102,7 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
InetSocketAddress javaAddr = proxyServer.getBoundAddress(); InetSocketAddress javaAddr = proxyServer.getBoundAddress();
// By default this should be localhost but may need to be changed in some circumstances // By default this should be localhost but may need to be changed in some circumstances
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) { if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
this.geyserConfig.setAutoconfiguredRemote(true); this.geyserConfig.setAutoconfiguredRemote(true);
// Don't use localhost if not listening on all interfaces // Don't use localhost if not listening on all interfaces
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) { if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
@ -128,7 +128,7 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
if (geyserConfig.getRemote().getAuthType() == AuthType.FLOODGATE && proxyServer.getPluginManager().getPlugin("floodgate").isEmpty()) { if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && proxyServer.getPluginManager().getPlugin("floodgate").isEmpty()) {
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
+ GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling")); + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
return; return;
@ -148,7 +148,8 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
this.geyserCommandManager = new GeyserVelocityCommandManager(geyser); this.geyserCommandManager = new GeyserVelocityCommandManager(geyser);
this.geyserCommandManager.init(); this.geyserCommandManager.init();
this.commandManager.register("geyser", new GeyserVelocityCommandExecutor(geyser)); this.commandManager.register("geyser", new GeyserVelocityCommandExecutor(geyser, geyserCommandManager.getCommands()));
this.commandManager.register("geyserext", new GeyserVelocityCommandExecutor(geyser, geyserCommandManager.commands()));
if (geyserConfig.isLegacyPingPassthrough()) { if (geyserConfig.isLegacyPingPassthrough()) {
this.geyserPingPassthrough = GeyserLegacyPingPassthrough.init(geyser); this.geyserPingPassthrough = GeyserLegacyPingPassthrough.init(geyser);
} else { } else {

Datei anzeigen

@ -27,6 +27,7 @@ package org.geysermc.geyser.platform.velocity.command;
import com.velocitypowered.api.command.SimpleCommand; import com.velocitypowered.api.command.SimpleCommand;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.command.GeyserCommand; import org.geysermc.geyser.command.GeyserCommand;
import org.geysermc.geyser.command.GeyserCommandExecutor; import org.geysermc.geyser.command.GeyserCommandExecutor;
import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.command.GeyserCommandSource;
@ -37,11 +38,12 @@ import org.geysermc.geyser.text.GeyserLocale;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
public class GeyserVelocityCommandExecutor extends GeyserCommandExecutor implements SimpleCommand { public class GeyserVelocityCommandExecutor extends GeyserCommandExecutor implements SimpleCommand {
public GeyserVelocityCommandExecutor(GeyserImpl geyser) { public GeyserVelocityCommandExecutor(GeyserImpl geyser, Map<String, Command> commands) {
super(geyser); super(geyser, commands);
} }
@Override @Override

Datei anzeigen

@ -34,7 +34,7 @@ import java.nio.file.Path;
public class FloodgateKeyLoader { public class FloodgateKeyLoader {
public static Path getKeyPath(GeyserJacksonConfiguration config, Path floodgateDataFolder, Path geyserDataFolder, GeyserLogger logger) { public static Path getKeyPath(GeyserJacksonConfiguration config, Path floodgateDataFolder, Path geyserDataFolder, GeyserLogger logger) {
if (config.getRemote().getAuthType() != AuthType.FLOODGATE) { if (config.getRemote().authType() != AuthType.FLOODGATE) {
return geyserDataFolder.resolve(config.getFloodgateKeyFile()); return geyserDataFolder.resolve(config.getFloodgateKeyFile());
} }

Datei anzeigen

@ -64,14 +64,10 @@ import org.geysermc.geyser.entity.EntityDefinitions;
import org.geysermc.geyser.event.GeyserEventBus; import org.geysermc.geyser.event.GeyserEventBus;
import org.geysermc.geyser.extension.GeyserExtensionManager; import org.geysermc.geyser.extension.GeyserExtensionManager;
import org.geysermc.geyser.level.WorldManager; import org.geysermc.geyser.level.WorldManager;
import org.geysermc.geyser.network.BedrockListenerImpl;
import org.geysermc.geyser.network.ConnectorServerEventHandler; import org.geysermc.geyser.network.ConnectorServerEventHandler;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.network.RemoteServerImpl;
import org.geysermc.geyser.pack.ResourcePack; import org.geysermc.geyser.pack.ResourcePack;
import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.provider.GeyserProviderManager;
import org.geysermc.geyser.scoreboard.ScoreboardUpdater; import org.geysermc.geyser.scoreboard.ScoreboardUpdater;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.PendingMicrosoftAuthentication; import org.geysermc.geyser.session.PendingMicrosoftAuthentication;
@ -90,7 +86,6 @@ import javax.naming.directory.InitialDirContext;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
@ -148,10 +143,6 @@ public class GeyserImpl implements GeyserApi {
private final EventBus eventBus; private final EventBus eventBus;
private final GeyserExtensionManager extensionManager; private final GeyserExtensionManager extensionManager;
private final GeyserProviderManager providerManager = new GeyserProviderManager();
private final RemoteServer remoteServer;
private final BedrockListener bedrockListener;
private Metrics metrics; private Metrics metrics;
@ -215,22 +206,6 @@ public class GeyserImpl implements GeyserApi {
} }
} }
this.remoteServer = new RemoteServerImpl(
config.getRemote().getAddress(),
config.getRemote().getPort(),
GameProtocol.getJavaProtocolVersion(),
GameProtocol.getJavaMinecraftVersion(),
config.getRemote().getAuthType()
);
this.bedrockListener = new BedrockListenerImpl(
config.getBedrock().getAddress(),
config.getBedrock().getPort(),
config.getBedrock().getMotd1(),
config.getBedrock().getMotd2(),
config.getBedrock().getServerName()
);
double completeTime = (System.currentTimeMillis() - startupTime) / 1000D; double completeTime = (System.currentTimeMillis() - startupTime) / 1000D;
String message = GeyserLocale.getLocaleStringLog("geyser.core.finish.done", new DecimalFormat("#.###").format(completeTime)) + " "; String message = GeyserLocale.getLocaleStringLog("geyser.core.finish.done", new DecimalFormat("#.###").format(completeTime)) + " ";
if (isGui) { if (isGui) {
@ -243,7 +218,7 @@ public class GeyserImpl implements GeyserApi {
if (platformType == PlatformType.STANDALONE) { if (platformType == PlatformType.STANDALONE) {
logger.warning(GeyserLocale.getLocaleStringLog("geyser.core.movement_warn")); logger.warning(GeyserLocale.getLocaleStringLog("geyser.core.movement_warn"));
} else if (config.getRemote().getAuthType() == AuthType.FLOODGATE) { } else if (config.getRemote().authType() == AuthType.FLOODGATE) {
VersionCheckUtils.checkForOutdatedFloodgate(logger); VersionCheckUtils.checkForOutdatedFloodgate(logger);
} }
} }
@ -260,7 +235,7 @@ public class GeyserImpl implements GeyserApi {
ResourcePack.loadPacks(); ResourcePack.loadPacks();
if (platformType != PlatformType.STANDALONE && config.getRemote().getAddress().equals("auto")) { if (platformType != PlatformType.STANDALONE && config.getRemote().address().equals("auto")) {
// Set the remote address to localhost since that is where we are always connecting // Set the remote address to localhost since that is where we are always connecting
try { try {
config.getRemote().setAddress(InetAddress.getLocalHost().getHostAddress()); config.getRemote().setAddress(InetAddress.getLocalHost().getHostAddress());
@ -272,7 +247,7 @@ public class GeyserImpl implements GeyserApi {
config.getRemote().setAddress(InetAddress.getLoopbackAddress().getHostAddress()); config.getRemote().setAddress(InetAddress.getLoopbackAddress().getHostAddress());
} }
} }
String remoteAddress = config.getRemote().getAddress(); String remoteAddress = config.getRemote().address();
// Filters whether it is not an IP address or localhost, because otherwise it is not possible to find out an SRV entry. // Filters whether it is not an IP address or localhost, because otherwise it is not possible to find out an SRV entry.
if (!remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) { if (!remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) {
int remotePort; int remotePort;
@ -298,24 +273,6 @@ public class GeyserImpl implements GeyserApi {
// Ensure that PacketLib does not create an event loop for handling packets; we'll do that ourselves // Ensure that PacketLib does not create an event loop for handling packets; we'll do that ourselves
TcpSession.USE_EVENT_LOOP_FOR_PACKETS = false; TcpSession.USE_EVENT_LOOP_FOR_PACKETS = false;
String branch = "unknown";
int buildNumber = -1;
if (this.isProductionEnvironment()) {
try (InputStream stream = bootstrap.getResource("git.properties")) {
Properties gitProperties = new Properties();
gitProperties.load(stream);
branch = gitProperties.getProperty("git.branch");
String build = gitProperties.getProperty("git.build.number");
if (build != null) {
buildNumber = Integer.parseInt(build);
}
} catch (Throwable e) {
logger.error("Failed to read git.properties", e);
}
} else {
logger.debug("Not getting git properties for the news handler as we are in a development environment.");
}
pendingMicrosoftAuthentication = new PendingMicrosoftAuthentication(config.getPendingAuthenticationTimeout()); pendingMicrosoftAuthentication = new PendingMicrosoftAuthentication(config.getPendingAuthenticationTimeout());
this.newsHandler = new NewsHandler(BRANCH, this.buildNumber()); this.newsHandler = new NewsHandler(BRANCH, this.buildNumber());
@ -335,7 +292,7 @@ public class GeyserImpl implements GeyserApi {
boolean enableProxyProtocol = config.getBedrock().isEnableProxyProtocol(); boolean enableProxyProtocol = config.getBedrock().isEnableProxyProtocol();
bedrockServer = new BedrockServer( bedrockServer = new BedrockServer(
new InetSocketAddress(config.getBedrock().getAddress(), config.getBedrock().getPort()), new InetSocketAddress(config.getBedrock().address(), config.getBedrock().port()),
bedrockThreadCount, bedrockThreadCount,
EventLoops.commonGroup(), EventLoops.commonGroup(),
enableProxyProtocol enableProxyProtocol
@ -358,11 +315,11 @@ public class GeyserImpl implements GeyserApi {
if (shouldStartListener) { if (shouldStartListener) {
bedrockServer.bind().whenComplete((avoid, throwable) -> { bedrockServer.bind().whenComplete((avoid, throwable) -> {
if (throwable == null) { if (throwable == null) {
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().getAddress(), logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().address(),
String.valueOf(config.getBedrock().getPort()))); String.valueOf(config.getBedrock().port())));
} else { } else {
String address = config.getBedrock().getAddress(); String address = config.getBedrock().address();
int port = config.getBedrock().getPort(); int port = config.getBedrock().port();
logger.severe(GeyserLocale.getLocaleStringLog("geyser.core.fail", address, String.valueOf(port))); logger.severe(GeyserLocale.getLocaleStringLog("geyser.core.fail", address, String.valueOf(port)));
if (!"0.0.0.0".equals(address)) { if (!"0.0.0.0".equals(address)) {
logger.info(ChatColor.GREEN + "Suggestion: try setting `address` under `bedrock` in the Geyser config back to 0.0.0.0"); logger.info(ChatColor.GREEN + "Suggestion: try setting `address` under `bedrock` in the Geyser config back to 0.0.0.0");
@ -372,7 +329,7 @@ public class GeyserImpl implements GeyserApi {
}).join(); }).join();
} }
if (config.getRemote().getAuthType() == AuthType.FLOODGATE) { if (config.getRemote().authType() == AuthType.FLOODGATE) {
try { try {
Key key = new AesKeyProducer().produceFrom(config.getFloodgateKeyPath()); Key key = new AesKeyProducer().produceFrom(config.getFloodgateKeyPath());
cipher = new AesCipher(new Base64Topping()); cipher = new AesCipher(new Base64Topping());
@ -390,7 +347,7 @@ public class GeyserImpl implements GeyserApi {
metrics = new Metrics(this, "GeyserMC", config.getMetrics().getUniqueId(), false, java.util.logging.Logger.getLogger("")); metrics = new Metrics(this, "GeyserMC", config.getMetrics().getUniqueId(), false, java.util.logging.Logger.getLogger(""));
metrics.addCustomChart(new Metrics.SingleLineChart("players", sessionManager::size)); metrics.addCustomChart(new Metrics.SingleLineChart("players", sessionManager::size));
// Prevent unwanted words best we can // Prevent unwanted words best we can
metrics.addCustomChart(new Metrics.SimplePie("authMode", () -> config.getRemote().getAuthType().toString().toLowerCase(Locale.ROOT))); metrics.addCustomChart(new Metrics.SimplePie("authMode", () -> config.getRemote().authType().toString().toLowerCase(Locale.ROOT)));
metrics.addCustomChart(new Metrics.SimplePie("platform", platformType::getPlatformName)); metrics.addCustomChart(new Metrics.SimplePie("platform", platformType::getPlatformName));
metrics.addCustomChart(new Metrics.SimplePie("defaultLocale", GeyserLocale::getDefaultLocale)); metrics.addCustomChart(new Metrics.SimplePie("defaultLocale", GeyserLocale::getDefaultLocale));
metrics.addCustomChart(new Metrics.SimplePie("version", () -> GeyserImpl.VERSION)); metrics.addCustomChart(new Metrics.SimplePie("version", () -> GeyserImpl.VERSION));
@ -474,7 +431,7 @@ public class GeyserImpl implements GeyserApi {
metrics = null; metrics = null;
} }
if (config.getRemote().getAuthType() == AuthType.ONLINE) { if (config.getRemote().authType() == AuthType.ONLINE) {
if (config.getUserAuths() != null && !config.getUserAuths().isEmpty()) { if (config.getUserAuths() != null && !config.getUserAuths().isEmpty()) {
getLogger().warning("The 'userAuths' config section is now deprecated, and will be removed in the near future! " + getLogger().warning("The 'userAuths' config section is now deprecated, and will be removed in the near future! " +
"Please migrate to the new 'saved-user-logins' config option: " + "Please migrate to the new 'saved-user-logins' config option: " +
@ -552,7 +509,6 @@ public class GeyserImpl implements GeyserApi {
return null; return null;
} }
@Override
public void shutdown() { public void shutdown() {
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown")); bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown"));
shuttingDown = true; shuttingDown = true;
@ -579,7 +535,6 @@ public class GeyserImpl implements GeyserApi {
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.done")); bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.done"));
} }
@Override
public void reload() { public void reload() {
shutdown(); shutdown();
this.extensionManager.enableExtensions(); this.extensionManager.enableExtensions();
@ -592,10 +547,10 @@ public class GeyserImpl implements GeyserApi {
* *
* @return true if the version number is not 'DEV'. * @return true if the version number is not 'DEV'.
*/ */
@Override
public boolean isProductionEnvironment() { public boolean isProductionEnvironment() {
// First is if Blossom runs, second is if Blossom doesn't run
// noinspection ConstantConditions - changes in production // noinspection ConstantConditions - changes in production
return !"${gitVersion}".equals(GeyserImpl.GIT_VERSION); return !("git-local/dev-0000000".equals(GeyserImpl.GIT_VERSION) || "${gitVersion}".equals(GeyserImpl.GIT_VERSION));
} }
@Override @Override
@ -609,8 +564,8 @@ public class GeyserImpl implements GeyserApi {
} }
@Override @Override
public GeyserProviderManager providerManager() { public <R extends T, T> @NonNull R provider(@NonNull Class<T> apiClass, @Nullable Object... args) {
return this.providerManager; return (R) Registries.PROVIDERS.get(apiClass).create(args);
} }
@Override @Override
@ -619,17 +574,12 @@ public class GeyserImpl implements GeyserApi {
} }
public RemoteServer defaultRemoteServer() { public RemoteServer defaultRemoteServer() {
return this.remoteServer; return getConfig().getRemote();
} }
@Override @Override
public BedrockListener bedrockListener() { public BedrockListener bedrockListener() {
return this.bedrockListener; return getConfig().getBedrock();
}
@Override
public int maxPlayers() {
return this.getConfig().getMaxPlayers();
} }
public int buildNumber() { public int buildNumber() {

Datei anzeigen

@ -37,15 +37,16 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* Represents helper functions for listening to {@code /geyser} commands. * Represents helper functions for listening to {@code /geyser} or {@code /geyserext} commands.
*/ */
@AllArgsConstructor @AllArgsConstructor
public class GeyserCommandExecutor { public class GeyserCommandExecutor {
protected final GeyserImpl geyser; protected final GeyserImpl geyser;
private final Map<String, Command> commands;
public GeyserCommand getCommand(String label) { public GeyserCommand getCommand(String label) {
return (GeyserCommand) geyser.commandManager().commands().get(label); return (GeyserCommand) commands.get(label);
} }
@Nullable @Nullable
@ -78,7 +79,6 @@ public class GeyserCommandExecutor {
} }
List<String> availableCommands = new ArrayList<>(); List<String> availableCommands = new ArrayList<>();
Map<String, Command> commands = geyser.commandManager().getCommands();
// Only show commands they have permission to use // Only show commands they have permission to use
for (Map.Entry<String, Command> entry : commands.entrySet()) { for (Map.Entry<String, Command> entry : commands.entrySet()) {

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.geyser.command; package org.geysermc.geyser.command;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@ -34,7 +35,6 @@ import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.command.CommandExecutor; import org.geysermc.geyser.api.command.CommandExecutor;
import org.geysermc.geyser.api.command.CommandManager; import org.geysermc.geyser.api.command.CommandManager;
import org.geysermc.geyser.api.command.CommandSource; import org.geysermc.geyser.api.command.CommandSource;
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCommandsEvent;
import org.geysermc.geyser.command.defaults.*; import org.geysermc.geyser.command.defaults.*;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
@ -42,91 +42,104 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
@RequiredArgsConstructor @RequiredArgsConstructor
public abstract class GeyserCommandManager extends CommandManager { public abstract class GeyserCommandManager extends CommandManager {
@Getter @Getter
private final Map<String, Command> commands = new HashMap<>(); private final Map<String, Command> commands = new Object2ObjectOpenHashMap<>(12);
private final Map<String, Command> extensionCommands = new Object2ObjectOpenHashMap<>(0);
private final GeyserImpl geyser; private final GeyserImpl geyser;
public void init() { public void init() {
register(new HelpCommand(geyser, "help", "geyser.commands.help.desc", "geyser.command.help")); registerBuiltInCommand(new HelpCommand(geyser, "help", "geyser.commands.help.desc", "geyser.command.help", "geyser", commands));
register(new ListCommand(geyser, "list", "geyser.commands.list.desc", "geyser.command.list")); registerBuiltInCommand(new ListCommand(geyser, "list", "geyser.commands.list.desc", "geyser.command.list"));
register(new ReloadCommand(geyser, "reload", "geyser.commands.reload.desc", "geyser.command.reload")); registerBuiltInCommand(new ReloadCommand(geyser, "reload", "geyser.commands.reload.desc", "geyser.command.reload"));
register(new OffhandCommand(geyser, "offhand", "geyser.commands.offhand.desc", "geyser.command.offhand")); registerBuiltInCommand(new OffhandCommand(geyser, "offhand", "geyser.commands.offhand.desc", "geyser.command.offhand"));
register(new DumpCommand(geyser, "dump", "geyser.commands.dump.desc", "geyser.command.dump")); registerBuiltInCommand(new DumpCommand(geyser, "dump", "geyser.commands.dump.desc", "geyser.command.dump"));
register(new VersionCommand(geyser, "version", "geyser.commands.version.desc", "geyser.command.version")); registerBuiltInCommand(new VersionCommand(geyser, "version", "geyser.commands.version.desc", "geyser.command.version"));
register(new SettingsCommand(geyser, "settings", "geyser.commands.settings.desc", "geyser.command.settings")); registerBuiltInCommand(new SettingsCommand(geyser, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
register(new StatisticsCommand(geyser, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics")); registerBuiltInCommand(new StatisticsCommand(geyser, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
register(new AdvancementsCommand("advancements", "geyser.commands.advancements.desc", "geyser.command.advancements")); registerBuiltInCommand(new AdvancementsCommand("advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
register(new AdvancedTooltipsCommand("tooltips", "geyser.commands.advancedtooltips.desc", "geyser.command.tooltips")); registerBuiltInCommand(new AdvancedTooltipsCommand("tooltips", "geyser.commands.advancedtooltips.desc", "geyser.command.tooltips"));
register(new ExtensionsCommand(geyser, "extensions", "geyser.commands.extensions.desc", "geyser.command.extensions"));
if (GeyserImpl.getInstance().getPlatformType() == PlatformType.STANDALONE) { if (GeyserImpl.getInstance().getPlatformType() == PlatformType.STANDALONE) {
register(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop")); registerBuiltInCommand(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));
} }
this.geyser.eventBus().fire(new GeyserDefineCommandsEvent(this, this.commands())); register(new HelpCommand(geyser, "help", "geyser.commands.exthelp.desc", "geyser.command.exthelp", "geyserext", extensionCommands));
}
/**
* For internal Geyser commands
*/
public void registerBuiltInCommand(GeyserCommand command) {
register(command, this.commands);
} }
@Override @Override
public void register(@NonNull Command command) { public void register(@NonNull Command command) {
this.commands.put(command.name(), command); register(command, this.extensionCommands);
this.geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.commands.registered", command.name())); }
private void register(Command command, Map<String, Command> commands) {
commands.put(command.name(), command);
geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.commands.registered", command.name()));
if (command.aliases().isEmpty()) { if (command.aliases().isEmpty()) {
return; return;
} }
for (String alias : command.aliases()) { for (String alias : command.aliases()) {
this.commands.put(alias, command); commands.put(alias, command);
} }
} }
@Override @Override
public void unregister(@NonNull Command command) { public void unregister(@NonNull Command command) {
this.commands.remove(command.name(), command); this.extensionCommands.remove(command.name(), command);
if (command.aliases().isEmpty()) { if (command.aliases().isEmpty()) {
return; return;
} }
for (String alias : command.aliases()) { for (String alias : command.aliases()) {
this.commands.remove(alias, command); this.extensionCommands.remove(alias, command);
} }
} }
@NotNull @NotNull
@Override @Override
public Map<String, Command> commands() { public Map<String, Command> commands() {
return Collections.unmodifiableMap(this.commands); return Collections.unmodifiableMap(this.extensionCommands);
} }
public void runCommand(GeyserCommandSource sender, String command) { public boolean runCommand(GeyserCommandSource sender, String command) {
if (!command.startsWith("geyser ")) boolean extensionCommand = command.startsWith("geyserext ");
return; if (!command.startsWith("geyser ") && !extensionCommand) {
return false;
}
command = command.trim().replace("geyser ", ""); command = command.trim().replace(extensionCommand ? "geyserext " : "geyser ", "");
String label; String label;
String[] args; String[] args;
if (!command.contains(" ")) { if (!command.contains(" ")) {
label = command.toLowerCase(); label = command.toLowerCase(Locale.ROOT);
args = new String[0]; args = new String[0];
} else { } else {
label = command.substring(0, command.indexOf(" ")).toLowerCase(); label = command.substring(0, command.indexOf(" ")).toLowerCase(Locale.ROOT);
String argLine = command.substring(command.indexOf(" ") + 1); String argLine = command.substring(command.indexOf(" ") + 1);
args = argLine.contains(" ") ? argLine.split(" ") : new String[] { argLine }; args = argLine.contains(" ") ? argLine.split(" ") : new String[] { argLine };
} }
Command cmd = commands.get(label); Command cmd = (extensionCommand ? this.extensionCommands : this.commands).get(label);
if (cmd == null) { if (cmd == null) {
geyser.getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.invalid")); geyser.getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.invalid"));
return; return false;
} }
if (cmd instanceof GeyserCommand) { if (cmd instanceof GeyserCommand) {
@ -140,6 +153,8 @@ public abstract class GeyserCommandManager extends CommandManager {
} }
} }
} }
return true;
} }
/** /**

Datei anzeigen

@ -39,10 +39,15 @@ import java.util.Map;
public class HelpCommand extends GeyserCommand { public class HelpCommand extends GeyserCommand {
private final GeyserImpl geyser; private final GeyserImpl geyser;
private final String baseCommand;
private final Map<String, Command> commands;
public HelpCommand(GeyserImpl geyser, String name, String description, String permission) { public HelpCommand(GeyserImpl geyser, String name, String description, String permission,
String baseCommand, Map<String, Command> commands) {
super(name, description, permission); super(name, description, permission);
this.geyser = geyser; this.geyser = geyser;
this.baseCommand = baseCommand;
this.commands = commands;
this.setAliases(Collections.singletonList("?")); this.setAliases(Collections.singletonList("?"));
} }
@ -61,8 +66,7 @@ public class HelpCommand extends GeyserCommand {
String header = GeyserLocale.getPlayerLocaleString("geyser.commands.help.header", sender.locale(), page, maxPage); String header = GeyserLocale.getPlayerLocaleString("geyser.commands.help.header", sender.locale(), page, maxPage);
sender.sendMessage(header); sender.sendMessage(header);
Map<String, Command> cmds = geyser.commandManager().getCommands(); for (Map.Entry<String, Command> entry : commands.entrySet()) {
for (Map.Entry<String, Command> entry : cmds.entrySet()) {
Command cmd = entry.getValue(); Command cmd = entry.getValue();
// Standalone hack-in since it doesn't have a concept of permissions // Standalone hack-in since it doesn't have a concept of permissions
@ -72,7 +76,7 @@ public class HelpCommand extends GeyserCommand {
continue; continue;
} }
sender.sendMessage(ChatColor.YELLOW + "/geyser " + entry.getKey() + ChatColor.WHITE + ": " + sender.sendMessage(ChatColor.YELLOW + "/" + baseCommand + " " + entry.getKey() + ChatColor.WHITE + ": " +
GeyserLocale.getPlayerLocaleString(cmd.description(), sender.locale())); GeyserLocale.getPlayerLocaleString(cmd.description(), sender.locale()));
} }
} }

Datei anzeigen

@ -27,8 +27,10 @@ package org.geysermc.geyser.configuration;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.api.network.AuthType; import org.geysermc.geyser.api.network.BedrockListener;
import org.geysermc.geyser.api.network.RemoteServer;
import org.geysermc.geyser.network.CIDRMatcher; import org.geysermc.geyser.network.CIDRMatcher;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import java.nio.file.Path; import java.nio.file.Path;
@ -113,20 +115,10 @@ public interface GeyserConfiguration {
int getPendingAuthenticationTimeout(); int getPendingAuthenticationTimeout();
interface IBedrockConfiguration { interface IBedrockConfiguration extends BedrockListener {
String getAddress();
int getPort();
boolean isCloneRemotePort(); boolean isCloneRemotePort();
String getMotd1();
String getMotd2();
String getServerName();
int getCompressionLevel(); int getCompressionLevel();
boolean isEnableProxyProtocol(); boolean isEnableProxyProtocol();
@ -139,23 +131,25 @@ public interface GeyserConfiguration {
List<CIDRMatcher> getWhitelistedIPsMatchers(); List<CIDRMatcher> getWhitelistedIPsMatchers();
} }
interface IRemoteConfiguration { interface IRemoteConfiguration extends RemoteServer {
String getAddress();
int getPort();
void setAddress(String address); void setAddress(String address);
void setPort(int port); void setPort(int port);
AuthType getAuthType();
boolean isPasswordAuthentication(); boolean isPasswordAuthentication();
boolean isUseProxyProtocol(); boolean isUseProxyProtocol();
boolean isForwardHost(); boolean isForwardHost();
default String minecraftVersion() {
return GameProtocol.getJavaMinecraftVersion();
}
default int protocolVersion() {
return GameProtocol.getJavaProtocolVersion();
}
} }
interface IUserAuthenticationInfo { interface IUserAuthenticationInfo {

Datei anzeigen

@ -159,24 +159,50 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
@JsonProperty("pending-authentication-timeout") @JsonProperty("pending-authentication-timeout")
private int pendingAuthenticationTimeout = 120; private int pendingAuthenticationTimeout = 120;
@Getter
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public static class BedrockConfiguration implements IBedrockConfiguration { public static class BedrockConfiguration implements IBedrockConfiguration {
@AsteriskSerializer.Asterisk(isIp = true) @AsteriskSerializer.Asterisk(isIp = true)
private String address = "0.0.0.0"; private String address = "0.0.0.0";
@Override
public String address() {
return address;
}
@Setter @Setter
private int port = 19132; private int port = 19132;
@Override
public int port() {
return port;
}
@Getter
@JsonProperty("clone-remote-port") @JsonProperty("clone-remote-port")
private boolean cloneRemotePort = false; private boolean cloneRemotePort = false;
private String motd1 = "GeyserMC"; private String motd1 = "GeyserMC";
@Override
public String primaryMotd() {
return motd1;
}
private String motd2 = "Geyser"; private String motd2 = "Geyser";
@Override
public String secondaryMotd() {
return motd2;
}
@JsonProperty("server-name") @JsonProperty("server-name")
private String serverName = GeyserImpl.NAME; private String serverName = GeyserImpl.NAME;
@Override
public String serverName() {
return serverName;
}
@JsonProperty("compression-level") @JsonProperty("compression-level")
private int compressionLevel = 6; private int compressionLevel = 6;
@ -184,9 +210,11 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
return Math.max(-1, Math.min(compressionLevel, 9)); return Math.max(-1, Math.min(compressionLevel, 9));
} }
@Getter
@JsonProperty("enable-proxy-protocol") @JsonProperty("enable-proxy-protocol")
private boolean enableProxyProtocol = false; private boolean enableProxyProtocol = false;
@Getter
@JsonProperty("proxy-protocol-whitelisted-ips") @JsonProperty("proxy-protocol-whitelisted-ips")
private List<String> proxyProtocolWhitelistedIPs = Collections.emptyList(); private List<String> proxyProtocolWhitelistedIPs = Collections.emptyList();
@ -208,28 +236,45 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
} }
} }
@Getter
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public static class RemoteConfiguration implements IRemoteConfiguration { public static class RemoteConfiguration implements IRemoteConfiguration {
@Setter @Setter
@AsteriskSerializer.Asterisk(isIp = true) @AsteriskSerializer.Asterisk(isIp = true)
private String address = "auto"; private String address = "auto";
@Override
public String address() {
return address;
}
@JsonDeserialize(using = PortDeserializer.class) @JsonDeserialize(using = PortDeserializer.class)
@Setter @Setter
private int port = 25565; private int port = 25565;
@Override
public int port() {
return port;
}
@Setter @Setter
@JsonDeserialize(using = AuthTypeDeserializer.class) @JsonDeserialize(using = AuthTypeDeserializer.class)
@JsonProperty("auth-type") @JsonProperty("auth-type")
private AuthType authType = AuthType.ONLINE; private AuthType authType = AuthType.ONLINE;
@Override
public AuthType authType() {
return authType;
}
@Getter
@JsonProperty("allow-password-authentication") @JsonProperty("allow-password-authentication")
private boolean passwordAuthentication = true; private boolean passwordAuthentication = true;
@Getter
@JsonProperty("use-proxy-protocol") @JsonProperty("use-proxy-protocol")
private boolean useProxyProtocol = false; private boolean useProxyProtocol = false;
@Getter
@JsonProperty("forward-hostname") @JsonProperty("forward-hostname")
private boolean forwardHost = false; private boolean forwardHost = false;
} }

Datei anzeigen

@ -1,31 +0,0 @@
/*
* Copyright (c) 2019-2022 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.network;
import org.geysermc.geyser.api.network.BedrockListener;
public record BedrockListenerImpl(String address, int port, String primaryMotd, String secondaryMotd, String serverName) implements BedrockListener {
}

Datei anzeigen

@ -108,7 +108,7 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
pong.setNintendoLimited(false); pong.setNintendoLimited(false);
pong.setProtocolVersion(GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()); pong.setProtocolVersion(GameProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion());
pong.setVersion(GameProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion()); // Required to not be empty as of 1.16.210.59. Can only contain . and numbers. pong.setVersion(GameProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion()); // Required to not be empty as of 1.16.210.59. Can only contain . and numbers.
pong.setIpv4Port(config.getBedrock().getPort()); pong.setIpv4Port(config.getBedrock().port());
if (config.isPassthroughMotd() && pingInfo != null && pingInfo.getDescription() != null) { if (config.isPassthroughMotd() && pingInfo != null && pingInfo.getDescription() != null) {
String[] motd = MessageTranslator.convertMessageLenient(pingInfo.getDescription()).split("\n"); String[] motd = MessageTranslator.convertMessageLenient(pingInfo.getDescription()).split("\n");
@ -118,8 +118,8 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
pong.setMotd(mainMotd.trim()); pong.setMotd(mainMotd.trim());
pong.setSubMotd(subMotd.trim()); // Trimmed to shift it to the left, prevents the universe from collapsing on us just because we went 2 characters over the text box's limit. pong.setSubMotd(subMotd.trim()); // Trimmed to shift it to the left, prevents the universe from collapsing on us just because we went 2 characters over the text box's limit.
} else { } else {
pong.setMotd(config.getBedrock().getMotd1()); pong.setMotd(config.getBedrock().primaryMotd());
pong.setSubMotd(config.getBedrock().getMotd2()); pong.setSubMotd(config.getBedrock().secondaryMotd());
} }
if (config.isPassthroughPlayerCounts() && pingInfo != null) { if (config.isPassthroughPlayerCounts() && pingInfo != null) {

Datei anzeigen

@ -153,7 +153,7 @@ public class QueryPacketHandler {
String[] javaMotd = MessageTranslator.convertMessageLenient(pingInfo.getDescription()).split("\n"); String[] javaMotd = MessageTranslator.convertMessageLenient(pingInfo.getDescription()).split("\n");
motd = javaMotd[0].trim(); // First line of the motd. motd = javaMotd[0].trim(); // First line of the motd.
} else { } else {
motd = geyser.getConfig().getBedrock().getMotd1(); motd = geyser.getConfig().getBedrock().primaryMotd();
} }
// If passthrough player counts is enabled lets get players from the server // If passthrough player counts is enabled lets get players from the server
@ -182,8 +182,8 @@ public class QueryPacketHandler {
gameData.put("map", map); gameData.put("map", map);
gameData.put("numplayers", currentPlayerCount); gameData.put("numplayers", currentPlayerCount);
gameData.put("maxplayers", maxPlayerCount); gameData.put("maxplayers", maxPlayerCount);
gameData.put("hostport", String.valueOf(geyser.getConfig().getBedrock().getPort())); gameData.put("hostport", String.valueOf(geyser.getConfig().getBedrock().port()));
gameData.put("hostip", geyser.getConfig().getBedrock().getAddress()); gameData.put("hostip", geyser.getConfig().getBedrock().address());
try { try {
writeString(query, "GeyserMC"); writeString(query, "GeyserMC");

Datei anzeigen

@ -1,32 +0,0 @@
/*
* Copyright (c) 2019-2022 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.network;
import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.api.network.RemoteServer;
public record RemoteServerImpl(String address, int port, int protocolVersion, String minecraftVersion, AuthType authType) implements RemoteServer {
}

Datei anzeigen

@ -31,7 +31,6 @@ import com.nukkitx.protocol.bedrock.data.ExperimentData;
import com.nukkitx.protocol.bedrock.data.ResourcePackType; import com.nukkitx.protocol.bedrock.data.ResourcePackType;
import com.nukkitx.protocol.bedrock.packet.*; import com.nukkitx.protocol.bedrock.packet.*;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.session.PendingMicrosoftAuthentication;
import org.geysermc.geyser.api.network.AuthType; import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.configuration.GeyserConfiguration; import org.geysermc.geyser.configuration.GeyserConfiguration;
import org.geysermc.geyser.pack.ResourcePack; import org.geysermc.geyser.pack.ResourcePack;
@ -39,6 +38,7 @@ import org.geysermc.geyser.pack.ResourcePackManifest;
import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.PendingMicrosoftAuthentication;
import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.GeyserLocale;
import org.geysermc.geyser.util.LoginEncryptionUtils; import org.geysermc.geyser.util.LoginEncryptionUtils;
import org.geysermc.geyser.util.MathUtils; import org.geysermc.geyser.util.MathUtils;
@ -119,7 +119,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
public boolean handle(ResourcePackClientResponsePacket packet) { public boolean handle(ResourcePackClientResponsePacket packet) {
switch (packet.getStatus()) { switch (packet.getStatus()) {
case COMPLETED: case COMPLETED:
if (geyser.getConfig().getRemote().getAuthType() != AuthType.ONLINE) { if (geyser.getConfig().getRemote().authType() != AuthType.ONLINE) {
session.authenticate(session.getAuthData().name()); session.authenticate(session.getAuthData().name());
} else if (!couldLoginUserByName(session.getAuthData().name())) { } else if (!couldLoginUserByName(session.getAuthData().name())) {
// We must spawn the white world // We must spawn the white world

Datei anzeigen

@ -77,8 +77,8 @@ public class GeyserLegacyPingPassthrough implements IGeyserPingPassthrough, Runn
@Override @Override
public void run() { public void run() {
try (Socket socket = new Socket()) { try (Socket socket = new Socket()) {
String address = geyser.getConfig().getRemote().getAddress(); String address = geyser.getConfig().getRemote().address();
int port = geyser.getConfig().getRemote().getPort(); int port = geyser.getConfig().getRemote().port();
socket.connect(new InetSocketAddress(address, port), 5000); socket.connect(new InetSocketAddress(address, port), 5000);
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();

Datei anzeigen

@ -1,42 +0,0 @@
/*
* Copyright (c) 2019-2022 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.registry;
import org.geysermc.geyser.api.provider.Provider;
import org.geysermc.geyser.registry.loader.ProviderRegistryLoader;
import org.geysermc.geyser.registry.provider.GeyserBuilderProvider;
import org.geysermc.geyser.registry.provider.ProviderSupplier;
/**
* Holds registries for the available {@link Provider}s
*/
public class ProviderRegistries {
/**
* A registry containing all the providers for builders.
*/
public static final SimpleMappedRegistry<Class<?>, ProviderSupplier> BUILDERS = SimpleMappedRegistry.create(GeyserBuilderProvider.INSTANCE, ProviderRegistryLoader::new);
}

Datei anzeigen

@ -40,8 +40,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.kyori.adventure.key.Key;
import org.geysermc.geyser.api.extension.ExtensionLoader;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.inventory.item.Enchantment.JavaEnchantment; import org.geysermc.geyser.inventory.item.Enchantment.JavaEnchantment;
import org.geysermc.geyser.inventory.recipe.GeyserRecipe; import org.geysermc.geyser.inventory.recipe.GeyserRecipe;
@ -49,6 +47,7 @@ import org.geysermc.geyser.registry.loader.*;
import org.geysermc.geyser.registry.populator.ItemRegistryPopulator; import org.geysermc.geyser.registry.populator.ItemRegistryPopulator;
import org.geysermc.geyser.registry.populator.PacketRegistryPopulator; import org.geysermc.geyser.registry.populator.PacketRegistryPopulator;
import org.geysermc.geyser.registry.populator.RecipeRegistryPopulator; import org.geysermc.geyser.registry.populator.RecipeRegistryPopulator;
import org.geysermc.geyser.registry.provider.ProviderSupplier;
import org.geysermc.geyser.registry.type.EnchantmentData; import org.geysermc.geyser.registry.type.EnchantmentData;
import org.geysermc.geyser.registry.type.ItemMappings; import org.geysermc.geyser.registry.type.ItemMappings;
import org.geysermc.geyser.registry.type.ParticleMapping; import org.geysermc.geyser.registry.type.ParticleMapping;
@ -59,10 +58,7 @@ import org.geysermc.geyser.translator.level.event.LevelEventTranslator;
import org.geysermc.geyser.translator.sound.SoundInteractionTranslator; import org.geysermc.geyser.translator.sound.SoundInteractionTranslator;
import org.geysermc.geyser.translator.sound.SoundTranslator; import org.geysermc.geyser.translator.sound.SoundTranslator;
import java.util.EnumMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
/** /**
* Holds all the common registries in Geyser. * Holds all the common registries in Geyser.
@ -140,6 +136,11 @@ public final class Registries {
*/ */
public static final SimpleRegistry<Set<PotionMixData>> POTION_MIXES; public static final SimpleRegistry<Set<PotionMixData>> POTION_MIXES;
/**
* A registry holding all the
*/
public static final SimpleMappedRegistry<Class<?>, ProviderSupplier> PROVIDERS = SimpleMappedRegistry.create(new IdentityHashMap<>(), ProviderRegistryLoader::new);
/** /**
* A versioned registry holding all the recipes, with the net ID being the key, and {@link GeyserRecipe} as the value. * A versioned registry holding all the recipes, with the net ID being the key, and {@link GeyserRecipe} as the value.
*/ */

Datei anzeigen

@ -25,21 +25,32 @@
package org.geysermc.geyser.registry.loader; package org.geysermc.geyser.registry.loader;
import org.geysermc.geyser.registry.provider.AbstractProvider; import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.command.CommandSource;
import org.geysermc.geyser.api.item.custom.CustomItemData;
import org.geysermc.geyser.api.item.custom.CustomItemOptions;
import org.geysermc.geyser.api.item.custom.NonVanillaCustomItemData;
import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.item.GeyserCustomItemData;
import org.geysermc.geyser.item.GeyserCustomItemOptions;
import org.geysermc.geyser.item.GeyserNonVanillaCustomItemData;
import org.geysermc.geyser.registry.provider.ProviderSupplier; import org.geysermc.geyser.registry.provider.ProviderSupplier;
import java.util.IdentityHashMap;
import java.util.Map; import java.util.Map;
/** /**
* Registers the provider data from the provider. * Registers the provider data from the provider.
*/ */
public class ProviderRegistryLoader implements RegistryLoader<AbstractProvider, Map<Class<?>, ProviderSupplier>> { public class ProviderRegistryLoader implements RegistryLoader<Map<Class<?>, ProviderSupplier>, Map<Class<?>, ProviderSupplier>> {
@SuppressWarnings("unchecked")
@Override @Override
public Map<Class<?>, ProviderSupplier> load(AbstractProvider input) { public Map<Class<?>, ProviderSupplier> load(Map<Class<?>, ProviderSupplier> providers) {
Map<Class<?>, ProviderSupplier> providers = new IdentityHashMap<>(); providers.put(Command.Builder.class, args -> new GeyserCommandManager.CommandBuilder<>((Class<? extends CommandSource>) args[0]));
input.registerProviders(providers); providers.put(CustomItemData.Builder.class, args -> new GeyserCustomItemData.CustomItemDataBuilder());
providers.put(CustomItemOptions.Builder.class, args -> new GeyserCustomItemOptions.CustomItemOptionsBuilder());
providers.put(NonVanillaCustomItemData.Builder.class, args -> new GeyserNonVanillaCustomItemData.NonVanillaCustomItemDataBuilder());
return providers; return providers;
} }
} }

Datei anzeigen

@ -1,39 +0,0 @@
/*
* Copyright (c) 2019-2022 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.registry.provider;
import lombok.RequiredArgsConstructor;
import org.geysermc.geyser.api.provider.Provider;
import org.geysermc.geyser.registry.SimpleMappedRegistry;
import java.util.Map;
@RequiredArgsConstructor
public abstract class AbstractProvider implements Provider {
public abstract void registerProviders(Map<Class<?>, ProviderSupplier> providers);
public abstract SimpleMappedRegistry<Class<?>, ProviderSupplier> providerRegistry();
}

Datei anzeigen

@ -1,81 +0,0 @@
/*
* Copyright (c) 2019-2022 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.registry.provider;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.api.block.custom.CustomBlockData;
import org.geysermc.geyser.api.block.custom.CustomBlockPermutation;
import org.geysermc.geyser.api.block.custom.component.CustomBlockComponents;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.command.CommandSource;
import org.geysermc.geyser.api.item.custom.CustomItemData;
import org.geysermc.geyser.api.item.custom.CustomItemOptions;
import org.geysermc.geyser.api.item.custom.NonVanillaCustomItemData;
import org.geysermc.geyser.api.provider.BuilderProvider;
import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.item.GeyserCustomItemData;
import org.geysermc.geyser.item.GeyserCustomItemOptions;
import org.geysermc.geyser.item.GeyserNonVanillaCustomItemData;
import org.geysermc.geyser.level.block.GeyserCustomBlockComponents;
import org.geysermc.geyser.level.block.GeyserCustomBlockData;
import org.geysermc.geyser.level.block.GeyserCustomBlockPermutation;
import org.geysermc.geyser.registry.ProviderRegistries;
import org.geysermc.geyser.registry.SimpleMappedRegistry;
import java.util.Map;
public class GeyserBuilderProvider extends AbstractProvider implements BuilderProvider {
public static GeyserBuilderProvider INSTANCE = new GeyserBuilderProvider();
private GeyserBuilderProvider() {
}
@SuppressWarnings("unchecked")
@Override
public void registerProviders(Map<Class<?>, ProviderSupplier> providers) {
providers.put(Command.Builder.class, args -> new GeyserCommandManager.CommandBuilder<>((Class<? extends CommandSource>) args[0]));
providers.put(CustomBlockComponents.Builder.class, args -> new GeyserCustomBlockComponents.CustomBlockComponentsBuilder());
providers.put(CustomBlockData.Builder.class, args -> new GeyserCustomBlockData.CustomBlockDataBuilder());
providers.put(CustomBlockPermutation.Builder.class, args -> new GeyserCustomBlockPermutation.CustomBlockPermutationBuilder());
providers.put(CustomItemData.Builder.class, args -> new GeyserCustomItemData.CustomItemDataBuilder());
providers.put(CustomItemOptions.Builder.class, args -> new GeyserCustomItemOptions.CustomItemOptionsBuilder());
providers.put(NonVanillaCustomItemData.Builder.class, args -> new GeyserNonVanillaCustomItemData.NonVanillaCustomItemDataBuilder());
}
@Override
public SimpleMappedRegistry<Class<?>, ProviderSupplier> providerRegistry() {
return ProviderRegistries.BUILDERS;
}
@SuppressWarnings("unchecked")
@Override
public <B extends T, T> @NonNull B provideBuilder(@NonNull Class<T> builderClass, @Nullable Object... args) {
return (B) this.providerRegistry().get(builderClass).create(args);
}
}

Datei anzeigen

@ -1,36 +0,0 @@
/*
* Copyright (c) 2019-2022 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.registry.provider;
import org.geysermc.geyser.api.provider.ProviderManager;
public class GeyserProviderManager implements ProviderManager {
@Override
public GeyserBuilderProvider builderProvider() {
return GeyserBuilderProvider.INSTANCE;
}
}

Datei anzeigen

@ -597,7 +597,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
disconnect(message); disconnect(message);
}); });
this.remoteServer = geyser.getRemoteServer(); this.remoteServer = geyser.defaultRemoteServer();
} }
/** /**
@ -1473,7 +1473,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
startGamePacket.setFromWorldTemplate(false); startGamePacket.setFromWorldTemplate(false);
startGamePacket.setWorldTemplateOptionLocked(false); startGamePacket.setWorldTemplateOptionLocked(false);
String serverName = geyser.getConfig().getBedrock().getServerName(); String serverName = geyser.getConfig().getBedrock().serverName();
startGamePacket.setLevelId(serverName); startGamePacket.setLevelId(serverName);
startGamePacket.setLevelName(serverName); startGamePacket.setLevelName(serverName);

Datei anzeigen

@ -286,7 +286,7 @@ public class SkinManager {
String skinUrl = isAlex ? SkinProvider.EMPTY_SKIN_ALEX.getTextureUrl() : SkinProvider.EMPTY_SKIN.getTextureUrl(); String skinUrl = isAlex ? SkinProvider.EMPTY_SKIN_ALEX.getTextureUrl() : SkinProvider.EMPTY_SKIN.getTextureUrl();
String capeUrl = SkinProvider.EMPTY_CAPE.getTextureUrl(); String capeUrl = SkinProvider.EMPTY_CAPE.getTextureUrl();
if (("steve".equals(skinUrl) || "alex".equals(skinUrl)) && GeyserImpl.getInstance().getConfig().getRemote().getAuthType() != AuthType.ONLINE) { if (("steve".equals(skinUrl) || "alex".equals(skinUrl)) && GeyserImpl.getInstance().getConfig().getRemote().authType() != AuthType.ONLINE) {
GeyserSession session = GeyserImpl.getInstance().connectionByUuid(uuid); GeyserSession session = GeyserImpl.getInstance().connectionByUuid(uuid);
if (session != null) { if (session != null) {

Datei anzeigen

@ -28,7 +28,6 @@ package org.geysermc.geyser.translator.protocol.bedrock;
import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket; import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket;
import org.geysermc.common.PlatformType; import org.geysermc.common.PlatformType;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
@ -40,10 +39,8 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
@Override @Override
public void translate(GeyserSession session, CommandRequestPacket packet) { public void translate(GeyserSession session, CommandRequestPacket packet) {
String command = packet.getCommand().replace("/", ""); String command = packet.getCommand().replace("/", "");
GeyserCommandManager commandManager = GeyserImpl.getInstance().commandManager(); if (!(session.getGeyser().getPlatformType() == PlatformType.STANDALONE
if (session.getGeyser().getPlatformType() == PlatformType.STANDALONE && command.trim().startsWith("geyser ") && commandManager.getCommands().containsKey(command.split(" ")[1])) { && GeyserImpl.getInstance().commandManager().runCommand(session, command))) {
commandManager.runCommand(session, command);
} else {
String message = packet.getCommand().trim(); String message = packet.getCommand().trim();
if (MessageTranslator.isTooLong(message, session)) { if (MessageTranslator.isTooLong(message, session)) {