Search in sources :

Example 1 with VelocityCommandManager

use of cloud.commandframework.velocity.VelocityCommandManager in project Floodgate by GeyserMC.

the class VelocityPlatformModule method configure.

@Override
protected void configure() {
    VelocityCommandUtil commandUtil = new VelocityCommandUtil();
    requestInjection(commandUtil);
    bind(CommandUtil.class).to(VelocityCommandUtil.class);
    bind(VelocityCommandUtil.class).toInstance(commandUtil);
    Injector child = guice.createChildInjector(new CloudInjectionModule<>(UserAudience.class, CommandExecutionCoordinator.simpleCoordinator(), commandUtil::getAudience, audience -> (CommandSource) audience.source()));
    CommandManager<UserAudience> commandManager = child.getInstance(new Key<VelocityCommandManager<UserAudience>>() {
    });
    bind(new Key<CommandManager<UserAudience>>() {
    }).toInstance(commandManager);
    commandManager.registerCommandPreProcessor(new FloodgateCommandPreprocessor<>(commandUtil));
}
Also used : CommandExecutionCoordinator(cloud.commandframework.execution.CommandExecutionCoordinator) VelocityCommandUtil(org.geysermc.floodgate.util.VelocityCommandUtil) VelocityInjector(org.geysermc.floodgate.inject.velocity.VelocityInjector) VelocityPluginMessageRegistration(org.geysermc.floodgate.pluginmessage.VelocityPluginMessageRegistration) LanguageManager(org.geysermc.floodgate.util.LanguageManager) CommandUtil(org.geysermc.floodgate.platform.command.CommandUtil) ListenerRegistration(org.geysermc.floodgate.platform.listener.ListenerRegistration) Key(com.google.inject.Key) RequiredArgsConstructor(lombok.RequiredArgsConstructor) CommandManager(cloud.commandframework.CommandManager) CloudInjectionModule(cloud.commandframework.velocity.CloudInjectionModule) VelocitySkinApplier(org.geysermc.floodgate.util.VelocitySkinApplier) UserAudience(org.geysermc.floodgate.player.UserAudience) ProxyServer(com.velocitypowered.api.proxy.ProxyServer) VelocityCommandManager(cloud.commandframework.velocity.VelocityCommandManager) PluginMessageManager(org.geysermc.floodgate.pluginmessage.PluginMessageManager) VelocityPlugin(org.geysermc.floodgate.VelocityPlugin) FloodgateCommandPreprocessor(org.geysermc.floodgate.player.FloodgateCommandPreprocessor) Logger(org.slf4j.Logger) CommonPlatformInjector(org.geysermc.floodgate.inject.CommonPlatformInjector) VelocityListenerRegistration(org.geysermc.floodgate.listener.VelocityListenerRegistration) PluginMessageRegistration(org.geysermc.floodgate.pluginmessage.PluginMessageRegistration) Injector(com.google.inject.Injector) FloodgateLogger(org.geysermc.floodgate.api.logger.FloodgateLogger) Provides(com.google.inject.Provides) VelocityPluginMessageUtils(org.geysermc.floodgate.pluginmessage.VelocityPluginMessageUtils) PluginMessageUtils(org.geysermc.floodgate.platform.pluginmessage.PluginMessageUtils) Named(com.google.inject.name.Named) Slf4jFloodgateLogger(org.geysermc.floodgate.logger.Slf4jFloodgateLogger) SkinApplier(org.geysermc.floodgate.skin.SkinApplier) CommandSource(com.velocitypowered.api.command.CommandSource) EventManager(com.velocitypowered.api.event.EventManager) AbstractModule(com.google.inject.AbstractModule) Singleton(com.google.inject.Singleton) UserAudience(org.geysermc.floodgate.player.UserAudience) VelocityInjector(org.geysermc.floodgate.inject.velocity.VelocityInjector) CommonPlatformInjector(org.geysermc.floodgate.inject.CommonPlatformInjector) Injector(com.google.inject.Injector) VelocityCommandUtil(org.geysermc.floodgate.util.VelocityCommandUtil) CommandUtil(org.geysermc.floodgate.platform.command.CommandUtil) CommandSource(com.velocitypowered.api.command.CommandSource) VelocityCommandUtil(org.geysermc.floodgate.util.VelocityCommandUtil) VelocityCommandManager(cloud.commandframework.velocity.VelocityCommandManager) Key(com.google.inject.Key)

Example 2 with VelocityCommandManager

use of cloud.commandframework.velocity.VelocityCommandManager in project message by OskarsMC-Plugins.

the class Message method onProxyInitialization.

/**
 * Initialise the plugin.
 * @param event Proxy Initialise Event
 */
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
    MessageSettings messageSettings = injector.getInstance(MessageSettings.class);
    injector = injector.createChildInjector(new CloudInjectionModule<>(CommandSource.class, CommandExecutionCoordinator.simpleCoordinator(), Function.identity(), Function.identity()), new MessageModule(messageSettings));
    injector.getInstance(TranslationManager.class);
    if (messageSettings.enabled()) {
        if (messageSettings.luckpermsIntegration()) {
            if (DependencyChecker.luckperms()) {
                logger.info("LuckPerms integration enabled. Targeted LuckPerms version 5.3, using " + LuckPermsProvider.get().getPluginMetadata().getVersion());
            } else {
                logger.warn("LuckPerms integration was enabled but LuckPerms was not detected on the proxy. Continuing without it.");
                messageSettings.luckpermsIntegration(false);
            }
        }
        // Allow autocompletion regardless of capitalisation
        injector.getInstance(Key.get(new TypeLiteral<VelocityCommandManager<CommandSource>>() {
        })).setCommandSuggestionProcessor(new CloudSuggestionProcessor());
        // Commands
        injector.getInstance(MessageCommand.class);
        injector.getInstance(SocialSpyCommand.class);
        injector.getInstance(ReplyCommand.class);
        // Metrics
        injector.getInstance(MessageMetrics.class);
    }
    logger.info("Loaded message " + getClass().getPackage().getImplementationVersion());
}
Also used : CloudSuggestionProcessor(com.oskarsmc.message.util.CloudSuggestionProcessor) MessageSettings(com.oskarsmc.message.configuration.MessageSettings) MessageModule(com.oskarsmc.message.util.MessageModule) CloudInjectionModule(cloud.commandframework.velocity.CloudInjectionModule) VelocityCommandManager(cloud.commandframework.velocity.VelocityCommandManager) Subscribe(com.velocitypowered.api.event.Subscribe)

Aggregations

CloudInjectionModule (cloud.commandframework.velocity.CloudInjectionModule)2 VelocityCommandManager (cloud.commandframework.velocity.VelocityCommandManager)2 CommandManager (cloud.commandframework.CommandManager)1 CommandExecutionCoordinator (cloud.commandframework.execution.CommandExecutionCoordinator)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 Key (com.google.inject.Key)1 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 Named (com.google.inject.name.Named)1 MessageSettings (com.oskarsmc.message.configuration.MessageSettings)1 CloudSuggestionProcessor (com.oskarsmc.message.util.CloudSuggestionProcessor)1 MessageModule (com.oskarsmc.message.util.MessageModule)1 CommandSource (com.velocitypowered.api.command.CommandSource)1 EventManager (com.velocitypowered.api.event.EventManager)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 ProxyServer (com.velocitypowered.api.proxy.ProxyServer)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 VelocityPlugin (org.geysermc.floodgate.VelocityPlugin)1 FloodgateLogger (org.geysermc.floodgate.api.logger.FloodgateLogger)1