mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Some nitpicks and cleaning up the provider API
The command changes here are not final. Internally we're discussing if we want to allow extensions to register root commands on platforms.
This commit is contained in:
commit
40fde6b046
45 changed files with 245 additions and 644 deletions
|
@ -34,7 +34,7 @@ import java.nio.file.Path;
|
|||
|
||||
public class FloodgateKeyLoader {
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -64,14 +64,10 @@ import org.geysermc.geyser.entity.EntityDefinitions;
|
|||
import org.geysermc.geyser.event.GeyserEventBus;
|
||||
import org.geysermc.geyser.extension.GeyserExtensionManager;
|
||||
import org.geysermc.geyser.level.WorldManager;
|
||||
import org.geysermc.geyser.network.BedrockListenerImpl;
|
||||
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.registry.BlockRegistries;
|
||||
import org.geysermc.geyser.registry.Registries;
|
||||
import org.geysermc.geyser.registry.provider.GeyserProviderManager;
|
||||
import org.geysermc.geyser.scoreboard.ScoreboardUpdater;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.session.PendingMicrosoftAuthentication;
|
||||
|
@ -90,7 +86,6 @@ import javax.naming.directory.InitialDirContext;
|
|||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
@ -148,10 +143,6 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
private final EventBus eventBus;
|
||||
private final GeyserExtensionManager extensionManager;
|
||||
private final GeyserProviderManager providerManager = new GeyserProviderManager();
|
||||
|
||||
private final RemoteServer remoteServer;
|
||||
private final BedrockListener bedrockListener;
|
||||
|
||||
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;
|
||||
String message = GeyserLocale.getLocaleStringLog("geyser.core.finish.done", new DecimalFormat("#.###").format(completeTime)) + " ";
|
||||
if (isGui) {
|
||||
|
@ -243,7 +218,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
if (platformType == PlatformType.STANDALONE) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +235,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
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
|
||||
try {
|
||||
config.getRemote().setAddress(InetAddress.getLocalHost().getHostAddress());
|
||||
|
@ -272,7 +247,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
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.
|
||||
if (!remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) {
|
||||
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
|
||||
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());
|
||||
|
||||
this.newsHandler = new NewsHandler(BRANCH, this.buildNumber());
|
||||
|
@ -335,7 +292,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
boolean enableProxyProtocol = config.getBedrock().isEnableProxyProtocol();
|
||||
bedrockServer = new BedrockServer(
|
||||
new InetSocketAddress(config.getBedrock().getAddress(), config.getBedrock().getPort()),
|
||||
new InetSocketAddress(config.getBedrock().address(), config.getBedrock().port()),
|
||||
bedrockThreadCount,
|
||||
EventLoops.commonGroup(),
|
||||
enableProxyProtocol
|
||||
|
@ -358,11 +315,11 @@ public class GeyserImpl implements GeyserApi {
|
|||
if (shouldStartListener) {
|
||||
bedrockServer.bind().whenComplete((avoid, throwable) -> {
|
||||
if (throwable == null) {
|
||||
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().getAddress(),
|
||||
String.valueOf(config.getBedrock().getPort())));
|
||||
logger.info(GeyserLocale.getLocaleStringLog("geyser.core.start", config.getBedrock().address(),
|
||||
String.valueOf(config.getBedrock().port())));
|
||||
} else {
|
||||
String address = config.getBedrock().getAddress();
|
||||
int port = config.getBedrock().getPort();
|
||||
String address = config.getBedrock().address();
|
||||
int port = config.getBedrock().port();
|
||||
logger.severe(GeyserLocale.getLocaleStringLog("geyser.core.fail", address, String.valueOf(port)));
|
||||
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");
|
||||
|
@ -372,7 +329,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
}).join();
|
||||
}
|
||||
|
||||
if (config.getRemote().getAuthType() == AuthType.FLOODGATE) {
|
||||
if (config.getRemote().authType() == AuthType.FLOODGATE) {
|
||||
try {
|
||||
Key key = new AesKeyProducer().produceFrom(config.getFloodgateKeyPath());
|
||||
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.addCustomChart(new Metrics.SingleLineChart("players", sessionManager::size));
|
||||
// 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("defaultLocale", GeyserLocale::getDefaultLocale));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("version", () -> GeyserImpl.VERSION));
|
||||
|
@ -474,7 +431,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
metrics = null;
|
||||
}
|
||||
|
||||
if (config.getRemote().getAuthType() == AuthType.ONLINE) {
|
||||
if (config.getRemote().authType() == AuthType.ONLINE) {
|
||||
if (config.getUserAuths() != null && !config.getUserAuths().isEmpty()) {
|
||||
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: " +
|
||||
|
@ -552,7 +509,6 @@ public class GeyserImpl implements GeyserApi {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown"));
|
||||
shuttingDown = true;
|
||||
|
@ -579,7 +535,6 @@ public class GeyserImpl implements GeyserApi {
|
|||
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.done"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
shutdown();
|
||||
this.extensionManager.enableExtensions();
|
||||
|
@ -592,10 +547,10 @@ public class GeyserImpl implements GeyserApi {
|
|||
*
|
||||
* @return true if the version number is not 'DEV'.
|
||||
*/
|
||||
@Override
|
||||
public boolean isProductionEnvironment() {
|
||||
// First is if Blossom runs, second is if Blossom doesn't run
|
||||
// noinspection ConstantConditions - changes in production
|
||||
return !"git-local/dev-0000000".equals(GeyserImpl.GIT_VERSION);
|
||||
return !("git-local/dev-0000000".equals(GeyserImpl.GIT_VERSION) || "${gitVersion}".equals(GeyserImpl.GIT_VERSION));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -609,8 +564,8 @@ public class GeyserImpl implements GeyserApi {
|
|||
}
|
||||
|
||||
@Override
|
||||
public GeyserProviderManager providerManager() {
|
||||
return this.providerManager;
|
||||
public <R extends T, T> @NonNull R provider(@NonNull Class<T> apiClass, @Nullable Object... args) {
|
||||
return (R) Registries.PROVIDERS.get(apiClass).create(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -619,17 +574,12 @@ public class GeyserImpl implements GeyserApi {
|
|||
}
|
||||
|
||||
public RemoteServer defaultRemoteServer() {
|
||||
return this.remoteServer;
|
||||
return getConfig().getRemote();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BedrockListener bedrockListener() {
|
||||
return this.bedrockListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxPlayers() {
|
||||
return this.getConfig().getMaxPlayers();
|
||||
return getConfig().getBedrock();
|
||||
}
|
||||
|
||||
public int buildNumber() {
|
||||
|
|
|
@ -37,15 +37,16 @@ import java.util.List;
|
|||
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
|
||||
public class GeyserCommandExecutor {
|
||||
|
||||
protected final GeyserImpl geyser;
|
||||
private final Map<String, Command> commands;
|
||||
|
||||
public GeyserCommand getCommand(String label) {
|
||||
return (GeyserCommand) geyser.commandManager().commands().get(label);
|
||||
return (GeyserCommand) commands.get(label);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -78,7 +79,6 @@ public class GeyserCommandExecutor {
|
|||
}
|
||||
|
||||
List<String> availableCommands = new ArrayList<>();
|
||||
Map<String, Command> commands = geyser.commandManager().getCommands();
|
||||
|
||||
// Only show commands they have permission to use
|
||||
for (Map.Entry<String, Command> entry : commands.entrySet()) {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
package org.geysermc.geyser.command;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.CommandManager;
|
||||
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.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
|
@ -42,91 +42,104 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class GeyserCommandManager extends CommandManager {
|
||||
|
||||
@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;
|
||||
|
||||
public void init() {
|
||||
register(new HelpCommand(geyser, "help", "geyser.commands.help.desc", "geyser.command.help"));
|
||||
register(new ListCommand(geyser, "list", "geyser.commands.list.desc", "geyser.command.list"));
|
||||
register(new ReloadCommand(geyser, "reload", "geyser.commands.reload.desc", "geyser.command.reload"));
|
||||
register(new OffhandCommand(geyser, "offhand", "geyser.commands.offhand.desc", "geyser.command.offhand"));
|
||||
register(new DumpCommand(geyser, "dump", "geyser.commands.dump.desc", "geyser.command.dump"));
|
||||
register(new VersionCommand(geyser, "version", "geyser.commands.version.desc", "geyser.command.version"));
|
||||
register(new SettingsCommand(geyser, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
|
||||
register(new StatisticsCommand(geyser, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
|
||||
register(new AdvancementsCommand("advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
|
||||
register(new AdvancedTooltipsCommand("tooltips", "geyser.commands.advancedtooltips.desc", "geyser.command.tooltips"));
|
||||
register(new ExtensionsCommand(geyser, "extensions", "geyser.commands.extensions.desc", "geyser.command.extensions"));
|
||||
registerBuiltInCommand(new HelpCommand(geyser, "help", "geyser.commands.help.desc", "geyser.command.help", "geyser", commands));
|
||||
registerBuiltInCommand(new ListCommand(geyser, "list", "geyser.commands.list.desc", "geyser.command.list"));
|
||||
registerBuiltInCommand(new ReloadCommand(geyser, "reload", "geyser.commands.reload.desc", "geyser.command.reload"));
|
||||
registerBuiltInCommand(new OffhandCommand(geyser, "offhand", "geyser.commands.offhand.desc", "geyser.command.offhand"));
|
||||
registerBuiltInCommand(new DumpCommand(geyser, "dump", "geyser.commands.dump.desc", "geyser.command.dump"));
|
||||
registerBuiltInCommand(new VersionCommand(geyser, "version", "geyser.commands.version.desc", "geyser.command.version"));
|
||||
registerBuiltInCommand(new SettingsCommand(geyser, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
|
||||
registerBuiltInCommand(new StatisticsCommand(geyser, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
|
||||
registerBuiltInCommand(new AdvancementsCommand("advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
|
||||
registerBuiltInCommand(new AdvancedTooltipsCommand("tooltips", "geyser.commands.advancedtooltips.desc", "geyser.command.tooltips"));
|
||||
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
|
||||
public void register(@NonNull Command command) {
|
||||
this.commands.put(command.name(), command);
|
||||
this.geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.commands.registered", command.name()));
|
||||
register(command, this.extensionCommands);
|
||||
}
|
||||
|
||||
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()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String alias : command.aliases()) {
|
||||
this.commands.put(alias, command);
|
||||
commands.put(alias, command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister(@NonNull Command command) {
|
||||
this.commands.remove(command.name(), command);
|
||||
this.extensionCommands.remove(command.name(), command);
|
||||
|
||||
if (command.aliases().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String alias : command.aliases()) {
|
||||
this.commands.remove(alias, command);
|
||||
this.extensionCommands.remove(alias, command);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, Command> commands() {
|
||||
return Collections.unmodifiableMap(this.commands);
|
||||
return Collections.unmodifiableMap(this.extensionCommands);
|
||||
}
|
||||
|
||||
public void runCommand(GeyserCommandSource sender, String command) {
|
||||
if (!command.startsWith("geyser "))
|
||||
return;
|
||||
public boolean runCommand(GeyserCommandSource sender, String command) {
|
||||
boolean extensionCommand = command.startsWith("geyserext ");
|
||||
if (!command.startsWith("geyser ") && !extensionCommand) {
|
||||
return false;
|
||||
}
|
||||
|
||||
command = command.trim().replace("geyser ", "");
|
||||
command = command.trim().replace(extensionCommand ? "geyserext " : "geyser ", "");
|
||||
String label;
|
||||
String[] args;
|
||||
|
||||
if (!command.contains(" ")) {
|
||||
label = command.toLowerCase();
|
||||
label = command.toLowerCase(Locale.ROOT);
|
||||
args = new String[0];
|
||||
} else {
|
||||
label = command.substring(0, command.indexOf(" ")).toLowerCase();
|
||||
label = command.substring(0, command.indexOf(" ")).toLowerCase(Locale.ROOT);
|
||||
String argLine = command.substring(command.indexOf(" ") + 1);
|
||||
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) {
|
||||
geyser.getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.invalid"));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cmd instanceof GeyserCommand) {
|
||||
|
@ -140,6 +153,8 @@ public abstract class GeyserCommandManager extends CommandManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,10 +39,15 @@ import java.util.Map;
|
|||
|
||||
public class HelpCommand extends GeyserCommand {
|
||||
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);
|
||||
this.geyser = geyser;
|
||||
this.baseCommand = baseCommand;
|
||||
this.commands = commands;
|
||||
|
||||
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);
|
||||
sender.sendMessage(header);
|
||||
|
||||
Map<String, Command> cmds = geyser.commandManager().getCommands();
|
||||
for (Map.Entry<String, Command> entry : cmds.entrySet()) {
|
||||
for (Map.Entry<String, Command> entry : commands.entrySet()) {
|
||||
Command cmd = entry.getValue();
|
||||
|
||||
// Standalone hack-in since it doesn't have a concept of permissions
|
||||
|
@ -72,7 +76,7 @@ public class HelpCommand extends GeyserCommand {
|
|||
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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,10 @@ package org.geysermc.geyser.configuration;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
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.GameProtocol;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
@ -109,20 +111,10 @@ public interface GeyserConfiguration {
|
|||
|
||||
int getPendingAuthenticationTimeout();
|
||||
|
||||
interface IBedrockConfiguration {
|
||||
|
||||
String getAddress();
|
||||
|
||||
int getPort();
|
||||
interface IBedrockConfiguration extends BedrockListener {
|
||||
|
||||
boolean isCloneRemotePort();
|
||||
|
||||
String getMotd1();
|
||||
|
||||
String getMotd2();
|
||||
|
||||
String getServerName();
|
||||
|
||||
int getCompressionLevel();
|
||||
|
||||
boolean isEnableProxyProtocol();
|
||||
|
@ -135,23 +127,25 @@ public interface GeyserConfiguration {
|
|||
List<CIDRMatcher> getWhitelistedIPsMatchers();
|
||||
}
|
||||
|
||||
interface IRemoteConfiguration {
|
||||
|
||||
String getAddress();
|
||||
|
||||
int getPort();
|
||||
interface IRemoteConfiguration extends RemoteServer {
|
||||
|
||||
void setAddress(String address);
|
||||
|
||||
void setPort(int port);
|
||||
|
||||
AuthType getAuthType();
|
||||
|
||||
boolean isPasswordAuthentication();
|
||||
|
||||
boolean isUseProxyProtocol();
|
||||
|
||||
boolean isForwardHost();
|
||||
|
||||
default String minecraftVersion() {
|
||||
return GameProtocol.getJavaMinecraftVersion();
|
||||
}
|
||||
|
||||
default int protocolVersion() {
|
||||
return GameProtocol.getJavaProtocolVersion();
|
||||
}
|
||||
}
|
||||
|
||||
interface IUserAuthenticationInfo {
|
||||
|
|
|
@ -153,24 +153,50 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
|||
@JsonProperty("pending-authentication-timeout")
|
||||
private int pendingAuthenticationTimeout = 120;
|
||||
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class BedrockConfiguration implements IBedrockConfiguration {
|
||||
@AsteriskSerializer.Asterisk(isIp = true)
|
||||
private String address = "0.0.0.0";
|
||||
|
||||
@Override
|
||||
public String address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@Setter
|
||||
private int port = 19132;
|
||||
|
||||
@Override
|
||||
public int port() {
|
||||
return port;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@JsonProperty("clone-remote-port")
|
||||
private boolean cloneRemotePort = false;
|
||||
|
||||
private String motd1 = "GeyserMC";
|
||||
|
||||
@Override
|
||||
public String primaryMotd() {
|
||||
return motd1;
|
||||
}
|
||||
|
||||
private String motd2 = "Geyser";
|
||||
|
||||
@Override
|
||||
public String secondaryMotd() {
|
||||
return motd2;
|
||||
}
|
||||
|
||||
@JsonProperty("server-name")
|
||||
private String serverName = GeyserImpl.NAME;
|
||||
|
||||
@Override
|
||||
public String serverName() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
@JsonProperty("compression-level")
|
||||
private int compressionLevel = 6;
|
||||
|
||||
|
@ -178,9 +204,11 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
|||
return Math.max(-1, Math.min(compressionLevel, 9));
|
||||
}
|
||||
|
||||
@Getter
|
||||
@JsonProperty("enable-proxy-protocol")
|
||||
private boolean enableProxyProtocol = false;
|
||||
|
||||
@Getter
|
||||
@JsonProperty("proxy-protocol-whitelisted-ips")
|
||||
private List<String> proxyProtocolWhitelistedIPs = Collections.emptyList();
|
||||
|
||||
|
@ -202,28 +230,45 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class RemoteConfiguration implements IRemoteConfiguration {
|
||||
@Setter
|
||||
@AsteriskSerializer.Asterisk(isIp = true)
|
||||
private String address = "auto";
|
||||
|
||||
@Override
|
||||
public String address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
@JsonDeserialize(using = PortDeserializer.class)
|
||||
@Setter
|
||||
private int port = 25565;
|
||||
|
||||
@Override
|
||||
public int port() {
|
||||
return port;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@JsonDeserialize(using = AuthTypeDeserializer.class)
|
||||
@JsonProperty("auth-type")
|
||||
private AuthType authType = AuthType.ONLINE;
|
||||
|
||||
@Override
|
||||
public AuthType authType() {
|
||||
return authType;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@JsonProperty("allow-password-authentication")
|
||||
private boolean passwordAuthentication = true;
|
||||
|
||||
@Getter
|
||||
@JsonProperty("use-proxy-protocol")
|
||||
private boolean useProxyProtocol = false;
|
||||
|
||||
@Getter
|
||||
@JsonProperty("forward-hostname")
|
||||
private boolean forwardHost = false;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
}
|
|
@ -108,7 +108,7 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
|||
pong.setNintendoLimited(false);
|
||||
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.setIpv4Port(config.getBedrock().getPort());
|
||||
pong.setIpv4Port(config.getBedrock().port());
|
||||
|
||||
if (config.isPassthroughMotd() && pingInfo != null && pingInfo.getDescription() != null) {
|
||||
String[] motd = MessageTranslator.convertMessageLenient(pingInfo.getDescription()).split("\n");
|
||||
|
@ -118,8 +118,8 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler {
|
|||
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.
|
||||
} else {
|
||||
pong.setMotd(config.getBedrock().getMotd1());
|
||||
pong.setSubMotd(config.getBedrock().getMotd2());
|
||||
pong.setMotd(config.getBedrock().primaryMotd());
|
||||
pong.setSubMotd(config.getBedrock().secondaryMotd());
|
||||
}
|
||||
|
||||
if (config.isPassthroughPlayerCounts() && pingInfo != null) {
|
||||
|
|
|
@ -153,7 +153,7 @@ public class QueryPacketHandler {
|
|||
String[] javaMotd = MessageTranslator.convertMessageLenient(pingInfo.getDescription()).split("\n");
|
||||
motd = javaMotd[0].trim(); // First line of the motd.
|
||||
} else {
|
||||
motd = geyser.getConfig().getBedrock().getMotd1();
|
||||
motd = geyser.getConfig().getBedrock().primaryMotd();
|
||||
}
|
||||
|
||||
// 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("numplayers", currentPlayerCount);
|
||||
gameData.put("maxplayers", maxPlayerCount);
|
||||
gameData.put("hostport", String.valueOf(geyser.getConfig().getBedrock().getPort()));
|
||||
gameData.put("hostip", geyser.getConfig().getBedrock().getAddress());
|
||||
gameData.put("hostport", String.valueOf(geyser.getConfig().getBedrock().port()));
|
||||
gameData.put("hostip", geyser.getConfig().getBedrock().address());
|
||||
|
||||
try {
|
||||
writeString(query, "GeyserMC");
|
||||
|
|
|
@ -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 {
|
||||
}
|
|
@ -31,7 +31,6 @@ import com.nukkitx.protocol.bedrock.data.ExperimentData;
|
|||
import com.nukkitx.protocol.bedrock.data.ResourcePackType;
|
||||
import com.nukkitx.protocol.bedrock.packet.*;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.session.PendingMicrosoftAuthentication;
|
||||
import org.geysermc.geyser.api.network.AuthType;
|
||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||
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.Registries;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.session.PendingMicrosoftAuthentication;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.LoginEncryptionUtils;
|
||||
import org.geysermc.geyser.util.MathUtils;
|
||||
|
@ -119,7 +119,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
|||
public boolean handle(ResourcePackClientResponsePacket packet) {
|
||||
switch (packet.getStatus()) {
|
||||
case COMPLETED:
|
||||
if (geyser.getConfig().getRemote().getAuthType() != AuthType.ONLINE) {
|
||||
if (geyser.getConfig().getRemote().authType() != AuthType.ONLINE) {
|
||||
session.authenticate(session.getAuthData().name());
|
||||
} else if (!couldLoginUserByName(session.getAuthData().name())) {
|
||||
// We must spawn the white world
|
||||
|
|
|
@ -77,8 +77,8 @@ public class GeyserLegacyPingPassthrough implements IGeyserPingPassthrough, Runn
|
|||
@Override
|
||||
public void run() {
|
||||
try (Socket socket = new Socket()) {
|
||||
String address = geyser.getConfig().getRemote().getAddress();
|
||||
int port = geyser.getConfig().getRemote().getPort();
|
||||
String address = geyser.getConfig().getRemote().address();
|
||||
int port = geyser.getConfig().getRemote().port();
|
||||
socket.connect(new InetSocketAddress(address, port), 5000);
|
||||
|
||||
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -40,8 +40,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
|||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
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.inventory.item.Enchantment.JavaEnchantment;
|
||||
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.PacketRegistryPopulator;
|
||||
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.ItemMappings;
|
||||
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.SoundTranslator;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Holds all the common registries in Geyser.
|
||||
|
@ -140,6 +136,11 @@ public final class Registries {
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -25,21 +25,32 @@
|
|||
|
||||
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 java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 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
|
||||
public Map<Class<?>, ProviderSupplier> load(AbstractProvider input) {
|
||||
Map<Class<?>, ProviderSupplier> providers = new IdentityHashMap<>();
|
||||
input.registerProviders(providers);
|
||||
public Map<Class<?>, ProviderSupplier> load(Map<Class<?>, ProviderSupplier> providers) {
|
||||
providers.put(Command.Builder.class, args -> new GeyserCommandManager.CommandBuilder<>((Class<? extends CommandSource>) args[0]));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -1,70 +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.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.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(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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -597,7 +597,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||
disconnect(message);
|
||||
});
|
||||
|
||||
this.remoteServer = geyser.getRemoteServer();
|
||||
this.remoteServer = geyser.defaultRemoteServer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1473,7 +1473,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||
startGamePacket.setFromWorldTemplate(false);
|
||||
startGamePacket.setWorldTemplateOptionLocked(false);
|
||||
|
||||
String serverName = geyser.getConfig().getBedrock().getServerName();
|
||||
String serverName = geyser.getConfig().getBedrock().serverName();
|
||||
startGamePacket.setLevelId(serverName);
|
||||
startGamePacket.setLevelName(serverName);
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ public class SkinManager {
|
|||
|
||||
String skinUrl = isAlex ? SkinProvider.EMPTY_SKIN_ALEX.getTextureUrl() : SkinProvider.EMPTY_SKIN.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);
|
||||
|
||||
if (session != null) {
|
||||
|
|
|
@ -28,7 +28,6 @@ package org.geysermc.geyser.translator.protocol.bedrock;
|
|||
import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||
import org.geysermc.geyser.translator.protocol.Translator;
|
||||
|
@ -40,10 +39,8 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
|
|||
@Override
|
||||
public void translate(GeyserSession session, CommandRequestPacket packet) {
|
||||
String command = packet.getCommand().replace("/", "");
|
||||
GeyserCommandManager commandManager = GeyserImpl.getInstance().commandManager();
|
||||
if (session.getGeyser().getPlatformType() == PlatformType.STANDALONE && command.trim().startsWith("geyser ") && commandManager.getCommands().containsKey(command.split(" ")[1])) {
|
||||
commandManager.runCommand(session, command);
|
||||
} else {
|
||||
if (!(session.getGeyser().getPlatformType() == PlatformType.STANDALONE
|
||||
&& GeyserImpl.getInstance().commandManager().runCommand(session, command))) {
|
||||
String message = packet.getCommand().trim();
|
||||
|
||||
if (MessageTranslator.isTooLong(message, session)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue