fix: Fixed Session Support and removed legacy support

This commit is contained in:
Adrian 2023-12-18 21:53:29 -05:00
parent e7c246bc1f
commit 9d452e6c32
No known key found for this signature in database
GPG Key ID: FB8EF84DCE1BE452
16 changed files with 77 additions and 132 deletions

View File

@ -12,9 +12,9 @@ tasks {
(options as StandardJavadocDocletOptions).run {
encoding = Charsets.UTF_8.name()
links(
"https://jd.advntr.dev/api/4.12.0/",
"https://jd.advntr.dev/text-minimessage/4.12.0/",
"https://jd.papermc.io/paper/1.19/"
"https://jd.advntr.dev/api/${libs.versions.adventure.get()}/",
"https://jd.advntr.dev/text-minimessage/${libs.versions.adventure.get()}/",
"https://jd.papermc.io/paper/1.20/"
)
}
}

View File

@ -17,6 +17,7 @@
package io.github._4drian3d.authmevelocity.api.paper.event;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@ -36,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);
super(player, !Bukkit.isPrimaryThread());
}
@Override

View File

@ -1,10 +1,6 @@
allprojects {
apply<JavaPlugin>()
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
tasks.withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
options.release.set(17)

View File

@ -4,10 +4,6 @@ plugins {
id("authmevelocity.spotless")
}
repositories {
maven("https://repo.alessiodp.com/releases/")
}
dependencies {
compileOnly(libs.configurate.hocon)
compileOnly(libs.libby.core)

View File

@ -1,5 +1,5 @@
group = io.github.4drian3d
version = 4.0.5-SNAPSHOT
version = 4.1.0-SNAPSHOT
description = AuthMeReloaded Support for Velocity
url = https://modrinth.com/plugin/authmevelocity
id = authmevelocity

View File

@ -2,8 +2,8 @@ metadata.format.version = "1.1"
[versions]
velocity = "3.2.0-SNAPSHOT"
paper = "1.20-R0.1-SNAPSHOT"
velocity = "3.3.0-SNAPSHOT"
paper = "1.20.4-R0.1-SNAPSHOT"
miniplaceholders = "2.2.3"
fastlogin = "1.12-SNAPSHOT"
authme = "5.6.0-SNAPSHOT"
@ -29,7 +29,7 @@ adventure = { group = "net.kyori", name = "adventure-api", version.ref = "advent
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
velocity-api = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" }
velocity-proxy = { group = "com.velocitypowered", name = "velocity-proxy", version.ref = "velocity" }
velocity-proxy = { group = "com.velocitypowered", name = "velocity-proxy", version = "3.2.0-SNAPSHOT" }
authme = { module = "fr.xephi:authme", version.ref = "authme" }
libby-core = { group = "net.byteflux", name = "libby-core", version.ref = "libby" }

View File

@ -4,19 +4,6 @@ plugins {
id("authmevelocity.spotless")
}
repositories {
maven("https://repo.codemc.org/repository/maven-public/") {
mavenContent {
includeGroup("fr.xephi")
}
}
maven("https://repo.alessiodp.com/releases/"){
mavenContent {
includeGroup("net.byteflux")
}
}
}
dependencies {
compileOnly(libs.paper)
compileOnly(libs.authme)
@ -26,7 +13,6 @@ dependencies {
implementation(projects.authmevelocityCommon)
implementation(projects.authmevelocityApiPaper)
implementation(libs.libby.bukkit)
implementation(libs.libby.paper)
}
@ -43,10 +29,10 @@ tasks {
dependsOn(shadowJar)
}
runServer {
minecraftVersion("1.19.4")
minecraftVersion("1.20.4")
}
processResources {
filesMatching(listOf("paper-plugin.yml", "plugin.yml")) {
filesMatching("paper-plugin.yml") {
expand("version" to project.version)
}
}

View File

@ -25,48 +25,38 @@ import io.github._4drian3d.authmevelocity.common.configuration.ConfigurationCont
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.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.nio.file.Path;
import java.util.logging.Level;
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
public final class AuthMeVelocityPlugin extends JavaPlugin {
private static final String CHANNEL = "authmevelocity:main";
private final Path dataFolder;
private ComponentLogger componentLogger;
private ConfigurationContainer<PaperConfiguration> config;
@SuppressWarnings("unused")
public AuthMeVelocityPlugin() {
this.dataFolder = getDataFolder().toPath();
}
public AuthMeVelocityPlugin(final Path dataFolder) {
this.dataFolder = dataFolder;
}
@Override
public void onEnable() {
LibraryManager libraryManager;
try {
Class.forName("io.papermc.paper.plugin.bootstrap.PluginBootstrap");
libraryManager = new PaperLibraryManager(this);
} catch (ClassNotFoundException e) {
libraryManager = new BukkitLibraryManager(this);
this.getLogger().warning("You are using Spigot or a very old version of the platform you are using."
+"\nIn the future AuthMeVelocity will no longer support this version. Consider upgrading to Paper 1.19.4+.");
}
this.componentLogger = getComponentLogger();
final LibraryManager libraryManager = new PaperLibraryManager(this);
new LibsManager(libraryManager).loadLibraries();
try {
this.config = ConfigurationContainer.load(dataFolder, PaperConfiguration.class);
} catch (Throwable e) {
this.getLogger().log(Level.SEVERE, "Could not load config.conf file", e);
componentLogger.error("Could not load config.conf file", e);
this.getServer().getPluginManager().disablePlugin(this);
return;
}
@ -81,7 +71,7 @@ public final class AuthMeVelocityPlugin extends JavaPlugin {
AuthMePlaceholders.getExpansion().register();
}
this.getLogger().info("AuthMeVelocity enabled");
componentLogger.info(miniMessage().deserialize("<gradient:aqua:dark_aqua>AuthMeVelocity</gradient> <aqua>enabled"));
}
@Override
@ -89,7 +79,7 @@ public final class AuthMeVelocityPlugin extends JavaPlugin {
this.getServer().getMessenger().unregisterOutgoingPluginChannel(this, CHANNEL);
this.getServer().getMessenger().unregisterIncomingPluginChannel(this, CHANNEL);
this.getLogger().info("AuthMeVelocity disabled");
componentLogger.info(miniMessage().deserialize("<gradient:aqua:dark_aqua>AuthMeVelocity</gradient> <red>disabled"));
}
public void sendMessageToProxy(
@ -97,16 +87,16 @@ public final class AuthMeVelocityPlugin extends JavaPlugin {
final @NotNull MessageType type,
final @NotNull String playerName
) {
@SuppressWarnings("UnstableApiUsage") final ByteArrayDataOutput out = ByteStreams.newDataOutput();
final ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(type.toString());
out.writeUTF(playerName);
if (player == null) {
logDebug("MessageToProxy | Null Player, Player Name: " + playerName);
Bukkit.getServer().sendPluginMessage(this, CHANNEL, out.toByteArray());
logDebug("MessageToProxy | Null Player, Player Name: " + playerName);
} else {
logDebug("MessageToProxy | Player Present: " + player.getName() + ", Player Name: " + playerName);
player.sendPluginMessage(this, CHANNEL, out.toByteArray());
logDebug("MessageToProxy | Player Present: " + player.getName() + ", Player Name: " + playerName);
}
}
@ -119,7 +109,7 @@ public final class AuthMeVelocityPlugin extends JavaPlugin {
public void logDebug(String debug) {
if (config.get().debug()) {
getLogger().info("[DEBUG] " + debug);
componentLogger.info("[DEBUG] " + debug);
}
}
}

View File

@ -21,16 +21,17 @@ import fr.xephi.authme.events.*;
import io.github._4drian3d.authmevelocity.api.paper.event.PreSendLoginEvent;
import io.github._4drian3d.authmevelocity.common.MessageType;
import io.github._4drian3d.authmevelocity.paper.AuthMeVelocityPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.util.concurrent.TimeUnit;
public final class AuthMeListener implements Listener {
private final AuthMeVelocityPlugin plugin;
public AuthMeListener(AuthMeVelocityPlugin plugin) {
public AuthMeListener(final AuthMeVelocityPlugin plugin) {
this.plugin = plugin;
}
@ -39,14 +40,12 @@ public final class AuthMeListener implements Listener {
final Player player = event.getPlayer();
plugin.logDebug("LoginEvent | Start");
// I hate this, but... Spigot compatibility ¯\_()_/¯
final var preSendLoginEvent = new PreSendLoginEvent(player);
Bukkit.getPluginManager().callEvent(preSendLoginEvent);
if (!preSendLoginEvent.isCancelled()) {
plugin.getServer().getAsyncScheduler().runDelayed(plugin, task -> {
if (new PreSendLoginEvent(player).callEvent()) {
plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName());
plugin.logDebug("LoginEvent | PreSendLoginEvent allowed");
}
}, 1, TimeUnit.SECONDS);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -54,14 +53,12 @@ public final class AuthMeListener implements Listener {
final Player player = event.getPlayer();
plugin.logDebug("RestoreSessionEvent | Start");
// I hate this, but... Spigot compatibility ¯\_()_/¯
final var preSendLoginEvent = new PreSendLoginEvent(player);
Bukkit.getPluginManager().callEvent(preSendLoginEvent);
if (!preSendLoginEvent.isCancelled()) {
plugin.getServer().getAsyncScheduler().runDelayed(plugin, task -> {
if (new PreSendLoginEvent(player).callEvent()) {
plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName());
plugin.logDebug("RestoreSessionEvent | PreSendLoginEvent allowed");
}
}, 1, TimeUnit.SECONDS);
}
@EventHandler

View File

@ -42,7 +42,6 @@ public final class MessageListener implements PluginMessageListener {
final byte @NotNull [] bytes
) {
if (identifier.equals("authmevelocity:main")) {
@SuppressWarnings("UnstableApiUsage")
final ByteArrayDataInput input = ByteStreams.newDataInput(bytes);
final String data = input.readUTF();

View File

@ -10,9 +10,10 @@ website: https://modrinth.com/plugin/authmevelocity
api-version: '1.19'
folia-supported: true
dependencies:
- name: MiniPlaceholders
server:
MiniPlaceholders:
required: false
bootstrap: false
- name: AuthMe
load: BEFORE
AuthMe:
required: true
bootstrap: false
load: BEFORE

View File

@ -1,14 +0,0 @@
name: AuthMeVelocity
version: "${version}"
main: io.github._4drian3d.authmevelocity.paper.AuthMeVelocityPlugin
description: AuthMeReloaded Support for Velocity
authors:
- xQuickGlare
- 4drian3d
website: https://modrinth.com/plugin/authmevelocity
depend:
- AuthMe
api-version: 1.13
folia-supported: true
softdepend:
- MiniPlaceholders

View File

@ -1,3 +1,4 @@
@file:Suppress("UnstableApiUsage")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
rootProject.name = "authmevelocity-parent"
@ -20,3 +21,23 @@ pluginManagement {
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://repo.codemc.org/repository/maven-public/") {
mavenContent {
includeGroup("com.github.games647")
includeGroup("fr.xephi")
}
}
maven("https://repo.alessiodp.com/releases/") {
mavenContent {
includeGroup("net.byteflux")
}
}
maven("https://maven.elytrium.net/repo/")
}
}

View File

@ -4,20 +4,6 @@ plugins {
id("authmevelocity.spotless")
}
repositories {
maven("https://repo.codemc.org/repository/maven-public/") {
mavenContent {
includeGroup("com.github.games647")
}
}
maven("https://repo.alessiodp.com/releases/") {
mavenContent {
includeGroup("net.byteflux")
}
}
maven("https://maven.elytrium.net/repo/")
}
dependencies {
compileOnly(libs.velocity.api)
compileOnly(libs.velocity.proxy)
@ -31,7 +17,6 @@ dependencies {
implementation(projects.authmevelocityCommon)
implementation(projects.authmevelocityApiVelocity)
implementation(libs.libby.velocity)
implementation(libs.bstats.velocity)
testImplementation(platform("org.junit:junit-bom:5.10.1"))
@ -47,9 +32,6 @@ tasks {
archiveClassifier.set("")
relocate("org.bstats", "io.github._4drian3d.authmevelocity.libs.bstats")
relocate("net.byteflux.libby", "io.github._4drian3d.authmevelocity.libs.libby")
relocate("org.spongepowered", "io.github._4drian3d.authmevelocity.libs.sponge")
relocate("io.leangen.geantyref", "io.github._4drian3d.authmevelocity.libs.geantyref")
}
build {
dependsOn(shadowJar)

View File

@ -19,7 +19,6 @@ package io.github._4drian3d.authmevelocity.velocity;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Dependency;
@ -35,7 +34,6 @@ import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import io.github._4drian3d.authmevelocity.api.velocity.AuthMeVelocityAPI;
import io.github._4drian3d.authmevelocity.common.Constants;
import io.github._4drian3d.authmevelocity.common.LibsManager;
import io.github._4drian3d.authmevelocity.common.configuration.ConfigurationContainer;
import io.github._4drian3d.authmevelocity.common.configuration.ProxyConfiguration;
import io.github._4drian3d.authmevelocity.velocity.commands.AuthMeCommand;
@ -52,12 +50,10 @@ import io.github._4drian3d.authmevelocity.velocity.listener.input.ChatListener;
import io.github._4drian3d.authmevelocity.velocity.listener.input.CommandListener;
import io.github._4drian3d.authmevelocity.velocity.listener.input.CompletionPacketListener;
import io.github._4drian3d.authmevelocity.velocity.listener.input.TabCompleteListener;
import net.byteflux.libby.VelocityLibraryManager;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
import org.bstats.charts.SimplePie;
import org.bstats.velocity.Metrics;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import java.nio.file.Path;
import java.util.Set;
@ -67,6 +63,8 @@ import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Stream;
import static net.kyori.adventure.text.minimessage.MiniMessage.miniMessage;
@Plugin(
id = "authmevelocity",
name = "AuthMeVelocity",
@ -103,7 +101,7 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
@Inject
private PluginManager pluginManager;
@Inject
private Logger logger;
private ComponentLogger logger;
@Inject
@DataDirectory
private Path pluginDirectory;
@ -117,12 +115,6 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
final LibsManager libraries
= new LibsManager(
new VelocityLibraryManager<>(
logger, pluginDirectory, pluginManager, this));
libraries.loadLibraries();
try {
this.config = ConfigurationContainer.load(pluginDirectory, ProxyConfiguration.class);
} catch (Exception e) {
@ -179,13 +171,10 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
}
public void sendInfoMessage() {
final CommandSource source = proxy.getConsoleCommandSource();
source.sendMessage(MiniMessage.miniMessage().deserialize(
" <gray>--- <aqua>AuthMeVelocity</aqua> ---"));
source.sendMessage(MiniMessage.miniMessage().deserialize(
"<gray>AuthServers: <green>" + config.get().authServers()));
logger.info(miniMessage().deserialize(" <gray>--- <gradient:aqua:dark_aqua>AuthMeVelocity</gradient> ---"));
logger.info(miniMessage().deserialize("<gray>AuthServers: <green>" + config.get().authServers()));
if (config.get().sendOnLogin().sendToServerOnLogin()) {
source.sendMessage(MiniMessage.miniMessage().deserialize(
logger.info(miniMessage().deserialize(
"<gray>LobbyServers: <green>" + config.get().sendOnLogin().teleportServers()));
}
}

View File

@ -57,8 +57,9 @@ public final class PluginMessageListener implements Listener<PluginMessageEvent>
@Override
public EventTask executeAsync(final PluginMessageEvent event) {
return EventTask.async(() -> {
plugin.logDebug(() -> "PluginMessageEvent | Start");
if (notAllowedEvent(event)) {
plugin.logDebug("PluginMessageEvent | Not allowed");
plugin.logDebug(() -> "PluginMessageEvent | Not allowed");
return;
}