mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
chore: cleanup command registration
This commit is contained in:
1 parent
50327c7564
commit
45369aa261
7 files changed
+97
-62
No files matched your search
@@ -21,8 +21,10 @@ package net.draycia.carbon.velocity;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import java.util.Set;
|
||||
@@ -38,10 +40,7 @@ import net.draycia.carbon.common.messaging.MessagingManager;
|
||||
import net.draycia.carbon.common.users.PlatformUserManager;
|
||||
import net.draycia.carbon.common.users.ProfileCache;
|
||||
import net.draycia.carbon.common.users.ProfileResolver;
|
||||
import net.draycia.carbon.velocity.listeners.VelocityChatListener;
|
||||
import net.draycia.carbon.velocity.listeners.VelocityListener;
|
||||
import net.draycia.carbon.velocity.listeners.VelocityPlayerJoinListener;
|
||||
import net.draycia.carbon.velocity.listeners.VelocityPlayerLeaveListener;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@@ -50,12 +49,6 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@Singleton
|
||||
public class CarbonChatVelocity extends CarbonChatInternal {
|
||||
|
||||
private static final Set<Class<? extends VelocityListener<?>>> LISTENER_CLASSES = Set.of(
|
||||
VelocityChatListener.class,
|
||||
VelocityPlayerJoinListener.class,
|
||||
VelocityPlayerLeaveListener.class
|
||||
);
|
||||
|
||||
private final ProxyServer proxyServer;
|
||||
|
||||
@Inject
|
||||
@@ -96,8 +89,9 @@ public class CarbonChatVelocity extends CarbonChatInternal {
|
||||
public void onInitialization(final CarbonVelocityBootstrap carbonVelocityBootstrap) {
|
||||
this.init();
|
||||
|
||||
for (final Class<? extends VelocityListener<?>> clazz : LISTENER_CLASSES) {
|
||||
this.injector().getInstance(clazz).register(this.proxyServer.getEventManager(), carbonVelocityBootstrap);
|
||||
final Set<VelocityListener<?>> listeners = this.injector().getInstance(Key.get(new TypeLiteral<Set<VelocityListener<?>>>() {}));
|
||||
for (final VelocityListener<?> listener : listeners) {
|
||||
listener.register(this.proxyServer.getEventManager(), carbonVelocityBootstrap);
|
||||
}
|
||||
|
||||
this.checkVersion();
|
||||
|
||||
@@ -24,6 +24,8 @@ import cloud.commandframework.velocity.VelocityCommandManager;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.multibindings.Multibinder;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
@@ -43,6 +45,10 @@ import net.draycia.carbon.common.users.ProfileResolver;
|
||||
import net.draycia.carbon.common.util.CloudUtils;
|
||||
import net.draycia.carbon.velocity.command.VelocityCommander;
|
||||
import net.draycia.carbon.velocity.command.VelocityPlayerCommander;
|
||||
import net.draycia.carbon.velocity.listeners.VelocityChatListener;
|
||||
import net.draycia.carbon.velocity.listeners.VelocityListener;
|
||||
import net.draycia.carbon.velocity.listeners.VelocityPlayerJoinListener;
|
||||
import net.draycia.carbon.velocity.listeners.VelocityPlayerLeaveListener;
|
||||
import net.draycia.carbon.velocity.users.CarbonPlayerVelocity;
|
||||
import net.draycia.carbon.velocity.users.VelocityProfileResolver;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -110,4 +116,11 @@ public final class CarbonChatVelocityModule extends AbstractModule {
|
||||
this.bind(CarbonMessageRenderer.class).to(VelocityMessageRenderer.class);
|
||||
}
|
||||
|
||||
private void configureListeners() {
|
||||
final Multibinder<VelocityListener<?>> listeners = Multibinder.newSetBinder(this.binder(), new TypeLiteral<VelocityListener<?>>() {});
|
||||
listeners.addBinding().to(VelocityChatListener.class);
|
||||
listeners.addBinding().to(VelocityPlayerJoinListener.class);
|
||||
listeners.addBinding().to(VelocityPlayerLeaveListener.class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user