refactor(api): Implement API modules
This commit is contained in:
parent
07c6bc99eb
commit
23faeb5ab4
3
api/paper/build.gradle.kts
Normal file
3
api/paper/build.gradle.kts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dependencies {
|
||||||
|
compileOnly("io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT")
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package me.adrianed.authmevelocity.paper.events;
|
package me.adrianed.authmevelocity.api.paper.event;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
5
api/paper/src/main/java/module-info.java
Normal file
5
api/paper/src/main/java/module-info.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module me.adrianed.authmevelocity.api.paper {
|
||||||
|
requires static transitive org.bukkit;
|
||||||
|
requires static org.jetbrains.annotations;
|
||||||
|
exports me.adrianed.authmevelocity.api.paper.event;
|
||||||
|
}
|
3
api/velocity/build.gradle.kts
Normal file
3
api/velocity/build.gradle.kts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dependencies {
|
||||||
|
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||||
|
}
|
@ -1,8 +1,7 @@
|
|||||||
package me.adrianed.authmevelocity.velocity;
|
package me.adrianed.authmevelocity.api.velocity;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import me.adrianed.authmevelocity.velocity.config.AuthMeConfig;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
@ -12,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* API provided to interact with logged players
|
* API provided to interact with logged players
|
||||||
*/
|
*/
|
||||||
public sealed interface AuthMeVelocityAPI permits AuthMeVelocityPlugin {
|
public interface AuthMeVelocityAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the player is logged in or not
|
* Check if the player is logged in or not
|
@ -1,4 +1,4 @@
|
|||||||
package me.adrianed.authmevelocity.velocity.event;
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package me.adrianed.authmevelocity.velocity.event;
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package me.adrianed.authmevelocity.velocity.event;
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package me.adrianed.authmevelocity.velocity.event;
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package me.adrianed.authmevelocity.velocity.event;
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package me.adrianed.authmevelocity.velocity.event;
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
6
api/velocity/src/main/java/module-info.java
Normal file
6
api/velocity/src/main/java/module-info.java
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module me.adrianed.authmevelocity.api.velocity {
|
||||||
|
requires static transitive com.velocitypowered.api;
|
||||||
|
requires static org.jetbrains.annotations;
|
||||||
|
exports me.adrianed.authmevelocity.api.velocity;
|
||||||
|
exports me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
}
|
@ -15,6 +15,8 @@ allprojects {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
shadow(project(":authmevelocity-common"))
|
shadow(project(":authmevelocity-common"))
|
||||||
|
shadow(project(":authmevelocity-api-paper"))
|
||||||
|
shadow(project(":authmevelocity-api-velocity"))
|
||||||
shadow(project(":authmevelocity-velocity"))
|
shadow(project(":authmevelocity-velocity"))
|
||||||
shadow(project(":authmevelocity-paper"))
|
shadow(project(":authmevelocity-paper"))
|
||||||
}
|
}
|
||||||
|
4
common/src/main/java/module-info.java
Normal file
4
common/src/main/java/module-info.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
module me.adrianed.authmevelocity.common {
|
||||||
|
exports me.adrianed.authmevelocity.common;
|
||||||
|
exports me.adrianed.authmevelocity.common.configuration;
|
||||||
|
}
|
@ -12,11 +12,12 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compileOnly(project(":authmevelocity-common"))
|
||||||
|
compileOnly(project(":authmevelocity-api-paper"))
|
||||||
compileOnly("io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("fr.xephi:authme:5.6.0-SNAPSHOT")
|
compileOnly("fr.xephi:authme:5.6.0-SNAPSHOT")
|
||||||
compileOnly("com.github.4drian3d:MiniPlaceholders:1.1.1")
|
compileOnly("com.github.4drian3d:MiniPlaceholders:1.1.1")
|
||||||
shadow("net.byteflux:libby-bukkit:1.1.5")
|
shadow("net.byteflux:libby-bukkit:1.1.5")
|
||||||
compileOnly(project(":authmevelocity-common"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bukkit {
|
bukkit {
|
||||||
|
@ -10,7 +10,7 @@ import net.kyori.adventure.text.minimessage.tag.Tag;
|
|||||||
import static me.dreamerzero.miniplaceholders.api.utils.Components.*;
|
import static me.dreamerzero.miniplaceholders.api.utils.Components.*;
|
||||||
|
|
||||||
final class AuthmePlaceholders {
|
final class AuthmePlaceholders {
|
||||||
private AuthmePlaceholders(){}
|
private AuthmePlaceholders() {}
|
||||||
|
|
||||||
static Expansion getExpansion(){
|
static Expansion getExpansion(){
|
||||||
return Expansion.builder("authme")
|
return Expansion.builder("authme")
|
||||||
@ -23,7 +23,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 name").value();
|
String playerName = queue.popOr("you need to provide a player name").value();
|
||||||
Player player = Bukkit.getPlayer(playerName);
|
Player player = Bukkit.getPlayer(playerName);
|
||||||
if(player == null) return Tag.selfClosingInserting(FALSE_COMPONENT);
|
if (player == null) return Tag.selfClosingInserting(FALSE_COMPONENT);
|
||||||
return Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated(player)
|
return Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated(player)
|
||||||
? TRUE_COMPONENT
|
? TRUE_COMPONENT
|
||||||
: FALSE_COMPONENT);
|
: FALSE_COMPONENT);
|
||||||
|
@ -2,7 +2,7 @@ package me.adrianed.authmevelocity.paper.listeners;
|
|||||||
|
|
||||||
import me.adrianed.authmevelocity.paper.AuthMeVelocityPlugin;
|
import me.adrianed.authmevelocity.paper.AuthMeVelocityPlugin;
|
||||||
import me.adrianed.authmevelocity.common.MessageType;
|
import me.adrianed.authmevelocity.common.MessageType;
|
||||||
import me.adrianed.authmevelocity.paper.events.PreSendLoginEvent;
|
import me.adrianed.authmevelocity.api.paper.event.PreSendLoginEvent;
|
||||||
|
|
||||||
import fr.xephi.authme.events.LoginEvent;
|
import fr.xephi.authme.events.LoginEvent;
|
||||||
import fr.xephi.authme.events.LogoutEvent;
|
import fr.xephi.authme.events.LogoutEvent;
|
||||||
|
@ -3,4 +3,9 @@ rootProject.name = "authmevelocity-parent"
|
|||||||
listOf("common", "paper", "velocity").forEach {
|
listOf("common", "paper", "velocity").forEach {
|
||||||
include("authmevelocity-$it")
|
include("authmevelocity-$it")
|
||||||
project(":authmevelocity-$it").projectDir = file(it)
|
project(":authmevelocity-$it").projectDir = file(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
listOf("paper", "velocity").forEach {
|
||||||
|
include("authmevelocity-api-$it")
|
||||||
|
project(":authmevelocity-api-$it").projectDir = file("api/$it")
|
||||||
}
|
}
|
@ -15,6 +15,7 @@ dependencies {
|
|||||||
compileOnly("com.github.games647:fastlogin.velocity:1.11-SNAPSHOT")
|
compileOnly("com.github.games647:fastlogin.velocity:1.11-SNAPSHOT")
|
||||||
shadow("net.byteflux:libby-velocity:1.1.5")
|
shadow("net.byteflux:libby-velocity:1.1.5")
|
||||||
compileOnly(project(":authmevelocity-common"))
|
compileOnly(project(":authmevelocity-common"))
|
||||||
|
compileOnly(project(":authmevelocity-api-velocity"))
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.compileJava {
|
tasks.compileJava {
|
||||||
|
@ -6,6 +6,7 @@ import me.adrianed.authmevelocity.velocity.listener.ConnectListener;
|
|||||||
import me.adrianed.authmevelocity.velocity.listener.FastLoginListener;
|
import me.adrianed.authmevelocity.velocity.listener.FastLoginListener;
|
||||||
import me.adrianed.authmevelocity.velocity.listener.PluginMessageListener;
|
import me.adrianed.authmevelocity.velocity.listener.PluginMessageListener;
|
||||||
import me.adrianed.authmevelocity.velocity.listener.ProxyListener;
|
import me.adrianed.authmevelocity.velocity.listener.ProxyListener;
|
||||||
|
import me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.moandjiezana.toml.Toml;
|
import com.moandjiezana.toml.Toml;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
|
@ -19,7 +19,7 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
|||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
|
||||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityAPI;
|
import me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
|
||||||
|
|
||||||
public class ConnectListener {
|
public class ConnectListener {
|
||||||
private final ProxyServer proxy;
|
private final ProxyServer proxy;
|
||||||
|
@ -4,7 +4,7 @@ import com.github.games647.fastlogin.velocity.event.VelocityFastLoginAutoLoginEv
|
|||||||
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 me.adrianed.authmevelocity.velocity.AuthMeVelocityAPI;
|
import me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
|
||||||
|
|
||||||
public class FastLoginListener {
|
public class FastLoginListener {
|
||||||
private final ProxyServer server;
|
private final ProxyServer server;
|
||||||
|
@ -4,12 +4,12 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import me.adrianed.authmevelocity.velocity.config.AuthMeConfig;
|
import me.adrianed.authmevelocity.velocity.config.AuthMeConfig;
|
||||||
import me.adrianed.authmevelocity.velocity.event.PreSendOnLoginEvent;
|
import me.adrianed.authmevelocity.api.velocity.event.PreSendOnLoginEvent;
|
||||||
import me.adrianed.authmevelocity.velocity.event.ProxyForcedUnregisterEvent;
|
import me.adrianed.authmevelocity.api.velocity.event.ProxyForcedUnregisterEvent;
|
||||||
import me.adrianed.authmevelocity.velocity.event.ProxyLoginEvent;
|
import me.adrianed.authmevelocity.api.velocity.event.ProxyLoginEvent;
|
||||||
import me.adrianed.authmevelocity.velocity.event.ProxyLogoutEvent;
|
import me.adrianed.authmevelocity.api.velocity.event.ProxyLogoutEvent;
|
||||||
import me.adrianed.authmevelocity.velocity.event.ProxyRegisterEvent;
|
import me.adrianed.authmevelocity.api.velocity.event.ProxyRegisterEvent;
|
||||||
import me.adrianed.authmevelocity.velocity.event.ProxyUnregisterEvent;
|
import me.adrianed.authmevelocity.api.velocity.event.ProxyUnregisterEvent;
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.velocitypowered.api.event.Continuation;
|
import com.velocitypowered.api.event.Continuation;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
@ -22,7 +22,7 @@ import com.velocitypowered.api.proxy.ServerConnection;
|
|||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
|
||||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityAPI;
|
import me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -13,7 +13,7 @@ import com.velocitypowered.api.event.player.PlayerChatEvent;
|
|||||||
import com.velocitypowered.api.event.player.TabCompleteEvent;
|
import com.velocitypowered.api.event.player.TabCompleteEvent;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
import me.adrianed.authmevelocity.velocity.AuthMeVelocityAPI;
|
import me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user