refactor: Migrate to gradle
This commit is contained in:
parent
08bfbd7469
commit
a401655551
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,4 +1,9 @@
|
||||
|
||||
|
||||
.gradle/
|
||||
/.idea/
|
||||
build/
|
||||
bin/
|
||||
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
|
38
build.gradle.kts
Normal file
38
build.gradle.kts
Normal file
@ -0,0 +1,38 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins {
|
||||
java
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
shadow(project(":authmevelocity-common"))
|
||||
shadow(project(":authmevelocity-velocity"))
|
||||
shadow(project(":authmevelocity-paper"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
archiveFileName.set("AuthMeVelocity.jar")
|
||||
configurations = listOf(project.configurations.shadow.get())
|
||||
}
|
||||
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
|
||||
options.release.set(17)
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.spigot;
|
||||
package me.adrianed.authmevelocity.common;
|
||||
|
||||
public enum MessageType {
|
||||
LOGIN, REGISTER, LOGOUT, FORCE_UNREGISTER, UNREGISTER;
|
@ -0,0 +1,5 @@
|
||||
package me.adrianed.authmevelocity.common.configuration;
|
||||
|
||||
public class Loader {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package me.adrianed.authmevelocity.common.configuration;
|
||||
|
||||
public class PaperConfiguration {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package me.adrianed.authmevelocity.common.configuration;
|
||||
|
||||
public class ProxyConfiguration {
|
||||
|
||||
}
|
9
gradle.properties
Normal file
9
gradle.properties
Normal file
@ -0,0 +1,9 @@
|
||||
group = me.adrianed.authmevelocity
|
||||
version = 3.0.0-SNAPSHOT
|
||||
description = A global chat regulator for you Velocity network
|
||||
url = https://forums.velocitypowered.com/t/chatregulator-a-global-chat-regulator-for-velocity/962
|
||||
id = chatregulator
|
||||
|
||||
caffeine-version = 3.1.1
|
||||
configurate-version = 4.1.2
|
||||
geantyref-version = 1.3.13
|
50
paper/build.gradle.kts
Normal file
50
paper/build.gradle.kts
Normal file
@ -0,0 +1,50 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins {
|
||||
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://jitpack.io")
|
||||
maven("https://repo.codemc.org/repository/maven-public/")
|
||||
maven("https://repo.alessiodp.com/releases/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT")
|
||||
compileOnly("fr.xephi:authme:5.6.0-SNAPSHOT")
|
||||
compileOnly("com.github.4drian3d:MiniPlaceholders:1.1.1")
|
||||
shadow("net.byteflux:libby-bukkit:1.1.5")
|
||||
compileOnly(project(":authmevelocity-common"))
|
||||
}
|
||||
|
||||
bukkit {
|
||||
name = "AuthMeVelocity"
|
||||
main = "me.adrianed.authmevelocity.paper.AuthMeVelocityPaper"
|
||||
apiVersion = "1.13"
|
||||
website = "https://github.com/4drian3d/AuthMeVelocity"
|
||||
authors = listOf("xQuickGlare", "4drian3d")
|
||||
softDepend = listOf("MiniPlaceholders")
|
||||
depend = listOf("AuthMe")
|
||||
version = "4.0.0"
|
||||
}
|
||||
tasks {
|
||||
shadowJar {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
relocate("net.byteflux.libby", "me.adrianed.authmevelocity.libs.libby")
|
||||
configurations = listOf(project.configurations.shadow.get())
|
||||
}
|
||||
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
|
||||
options.release.set(17)
|
||||
}
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
@ -1,7 +1,8 @@
|
||||
package com.glyart.authmevelocity.spigot;
|
||||
package me.adrianed.authmevelocity.paper;
|
||||
|
||||
import com.glyart.authmevelocity.spigot.listeners.AuthMeListener;
|
||||
import com.glyart.authmevelocity.spigot.listeners.MessageListener;
|
||||
import me.adrianed.authmevelocity.paper.listeners.AuthMeListener;
|
||||
import me.adrianed.authmevelocity.paper.listeners.MessageListener;
|
||||
import me.adrianed.authmevelocity.common.MessageType;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.spigot;
|
||||
package me.adrianed.authmevelocity.paper;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.spigot.events;
|
||||
package me.adrianed.authmevelocity.paper.events;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
@ -1,8 +1,8 @@
|
||||
package com.glyart.authmevelocity.spigot.listeners;
|
||||
package me.adrianed.authmevelocity.paper.listeners;
|
||||
|
||||
import com.glyart.authmevelocity.spigot.AuthMeVelocityPlugin;
|
||||
import com.glyart.authmevelocity.spigot.MessageType;
|
||||
import com.glyart.authmevelocity.spigot.events.PreSendLoginEvent;
|
||||
import me.adrianed.authmevelocity.paper.AuthMeVelocityPlugin;
|
||||
import me.adrianed.authmevelocity.common.MessageType;
|
||||
import me.adrianed.authmevelocity.paper.events.PreSendLoginEvent;
|
||||
|
||||
import fr.xephi.authme.events.LoginEvent;
|
||||
import fr.xephi.authme.events.LogoutEvent;
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.spigot.listeners;
|
||||
package me.adrianed.authmevelocity.paper.listeners;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
49
pom.xml
49
pom.xml
@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.glyart.authmevelocity</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>2.2.2</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>apache.snapshots</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<modules>
|
||||
<module>spigot</module>
|
||||
<module>proxy</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
<finalName>AuthMeVelocity-${project.name}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.glyart.authmevelocity</groupId>
|
||||
<version>2.2.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<artifactId>proxy</artifactId>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-snapshots</id>
|
||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.1.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.games647</groupId>
|
||||
<artifactId>fastlogin.velocity</artifactId>
|
||||
<version>1.11-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.4drian3d</groupId>
|
||||
<artifactId>MiniPlaceholders</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"id":"authmevelocity",
|
||||
"name":"AuthMeVelocity",
|
||||
"version":"${project.version}",
|
||||
"url":"https://github.com/4drian3d/AuthMeVelocity",
|
||||
"description":"This plugin adds the support for AuthMeReloaded to Velocity.",
|
||||
"authors":["xQuickGlare", "4drian3d"],
|
||||
"dependencies":[
|
||||
{
|
||||
"id":"fastlogin",
|
||||
"optional":true
|
||||
},
|
||||
{
|
||||
"id":"miniplaceholders",
|
||||
"optional":true
|
||||
}
|
||||
],
|
||||
"main":"com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin"
|
||||
}
|
6
settings.gradle.kts
Normal file
6
settings.gradle.kts
Normal file
@ -0,0 +1,6 @@
|
||||
rootProject.name = "authmevelocity-parent"
|
||||
|
||||
listOf("common", "paper", "velocity").forEach {
|
||||
include("authmevelocity-$it")
|
||||
project(":authmevelocity-$it").projectDir = file(it)
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>com.glyart.authmevelocity</groupId>
|
||||
<version>2.2.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spigot</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.xephi</groupId>
|
||||
<artifactId>authme</artifactId>
|
||||
<version>5.6.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.4drian3d</groupId>
|
||||
<artifactId>MiniPlaceholders</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,8 +0,0 @@
|
||||
name: AuthMeVelocity
|
||||
authors: [xQuickGlare, 4drian3d]
|
||||
version: ${project.version}
|
||||
main: com.glyart.authmevelocity.spigot.AuthMeVelocityPlugin
|
||||
depend: [AuthMe]
|
||||
soft-depend: [MiniPlaceholders]
|
||||
# pls, dont use outdated versions, use 1.16.5+
|
||||
api-version: 1.13
|
26
velocity/build.gradle.kts
Normal file
26
velocity/build.gradle.kts
Normal file
@ -0,0 +1,26 @@
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://jitpack.io")
|
||||
maven("https://repo.codemc.org/repository/maven-public/")
|
||||
maven("https://repo.alessiodp.com/releases/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||
annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||
compileOnly("com.github.4drian3d:MiniPlaceholders:1.1.1")
|
||||
compileOnly("com.github.games647:fastlogin.velocity:1.11-SNAPSHOT")
|
||||
shadow("net.byteflux:libby-velocity:1.1.5")
|
||||
compileOnly(project(":authmevelocity-common"))
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
|
||||
options.release.set(17)
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.proxy;
|
||||
package me.adrianed.authmevelocity.velocity;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
@ -7,31 +7,31 @@ import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
|
||||
import static me.dreamerzero.miniplaceholders.api.utils.Components.*;
|
||||
|
||||
final class AuthmePlaceholders {
|
||||
private AuthmePlaceholders(){}
|
||||
final class AuthMePlaceholders {
|
||||
private AuthMePlaceholders() {}
|
||||
|
||||
static Expansion getExpansion(AuthMeVelocityPlugin plugin){
|
||||
return Expansion.builder("authme")
|
||||
.filter(Player.class)
|
||||
// Logged Placeholders
|
||||
.audiencePlaceholder("is_logged", (aud, queue, ctx) ->
|
||||
Tag.selfClosingInserting(plugin.getAPI().isLogged((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT))
|
||||
Tag.selfClosingInserting(plugin.isLogged((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT))
|
||||
.globalPlaceholder("is_player_logged", (queue, ctx) -> {
|
||||
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
||||
return Tag.selfClosingInserting(
|
||||
plugin.getProxy().getPlayer(playerName)
|
||||
.map(plugin.getAPI()::isLogged)
|
||||
.map(plugin::isLogged)
|
||||
.orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT
|
||||
);
|
||||
})
|
||||
// In Auth Server placeholders
|
||||
.audiencePlaceholder("in_auth_server", (aud, queue, ctx) ->
|
||||
Tag.selfClosingInserting(plugin.getAPI().isInAuthServer((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT))
|
||||
Tag.selfClosingInserting(plugin.isInAuthServer((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT))
|
||||
.globalPlaceholder("player_in_auth_server", (queue, ctx) -> {
|
||||
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
||||
return Tag.selfClosingInserting(
|
||||
plugin.getProxy().getPlayer(playerName)
|
||||
.map(plugin.getAPI()::isInAuthServer)
|
||||
.map(plugin::isInAuthServer)
|
||||
.orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT
|
||||
);
|
||||
})
|
@ -1,8 +1,8 @@
|
||||
package com.glyart.authmevelocity.proxy;
|
||||
package me.adrianed.authmevelocity.velocity;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
||||
import me.adrianed.authmevelocity.velocity.config.AuthMeConfig;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
@ -12,91 +12,67 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* API provided to interact with logged players
|
||||
*/
|
||||
public final class AuthmeVelocityAPI {
|
||||
private final AuthMeVelocityPlugin plugin;
|
||||
private final AuthMeConfig config;
|
||||
AuthmeVelocityAPI(AuthMeVelocityPlugin plugin, AuthMeConfig config){
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
}
|
||||
public sealed interface AuthMeVelocityAPI permits AuthMeVelocityPlugin {
|
||||
|
||||
/**
|
||||
* Check if the player is logged in or not
|
||||
* @param player the player
|
||||
* @return if the player is logged in or not
|
||||
*/
|
||||
public boolean isLogged(@NotNull Player player){
|
||||
return plugin.loggedPlayers.contains(player.getUniqueId());
|
||||
}
|
||||
boolean isLogged(@NotNull Player player);
|
||||
|
||||
/**
|
||||
* Check if the player is not logged
|
||||
* @param player the player
|
||||
* @return if the player is not logged
|
||||
*/
|
||||
public boolean isNotLogged(@NotNull Player player){
|
||||
return !plugin.loggedPlayers.contains(player.getUniqueId());
|
||||
}
|
||||
boolean isNotLogged(@NotNull Player player);
|
||||
|
||||
/**
|
||||
* Adds a player to the list of logged in players
|
||||
* @param player the new logged player
|
||||
* @return if the player was succesfully added
|
||||
*/
|
||||
public boolean addPlayer(@NotNull Player player){
|
||||
return plugin.loggedPlayers.add(player.getUniqueId());
|
||||
}
|
||||
boolean addPlayer(@NotNull Player player);
|
||||
|
||||
/**
|
||||
* Removes a player from the list of logged-in players
|
||||
* @param player the unlogged player
|
||||
* @return if the player was succesfully removed
|
||||
*/
|
||||
public boolean removePlayer(@NotNull Player player){
|
||||
return plugin.loggedPlayers.remove(player.getUniqueId());
|
||||
}
|
||||
boolean removePlayer(@NotNull Player player);
|
||||
|
||||
/**
|
||||
* Removes players who meet the established condition
|
||||
* @param predicate the condition
|
||||
*/
|
||||
public void removePlayerIf(@NotNull Predicate<Player> predicate){
|
||||
plugin.loggedPlayers.removeIf(uuid -> predicate.test(plugin.getProxy().getPlayer(uuid).orElse(null)));
|
||||
}
|
||||
void removePlayerIf(@NotNull Predicate<Player> predicate);
|
||||
|
||||
/**
|
||||
* Check if the player is on a login server
|
||||
* @param player the player
|
||||
* @return if the player is on a login server
|
||||
*/
|
||||
public boolean isInAuthServer(@NotNull Player player){
|
||||
return player.getCurrentServer().map(this::isAuthServer).orElse(false);
|
||||
}
|
||||
boolean isInAuthServer(@NotNull Player player);
|
||||
|
||||
/**
|
||||
* Check if a server is intended to be a logging server
|
||||
* @param server the server
|
||||
* @return if the server is a login server
|
||||
*/
|
||||
public boolean isAuthServer(@NotNull RegisteredServer server){
|
||||
return config.getAuthServers().contains(server.getServerInfo().getName());
|
||||
}
|
||||
boolean isAuthServer(@NotNull RegisteredServer server);
|
||||
|
||||
/**
|
||||
* Checks if a connection is made from a login server
|
||||
* @param connection the connection
|
||||
* @return if the connection is made from a login server
|
||||
*/
|
||||
public boolean isAuthServer(@NotNull ServerConnection connection){
|
||||
return config.getAuthServers().contains(connection.getServerInfo().getName());
|
||||
}
|
||||
boolean isAuthServer(@NotNull ServerConnection connection);
|
||||
|
||||
/**
|
||||
* Checks if a string is an name of an auth server
|
||||
* @param server the server name
|
||||
* @return if the server is an auth serverr
|
||||
*/
|
||||
public boolean isAuthServer(@NotNull String server){
|
||||
return config.getAuthServers().contains(server);
|
||||
}
|
||||
boolean isAuthServer(@NotNull String server);
|
||||
}
|
@ -1,18 +1,23 @@
|
||||
package com.glyart.authmevelocity.proxy;
|
||||
package me.adrianed.authmevelocity.velocity;
|
||||
|
||||
import com.glyart.authmevelocity.proxy.commands.AuthmeCommand;
|
||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
||||
import com.glyart.authmevelocity.proxy.listener.ConnectListener;
|
||||
import com.glyart.authmevelocity.proxy.listener.FastLoginListener;
|
||||
import com.glyart.authmevelocity.proxy.listener.PluginMessageListener;
|
||||
import com.glyart.authmevelocity.proxy.listener.ProxyListener;
|
||||
import me.adrianed.authmevelocity.velocity.commands.AuthmeCommand;
|
||||
import me.adrianed.authmevelocity.velocity.config.AuthMeConfig;
|
||||
import me.adrianed.authmevelocity.velocity.listener.ConnectListener;
|
||||
import me.adrianed.authmevelocity.velocity.listener.FastLoginListener;
|
||||
import me.adrianed.authmevelocity.velocity.listener.PluginMessageListener;
|
||||
import me.adrianed.authmevelocity.velocity.listener.ProxyListener;
|
||||
import com.google.inject.Inject;
|
||||
import com.moandjiezana.toml.Toml;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
|
||||
@ -20,6 +25,7 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
@ -32,13 +38,28 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AuthMeVelocityPlugin {
|
||||
@Plugin(
|
||||
id = "authmevelocity",
|
||||
name = "AuthMeVelocity",
|
||||
url = "https://github.com/4drian3d/AuthMeVelocity",
|
||||
description = "This plugin adds the support for AuthMeReloaded to Velocity",
|
||||
dependencies = {
|
||||
@Dependency(
|
||||
id = "miniplaceholders",
|
||||
optional = true
|
||||
),
|
||||
@Dependency(
|
||||
id = "fastlogin",
|
||||
optional = true
|
||||
)
|
||||
}
|
||||
)
|
||||
public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
||||
public static final ChannelIdentifier AUTHMEVELOCITY_CHANNEL
|
||||
= MinecraftChannelIdentifier.create("authmevelocity", "main");
|
||||
private final ProxyServer proxy;
|
||||
private final Logger logger;
|
||||
private final Path pluginDirectory;
|
||||
private AuthmeVelocityAPI api;
|
||||
private AuthMeConfig config;
|
||||
|
||||
private final List<Object> listeners = new ArrayList<>(3);
|
||||
@ -61,7 +82,7 @@ public class AuthMeVelocityPlugin {
|
||||
proxy.getChannelRegistrar().register(AUTHMEVELOCITY_CHANNEL);
|
||||
|
||||
if (proxy.getPluginManager().isLoaded("miniplaceholders")) {
|
||||
AuthmePlaceholders.getExpansion(this).register();
|
||||
AuthMePlaceholders.getExpansion(this).register();
|
||||
}
|
||||
|
||||
AuthmeCommand.register(this, proxy.getCommandManager());
|
||||
@ -73,10 +94,6 @@ public class AuthMeVelocityPlugin {
|
||||
return this.proxy;
|
||||
}
|
||||
|
||||
public AuthmeVelocityAPI getAPI(){
|
||||
return this.api;
|
||||
}
|
||||
|
||||
private Toml loadConfig(Path path){
|
||||
try {
|
||||
if (Files.notExists(path)) {
|
||||
@ -107,17 +124,16 @@ public class AuthMeVelocityPlugin {
|
||||
}
|
||||
|
||||
this.config = new AuthMeConfig(toml);
|
||||
this.api = new AuthmeVelocityAPI(this, config);
|
||||
|
||||
listeners.forEach(listener -> proxy.getEventManager().unregisterListener(this, listener));
|
||||
listeners.clear();
|
||||
|
||||
listeners.add(new ProxyListener(config, api));
|
||||
listeners.add(new ConnectListener(config, api, proxy, logger));
|
||||
listeners.add(new PluginMessageListener(proxy, logger, config, api));
|
||||
listeners.add(new ProxyListener(config, this));
|
||||
listeners.add(new ConnectListener(config, this, proxy, logger));
|
||||
listeners.add(new PluginMessageListener(proxy, logger, config, this));
|
||||
|
||||
if (proxy.getPluginManager().isLoaded("fastlogin")) {
|
||||
listeners.add(new FastLoginListener(proxy, api));
|
||||
listeners.add(new FastLoginListener(proxy, this));
|
||||
}
|
||||
|
||||
listeners.forEach(listener -> proxy.getEventManager().register(this, listener));
|
||||
@ -135,4 +151,49 @@ public class AuthMeVelocityPlugin {
|
||||
"<gray>LobbyServers: <green>" + config.getToServerOptions().getTeleportServers()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogged(Player player){
|
||||
return loggedPlayers.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotLogged(Player player){
|
||||
return !loggedPlayers.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPlayer(Player player){
|
||||
return loggedPlayers.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePlayer(Player player){
|
||||
return loggedPlayers.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayerIf(Predicate<Player> predicate){
|
||||
loggedPlayers.removeIf(uuid -> predicate.test(getProxy().getPlayer(uuid).orElse(null)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInAuthServer(Player player){
|
||||
return player.getCurrentServer().map(this::isAuthServer).orElse(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthServer(RegisteredServer server){
|
||||
return config.getAuthServers().contains(server.getServerInfo().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthServer(ServerConnection connection){
|
||||
return config.getAuthServers().contains(connection.getServerInfo().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthServer(String server){
|
||||
return config.getAuthServers().contains(server);
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.glyart.authmevelocity.proxy.commands;
|
||||
package me.adrianed.authmevelocity.velocity.commands;
|
||||
|
||||
import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
@ -9,6 +8,7 @@ import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.command.CommandMeta;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
|
||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
public class AuthmeCommand {
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.proxy.config;
|
||||
package me.adrianed.authmevelocity.velocity.config;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.proxy.config;
|
||||
package me.adrianed.authmevelocity.velocity.config;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.proxy.event;
|
||||
package me.adrianed.authmevelocity.velocity.event;
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.proxy.event;
|
||||
package me.adrianed.authmevelocity.velocity.event;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.proxy.event;
|
||||
package me.adrianed.authmevelocity.velocity.event;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.proxy.event;
|
||||
package me.adrianed.authmevelocity.velocity.event;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.proxy.event;
|
||||
package me.adrianed.authmevelocity.velocity.event;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.proxy.event;
|
||||
package me.adrianed.authmevelocity.velocity.event;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
@ -1,13 +1,11 @@
|
||||
package com.glyart.authmevelocity.proxy.listener;
|
||||
package me.adrianed.authmevelocity.velocity.listener;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
|
||||
import com.glyart.authmevelocity.proxy.AuthmeVelocityAPI;
|
||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
||||
import me.adrianed.authmevelocity.velocity.config.AuthMeConfig;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.velocitypowered.api.event.Continuation;
|
||||
@ -20,13 +18,16 @@ import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
|
||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityAPI;
|
||||
|
||||
public class ConnectListener {
|
||||
private final ProxyServer proxy;
|
||||
private final Logger logger;
|
||||
private final AuthMeConfig config;
|
||||
private final AuthmeVelocityAPI api;
|
||||
private final AuthMeVelocityAPI api;
|
||||
|
||||
public ConnectListener(AuthMeConfig config, AuthmeVelocityAPI api, ProxyServer proxy, Logger logger) {
|
||||
public ConnectListener(AuthMeConfig config, AuthMeVelocityAPI api, ProxyServer proxy, Logger logger) {
|
||||
this.config = config;
|
||||
this.api = api;
|
||||
this.logger = logger;
|
@ -1,14 +1,15 @@
|
||||
package com.glyart.authmevelocity.proxy.listener;
|
||||
package me.adrianed.authmevelocity.velocity.listener;
|
||||
|
||||
import com.github.games647.fastlogin.velocity.event.VelocityFastLoginAutoLoginEvent;
|
||||
import com.glyart.authmevelocity.proxy.AuthmeVelocityAPI;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
|
||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityAPI;
|
||||
|
||||
public class FastLoginListener {
|
||||
private final ProxyServer server;
|
||||
private final AuthmeVelocityAPI api;
|
||||
public FastLoginListener(ProxyServer server, AuthmeVelocityAPI api){
|
||||
private final AuthMeVelocityAPI api;
|
||||
public FastLoginListener(ProxyServer server, AuthMeVelocityAPI api){
|
||||
this.server = server;
|
||||
this.api = api;
|
||||
}
|
@ -1,17 +1,15 @@
|
||||
package com.glyart.authmevelocity.proxy.listener;
|
||||
package me.adrianed.authmevelocity.velocity.listener;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
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.PreSendOnLoginEvent;
|
||||
import com.glyart.authmevelocity.proxy.event.ProxyForcedUnregisterEvent;
|
||||
import com.glyart.authmevelocity.proxy.event.ProxyLoginEvent;
|
||||
import com.glyart.authmevelocity.proxy.event.ProxyLogoutEvent;
|
||||
import com.glyart.authmevelocity.proxy.event.ProxyRegisterEvent;
|
||||
import com.glyart.authmevelocity.proxy.event.ProxyUnregisterEvent;
|
||||
import me.adrianed.authmevelocity.velocity.config.AuthMeConfig;
|
||||
import me.adrianed.authmevelocity.velocity.event.PreSendOnLoginEvent;
|
||||
import me.adrianed.authmevelocity.velocity.event.ProxyForcedUnregisterEvent;
|
||||
import me.adrianed.authmevelocity.velocity.event.ProxyLoginEvent;
|
||||
import me.adrianed.authmevelocity.velocity.event.ProxyLogoutEvent;
|
||||
import me.adrianed.authmevelocity.velocity.event.ProxyRegisterEvent;
|
||||
import me.adrianed.authmevelocity.velocity.event.ProxyUnregisterEvent;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.velocitypowered.api.event.Continuation;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
@ -23,6 +21,9 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
|
||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityAPI;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
@ -32,9 +33,9 @@ public class PluginMessageListener {
|
||||
private final Logger logger;
|
||||
private final Random rm;
|
||||
private final AuthMeConfig config;
|
||||
private final AuthmeVelocityAPI api;
|
||||
private final AuthMeVelocityAPI api;
|
||||
|
||||
public PluginMessageListener(@NotNull ProxyServer proxy, @NotNull Logger logger, @NotNull AuthMeConfig config, AuthmeVelocityAPI api) {
|
||||
public PluginMessageListener(@NotNull ProxyServer proxy, @NotNull Logger logger, @NotNull AuthMeConfig config, AuthMeVelocityAPI api) {
|
||||
this.proxy = proxy;
|
||||
this.logger = logger;
|
||||
this.rm = new Random();
|
@ -1,9 +1,8 @@
|
||||
package com.glyart.authmevelocity.proxy.listener;
|
||||
package me.adrianed.authmevelocity.velocity.listener;
|
||||
|
||||
import com.glyart.authmevelocity.proxy.AuthmeVelocityAPI;
|
||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
||||
import com.glyart.authmevelocity.proxy.config.ConfigUtils;
|
||||
import com.glyart.authmevelocity.proxy.utils.AuthmeUtils;
|
||||
import me.adrianed.authmevelocity.velocity.config.AuthMeConfig;
|
||||
import me.adrianed.authmevelocity.velocity.config.ConfigUtils;
|
||||
import me.adrianed.authmevelocity.velocity.utils.AuthmeUtils;
|
||||
import com.velocitypowered.api.event.Continuation;
|
||||
import com.velocitypowered.api.event.EventTask;
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
@ -14,13 +13,15 @@ import com.velocitypowered.api.event.player.PlayerChatEvent;
|
||||
import com.velocitypowered.api.event.player.TabCompleteEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityAPI;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class ProxyListener {
|
||||
private final AuthMeConfig config;
|
||||
private final AuthmeVelocityAPI api;
|
||||
private final AuthMeVelocityAPI api;
|
||||
|
||||
public ProxyListener(@NotNull AuthMeConfig config, AuthmeVelocityAPI api) {
|
||||
public ProxyListener(@NotNull AuthMeConfig config, AuthMeVelocityAPI api) {
|
||||
this.config = config;
|
||||
this.api = api;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.glyart.authmevelocity.proxy.utils;
|
||||
package me.adrianed.authmevelocity.velocity.utils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
Loading…
x
Reference in New Issue
Block a user