This commit is contained in:
RedGuy 2024-12-19 17:12:04 +03:00
parent ea1362eeb9
commit 9ae4ee76cf
16 changed files with 57 additions and 46 deletions

View File

@ -10,10 +10,10 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 16
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 16
distribution: 'temurin'
cache: 'gradle'

View File

@ -8,7 +8,7 @@ This plugin adds the support for [Velocity](https://velocitypowered.com/) to [Au
## Requirements
- Paper or Folia 1.20+
- Velocity 3.3.0+
- Java 17+
- Java 16+
## Features
- Prevent your players from executing commands or typing in the chat before they are logged in

View File

@ -5,6 +5,7 @@ plugins {
dependencies {
compileOnly(libs.paper)
compileOnly(libs.annotations)
}
tasks {

View File

@ -37,7 +37,7 @@ public final class LoginByProxyEvent extends PlayerEvent {
* @param who the player to be logged in
*/
public LoginByProxyEvent(@NotNull Player who) {
super(who, !Bukkit.isPrimaryThread());
super(who);
}
@Override

View File

@ -37,7 +37,7 @@ public final class PreSendLoginEvent extends PlayerEvent implements Cancellable
* @param player the player to be sent
*/
public PreSendLoginEvent(@NotNull Player player) {
super(player, !Bukkit.isPrimaryThread());
super(player);
}
@Override
@ -50,6 +50,11 @@ public final class PreSendLoginEvent extends PlayerEvent implements Cancellable
this.isCancelled = cancelled;
}
public boolean callEvent() {
Bukkit.getPluginManager().callEvent(this);
return !isCancelled();
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;

View File

@ -14,6 +14,6 @@ repositories {
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(16))
}
}

View File

@ -3,10 +3,10 @@ allprojects {
tasks.withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
options.release.set(17)
options.release.set(16)
}
configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
toolchain.languageVersion.set(JavaLanguageVersion.of(16))
}
}

View File

@ -2,9 +2,9 @@ metadata.format.version = "1.1"
[versions]
velocity = "3.3.0-SNAPSHOT"
paper = "1.20.4-R0.1-SNAPSHOT"
miniplaceholders = "2.2.3"
velocity = "3.1.0"
spigot = "1.16.5-R0.1-SNAPSHOT"
miniplaceholders = "2.0.0"
fastlogin = "1.12-SNAPSHOT"
authme = "5.6.0"
libby = "1.3.1"
@ -12,13 +12,14 @@ pluginyml = "0.6.0"
bstats = "3.0.3"
shadow = "8.1.1"
configurate = "4.1.2"
adventure = "4.17.0"
adventure = "4.11.0"
blossom = "2.1.0"
geantyref = "1.3.13"
indra = "3.1.3"
runtask = "2.3.1"
vpacketevents = "1.1.0"
vpacketevents = "1.0.1"
luckperms = "5.4"
annotations = "26.0.1"
# Test versions
assertj = "3.26.3"
@ -26,19 +27,18 @@ assertj = "3.26.3"
[libraries]
adventure = { group = "net.kyori", name = "adventure-api", version.ref = "adventure" }
minimessage = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "adventure" }
logger-slf4j = { group = "net.kyori", name = "adventure-text-logger-slf4j", version.ref = "adventure" }
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
paper = { group = "org.spigotmc", name = "spigot-api", version.ref = "spigot" }
velocity-api = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
velocity-proxy = { group = "com.velocitypowered", name = "velocity-proxy", version.ref = "velocity" }
authme = { module = "fr.xephi:authme", version.ref = "authme" }
libby-core = { group = "net.byteflux", name = "libby-core", version.ref = "libby" }
libby-bukkit = { group = "net.byteflux", name = "libby-bukkit", version.ref = "libby" }
libby-paper = { group = "net.byteflux", name = "libby-paper", version.ref = "libby" }
libby-velocity = { group = "net.byteflux", name = "libby-velocity", version.ref = "libby" }
miniplaceholders = { group = "io.github.miniplaceholders", name = "miniplaceholders-api", version.ref = "miniplaceholders" }
vpacketevents = { group = "io.github.4drian3d", name = "vpacketevents-api", version.ref = "vpacketevents" }
luckperms = { module = "net.luckperms:api", version.ref = "luckperms" }
fastlogin-velocity = { group = "com.github.games647", name = "fastlogin.velocity", version.ref = "fastlogin" }
@ -52,6 +52,8 @@ plugin-shadow = { group = "com.github.johnrengelman", name = "shadow", version.r
assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" }
annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" }
[plugins]
pluginyml-bukkit = { id = "net.minecrell.plugin-yml.bukkit", version.ref = "pluginyml" }

View File

@ -12,8 +12,11 @@ dependencies {
implementation(projects.authmevelocityCommon)
implementation(projects.authmevelocityApiPaper)
implementation(libs.minimessage)
implementation(libs.logger.slf4j)
implementation(libs.adventure)
implementation(libs.libby.paper)
implementation(libs.libby.bukkit)
}
tasks {
@ -29,10 +32,10 @@ tasks {
dependsOn(shadowJar)
}
runServer {
minecraftVersion("1.20.4")
minecraftVersion("1.16.5")
}
processResources {
filesMatching("paper-plugin.yml") {
filesMatching("plugin.yml") {
expand("version" to project.version)
}
}

View File

@ -31,7 +31,7 @@ final class AuthMePlaceholders {
static Expansion getExpansion() {
return Expansion.builder("authme")
.filter(Player.class)
.filter((s) -> s instanceof Player)
.audiencePlaceholder("is_logged", (aud, queue, ctx) ->
Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated((Player)aud)
? TRUE_COMPONENT

View File

@ -17,21 +17,9 @@
package io.github._4drian3d.authmevelocity.paper;
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
import io.papermc.paper.plugin.bootstrap.PluginProviderContext;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("all")
public class AuthMeVelocityBootstrap implements PluginBootstrap {
@Override
public void bootstrap(@NotNull BootstrapContext context) {
public class AuthMeVelocityBootstrap extends JavaPlugin {
}
@Override
public @NotNull JavaPlugin createPlugin(@NotNull PluginProviderContext context) {
return new AuthMeVelocityPlugin(context.getDataDirectory());
}
}

View File

@ -19,21 +19,29 @@ package io.github._4drian3d.authmevelocity.paper;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.google.common.reflect.ClassPath;
import io.github._4drian3d.authmevelocity.common.LibsManager;
import io.github._4drian3d.authmevelocity.common.MessageType;
import io.github._4drian3d.authmevelocity.common.configuration.ConfigurationContainer;
import io.github._4drian3d.authmevelocity.common.configuration.PaperConfiguration;
import io.github._4drian3d.authmevelocity.paper.listeners.AuthMeListener;
import io.github._4drian3d.authmevelocity.paper.listeners.MessageListener;
import net.byteflux.libby.BukkitLibraryManager;
import net.byteflux.libby.LibraryManager;
import net.byteflux.libby.PaperLibraryManager;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Path;
import java.util.Set;
import java.util.stream.Collectors;
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
@ -43,14 +51,14 @@ public final class AuthMeVelocityPlugin extends JavaPlugin {
private ComponentLogger componentLogger;
private ConfigurationContainer<PaperConfiguration> config;
public AuthMeVelocityPlugin(final Path dataFolder) {
this.dataFolder = dataFolder;
public AuthMeVelocityPlugin() {
this.dataFolder = getDataFolder().toPath();
}
@Override
public void onEnable() {
this.componentLogger = getComponentLogger();
final LibraryManager libraryManager = new PaperLibraryManager(this);
this.componentLogger = ComponentLogger.logger();
final LibraryManager libraryManager = new BukkitLibraryManager(this);
new LibsManager(libraryManager).loadLibraries();
try {
@ -71,6 +79,11 @@ public final class AuthMeVelocityPlugin extends JavaPlugin {
AuthMePlaceholders.getExpansion().register();
}
Set<Class<?>> classes;
String packageName = "net.kyori.adventure.text";
Class c = Component.class;
componentLogger.info(miniMessage().deserialize("<gradient:aqua:dark_aqua>AuthMeVelocity</gradient> <aqua>enabled"));
}

View File

@ -40,12 +40,12 @@ public final class AuthMeListener implements Listener {
final Player player = event.getPlayer();
plugin.logDebug("LoginEvent | Start");
plugin.getServer().getAsyncScheduler().runDelayed(plugin, task -> {
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, task -> {
if (new PreSendLoginEvent(player).callEvent()) {
plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName());
plugin.logDebug("LoginEvent | PreSendLoginEvent allowed");
}
}, 1, TimeUnit.SECONDS);
}, 20);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -53,12 +53,12 @@ public final class AuthMeListener implements Listener {
final Player player = event.getPlayer();
plugin.logDebug("RestoreSessionEvent | Start");
plugin.getServer().getAsyncScheduler().runDelayed(plugin, task -> {
plugin.getServer().getScheduler().runTaskLater(plugin, task -> {
if (new PreSendLoginEvent(player).callEvent()) {
plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName());
plugin.logDebug("RestoreSessionEvent | PreSendLoginEvent allowed");
}
}, 1, TimeUnit.SECONDS);
}, 20);
}
@EventHandler

View File

@ -7,7 +7,7 @@ authors:
- xQuickGlare
- 4drian3d
website: https://modrinth.com/plugin/authmevelocity
api-version: '1.20'
api-version: '1.16'
folia-supported: true
dependencies:
server:

View File

@ -39,5 +39,6 @@ dependencyResolutionManagement {
includeGroup("net.byteflux")
}
}
mavenCentral()
}
}

View File

@ -6,12 +6,10 @@ plugins {
dependencies {
compileOnly(libs.velocity.api)
compileOnly(libs.velocity.proxy)
annotationProcessor(libs.velocity.api)
compileOnly(libs.miniplaceholders)
compileOnly(libs.fastlogin.velocity)
compileOnly(libs.vpacketevents)
compileOnly(libs.luckperms)
implementation(projects.authmevelocityCommon)