feat: implement injection
This commit is contained in:
parent
b15cb1f17b
commit
63f7af9046
@ -24,7 +24,7 @@ import org.spongepowered.configurate.CommentedConfigurationNode;
|
|||||||
import org.spongepowered.configurate.ConfigurateException;
|
import org.spongepowered.configurate.ConfigurateException;
|
||||||
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
|
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
|
||||||
|
|
||||||
public class ConfigurationContainer<C> {
|
public final class ConfigurationContainer<C> {
|
||||||
private C config;
|
private C config;
|
||||||
private final HoconConfigurationLoader loader;
|
private final HoconConfigurationLoader loader;
|
||||||
private final Class<C> clazz;
|
private final Class<C> clazz;
|
||||||
@ -45,16 +45,11 @@ public class ConfigurationContainer<C> {
|
|||||||
|
|
||||||
public CompletableFuture<Void> reload() {
|
public CompletableFuture<Void> reload() {
|
||||||
return CompletableFuture.runAsync(() -> {
|
return CompletableFuture.runAsync(() -> {
|
||||||
C newConfig = null;
|
|
||||||
try {
|
try {
|
||||||
final CommentedConfigurationNode node = loader.load();
|
final CommentedConfigurationNode node = loader.load();
|
||||||
newConfig = node.get(clazz);
|
config = node.get(clazz);
|
||||||
} catch (ConfigurateException exception) {
|
} catch (ConfigurateException exception) {
|
||||||
throw new CompletionException("Could not load config.conf file", exception);
|
throw new CompletionException("Could not load config.conf file", exception);
|
||||||
} finally {
|
|
||||||
if (newConfig != null) {
|
|
||||||
config = newConfig;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -75,17 +75,17 @@ public final class AuthMeVelocityPlugin extends JavaPlugin {
|
|||||||
public void sendMessageToProxy(
|
public void sendMessageToProxy(
|
||||||
final Player player,
|
final Player player,
|
||||||
final @NotNull MessageType type,
|
final @NotNull MessageType type,
|
||||||
final @NotNull String playername
|
final @NotNull String playerName
|
||||||
) {
|
) {
|
||||||
@SuppressWarnings("UnstableApiUsage") final ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
@SuppressWarnings("UnstableApiUsage") final ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
out.writeUTF(type.toString());
|
out.writeUTF(type.toString());
|
||||||
out.writeUTF(playername);
|
out.writeUTF(playerName);
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
logDebug("MessageToProxy | Null Player, Player Name: " + playername);
|
logDebug("MessageToProxy | Null Player, Player Name: " + playerName);
|
||||||
Bukkit.getServer().sendPluginMessage(this, CHANNEL, out.toByteArray());
|
Bukkit.getServer().sendPluginMessage(this, CHANNEL, out.toByteArray());
|
||||||
} else {
|
} else {
|
||||||
logDebug("MessageToProxy | Player Present: " + player.getName() + ", Player Name: " + playername);
|
logDebug("MessageToProxy | Player Present: " + player.getName() + ", Player Name: " + playerName);
|
||||||
player.sendPluginMessage(this, CHANNEL, out.toByteArray());
|
player.sendPluginMessage(this, CHANNEL, out.toByteArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
package io.github._4drian3d.authmevelocity.velocity;
|
package io.github._4drian3d.authmevelocity.velocity;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import io.github.miniplaceholders.api.Expansion;
|
import io.github.miniplaceholders.api.Expansion;
|
||||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
|
|
||||||
@ -25,10 +27,12 @@ import static io.github.miniplaceholders.api.utils.Components.FALSE_COMPONENT;
|
|||||||
import static io.github.miniplaceholders.api.utils.Components.TRUE_COMPONENT;
|
import static io.github.miniplaceholders.api.utils.Components.TRUE_COMPONENT;
|
||||||
|
|
||||||
final class AuthMePlaceholders {
|
final class AuthMePlaceholders {
|
||||||
private AuthMePlaceholders() {
|
@Inject
|
||||||
}
|
private AuthMeVelocityPlugin plugin;
|
||||||
|
@Inject
|
||||||
|
private ProxyServer proxyServer;
|
||||||
|
|
||||||
static Expansion getExpansion(AuthMeVelocityPlugin plugin) {
|
Expansion getExpansion() {
|
||||||
return Expansion.builder("authme")
|
return Expansion.builder("authme")
|
||||||
.filter(Player.class)
|
.filter(Player.class)
|
||||||
// Logged Placeholders
|
// Logged Placeholders
|
||||||
@ -37,7 +41,7 @@ final class AuthMePlaceholders {
|
|||||||
.globalPlaceholder("is_player_logged", (queue, ctx) -> {
|
.globalPlaceholder("is_player_logged", (queue, ctx) -> {
|
||||||
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
||||||
return Tag.selfClosingInserting(
|
return Tag.selfClosingInserting(
|
||||||
plugin.getProxy().getPlayer(playerName)
|
proxyServer.getPlayer(playerName)
|
||||||
.map(plugin::isLogged)
|
.map(plugin::isLogged)
|
||||||
.orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT
|
.orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT
|
||||||
);
|
);
|
||||||
@ -48,7 +52,7 @@ final class AuthMePlaceholders {
|
|||||||
.globalPlaceholder("player_in_auth_server", (queue, ctx) -> {
|
.globalPlaceholder("player_in_auth_server", (queue, ctx) -> {
|
||||||
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
||||||
return Tag.selfClosingInserting(
|
return Tag.selfClosingInserting(
|
||||||
plugin.getProxy().getPlayer(playerName)
|
proxyServer.getPlayer(playerName)
|
||||||
.map(plugin::isInAuthServer)
|
.map(plugin::isInAuthServer)
|
||||||
.orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT
|
.orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT
|
||||||
);
|
);
|
||||||
|
@ -18,11 +18,14 @@
|
|||||||
package io.github._4drian3d.authmevelocity.velocity;
|
package io.github._4drian3d.authmevelocity.velocity;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Injector;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
|
import com.velocitypowered.api.event.EventManager;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
import com.velocitypowered.api.plugin.Dependency;
|
import com.velocitypowered.api.plugin.Dependency;
|
||||||
import com.velocitypowered.api.plugin.Plugin;
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
|
import com.velocitypowered.api.plugin.PluginManager;
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
@ -50,11 +53,11 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Plugin(
|
@Plugin(
|
||||||
id = "authmevelocity",
|
id = "authmevelocity",
|
||||||
@ -82,12 +85,18 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
|||||||
@Inject
|
@Inject
|
||||||
private ProxyServer proxy;
|
private ProxyServer proxy;
|
||||||
@Inject
|
@Inject
|
||||||
|
private EventManager eventManager;
|
||||||
|
@Inject
|
||||||
|
private PluginManager pluginManager;
|
||||||
|
@Inject
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
@Inject
|
@Inject
|
||||||
@DataDirectory
|
@DataDirectory
|
||||||
private Path pluginDirectory;
|
private Path pluginDirectory;
|
||||||
@Inject
|
@Inject
|
||||||
private Metrics.Factory metricsFactory;
|
private Metrics.Factory metricsFactory;
|
||||||
|
@Inject
|
||||||
|
private Injector injector;
|
||||||
private ConfigurationContainer<ProxyConfiguration> config;
|
private ConfigurationContainer<ProxyConfiguration> config;
|
||||||
|
|
||||||
final Set<UUID> loggedPlayers = ConcurrentHashMap.newKeySet();
|
final Set<UUID> loggedPlayers = ConcurrentHashMap.newKeySet();
|
||||||
@ -97,7 +106,7 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
|||||||
final LibsManager libraries
|
final LibsManager libraries
|
||||||
= new LibsManager(
|
= new LibsManager(
|
||||||
new VelocityLibraryManager<>(
|
new VelocityLibraryManager<>(
|
||||||
logger, pluginDirectory, proxy.getPluginManager(), this));
|
logger, pluginDirectory, pluginManager, this));
|
||||||
libraries.loadLibraries();
|
libraries.loadLibraries();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -114,36 +123,32 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
|||||||
|
|
||||||
proxy.getChannelRegistrar().register(MODERN_CHANNEL, LEGACY_CHANNEL);
|
proxy.getChannelRegistrar().register(MODERN_CHANNEL, LEGACY_CHANNEL);
|
||||||
|
|
||||||
List.of(
|
Stream.of(
|
||||||
new ProxyListener(this),
|
ProxyListener.class,
|
||||||
new ConnectListener(this, proxy, logger),
|
ConnectListener.class,
|
||||||
new PluginMessageListener(proxy, logger, this)
|
PluginMessageListener.class
|
||||||
).forEach(listener ->
|
).map(injector::getInstance)
|
||||||
proxy.getEventManager().register(this, listener));
|
.forEach(listener -> eventManager.register(this, listener));
|
||||||
|
|
||||||
final boolean fastlogin = proxy.getPluginManager().isLoaded("fastlogin");
|
final boolean fastlogin = pluginManager.isLoaded("fastlogin");
|
||||||
metrics.addCustomChart(new SimplePie("fastlogin_compatibility", () -> Boolean.toString(fastlogin)));
|
metrics.addCustomChart(new SimplePie("fastlogin_compatibility", () -> Boolean.toString(fastlogin)));
|
||||||
if (fastlogin) {
|
if (fastlogin) {
|
||||||
logDebug("Register FastLogin compatibility");
|
logDebug("Register FastLogin compatibility");
|
||||||
proxy.getEventManager().register(this, new FastLoginListener(proxy, this));
|
eventManager.register(this, injector.getInstance(FastLoginListener.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean miniplaceholders = proxy.getPluginManager().isLoaded("miniplaceholders");
|
final boolean miniplaceholders = pluginManager.isLoaded("miniplaceholders");
|
||||||
metrics.addCustomChart(new SimplePie("miniplaceholders_compatibility", () -> Boolean.toString(miniplaceholders)));
|
metrics.addCustomChart(new SimplePie("miniplaceholders_compatibility", () -> Boolean.toString(miniplaceholders)));
|
||||||
if (miniplaceholders) {
|
if (miniplaceholders) {
|
||||||
logDebug("Register MiniPlaceholders compatibility");
|
logDebug("Register MiniPlaceholders compatibility");
|
||||||
AuthMePlaceholders.getExpansion(this).register();
|
injector.getInstance(AuthMePlaceholders.class).getExpansion().register();
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthMeCommand.register(this, proxy.getCommandManager(), logger);
|
injector.getInstance(AuthMeCommand.class).register();
|
||||||
|
|
||||||
this.sendInfoMessage();
|
this.sendInfoMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyServer getProxy(){
|
|
||||||
return this.proxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendInfoMessage() {
|
public void sendInfoMessage() {
|
||||||
final CommandSource source = proxy.getConsoleCommandSource();
|
final CommandSource source = proxy.getConsoleCommandSource();
|
||||||
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
||||||
@ -182,7 +187,7 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removePlayerIf(@NotNull Predicate<Player> predicate){
|
public void removePlayerIf(@NotNull Predicate<Player> predicate){
|
||||||
loggedPlayers.removeIf(uuid -> predicate.test(getProxy().getPlayer(uuid).orElse(null)));
|
loggedPlayers.removeIf(uuid -> predicate.test(proxy.getPlayer(uuid).orElse(null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package io.github._4drian3d.authmevelocity.velocity.commands;
|
package io.github._4drian3d.authmevelocity.velocity.commands;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.velocitypowered.api.command.BrigadierCommand;
|
import com.velocitypowered.api.command.BrigadierCommand;
|
||||||
@ -29,14 +30,14 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
public class AuthMeCommand {
|
public class AuthMeCommand {
|
||||||
private AuthMeCommand() {
|
@Inject
|
||||||
}
|
private AuthMeVelocityPlugin plugin;
|
||||||
|
@Inject
|
||||||
|
private CommandManager manager;
|
||||||
|
@Inject
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
public static void register(
|
public void register() {
|
||||||
final AuthMeVelocityPlugin plugin,
|
|
||||||
final CommandManager manager,
|
|
||||||
final Logger logger
|
|
||||||
) {
|
|
||||||
final var command = LiteralArgumentBuilder.<CommandSource>literal("authmevelocity")
|
final var command = LiteralArgumentBuilder.<CommandSource>literal("authmevelocity")
|
||||||
.requires(src -> src.hasPermission("authmevelocity.commands"))
|
.requires(src -> src.hasPermission("authmevelocity.commands"))
|
||||||
.then(LiteralArgumentBuilder.<CommandSource>literal("reload")
|
.then(LiteralArgumentBuilder.<CommandSource>literal("reload")
|
||||||
|
@ -19,6 +19,7 @@ package io.github._4drian3d.authmevelocity.velocity.listener;
|
|||||||
|
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.velocitypowered.api.event.Continuation;
|
import com.velocitypowered.api.event.Continuation;
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
@ -35,19 +36,12 @@ import org.slf4j.Logger;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public final class ConnectListener {
|
public final class ConnectListener {
|
||||||
private final ProxyServer proxy;
|
@Inject
|
||||||
private final Logger logger;
|
private ProxyServer proxy;
|
||||||
private final AuthMeVelocityPlugin plugin;
|
@Inject
|
||||||
|
private Logger logger;
|
||||||
public ConnectListener(
|
@Inject
|
||||||
final AuthMeVelocityPlugin plugin,
|
private AuthMeVelocityPlugin plugin;
|
||||||
final ProxyServer proxy,
|
|
||||||
final Logger logger
|
|
||||||
) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.logger = logger;
|
|
||||||
this.proxy = proxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.LATE)
|
@Subscribe(order = PostOrder.LATE)
|
||||||
public void onInitialServer(
|
public void onInitialServer(
|
||||||
|
@ -18,17 +18,17 @@
|
|||||||
package io.github._4drian3d.authmevelocity.velocity.listener;
|
package io.github._4drian3d.authmevelocity.velocity.listener;
|
||||||
|
|
||||||
import com.github.games647.fastlogin.velocity.event.VelocityFastLoginAutoLoginEvent;
|
import com.github.games647.fastlogin.velocity.event.VelocityFastLoginAutoLoginEvent;
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
|
import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
|
|
||||||
public class FastLoginListener {
|
public class FastLoginListener {
|
||||||
private final ProxyServer proxy;
|
@Inject
|
||||||
private final AuthMeVelocityPlugin plugin;
|
private ProxyServer proxy;
|
||||||
public FastLoginListener(ProxyServer proxy, AuthMeVelocityPlugin plugin){
|
@Inject
|
||||||
this.proxy = proxy;
|
private AuthMeVelocityPlugin plugin;
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onAutoLogin(VelocityFastLoginAutoLoginEvent event){
|
public void onAutoLogin(VelocityFastLoginAutoLoginEvent event){
|
||||||
plugin.logDebug("VelocityFastLoginAutoLoginEvent | Attempt to auto register player");
|
plugin.logDebug("VelocityFastLoginAutoLoginEvent | Attempt to auto register player");
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
package io.github._4drian3d.authmevelocity.velocity.listener;
|
package io.github._4drian3d.authmevelocity.velocity.listener;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.velocitypowered.api.event.Continuation;
|
import com.velocitypowered.api.event.Continuation;
|
||||||
|
import com.velocitypowered.api.event.EventManager;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
@ -29,22 +31,20 @@ import io.github._4drian3d.authmevelocity.api.velocity.event.*;
|
|||||||
import io.github._4drian3d.authmevelocity.common.MessageType;
|
import io.github._4drian3d.authmevelocity.common.MessageType;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
|
import io.github._4drian3d.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
import io.github._4drian3d.authmevelocity.velocity.utils.AuthMeUtils;
|
import io.github._4drian3d.authmevelocity.velocity.utils.AuthMeUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class PluginMessageListener {
|
public class PluginMessageListener {
|
||||||
private final ProxyServer proxy;
|
@Inject
|
||||||
private final Logger logger;
|
private ProxyServer proxy;
|
||||||
private final AuthMeVelocityPlugin plugin;
|
@Inject
|
||||||
|
private EventManager eventManager;
|
||||||
public PluginMessageListener(@NotNull ProxyServer proxy, @NotNull Logger logger, AuthMeVelocityPlugin plugin) {
|
@Inject
|
||||||
this.proxy = proxy;
|
private Logger logger;
|
||||||
this.logger = logger;
|
@Inject
|
||||||
this.plugin = plugin;
|
private AuthMeVelocityPlugin plugin;
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPluginMessage(final PluginMessageEvent event, Continuation continuation) {
|
public void onPluginMessage(final PluginMessageEvent event, Continuation continuation) {
|
||||||
@ -73,7 +73,7 @@ public class PluginMessageListener {
|
|||||||
case LOGIN -> {
|
case LOGIN -> {
|
||||||
plugin.logDebug("PluginMessageEvent | Login type");
|
plugin.logDebug("PluginMessageEvent | Login type");
|
||||||
if (player != null && plugin.addPlayer(player)) {
|
if (player != null && plugin.addPlayer(player)) {
|
||||||
proxy.getEventManager().fireAndForget(new ProxyLoginEvent(player));
|
eventManager.fireAndForget(new ProxyLoginEvent(player));
|
||||||
if (plugin.config().get().sendOnLogin().sendToServerOnLogin()) {
|
if (plugin.config().get().sendOnLogin().sendToServerOnLogin()) {
|
||||||
this.createServerConnectionRequest(player, connection);
|
this.createServerConnectionRequest(player, connection);
|
||||||
}
|
}
|
||||||
@ -83,14 +83,14 @@ public class PluginMessageListener {
|
|||||||
case LOGOUT -> {
|
case LOGOUT -> {
|
||||||
plugin.logDebug("PluginMessageEvent | Logout type");
|
plugin.logDebug("PluginMessageEvent | Logout type");
|
||||||
if (player != null && plugin.removePlayer(player)){
|
if (player != null && plugin.removePlayer(player)){
|
||||||
proxy.getEventManager().fireAndForget(new ProxyLogoutEvent(player));
|
eventManager.fireAndForget(new ProxyLogoutEvent(player));
|
||||||
plugin.logDebug("PluginMessageEvent | Player not null");
|
plugin.logDebug("PluginMessageEvent | Player not null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case REGISTER -> {
|
case REGISTER -> {
|
||||||
plugin.logDebug("PluginMessageEvent | Register");
|
plugin.logDebug("PluginMessageEvent | Register");
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
proxy.getEventManager().fireAndForget(new ProxyRegisterEvent(player));
|
eventManager.fireAndForget(new ProxyRegisterEvent(player));
|
||||||
plugin.logDebug("PluginMessageEvent | Player not null");
|
plugin.logDebug("PluginMessageEvent | Player not null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,11 +98,11 @@ public class PluginMessageListener {
|
|||||||
plugin.logDebug("PluginMessageEvent | Unregister type");
|
plugin.logDebug("PluginMessageEvent | Unregister type");
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
plugin.logDebug("PluginMessageEvent | Player not null");
|
plugin.logDebug("PluginMessageEvent | Player not null");
|
||||||
proxy.getEventManager().fireAndForget(new ProxyUnregisterEvent(player));
|
eventManager.fireAndForget(new ProxyUnregisterEvent(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case FORCE_UNREGISTER -> {
|
case FORCE_UNREGISTER -> {
|
||||||
proxy.getEventManager().fireAndForget(new ProxyForcedUnregisterEvent(player));
|
eventManager.fireAndForget(new ProxyForcedUnregisterEvent(player));
|
||||||
plugin.logDebug("PluginMessageEvent | Forced Unregister type");
|
plugin.logDebug("PluginMessageEvent | Forced Unregister type");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public class PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy.getEventManager().fire(new PreSendOnLoginEvent(player, loginServer, toSend.object()))
|
eventManager.fire(new PreSendOnLoginEvent(player, loginServer, toSend.object()))
|
||||||
.thenAccept(event -> {
|
.thenAccept(event -> {
|
||||||
if (!event.getResult().isAllowed()) {
|
if (!event.getResult().isAllowed()) {
|
||||||
return;
|
return;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package io.github._4drian3d.authmevelocity.velocity.listener;
|
package io.github._4drian3d.authmevelocity.velocity.listener;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.velocitypowered.api.event.Continuation;
|
import com.velocitypowered.api.event.Continuation;
|
||||||
import com.velocitypowered.api.event.EventTask;
|
import com.velocitypowered.api.event.EventTask;
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
@ -31,11 +32,8 @@ import io.github._4drian3d.authmevelocity.velocity.utils.AuthMeUtils;
|
|||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
|
||||||
public final class ProxyListener {
|
public final class ProxyListener {
|
||||||
private final AuthMeVelocityPlugin plugin;
|
@Inject
|
||||||
|
private AuthMeVelocityPlugin plugin;
|
||||||
public ProxyListener(AuthMeVelocityPlugin plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public EventTask onDisconnect(final DisconnectEvent event) {
|
public EventTask onDisconnect(final DisconnectEvent event) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user