mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Simplify user manager hierarchy
This commit is contained in:
19 files changed
+72
-207
No files matched your search
@@ -35,6 +35,7 @@ import net.draycia.carbon.common.channels.CarbonChannelRegistry;
|
||||
import net.draycia.carbon.common.command.commands.ExecutionCoordinatorHolder;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
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;
|
||||
@@ -67,7 +68,7 @@ public class CarbonChatVelocity extends CarbonChatInternal<CarbonPlayerVelocity>
|
||||
final ProfileCache profileCache,
|
||||
final ProfileResolver profileResolver,
|
||||
final ExecutionCoordinatorHolder commandExecutor,
|
||||
final VelocityUserManager userManager,
|
||||
final PlatformUserManager userManager,
|
||||
final CarbonServerVelocity carbonServer,
|
||||
final CarbonMessages carbonMessages,
|
||||
final CarbonEventHandler eventHandler,
|
||||
|
||||
@@ -24,7 +24,6 @@ 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.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
@@ -39,11 +38,12 @@ import net.draycia.carbon.common.command.Commander;
|
||||
import net.draycia.carbon.common.command.commands.ExecutionCoordinatorHolder;
|
||||
import net.draycia.carbon.common.messages.CarbonMessageRenderer;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.draycia.carbon.common.users.PlatformUserManager;
|
||||
import net.draycia.carbon.common.users.ProfileResolver;
|
||||
import net.draycia.carbon.common.users.UserManagerInternal;
|
||||
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.users.CarbonPlayerVelocity;
|
||||
import net.draycia.carbon.velocity.users.VelocityProfileResolver;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -106,8 +106,7 @@ public final class CarbonChatVelocityModule extends AbstractModule {
|
||||
this.bind(Path.class).annotatedWith(DataDirectory.class).toInstance(this.dataDirectory);
|
||||
this.bind(Logger.class).toInstance(this.logger);
|
||||
this.bind(PlatformScheduler.class).to(PlatformScheduler.RunImmediately.class);
|
||||
this.bind(new TypeLiteral<UserManager<?>>() {}).to(VelocityUserManager.class);
|
||||
this.bind(new TypeLiteral<UserManagerInternal<?>>() {}).to(VelocityUserManager.class);
|
||||
this.install(PlatformUserManager.PlayerFactory.moduleFor(CarbonPlayerVelocity.class));
|
||||
this.bind(CarbonMessageRenderer.class).to(VelocityMessageRenderer.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2023 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.velocity;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.draycia.carbon.common.users.Backing;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.common.users.PlatformUserManager;
|
||||
import net.draycia.carbon.common.users.UserManagerInternal;
|
||||
import net.draycia.carbon.velocity.users.CarbonPlayerVelocity;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
@Singleton
|
||||
public class VelocityUserManager extends PlatformUserManager<CarbonPlayerVelocity> {
|
||||
|
||||
private final ProxyServer proxyServer;
|
||||
|
||||
@Inject
|
||||
public VelocityUserManager(@Backing final UserManagerInternal<CarbonPlayerCommon> proxiedUserManager, final ProxyServer proxyServer) {
|
||||
super(proxiedUserManager);
|
||||
this.proxyServer = proxyServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CarbonPlayerVelocity wrap(final CarbonPlayerCommon common) {
|
||||
return new CarbonPlayerVelocity(this.proxyServer, common);
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -23,8 +23,8 @@ import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.EventManager;
|
||||
import com.velocitypowered.api.event.EventTask;
|
||||
import com.velocitypowered.api.event.connection.LoginEvent;
|
||||
import net.draycia.carbon.common.users.UserManagerInternal;
|
||||
import net.draycia.carbon.velocity.CarbonVelocityBootstrap;
|
||||
import net.draycia.carbon.velocity.VelocityUserManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@@ -34,12 +34,12 @@ import static net.draycia.carbon.common.util.PlayerUtils.joinExceptionHandler;
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class VelocityPlayerJoinListener implements VelocityListener<LoginEvent> {
|
||||
|
||||
private final VelocityUserManager userManager;
|
||||
private final UserManagerInternal<?> userManager;
|
||||
private final Logger logger;
|
||||
|
||||
@Inject
|
||||
public VelocityPlayerJoinListener(
|
||||
final VelocityUserManager userManager,
|
||||
final UserManagerInternal<?> userManager,
|
||||
final Logger logger
|
||||
) {
|
||||
this.userManager = userManager;
|
||||
|
||||
+3
-3
@@ -23,8 +23,8 @@ import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.EventManager;
|
||||
import com.velocitypowered.api.event.EventTask;
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import net.draycia.carbon.common.users.UserManagerInternal;
|
||||
import net.draycia.carbon.velocity.CarbonVelocityBootstrap;
|
||||
import net.draycia.carbon.velocity.VelocityUserManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@@ -34,12 +34,12 @@ import static net.draycia.carbon.common.util.PlayerUtils.saveExceptionHandler;
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class VelocityPlayerLeaveListener implements VelocityListener<DisconnectEvent> {
|
||||
|
||||
private final VelocityUserManager userManager;
|
||||
private final UserManagerInternal<?> userManager;
|
||||
private final Logger logger;
|
||||
|
||||
@Inject
|
||||
public VelocityPlayerLeaveListener(
|
||||
final VelocityUserManager userManager,
|
||||
final UserManagerInternal<?> userManager,
|
||||
final Logger logger
|
||||
) {
|
||||
this.userManager = userManager;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
*/
|
||||
package net.draycia.carbon.velocity.users;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import java.util.Locale;
|
||||
@@ -42,7 +44,8 @@ public final class CarbonPlayerVelocity extends WrappedCarbonPlayer implements F
|
||||
|
||||
private final ProxyServer server;
|
||||
|
||||
public CarbonPlayerVelocity(final ProxyServer server, final CarbonPlayerCommon carbonPlayerCommon) {
|
||||
@AssistedInject
|
||||
private CarbonPlayerVelocity(final ProxyServer server, @Assisted final CarbonPlayerCommon carbonPlayerCommon) {
|
||||
super(carbonPlayerCommon);
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user