diff --git a/.gitignore b/.gitignore
index 18f0443..60a8bf0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,19 @@
-.idea
-target
-*.iml
\ No newline at end of file
+
+target/
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+release.properties
+dependency-reduced-pom.xml
+buildNumber.properties
+.mvn/timing.properties
+.mvn/wrapper/maven-wrapper.jar
+
+# Visual Studio Code
+
+.settings/
+.classpath
+.factorypath
+.project
+.vscode/
\ No newline at end of file
diff --git a/README.md b/README.md
index cb2be01..a00c6bd 100644
--- a/README.md
+++ b/README.md
@@ -2,12 +2,12 @@
This plugin adds the support for [Velocity](https://velocitypowered.com/) to [AuthMeReloaded](https://github.com/AuthMe/AuthMeReloaded)
## Requirements
-- Spigot, Paper, Tuinity, Airplane or Purpur
-- Velocity 1.1.x or 3.0.0
-- Java 8/11/16 (Java 11 recommended)
+- Paper, Tuinity, Airplane or Purpur
+- Velocity 3.0.0+
+- Java 16
## Setup
-1. Download the latest release of the plugin [link](https://github.com/Glyart/AuthMeVelocity/releases)
+1. Download the latest release of the plugin [link](https://github.com/4drian3d/AuthMeVelocity/releases)
2. Put the jar that ends with "-proxy" in Velocity's plugins folder
3. Put the jar that ends with "-spigot" in the Spigot servers that contains AuthMe
4. Start the Velocity proxy and set up the config.yml with the auth servers
diff --git a/pom.xml b/pom.xml
index ede82bc..684c7c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,18 +7,20 @@
com.glyart.authmevelocity
parent
pom
- 1.0.1
-
+ 1.1.0
+
+
+
+ apache.snapshots
+ https://repository.apache.org/snapshots/
+
+
+
spigot
proxy
-
- 11
- 11
-
-
AuthMeVelocity-${project.name}
@@ -26,14 +28,14 @@
org.apache.maven.plugins
maven-compiler-plugin
- 11
- 11
+ 16
+ 16
org.apache.maven.plugins
maven-shade-plugin
- 3.2.4
+ 3.3.0-SNAPSHOT
package
@@ -42,6 +44,13 @@
false
+ true
+
+
+ de.leonhard
+ com.glyart.authmevelocity.libs.simplixstorage
+
+
diff --git a/proxy/pom.xml b/proxy/pom.xml
index 38cf96c..d5abaef 100644
--- a/proxy/pom.xml
+++ b/proxy/pom.xml
@@ -5,45 +5,35 @@
parent
com.glyart.authmevelocity
- 1.0.1
+ 1.1.0
4.0.0
proxy
-
- 8
- 8
-
-
velocity
https://nexus.velocitypowered.com/repository/maven-public/
+
+ jitpack.io
+ https://jitpack.io
+
com.velocitypowered
velocity-api
- 3.0.0
+ 3.0.1
provided
-
- org.projectlombok
- lombok
- 1.18.20
- provided
-
-
-
- com.fasterxml.jackson.dataformat
- jackson-dataformat-yaml
- 2.12.5
+ com.github.simplix-softworks
+ SimplixStorage
+ 3.1.9
compile
-
diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java
index 1844d43..9e2e9d2 100644
--- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java
+++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/AuthMeVelocityPlugin.java
@@ -5,51 +5,42 @@ 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.Plugin;
-import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
-import lombok.Getter;
import org.slf4j.Logger;
+import de.leonhard.storage.Yaml;
+
import java.io.IOException;
-import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
-@Getter
public class AuthMeVelocityPlugin {
-
- private final ProxyServer server;
+ public final ProxyServer server;
private final Logger logger;
- private final Path dataFolder;
+ static Yaml config = new Yaml("config", "plugins/AuthmeVelocity");
- private final List loggedPlayers = Collections.synchronizedList(new ArrayList<>());
-
- private AuthMeConfig config;
+ public final List loggedPlayers = Collections.synchronizedList(new ArrayList<>());
@Inject
- public AuthMeVelocityPlugin(ProxyServer server, Logger logger, @DataDirectory Path dataFolder) {
+ public AuthMeVelocityPlugin(ProxyServer server, Logger logger) {
this.server = server;
this.logger = logger;
- this.dataFolder = dataFolder;
}
-
+
@Subscribe
- public void onProxyInitialize(ProxyInitializeEvent event) {
- try {
- config = AuthMeConfig.loadConfig(dataFolder);
- } catch (IOException e) {
- logger.error("An error occurred while enabling AuthMeVelocity.", e);
- return;
- }
-
+ public void onProxyInitialize(ProxyInitializeEvent event) throws IOException {
server.getChannelRegistrar().register(new LegacyChannelIdentifier("authmevelocity:main"), MinecraftChannelIdentifier.create("authmevelocity", "main"));
server.getEventManager().register(this, new ProxyListener(this));
+ AuthMeConfig.defaultConfig();
logger.info("AuthMeVelocity enabled.");
+ logger.info("AuthServers:" + config.getList("authservers"));
+ }
+
+ public static Yaml getConfig(){
+ return config;
}
-
}
diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java
index 382fbd0..a29ce7b 100644
--- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java
+++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/config/AuthMeConfig.java
@@ -1,36 +1,11 @@
package com.glyart.authmevelocity.proxy.config;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-import lombok.Getter;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.Arrays;
import java.util.List;
-@Getter
-public class AuthMeConfig {
-
- private List authServers = Arrays.asList("auth-1", "auth-2");
-
- public static AuthMeConfig loadConfig(Path folder) throws IOException {
- File folderFile = folder.toFile();
- File file = new File(folderFile, "config.yml");
- ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
- if (!folderFile.exists())
- folderFile.mkdir();
-
- if (!file.exists()) {
- file.createNewFile();
-
- AuthMeConfig config = new AuthMeConfig();
- mapper.writeValue(file, config);
- return config;
- }
-
- return mapper.readValue(file, AuthMeConfig.class);
+import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
+
+public interface AuthMeConfig {
+ public static void defaultConfig(){
+ AuthMeVelocityPlugin.getConfig().setDefault("authservers", List.of("auth1", "auth2"));
}
-
}
diff --git a/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java b/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java
index 02018fc..3fabc35 100644
--- a/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java
+++ b/proxy/src/main/java/com/glyart/authmevelocity/proxy/listener/ProxyListener.java
@@ -1,7 +1,6 @@
package com.glyart.authmevelocity.proxy.listener;
import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
-import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
import com.google.common.io.ByteArrayDataInput;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.command.CommandExecuteEvent;
@@ -18,84 +17,92 @@ import java.util.Optional;
import java.util.UUID;
public class ProxyListener {
-
+
private final AuthMeVelocityPlugin plugin;
private final ProxyServer server;
- private final AuthMeConfig config;
public ProxyListener(AuthMeVelocityPlugin plugin) {
this.plugin = plugin;
- server = plugin.getServer();
- config = plugin.getConfig();
+ server = plugin.server;
}
-
- @Subscribe
- public void onPluginMessage(PluginMessageEvent event) {
- if (!(event.getSource() instanceof ServerConnection))
- return;
- if (!event.getIdentifier().getId().equals("authmevelocity:main"))
+ @Subscribe
+ public void onPluginMessage(final PluginMessageEvent event) {
+ if (!(event.getSource() instanceof ServerConnection)) {
return;
+ }
+
+ if (!event.getIdentifier().getId().equals("authmevelocity:main")) {
+ return;
+ }
ByteArrayDataInput input = event.dataAsDataStream();
String sChannel = input.readUTF();
- if (!sChannel.equals("LOGIN"))
+ if (!sChannel.equals("LOGIN")) {
return;
+ }
String user = input.readUTF();
Optional player = server.getPlayer(UUID.fromString(user));
- if (!player.isPresent())
+ if (!player.isPresent()) {
return;
+ }
- plugin.getLoggedPlayers().add(player.get().getUniqueId());
+ plugin.loggedPlayers.add(player.get().getUniqueId());
}
-
+
@Subscribe
- public void onDisconnect(DisconnectEvent event) {
- plugin.getLoggedPlayers().remove(event.getPlayer().getUniqueId());
+ public void onDisconnect(final DisconnectEvent event) {
+ plugin.loggedPlayers.remove(event.getPlayer().getUniqueId());
}
-
+
@Subscribe
- public void onCommandExecute(CommandExecuteEvent event) {
+ public void onCommandExecute(final CommandExecuteEvent event) {
if (!(event.getCommandSource() instanceof Player))
return;
-
- Player player = (Player) event.getCommandSource();
- if (plugin.getLoggedPlayers().contains(player.getUniqueId()))
+
+ final var player = (Player) event.getCommandSource();
+ if (plugin.loggedPlayers.contains(player.getUniqueId()))
return;
-
+
Optional server = player.getCurrentServer();
- boolean isAuthServer = server.isPresent() && config.getAuthServers().contains(server.get().getServerInfo().getName());
- if (isAuthServer)
+ boolean isAuthServer =
+ server.isPresent() &&
+ AuthMeVelocityPlugin.getConfig().getList("authservers").contains(server.get().getServerInfo().getName());
+
+ if (isAuthServer) {
event.setResult(CommandExecuteEvent.CommandResult.forwardToServer());
- else
+ }
+ else {
event.setResult(CommandExecuteEvent.CommandResult.denied());
+ }
}
-
+
@Subscribe
- public void onPlayerChat(PlayerChatEvent event) {
+ public void onPlayerChat(final PlayerChatEvent event) {
Player player = event.getPlayer();
- if (plugin.getLoggedPlayers().contains(player.getUniqueId()))
+ if (plugin.loggedPlayers.contains(player.getUniqueId()))
return;
-
+
Optional server = player.getCurrentServer();
- if (server.isPresent() && config.getAuthServers().contains(server.get().getServerInfo().getName()))
+ if (server.isPresent() && AuthMeVelocityPlugin.getConfig().getList("authservers").contains(server.get().getServerInfo().getName())) {
return;
-
+ }
+
event.setResult(PlayerChatEvent.ChatResult.denied());
}
-
+
@Subscribe
public void onServerPreConnect(ServerPreConnectEvent event) {
Player player = event.getPlayer();
- if (plugin.getLoggedPlayers().contains(player.getUniqueId()))
+ if (plugin.loggedPlayers.contains(player.getUniqueId()))
return;
Optional server = event.getResult().getServer();
- if (server.isPresent() && config.getAuthServers().contains(server.get().getServerInfo().getName()))
+ if (server.isPresent() && AuthMeVelocityPlugin.getConfig().getList("authservers").contains(server.get().getServerInfo().getName())) {
return;
-
+ }
+
event.setResult(ServerPreConnectEvent.ServerResult.denied());
}
-
}
diff --git a/spigot/pom.xml b/spigot/pom.xml
index 099ce9d..e19bd4c 100644
--- a/spigot/pom.xml
+++ b/spigot/pom.xml
@@ -5,15 +5,15 @@
parent
com.glyart.authmevelocity
- 1.0.1
+ 1.1.0
4.0.0
spigot
- 11
- 11
+ 16
+ 16
@@ -27,7 +27,7 @@
https://repo.codemc.org/repository/maven-public/
-
+
io.papermc.paper
@@ -35,7 +35,6 @@
1.17.1-R0.1-SNAPSHOT
provided
-
fr.xephi
authme
@@ -43,5 +42,4 @@
provided
-
diff --git a/spigot/src/main/java/com/glyart/authmevelocity/spigot/AuthMeVelocityPlugin.java b/spigot/src/main/java/com/glyart/authmevelocity/spigot/AuthMeVelocityPlugin.java
index 740e36c..818d61c 100644
--- a/spigot/src/main/java/com/glyart/authmevelocity/spigot/AuthMeVelocityPlugin.java
+++ b/spigot/src/main/java/com/glyart/authmevelocity/spigot/AuthMeVelocityPlugin.java
@@ -12,21 +12,20 @@ public class AuthMeVelocityPlugin extends JavaPlugin {
public void onEnable() {
getServer().getMessenger().registerOutgoingPluginChannel(this, "authmevelocity:main");
getServer().getPluginManager().registerEvents(new AuthMeListener(this), this);
-
+
getLogger().info("AuthMeVelocity enabled.");
}
@Override
public void onDisable() {
-
+
}
-
+
public void sendLoginToProxy(Player player) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("LOGIN");
out.writeUTF(player.getUniqueId().toString());
-
+
player.sendPluginMessage(this, "authmevelocity:main", out.toByteArray());
}
-
}
diff --git a/spigot/src/main/java/com/glyart/authmevelocity/spigot/listeners/AuthMeListener.java b/spigot/src/main/java/com/glyart/authmevelocity/spigot/listeners/AuthMeListener.java
index eddc46d..354310c 100644
--- a/spigot/src/main/java/com/glyart/authmevelocity/spigot/listeners/AuthMeListener.java
+++ b/spigot/src/main/java/com/glyart/authmevelocity/spigot/listeners/AuthMeListener.java
@@ -6,16 +6,16 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class AuthMeListener implements Listener {
-
+
private final AuthMeVelocityPlugin plugin;
public AuthMeListener(AuthMeVelocityPlugin plugin) {
this.plugin = plugin;
}
-
+
@EventHandler
public void onLogin(LoginEvent event) {
plugin.sendLoginToProxy(event.getPlayer());
}
-
+
}