mirror of https://github.com/GeyserMC/Geyser.git
Start on cloud 2.0 changes
This commit is contained in:
parent
666c23f558
commit
dc1826c5f9
|
@ -9,7 +9,7 @@ platformRelocate("net.md_5.bungee.jni")
|
|||
platformRelocate("com.fasterxml.jackson")
|
||||
platformRelocate("io.netty.channel.kqueue") // This is not used because relocating breaks natives, but we must include it or else we get ClassDefNotFound
|
||||
platformRelocate("net.kyori")
|
||||
platformRelocate("cloud.commandframework")
|
||||
platformRelocate("org.incendo")
|
||||
platformRelocate("org.yaml") // Broken as of 1.20
|
||||
|
||||
// These dependencies are already present on the platform
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.platform.bungeecord;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.bungee.BungeeCommandManager;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import io.netty.channel.Channel;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
|
@ -39,8 +36,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.util.PlatformType;
|
||||
import org.geysermc.geyser.command.CommandSourceConverter;
|
||||
import org.geysermc.geyser.command.CommandRegistry;
|
||||
import org.geysermc.geyser.command.CommandSourceConverter;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||
|
@ -49,6 +46,9 @@ import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
|||
import org.geysermc.geyser.platform.bungeecord.command.BungeeCommandSource;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.bungee.BungeeCommandManager;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -159,13 +159,13 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||
var sourceConverter = new CommandSourceConverter<>(
|
||||
CommandSender.class,
|
||||
id -> getProxy().getPlayer(id),
|
||||
() -> getProxy().getConsole()
|
||||
() -> getProxy().getConsole(),
|
||||
BungeeCommandSource::new
|
||||
);
|
||||
CommandManager<GeyserCommandSource> cloud = new BungeeCommandManager<>(
|
||||
this,
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
BungeeCommandSource::new,
|
||||
sourceConverter::convert
|
||||
ExecutionCoordinator.simpleCoordinator(),
|
||||
sourceConverter
|
||||
);
|
||||
this.commandRegistry = new CommandRegistry(geyser, cloud);
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.platform.fabric;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.fabric.FabricServerCommandManager;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
|
@ -44,6 +41,9 @@ import org.geysermc.geyser.command.GeyserCommandSource;
|
|||
import org.geysermc.geyser.platform.mod.GeyserModBootstrap;
|
||||
import org.geysermc.geyser.platform.mod.GeyserModUpdateListener;
|
||||
import org.geysermc.geyser.platform.mod.command.ModCommandSource;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
import org.incendo.cloud.fabric.FabricServerCommandManager;
|
||||
|
||||
public class GeyserFabricBootstrap extends GeyserModBootstrap implements ModInitializer {
|
||||
|
||||
|
@ -72,12 +72,12 @@ public class GeyserFabricBootstrap extends GeyserModBootstrap implements ModInit
|
|||
CommandSourceStack.class,
|
||||
id -> getServer().getPlayerList().getPlayer(id),
|
||||
Player::createCommandSourceStack,
|
||||
() -> getServer().createCommandSourceStack() // NPE if method reference is used, since server is not available yet
|
||||
() -> getServer().createCommandSourceStack(), // NPE if method reference is used, since server is not available yet
|
||||
ModCommandSource::new
|
||||
);
|
||||
CommandManager<GeyserCommandSource> cloud = new FabricServerCommandManager<>(
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
ModCommandSource::new,
|
||||
sourceConverter::convert
|
||||
ExecutionCoordinator.simpleCoordinator(),
|
||||
sourceConverter
|
||||
);
|
||||
this.setCommandRegistry(new CommandRegistry(GeyserImpl.getInstance(), cloud));
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ dependencies {
|
|||
exclude(group = "org.slf4j")
|
||||
exclude(group = "io.netty.incubator")
|
||||
}
|
||||
|
||||
modImplementation(libs.cloud.neoforge)
|
||||
include(libs.cloud.neoforge)
|
||||
}
|
||||
|
||||
application {
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
package org.geysermc.geyser.platform.neoforge;
|
||||
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.loading.FMLLoader;
|
||||
|
@ -34,8 +35,16 @@ import net.neoforged.neoforge.event.entity.player.PlayerEvent;
|
|||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.CommandRegistry;
|
||||
import org.geysermc.geyser.command.CommandSourceConverter;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.platform.mod.GeyserModBootstrap;
|
||||
import org.geysermc.geyser.platform.mod.GeyserModUpdateListener;
|
||||
import org.geysermc.geyser.platform.mod.command.ModCommandSource;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
import org.incendo.cloud.neoforge.NeoForgeServerCommandManager;
|
||||
|
||||
@Mod(ModConstants.MOD_ID)
|
||||
public class GeyserNeoForgeBootstrap extends GeyserModBootstrap {
|
||||
|
@ -55,6 +64,20 @@ public class GeyserNeoForgeBootstrap extends GeyserModBootstrap {
|
|||
NeoForge.EVENT_BUS.addListener(this.permissionHandler::onPermissionGather);
|
||||
|
||||
this.onGeyserInitialize();
|
||||
|
||||
// TODO: verify; idek how to make permissions on neoforge work with this...
|
||||
var sourceConverter = CommandSourceConverter.layered(
|
||||
CommandSourceStack.class,
|
||||
id -> getServer().getPlayerList().getPlayer(id),
|
||||
Player::createCommandSourceStack,
|
||||
() -> getServer().createCommandSourceStack(),
|
||||
ModCommandSource::new
|
||||
);
|
||||
CommandManager<GeyserCommandSource> cloud = new NeoForgeServerCommandManager<>(
|
||||
ExecutionCoordinator.simpleCoordinator(),
|
||||
sourceConverter
|
||||
);
|
||||
this.setCommandRegistry(new CommandRegistry(GeyserImpl.getInstance(), cloud));
|
||||
}
|
||||
|
||||
private void onServerStarted(ServerStartedEvent event) {
|
||||
|
|
|
@ -27,7 +27,7 @@ platformRelocate("com.fasterxml.jackson")
|
|||
platformRelocate("net.kyori", "net.kyori.adventure.text.logger.slf4j.ComponentLogger")
|
||||
platformRelocate("org.objectweb.asm")
|
||||
platformRelocate("me.lucko.commodore")
|
||||
platformRelocate("cloud.commandframework")
|
||||
platformRelocate("org.incendo")
|
||||
platformRelocate("org.yaml") // Broken as of 1.20
|
||||
|
||||
// These dependencies are already present on the platform
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.platform.spigot;
|
||||
|
||||
import cloud.commandframework.bukkit.BukkitCommandManager;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.paper.PaperCommandManager;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.MappingData;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
|
||||
|
@ -44,14 +41,14 @@ import org.bukkit.permissions.PermissionDefault;
|
|||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserRegisterPermissionsEvent;
|
||||
import org.geysermc.geyser.api.util.PlatformType;
|
||||
import org.geysermc.geyser.Constants;
|
||||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
|
||||
import org.geysermc.geyser.command.CommandSourceConverter;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserRegisterPermissionsEvent;
|
||||
import org.geysermc.geyser.api.util.PlatformType;
|
||||
import org.geysermc.geyser.command.CommandRegistry;
|
||||
import org.geysermc.geyser.command.CommandSourceConverter;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||
|
@ -68,6 +65,10 @@ import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotNativeWorld
|
|||
import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotWorldManager;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.incendo.cloud.bukkit.BukkitCommandManager;
|
||||
import org.incendo.cloud.bukkit.CloudBukkitCapabilities;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
import org.incendo.cloud.paper.PaperCommandManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -166,28 +167,26 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
var sourceConverter = new CommandSourceConverter<>(
|
||||
CommandSender.class,
|
||||
Bukkit::getPlayer,
|
||||
Bukkit::getConsoleSender
|
||||
Bukkit::getConsoleSender,
|
||||
SpigotCommandSource::new
|
||||
);
|
||||
PaperCommandManager<GeyserCommandSource> cloud;
|
||||
try {
|
||||
cloud = new PaperCommandManager<>(
|
||||
this,
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
SpigotCommandSource::new,
|
||||
sourceConverter::convert
|
||||
ExecutionCoordinator.simpleCoordinator(),
|
||||
sourceConverter
|
||||
);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
// Should always be available on 1.13 and up
|
||||
cloud.registerBrigadier();
|
||||
} catch (BukkitCommandManager.BrigadierFailureException e) {
|
||||
geyserLogger.debug("Failed to initialize Brigadier support: " + e.getMessage());
|
||||
if (e.getReason() == BukkitCommandManager.BrigadierFailureReason.VERSION_TOO_HIGH) {
|
||||
// Commodore brig only supports Spigot 1.13 - 1.18.2
|
||||
geyserLogger.debug("Using Paper instead of Spigot will likely fix this.");
|
||||
if (cloud.hasCapability(CloudBukkitCapabilities.BRIGADIER)) {
|
||||
try {
|
||||
// Should always be available on 1.13 and up
|
||||
cloud.registerBrigadier();
|
||||
} catch (BukkitCommandManager.BrigadierInitializationException e) {
|
||||
geyserLogger.debug("Failed to initialize Brigadier support: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.platform.spigot.command;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -34,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.CommandRegistry;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ dependencies {
|
|||
platformRelocate("com.fasterxml.jackson")
|
||||
platformRelocate("it.unimi.dsi.fastutil")
|
||||
platformRelocate("net.kyori.adventure.text.serializer.gson.legacyimpl")
|
||||
platformRelocate("cloud.commandframework")
|
||||
platformRelocate("org.incendo")
|
||||
|
||||
exclude("com.google.*:*")
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.platform.velocity;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.velocity.VelocityCommandManager;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
|
@ -42,11 +39,11 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
|||
import lombok.Getter;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.util.PlatformType;
|
||||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.command.CommandSourceConverter;
|
||||
import org.geysermc.geyser.api.util.PlatformType;
|
||||
import org.geysermc.geyser.command.CommandRegistry;
|
||||
import org.geysermc.geyser.command.CommandSourceConverter;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||
|
@ -56,6 +53,9 @@ import org.geysermc.geyser.ping.IGeyserPingPassthrough;
|
|||
import org.geysermc.geyser.platform.velocity.command.VelocityCommandSource;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
import org.incendo.cloud.velocity.VelocityCommandManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -123,14 +123,14 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
|||
var sourceConverter = new CommandSourceConverter<>(
|
||||
CommandSource.class,
|
||||
id -> proxyServer.getPlayer(id).orElse(null),
|
||||
proxyServer::getConsoleCommandSource
|
||||
proxyServer::getConsoleCommandSource,
|
||||
VelocityCommandSource::new
|
||||
);
|
||||
CommandManager<GeyserCommandSource> cloud = new VelocityCommandManager<>(
|
||||
container,
|
||||
proxyServer,
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
VelocityCommandSource::new,
|
||||
sourceConverter::convert
|
||||
ExecutionCoordinator.simpleCoordinator(),
|
||||
sourceConverter
|
||||
);
|
||||
this.commandRegistry = new CommandRegistry(geyser, cloud);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ platformRelocate("net.kyori")
|
|||
platformRelocate("org.yaml")
|
||||
platformRelocate("it.unimi.dsi.fastutil")
|
||||
platformRelocate("org.cloudburstmc.netty")
|
||||
platformRelocate("org.incendo")
|
||||
|
||||
// These dependencies are already present on the platform
|
||||
provided(libs.viaproxy)
|
||||
|
|
|
@ -25,24 +25,16 @@
|
|||
|
||||
package org.geysermc.geyser.command;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.exceptions.ArgumentParseException;
|
||||
import cloud.commandframework.exceptions.CommandExecutionException;
|
||||
import cloud.commandframework.exceptions.InvalidCommandSenderException;
|
||||
import cloud.commandframework.exceptions.InvalidSyntaxException;
|
||||
import cloud.commandframework.exceptions.NoPermissionException;
|
||||
import cloud.commandframework.exceptions.NoSuchCommandException;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.GeyserLogger;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserRegisterPermissionsEvent;
|
||||
import org.geysermc.geyser.api.util.PlatformType;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.GeyserLogger;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCommandsEvent;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserRegisterPermissionsEvent;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
import org.geysermc.geyser.api.util.PlatformType;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.command.defaults.AdvancedTooltipsCommand;
|
||||
import org.geysermc.geyser.command.defaults.AdvancementsCommand;
|
||||
|
@ -62,7 +54,14 @@ import org.geysermc.geyser.event.type.GeyserDefineCommandsEventImpl;
|
|||
import org.geysermc.geyser.extension.command.GeyserExtensionCommand;
|
||||
import org.geysermc.geyser.text.ChatColor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.exception.ArgumentParseException;
|
||||
import org.incendo.cloud.exception.CommandExecutionException;
|
||||
import org.incendo.cloud.exception.InvalidCommandSenderException;
|
||||
import org.incendo.cloud.exception.InvalidSyntaxException;
|
||||
import org.incendo.cloud.exception.NoPermissionException;
|
||||
import org.incendo.cloud.exception.NoSuchCommandException;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -101,8 +100,8 @@ public class CommandRegistry {
|
|||
* For example: https://github.com/Incendo/cloud/blob/a4cc749b91564af57bb7bba36dd8011b556c2b3a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricExecutor.java#L94-L173
|
||||
*/
|
||||
private final List<ExceptionHandler<?>> exceptionHandlers = List.of(
|
||||
new ExceptionHandler<>(InvalidSyntaxException.class, (src, e) -> src.sendLocaleString("geyser.command.invalid_syntax", e.getCorrectSyntax())),
|
||||
new ExceptionHandler<>(InvalidCommandSenderException.class, (src, e) -> src.sendLocaleString("geyser.command.invalid_sender", e.getCommandSender().getClass().getSimpleName(), e.getRequiredSender().getSimpleName())),
|
||||
new ExceptionHandler<>(InvalidSyntaxException.class, (src, e) -> src.sendLocaleString("geyser.command.invalid_syntax", e.correctSyntax())),
|
||||
new ExceptionHandler<>(InvalidCommandSenderException.class, (src, e) -> src.sendLocaleString("geyser.command.invalid_sender", e.commandSender().getClass().getSimpleName(), e.requiredSender())),
|
||||
new ExceptionHandler<>(NoPermissionException.class, this::handleNoPermission),
|
||||
new ExceptionHandler<>(NoSuchCommandException.class, (src, e) -> src.sendLocaleString("geyser.command.not_found")),
|
||||
new ExceptionHandler<>(ArgumentParseException.class, (src, e) -> src.sendLocaleString("geyser.command.invalid_argument", e.getCause().getMessage())),
|
||||
|
@ -174,17 +173,17 @@ public class CommandRegistry {
|
|||
geyser.eventBus().subscribe(new GeyserEventRegistrar(this), GeyserRegisterPermissionsEvent.class, this::onRegisterPermissions);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNull
|
||||
public CommandManager<GeyserCommandSource> cloud() {
|
||||
return cloud;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNull
|
||||
public Map<String, Command> commands() {
|
||||
return Collections.unmodifiableMap(this.commands);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNull
|
||||
public Map<Extension, Map<String, Command>> extensionCommands() {
|
||||
return Collections.unmodifiableMap(this.extensionCommands);
|
||||
}
|
||||
|
@ -243,10 +242,10 @@ public class CommandRegistry {
|
|||
|
||||
/**
|
||||
* Dispatches a command into cloud and handles any thrown exceptions.
|
||||
* This method may or may not be blocking, depending on the {@link CommandExecutionCoordinator} in use by cloud.
|
||||
* This method may or may not be blocking, depending on the {@link ExecutionCoordinator} in use by cloud.
|
||||
*/
|
||||
public void runCommand(@NonNull GeyserCommandSource source, @NonNull String command) {
|
||||
cloud.executeCommand(source, command).whenComplete((result, throwable) -> {
|
||||
cloud.commandExecutor().executeCommand(source, command).whenComplete((result, throwable) -> {
|
||||
if (throwable == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -292,7 +291,7 @@ public class CommandRegistry {
|
|||
} else {
|
||||
GeyserLogger logger = GeyserImpl.getInstance().getLogger();
|
||||
if (logger.isDebug()) {
|
||||
logger.debug("Expected a GeyserPermission for %s but instead got %s".formatted(exception.getCurrentChain(), exception.missingPermission()));
|
||||
logger.debug("Expected a GeyserPermission for %s but instead got %s".formatted(exception.currentChain(), exception.missingPermission()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,28 +25,67 @@
|
|||
|
||||
package org.geysermc.geyser.command;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.GeyserLogger;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.incendo.cloud.SenderMapper;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Converts {@link GeyserCommandSource}s to the server's command sender type in a lenient manner.
|
||||
* Converts {@link GeyserCommandSource}s to the server's command sender type (and back) in a lenient manner.
|
||||
*
|
||||
* @param senderType class of the server command sender type
|
||||
* @param playerLookup function for looking up a player command sender by UUID
|
||||
* @param consoleProvider supplier of the console command sender
|
||||
* @param commandSourceLookup supplier of the platform implementation of the {@link GeyserCommandSource}
|
||||
* @param <S> server command sender type
|
||||
*/
|
||||
public record CommandSourceConverter<S>(Class<S> senderType,
|
||||
Function<UUID, S> playerLookup,
|
||||
Supplier<S> consoleProvider) {
|
||||
Supplier<S> consoleProvider,
|
||||
Function<S, GeyserCommandSource> commandSourceLookup
|
||||
) implements SenderMapper<S, GeyserCommandSource> {
|
||||
|
||||
/**
|
||||
* Creates a new CommandSourceConverter for a server platform
|
||||
* in which the player type is not a command sender type, and must be mapped.
|
||||
*
|
||||
* @param senderType class of the command sender type
|
||||
* @param playerLookup function for looking up a player by UUID
|
||||
* @param senderLookup function for converting a player to a command sender
|
||||
* @param consoleProvider supplier of the console command sender
|
||||
* @param commandSourceLookup supplier of the platform implementation of {@link GeyserCommandSource}
|
||||
* @return a new CommandSourceConverter
|
||||
* @param <P> server player type
|
||||
* @param <S> server command sender type
|
||||
*/
|
||||
public static <P, S> CommandSourceConverter<S> layered(Class<S> senderType,
|
||||
Function<UUID, P> playerLookup,
|
||||
Function<P, S> senderLookup,
|
||||
Supplier<S> consoleProvider,
|
||||
Function<S, GeyserCommandSource> commandSourceLookup) {
|
||||
Function<UUID, S> lookup = uuid -> {
|
||||
P player = playerLookup.apply(uuid);
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
return senderLookup.apply(player);
|
||||
};
|
||||
return new CommandSourceConverter<>(senderType, lookup, consoleProvider, commandSourceLookup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull GeyserCommandSource map(@NonNull S base) {
|
||||
return commandSourceLookup.apply(base);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public S convert(GeyserCommandSource source) throws IllegalArgumentException {
|
||||
@Override
|
||||
public @NonNull S reverse(GeyserCommandSource source) throws IllegalArgumentException {
|
||||
Object handle = source.handle();
|
||||
if (senderType.isInstance(handle)) {
|
||||
return (S) handle; // one of the server platform implementations
|
||||
|
@ -72,30 +111,4 @@ public record CommandSourceConverter<S>(Class<S> senderType,
|
|||
|
||||
throw new IllegalArgumentException("failed to find sender for name=%s, uuid=%s".formatted(source.name(), source.playerUuid()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new CommandSourceConverter for a server platform
|
||||
* in which the player type is not a command sender type, and must be mapped.
|
||||
*
|
||||
* @param senderType class of the command sender type
|
||||
* @param playerLookup function for looking up a player by UUID
|
||||
* @param senderLookup function for converting a player to a command sender
|
||||
* @param consoleProvider supplier of the console command sender
|
||||
* @return a new CommandSourceConverter
|
||||
* @param <P> server player type
|
||||
* @param <S> server command sender type
|
||||
*/
|
||||
public static <P, S> CommandSourceConverter<S> layered(Class<S> senderType,
|
||||
Function<UUID, P> playerLookup,
|
||||
Function<P, S> senderLookup,
|
||||
Supplier<S> consoleProvider) {
|
||||
Function<UUID, S> lookup = uuid -> {
|
||||
P player = playerLookup.apply(uuid);
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
return senderLookup.apply(player);
|
||||
};
|
||||
return new CommandSourceConverter<>(senderType, lookup, consoleProvider);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,15 +25,14 @@
|
|||
|
||||
package org.geysermc.geyser.command;
|
||||
|
||||
import cloud.commandframework.Command;
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.meta.CommandMeta;
|
||||
import cloud.commandframework.permission.CommandPermission;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
import org.incendo.cloud.description.CommandDescription;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -155,7 +154,7 @@ public abstract class GeyserCommand implements org.geysermc.geyser.api.command.C
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link CommandPermission} that handles {@link #isBedrockOnly()}, {@link #isPlayerOnly()}, and {@link #permission()}.
|
||||
* Returns a {@link org.incendo.cloud.permission.Permission} that handles {@link #isBedrockOnly()}, {@link #isPlayerOnly()}, and {@link #permission()}.
|
||||
*
|
||||
* @param manager the manager to be used for permission node checking
|
||||
* @return a permission that will properly restrict usage of this command
|
||||
|
@ -178,11 +177,11 @@ public abstract class GeyserCommand implements org.geysermc.geyser.api.command.C
|
|||
}
|
||||
|
||||
/**
|
||||
* @return an Applicable that applies this command's description as {@link CommandMeta#DESCRIPTION}
|
||||
* @return an Applicable that applies this command's description
|
||||
*/
|
||||
protected Command.Builder.Applicable<GeyserCommandSource> meta() {
|
||||
return builder -> builder
|
||||
.meta(CommandMeta.DESCRIPTION, GeyserLocale.getLocaleStringLog(description)); // used in cloud-bukkit impl
|
||||
.commandDescription(CommandDescription.commandDescription(GeyserLocale.getLocaleStringLog(description))); // used in cloud-bukkit impl
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
package org.geysermc.geyser.command;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.permission.PredicatePermission;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.permission.PredicatePermission;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class GeyserPermission implements PredicatePermission<GeyserCommandSource> {
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.ChatColor;
|
||||
import org.geysermc.geyser.text.MinecraftLocale;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class AdvancedTooltipsCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserSession session = Objects.requireNonNull(context.getSender().connection());
|
||||
GeyserSession session = Objects.requireNonNull(context.sender().connection());
|
||||
|
||||
String onOrOff = session.isAdvancedTooltips() ? "off" : "on";
|
||||
session.setAdvancedTooltips(!session.isAdvancedTooltips());
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class AdvancementsCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserSession session = Objects.requireNonNull(context.getSender().connection());
|
||||
GeyserSession session = Objects.requireNonNull(context.sender().connection());
|
||||
session.getAdvancementsCache().buildAndShowMenuForm();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,21 +25,16 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.standard.IntegerArgument;
|
||||
import cloud.commandframework.arguments.standard.StringArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.LoopbackUtil;
|
||||
import org.geysermc.geyser.util.WebUtils;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -78,7 +73,7 @@ public class ConnectionTestCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserCommandSource source = context.getSender();
|
||||
GeyserCommandSource source = context.sender();
|
||||
String ipArgument = context.get(ADDRESS);
|
||||
Integer portArgument = context.getOrDefault(PORT, null); // null if port was not specified
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.standard.StringArrayArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import com.fasterxml.jackson.core.util.DefaultIndenter;
|
||||
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
@ -41,6 +38,9 @@ import org.geysermc.geyser.text.AsteriskSerializer;
|
|||
import org.geysermc.geyser.text.ChatColor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.WebUtils;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.component.CommandComponent;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -68,7 +68,7 @@ public class DumpCommand extends GeyserCommand {
|
|||
.handler(this::execute));
|
||||
}
|
||||
|
||||
private StringArrayArgument<GeyserCommandSource> createArgument() {
|
||||
private CommandComponent<GeyserCommandSource> createArgument() {
|
||||
return StringArrayArgument.optional(ARGUMENTS, (context, currentInput) -> {
|
||||
// currentInput only provides the word currently being typed, so it's useless for checking the previous ones
|
||||
List<String> input = context.getRawInput();
|
||||
|
@ -88,7 +88,7 @@ public class DumpCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserCommandSource source = context.getSender();
|
||||
GeyserCommandSource source = context.sender();
|
||||
String[] args = context.getOrDefault(ARGUMENTS, new String[0]);
|
||||
|
||||
boolean showSensitive = false;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
|
@ -33,6 +32,7 @@ import org.geysermc.geyser.command.GeyserCommand;
|
|||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.text.ChatColor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -47,7 +47,7 @@ public class ExtensionsCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserCommandSource source = context.getSender();
|
||||
GeyserCommandSource source = context.sender();
|
||||
|
||||
// TODO: Pagination
|
||||
int page = 1;
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
|
@ -34,6 +32,8 @@ import org.geysermc.geyser.command.GeyserCommand;
|
|||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.text.ChatColor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -72,7 +72,7 @@ public class HelpCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserCommandSource source = context.getSender();
|
||||
GeyserCommandSource source = context.sender();
|
||||
boolean bedrockPlayer = source.connection() != null;
|
||||
|
||||
// todo: pagination
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class ListCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserCommandSource source = context.getSender();
|
||||
GeyserCommandSource source = context.sender();
|
||||
|
||||
String message = GeyserLocale.getPlayerLocaleString("geyser.commands.list.message", source.locale(),
|
||||
geyser.getSessionManager().size(),
|
||||
|
|
|
@ -25,12 +25,12 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class OffhandCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserSession session = Objects.requireNonNull(context.getSender().connection());
|
||||
GeyserSession session = Objects.requireNonNull(context.sender().connection());
|
||||
session.requestOffhandSwap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class ReloadCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserCommandSource source = context.getSender();
|
||||
GeyserCommandSource source = context.sender();
|
||||
source.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.reload.message", source.locale()));
|
||||
|
||||
geyser.getSessionManager().disconnectAll("geyser.commands.reload.kick");
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.util.SettingsUtils;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class SettingsCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserSession session = Objects.requireNonNull(context.getSender().connection());
|
||||
GeyserSession session = Objects.requireNonNull(context.sender().connection());
|
||||
session.sendForm(SettingsUtils.buildForm(session));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
|
@ -33,6 +32,7 @@ import org.geysermc.geyser.api.util.TriState;
|
|||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class StatisticsCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserSession session = Objects.requireNonNull(context.getSender().connection());
|
||||
GeyserSession session = Objects.requireNonNull(context.sender().connection());
|
||||
|
||||
session.setWaitingForStatistics(true);
|
||||
ServerboundClientCommandPacket packet = new ServerboundClientCommandPacket(ClientCommand.STATS);
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.command.defaults;
|
||||
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
|
||||
import org.geysermc.geyser.Constants;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
|
@ -37,6 +36,7 @@ import org.geysermc.geyser.network.GameProtocol;
|
|||
import org.geysermc.geyser.text.ChatColor;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.geysermc.geyser.util.WebUtils;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -53,7 +53,7 @@ public class VersionCommand extends GeyserCommand {
|
|||
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserCommandSource source = context.getSender();
|
||||
GeyserCommandSource source = context.sender();
|
||||
|
||||
String bedrockVersions;
|
||||
List<BedrockCodec> supportedCodecs = GameProtocol.SUPPORTED_BEDROCK_CODECS;
|
||||
|
|
|
@ -25,11 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.command.standalone;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.internal.CommandRegistrationHandler;
|
||||
import cloud.commandframework.meta.CommandMeta;
|
||||
import cloud.commandframework.meta.SimpleCommandMeta;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
|
@ -40,6 +35,11 @@ import org.geysermc.geyser.api.util.TriState;
|
|||
import org.geysermc.geyser.command.CommandRegistry;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.util.FileUtils;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.execution.ExecutionCoordinator;
|
||||
import org.incendo.cloud.internal.CommandRegistrationHandler;
|
||||
import org.incendo.cloud.meta.CommandMeta;
|
||||
import org.incendo.cloud.meta.SimpleCommandMeta;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -61,7 +61,7 @@ public class StandaloneCloudCommandManager extends CommandManager<GeyserCommandS
|
|||
private final Set<String> basePermissions = new ObjectOpenHashSet<>();
|
||||
|
||||
public StandaloneCloudCommandManager(GeyserImpl geyser) {
|
||||
super(CommandExecutionCoordinator.simpleCoordinator(), CommandRegistrationHandler.nullCommandRegistrationHandler());
|
||||
super(ExecutionCoordinator.simpleCoordinator(), CommandRegistrationHandler.nullCommandRegistrationHandler());
|
||||
// simpleCoordinator: execute commands immediately on the calling thread.
|
||||
// nullCommandRegistrationHandler: cloud is not responsible for handling our CommandRegistry, which is fairly decoupled.
|
||||
this.geyser = geyser;
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.extension.command;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.standard.StringArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
|
@ -39,6 +36,9 @@ import org.geysermc.geyser.api.util.TriState;
|
|||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.annotation.specifier.Greedy;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -125,6 +125,7 @@ public abstract class GeyserExtensionCommand extends GeyserCommand {
|
|||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal") // this is our doing
|
||||
@Override
|
||||
public Builder<T> suggestedOpOnly(boolean suggestedOpOnly) {
|
||||
this.suggestedOpOnly = suggestedOpOnly;
|
||||
|
@ -135,6 +136,7 @@ public abstract class GeyserExtensionCommand extends GeyserCommand {
|
|||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal") // this is our doing
|
||||
@Override
|
||||
public Builder<T> executableOnConsole(boolean executableOnConsole) {
|
||||
this.playerOnly = !executableOnConsole;
|
||||
|
@ -195,7 +197,7 @@ public abstract class GeyserExtensionCommand extends GeyserCommand {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||
GeyserCommandSource source = context.getSender();
|
||||
GeyserCommandSource source = context.sender();
|
||||
String[] args = context.getOrDefault("args", "").split(" ");
|
||||
|
||||
if (sourceType.isInstance(source)) {
|
||||
|
@ -215,6 +217,7 @@ public abstract class GeyserExtensionCommand extends GeyserCommand {
|
|||
source.sendMessage("You must be a " + sourceType.getSimpleName() + " to run this command.");
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal") // this is our doing
|
||||
@Override
|
||||
public boolean isSuggestedOpOnly() {
|
||||
return suggestedOpOnly;
|
||||
|
|
Loading…
Reference in New Issue