Merge pull request #15 from 4drian3d/configurate
Migration to Configurate and more
This commit is contained in:
commit
d32c1ae224
38
pom.xml
38
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>com.glyart.authmevelocity</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.2.0</version>
|
||||
<version>1.3.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>16</maven.compiler.source>
|
||||
@ -38,42 +38,6 @@
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>de.leonhard</pattern>
|
||||
<shadedPattern>com.glyart.authmevelocity.libs.simplixstorage</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer">
|
||||
</transformer>
|
||||
</transformers>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/maven/</exclude>
|
||||
<exclude>META-INF/*.MF</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.glyart.authmevelocity</groupId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -39,10 +39,9 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.simplix-softworks</groupId>
|
||||
<artifactId>SimplixStorage</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<scope>compile</scope>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>configurate-hocon</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.games647</groupId>
|
||||
@ -59,6 +58,42 @@
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.1-SNAPSHOT</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.spongepowered</pattern>
|
||||
<shadedPattern>com.glyart.authmevelocity.libs.configurate</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer">
|
||||
</transformer>
|
||||
</transformers>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/maven/</exclude>
|
||||
<exclude>META-INF/*.MF</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -6,28 +6,31 @@ import com.glyart.authmevelocity.proxy.listener.ProxyListener;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import de.leonhard.storage.Yaml;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AuthMeVelocityPlugin {
|
||||
private static ProxyServer proxy;
|
||||
private final ProxyServer proxy;
|
||||
private final Logger logger;
|
||||
private static Yaml config = new Yaml("config", "plugins/AuthmeVelocity");
|
||||
private final Path pluginDirectory;
|
||||
private static AuthMeVelocityPlugin plugin;
|
||||
|
||||
protected static final Set<UUID> loggedPlayers = Collections.synchronizedSet(new HashSet<UUID>());
|
||||
|
||||
@Inject
|
||||
public AuthMeVelocityPlugin(ProxyServer server, Logger logger) {
|
||||
proxy = server;
|
||||
public AuthMeVelocityPlugin(ProxyServer proxy, Logger logger, @DataDirectory Path dataDirectory) {
|
||||
plugin = this;
|
||||
this.proxy = proxy;
|
||||
this.logger = logger;
|
||||
this.pluginDirectory = dataDirectory;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@ -38,19 +41,20 @@ public class AuthMeVelocityPlugin {
|
||||
if(proxy.getPluginManager().getPlugin("fastlogin").isPresent()){
|
||||
proxy.getEventManager().register(this, new FastLoginListener(proxy));
|
||||
}
|
||||
AuthMeConfig.defaultConfig();
|
||||
AuthMeConfig.loadConfig(pluginDirectory, logger);
|
||||
logger.info("-- AuthMeVelocity enabled --");
|
||||
logger.info("AuthServers: " + config.getList("authservers"));
|
||||
if(config.getBoolean("teleport.send-to-server-after-login")){
|
||||
logger.info("LobbyServers: " + config.getList("teleport.servers"));
|
||||
var config = AuthMeConfig.getConfig();
|
||||
logger.info("AuthServers: {}", config.getAuthServers());
|
||||
if(config.getToServerOptions().sendToServer()){
|
||||
logger.info("LobbyServers: {}", config.getToServerOptions().getTeleportServers());
|
||||
}
|
||||
}
|
||||
|
||||
public static Yaml getConfig(){
|
||||
return config;
|
||||
}
|
||||
|
||||
protected static ProxyServer getProxy(){
|
||||
protected ProxyServer getProxy(){
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public static AuthMeVelocityPlugin getInstance(){
|
||||
return plugin;
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,15 @@ import java.util.function.Predicate;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AuthmeVelocityAPI {
|
||||
/**
|
||||
* Check if the player is logged in or not
|
||||
* @param player the player
|
||||
* @return if the player is logged in or not
|
||||
*/
|
||||
public static boolean isLogged(Player player){
|
||||
public static boolean isLogged(@NotNull Player player){
|
||||
final UUID playerUUID = player.getUniqueId();
|
||||
return AuthMeVelocityPlugin.loggedPlayers.contains(playerUUID);
|
||||
}
|
||||
@ -19,33 +21,33 @@ public class AuthmeVelocityAPI {
|
||||
/**
|
||||
* Adds a player to the list of logged in players
|
||||
* @param player the new logged player
|
||||
* @return if the player was succesfully added
|
||||
*/
|
||||
public static void addPlayer(Player player){
|
||||
public static boolean addPlayer(@NotNull Player player){
|
||||
final UUID playerUUID = player.getUniqueId();
|
||||
if(!AuthmeVelocityAPI.isLogged(player)){
|
||||
AuthMeVelocityPlugin.loggedPlayers.add(playerUUID);
|
||||
}
|
||||
return AuthMeVelocityPlugin.loggedPlayers.add(playerUUID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a player from the list of logged-in players
|
||||
* @param player the unlogged player
|
||||
* @return if the player was succesfully removed
|
||||
*/
|
||||
public static void removePlayer(Player player){
|
||||
public static boolean removePlayer(@NotNull Player player){
|
||||
final UUID playerUUID = player.getUniqueId();
|
||||
if(AuthmeVelocityAPI.isLogged(player)){
|
||||
AuthMeVelocityPlugin.loggedPlayers.remove(playerUUID);
|
||||
}
|
||||
return AuthMeVelocityPlugin.loggedPlayers.remove(playerUUID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes players who meet the established condition
|
||||
* @param predicate the condition
|
||||
*/
|
||||
public static void removePlayerIf(Predicate<Player> predicate){
|
||||
public static void removePlayerIf(@NotNull Predicate<Player> predicate){
|
||||
AuthMeVelocityPlugin.loggedPlayers.stream()
|
||||
.map(uuid -> AuthMeVelocityPlugin.getProxy().getPlayer(uuid).orElse(null))
|
||||
.map(uuid -> AuthMeVelocityPlugin.getInstance().getProxy().getPlayer(uuid).orElseThrow())
|
||||
.filter(predicate)
|
||||
.forEach(player -> AuthMeVelocityPlugin.loggedPlayers.remove(player.getUniqueId()));
|
||||
}
|
||||
|
||||
private AuthmeVelocityAPI(){}
|
||||
}
|
||||
|
@ -1,28 +1,90 @@
|
||||
package com.glyart.authmevelocity.proxy.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
|
||||
import de.leonhard.storage.Yaml;
|
||||
public class AuthMeConfig {
|
||||
private static final String HEADER = """
|
||||
AuthmeVelocity Proxy
|
||||
|
||||
public interface AuthMeConfig {
|
||||
public static void defaultConfig(){
|
||||
Yaml config = AuthMeVelocityPlugin.getConfig();
|
||||
config.setDefault(
|
||||
"authservers",
|
||||
List.of(
|
||||
"auth1",
|
||||
"auth2"
|
||||
));
|
||||
config.setDefault(
|
||||
"teleport.send-to-server-after-login",
|
||||
false);
|
||||
config.setDefault(
|
||||
"teleport.servers",
|
||||
List.of(
|
||||
"lobby1",
|
||||
"lobby2"
|
||||
));
|
||||
Original Developer: xQuickGlare
|
||||
Actual Developer: 4drian3d
|
||||
""";
|
||||
private static final HoconConfigurationLoader.Builder configBuilder = HoconConfigurationLoader.builder()
|
||||
.defaultOptions(opts -> opts
|
||||
.shouldCopyDefaults(true)
|
||||
.header(HEADER)
|
||||
);
|
||||
public static void loadConfig(@NotNull Path path, @NotNull Logger logger){
|
||||
File configFile = new File(path.toFile(), "config.conf");
|
||||
final HoconConfigurationLoader loader = configBuilder
|
||||
.file(configFile)
|
||||
.build();
|
||||
|
||||
try {
|
||||
final CommentedConfigurationNode node = loader.load();
|
||||
config = node.get(Config.class);
|
||||
node.set(Config.class, config);
|
||||
loader.save(node);
|
||||
} catch (ConfigurateException exception){
|
||||
logger.error("Could not load configuration: {}", exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigSerializable
|
||||
public static class Config {
|
||||
|
||||
@Comment("List of login/registration servers")
|
||||
private Set<String> authservers = Set.of(
|
||||
"auth1",
|
||||
"auth2"
|
||||
);
|
||||
|
||||
private ServerOnLogin send = new ServerOnLogin();
|
||||
|
||||
public Set<String> getAuthServers(){
|
||||
return this.authservers;
|
||||
}
|
||||
|
||||
public ServerOnLogin getToServerOptions(){
|
||||
return this.send;
|
||||
}
|
||||
}
|
||||
@ConfigSerializable
|
||||
public static class ServerOnLogin {
|
||||
@Comment("Send logged in players to another server?")
|
||||
private boolean sendToServerOnLogin = false;
|
||||
|
||||
@Comment("""
|
||||
List of servers to send
|
||||
One of these servers will be chosen at random
|
||||
""")
|
||||
private List<String> teleportServers = List.of(
|
||||
"lobby1",
|
||||
"lobby2"
|
||||
);
|
||||
|
||||
public boolean sendToServer(){
|
||||
return this.sendToServerOnLogin;
|
||||
}
|
||||
|
||||
public List<String> getTeleportServers(){
|
||||
return this.teleportServers;
|
||||
}
|
||||
}
|
||||
private static Config config;
|
||||
public static Config getConfig(){
|
||||
return config;
|
||||
}
|
||||
private AuthMeConfig(){}
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ public class FastLoginListener {
|
||||
@Subscribe
|
||||
public void onAutoLogin(VelocityFastLoginAutoLoginEvent event){
|
||||
Optional<Player> autoLoginPlayer = server.getPlayer(event.getProfile().getName());
|
||||
if(autoLoginPlayer.isPresent()){
|
||||
AuthmeVelocityAPI.addPlayer(autoLoginPlayer.get());
|
||||
}
|
||||
autoLoginPlayer.ifPresent(AuthmeVelocityAPI::addPlayer);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.glyart.authmevelocity.proxy.listener;
|
||||
|
||||
import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
|
||||
import com.glyart.authmevelocity.proxy.AuthmeVelocityAPI;
|
||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
||||
import com.glyart.authmevelocity.proxy.event.ProxyLoginEvent;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.velocitypowered.api.event.EventTask;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
@ -25,41 +26,40 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class ProxyListener {
|
||||
private final ProxyServer server;
|
||||
private final ProxyServer proxy;
|
||||
private final Logger logger;
|
||||
private final Random rm;
|
||||
private AuthMeConfig.Config config;
|
||||
|
||||
public ProxyListener(ProxyServer server, Logger logger) {
|
||||
this.server = server;
|
||||
public ProxyListener(ProxyServer proxy, Logger logger) {
|
||||
this.proxy = proxy;
|
||||
this.logger = logger;
|
||||
this.rm = new Random();
|
||||
this.config = AuthMeConfig.getConfig();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginMessage(final PluginMessageEvent event) {
|
||||
if (!(event.getSource() instanceof ServerConnection)) return;
|
||||
|
||||
if (!event.getIdentifier().getId().equals("authmevelocity:main")) return;
|
||||
if (!(event.getSource() instanceof ServerConnection) || !event.getIdentifier().getId().equals("authmevelocity:main"))
|
||||
return;
|
||||
|
||||
ByteArrayDataInput input = event.dataAsDataStream();
|
||||
String sChannel = input.readUTF();
|
||||
if (!sChannel.equals("LOGIN")) return;
|
||||
|
||||
String user = input.readUTF();
|
||||
Optional<Player> optionalPlayer = server.getPlayer(UUID.fromString(user));
|
||||
Optional<Player> optionalPlayer = proxy.getPlayer(UUID.fromString(user));
|
||||
if (!optionalPlayer.isPresent()) return;
|
||||
|
||||
Player loggedPlayer = optionalPlayer.get();
|
||||
if (!AuthmeVelocityAPI.isLogged(loggedPlayer)){
|
||||
AuthmeVelocityAPI.addPlayer(loggedPlayer);
|
||||
|
||||
RegisteredServer loginServer = loggedPlayer.getCurrentServer().get().getServer();
|
||||
server.getEventManager().fireAndForget(new ProxyLoginEvent(loggedPlayer, loginServer));
|
||||
if(AuthMeVelocityPlugin.getConfig().getBoolean("teleport.send-to-server-after-login")){
|
||||
Random rm = new Random();
|
||||
List<String> serverList = AuthMeVelocityPlugin.getConfig().getStringList("teleport.servers");
|
||||
if (AuthmeVelocityAPI.addPlayer(loggedPlayer)){
|
||||
RegisteredServer loginServer = loggedPlayer.getCurrentServer().orElseThrow().getServer();
|
||||
proxy.getEventManager().fireAndForget(new ProxyLoginEvent(loggedPlayer, loginServer));
|
||||
if(config.getToServerOptions().sendToServer()){
|
||||
List<String> serverList = config.getToServerOptions().getTeleportServers();
|
||||
String randomServer = serverList.get(rm.nextInt(serverList.size()));
|
||||
Optional<RegisteredServer> optionalServer = server.getServer(randomServer);
|
||||
if(optionalServer.isPresent()){
|
||||
RegisteredServer serverToSend = optionalServer.get();
|
||||
Optional<RegisteredServer> optionalServer = proxy.getServer(randomServer);
|
||||
optionalServer.ifPresentOrElse(serverToSend -> {
|
||||
try{
|
||||
if(!loggedPlayer.createConnectionRequest(serverToSend).connect().get().isSuccessful()){
|
||||
logger.info("Unable to connect the player {} to the server {}",
|
||||
@ -72,9 +72,7 @@ public class ProxyListener {
|
||||
serverToSend.getServerInfo().getName(),
|
||||
exception);
|
||||
}
|
||||
} else{
|
||||
logger.info("The server {} does not exist", randomServer);
|
||||
}
|
||||
}, () -> logger.info("The server {} does not exist", randomServer));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,15 +84,12 @@ public class ProxyListener {
|
||||
|
||||
@Subscribe
|
||||
public void onCommandExecute(final CommandExecuteEvent event) {
|
||||
if (!(event.getCommandSource() instanceof Player player)) return;
|
||||
|
||||
if (AuthmeVelocityAPI.isLogged(player)) return;
|
||||
if (!(event.getCommandSource() instanceof Player player) || AuthmeVelocityAPI.isLogged(player))
|
||||
return;
|
||||
|
||||
Optional<ServerConnection> server = player.getCurrentServer();
|
||||
boolean isAuthServer = server.isPresent() &&
|
||||
AuthMeVelocityPlugin.getConfig().getList("authservers").contains(server.get().getServerInfo().getName());
|
||||
|
||||
if (isAuthServer) {
|
||||
if (server.isPresent() && config.getAuthServers().contains(server.get().getServerInfo().getName())) {
|
||||
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
|
||||
} else {
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
@ -107,7 +102,7 @@ public class ProxyListener {
|
||||
if (AuthmeVelocityAPI.isLogged(player)) return;
|
||||
|
||||
Optional<ServerConnection> server = player.getCurrentServer();
|
||||
if (server.isPresent() && AuthMeVelocityPlugin.getConfig().getList("authservers").contains(server.get().getServerInfo().getName())) {
|
||||
if (server.isPresent() && config.getAuthServers().contains(server.get().getServerInfo().getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -119,7 +114,7 @@ public class ProxyListener {
|
||||
if (AuthmeVelocityAPI.isLogged(event.getPlayer())) return;
|
||||
|
||||
Optional<RegisteredServer> server = event.getResult().getServer();
|
||||
if (server.isPresent() && AuthMeVelocityPlugin.getConfig().getList("authservers").contains(server.get().getServerInfo().getName())) {
|
||||
if (server.isPresent() && config.getAuthServers().contains(server.get().getServerInfo().getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -127,10 +122,11 @@ public class ProxyListener {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onTabComplete(TabCompleteEvent event){
|
||||
Player player = event.getPlayer();
|
||||
public EventTask onTabComplete(TabCompleteEvent event){
|
||||
final Player player = event.getPlayer();
|
||||
if (!AuthmeVelocityAPI.isLogged(player)){
|
||||
event.getSuggestions().clear();
|
||||
return EventTask.async(() -> event.getSuggestions().clear());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
"version":"${project.version}",
|
||||
"url":"https://github.com/4drian3d/AuthMeVelocity",
|
||||
"description":"This plugin adds the support for AuthMeReloaded to Velocity.",
|
||||
"authors":["xQuickGlare"],
|
||||
"authors":["xQuickGlare", "4drian3d"],
|
||||
"dependencies":[
|
||||
{
|
||||
"id":"fastlogin",
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.glyart.authmevelocity</groupId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.3.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,17 +5,18 @@ import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AuthMeVelocityPlugin extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "authmevelocity:main");
|
||||
getServer().getPluginManager().registerEvents(new AuthMeListener(this), this);
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "authmevelocity:main");
|
||||
this.getServer().getPluginManager().registerEvents(new AuthMeListener(this), this);
|
||||
|
||||
getLogger().info("AuthMeVelocity enabled.");
|
||||
this.getLogger().info("AuthMeVelocity enabled.");
|
||||
}
|
||||
|
||||
public void sendLoginToProxy(Player player) {
|
||||
public void sendLoginToProxy(@NotNull final Player player) {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("LOGIN");
|
||||
out.writeUTF(player.getUniqueId().toString());
|
||||
|
@ -10,8 +10,8 @@ public class PreSendLoginEvent extends PlayerEvent implements Cancellable {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private boolean isCancelled;
|
||||
|
||||
public PreSendLoginEvent(@NotNull Player player) {
|
||||
super(player);
|
||||
public PreSendLoginEvent(@NotNull final Player player, boolean async) {
|
||||
super(player, async);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,10 +19,10 @@ public class AuthMeListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(LoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PreSendLoginEvent sendloginevent = new PreSendLoginEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(sendloginevent);
|
||||
if(!sendloginevent.isCancelled()){
|
||||
final Player player = event.getPlayer();
|
||||
PreSendLoginEvent preSendLoginEvent = new PreSendLoginEvent(player, false);
|
||||
Bukkit.getPluginManager().callEvent(preSendLoginEvent);
|
||||
if(!preSendLoginEvent.isCancelled()){
|
||||
plugin.sendLoginToProxy(player);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user