refactor(api): Implement API modules

This commit is contained in:
Adrian3d04 2022-08-05 02:03:48 +00:00
parent 07c6bc99eb
commit 23faeb5ab4
24 changed files with 54 additions and 24 deletions

View File

@ -0,0 +1,3 @@
dependencies {
compileOnly("io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT")
}

View File

@ -1,4 +1,4 @@
package me.adrianed.authmevelocity.paper.events;
package me.adrianed.authmevelocity.api.paper.event;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

View 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;
}

View File

@ -0,0 +1,3 @@
dependencies {
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
}

View File

@ -1,8 +1,7 @@
package me.adrianed.authmevelocity.velocity;
package me.adrianed.authmevelocity.api.velocity;
import java.util.function.Predicate;
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,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
/**
* 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

View File

@ -1,4 +1,4 @@
package me.adrianed.authmevelocity.velocity.event;
package me.adrianed.authmevelocity.api.velocity.event;
import java.util.Objects;

View File

@ -1,4 +1,4 @@
package me.adrianed.authmevelocity.velocity.event;
package me.adrianed.authmevelocity.api.velocity.event;
import com.velocitypowered.api.proxy.Player;

View File

@ -1,4 +1,4 @@
package me.adrianed.authmevelocity.velocity.event;
package me.adrianed.authmevelocity.api.velocity.event;
import com.velocitypowered.api.proxy.Player;

View File

@ -1,4 +1,4 @@
package me.adrianed.authmevelocity.velocity.event;
package me.adrianed.authmevelocity.api.velocity.event;
import com.velocitypowered.api.proxy.Player;

View File

@ -1,4 +1,4 @@
package me.adrianed.authmevelocity.velocity.event;
package me.adrianed.authmevelocity.api.velocity.event;
import com.velocitypowered.api.proxy.Player;

View File

@ -1,4 +1,4 @@
package me.adrianed.authmevelocity.velocity.event;
package me.adrianed.authmevelocity.api.velocity.event;
import com.velocitypowered.api.proxy.Player;

View 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;
}

View File

@ -15,6 +15,8 @@ allprojects {
dependencies {
shadow(project(":authmevelocity-common"))
shadow(project(":authmevelocity-api-paper"))
shadow(project(":authmevelocity-api-velocity"))
shadow(project(":authmevelocity-velocity"))
shadow(project(":authmevelocity-paper"))
}

View File

@ -0,0 +1,4 @@
module me.adrianed.authmevelocity.common {
exports me.adrianed.authmevelocity.common;
exports me.adrianed.authmevelocity.common.configuration;
}

View File

@ -12,11 +12,12 @@ repositories {
}
dependencies {
compileOnly(project(":authmevelocity-common"))
compileOnly(project(":authmevelocity-api-paper"))
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 {

View File

@ -10,7 +10,7 @@ import net.kyori.adventure.text.minimessage.tag.Tag;
import static me.dreamerzero.miniplaceholders.api.utils.Components.*;
final class AuthmePlaceholders {
private AuthmePlaceholders(){}
private AuthmePlaceholders() {}
static Expansion getExpansion(){
return Expansion.builder("authme")
@ -23,7 +23,7 @@ final class AuthmePlaceholders {
.globalPlaceholder("is_player_logged", (queue, ctx) -> {
String playerName = queue.popOr("you need to provide a player name").value();
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)
? TRUE_COMPONENT
: FALSE_COMPONENT);

View File

@ -2,7 +2,7 @@ package me.adrianed.authmevelocity.paper.listeners;
import me.adrianed.authmevelocity.paper.AuthMeVelocityPlugin;
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.LogoutEvent;

View File

@ -3,4 +3,9 @@ rootProject.name = "authmevelocity-parent"
listOf("common", "paper", "velocity").forEach {
include("authmevelocity-$it")
project(":authmevelocity-$it").projectDir = file(it)
}
listOf("paper", "velocity").forEach {
include("authmevelocity-api-$it")
project(":authmevelocity-api-$it").projectDir = file("api/$it")
}

View File

@ -15,6 +15,7 @@ dependencies {
compileOnly("com.github.games647:fastlogin.velocity:1.11-SNAPSHOT")
shadow("net.byteflux:libby-velocity:1.1.5")
compileOnly(project(":authmevelocity-common"))
compileOnly(project(":authmevelocity-api-velocity"))
}
tasks.compileJava {

View File

@ -6,6 +6,7 @@ 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 me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
import com.google.inject.Inject;
import com.moandjiezana.toml.Toml;
import com.velocitypowered.api.command.CommandSource;

View File

@ -19,7 +19,7 @@ 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;
import me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
public class ConnectListener {
private final ProxyServer proxy;

View File

@ -4,7 +4,7 @@ import com.github.games647.fastlogin.velocity.event.VelocityFastLoginAutoLoginEv
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.proxy.ProxyServer;
import me.adrianed.authmevelocity.velocity.AuthMeVelocityAPI;
import me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
public class FastLoginListener {
private final ProxyServer server;

View File

@ -4,12 +4,12 @@ import java.util.List;
import java.util.Random;
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 me.adrianed.authmevelocity.api.velocity.event.PreSendOnLoginEvent;
import me.adrianed.authmevelocity.api.velocity.event.ProxyForcedUnregisterEvent;
import me.adrianed.authmevelocity.api.velocity.event.ProxyLoginEvent;
import me.adrianed.authmevelocity.api.velocity.event.ProxyLogoutEvent;
import me.adrianed.authmevelocity.api.velocity.event.ProxyRegisterEvent;
import me.adrianed.authmevelocity.api.velocity.event.ProxyUnregisterEvent;
import com.google.common.io.ByteArrayDataInput;
import com.velocitypowered.api.event.Continuation;
import com.velocitypowered.api.event.Subscribe;
@ -22,7 +22,7 @@ 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 me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@ -13,7 +13,7 @@ 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 me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
import org.jetbrains.annotations.NotNull;