diff --git a/build.gradle.kts b/build.gradle.kts index 73ebd29..a20e596 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,6 +5,10 @@ plugins { id("com.github.johnrengelman.shadow") version "7.1.2" } +repositories { + maven("https://repo.alessiodp.com/releases/") +} + allprojects { apply(plugin = "java") repositories { @@ -14,11 +18,11 @@ allprojects { } dependencies { - shadow(project(":authmevelocity-common")) + shadow(project(":authmevelocity-common", "shadow")) shadow(project(":authmevelocity-api-paper")) shadow(project(":authmevelocity-api-velocity")) - shadow(project(":authmevelocity-velocity")) - shadow(project(":authmevelocity-paper")) + shadow(project(":authmevelocity-velocity", "shadow")) + shadow(project(":authmevelocity-paper", "shadow")) } tasks { diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 76986fd..def6d9e 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,3 +1,7 @@ +plugins { + id("com.github.johnrengelman.shadow") version "7.1.2" +} + repositories { maven("https://repo.alessiodp.com/releases/") } @@ -7,4 +11,11 @@ dependencies { compileOnly("space.arim.dazzleconf:dazzleconf-ext-snakeyaml:1.3.0-M1") compileOnly("org.slf4j:slf4j-api:1.7.36") compileOnly("net.byteflux:libby-core:1.1.5") +} + +tasks { + shadowJar { + relocate("net.byteflux.libby", "me.adrianed.authmevelocity.libs.libby") + relocate("space.arim.dazzleconf", "me.adrianed.authmevelocity.libs.dazzleconf") + } } \ No newline at end of file diff --git a/common/src/main/java/me/adrianed/authmevelocity/common/LibsManager.java b/common/src/main/java/me/adrianed/authmevelocity/common/LibsManager.java index 5be73e6..22f5f7b 100644 --- a/common/src/main/java/me/adrianed/authmevelocity/common/LibsManager.java +++ b/common/src/main/java/me/adrianed/authmevelocity/common/LibsManager.java @@ -1,7 +1,48 @@ package me.adrianed.authmevelocity.common; -//TODO: Abstract Class -public interface LibsManager { - void registerRepositories(); - void loadLibraries(); +import net.byteflux.libby.Library; +import net.byteflux.libby.LibraryManager; +import net.byteflux.libby.relocation.Relocation; + + +public final class LibsManager { + private final LibraryManager manager; + + public LibsManager(LibraryManager manager) { + this.manager = manager; + manager.addMavenCentral(); + } + + public void loadLibraries() { + final String dazzlePackage = new String(new char[] { + 's','p','a','c','e','.','a','r','i','m','.','d','a','z','z','l','e','c','o','n','f'}); + final Relocation dazzleRelocation + = new Relocation(dazzlePackage, "me.adrianed.authmevelocity.libs.dazzleconf"); + final Relocation snakeYamlRelocation + = new Relocation("org.yaml.snakeyaml", "me.adrianed.authmevelocity.libs.snakeyaml"); + final Library dazzleConf = Library.builder() + .groupId(dazzlePackage) + .artifactId("dazzleconf-core") + .version("1.3.0-M1") + .relocate(dazzleRelocation) + .build(); + final Library dazzleYaml = Library.builder() + .groupId(dazzlePackage) + .artifactId("dazzleconf-ext-snakeyaml") + .version("1.3.0-M1") + .relocate(dazzleRelocation) + .relocate(snakeYamlRelocation) + .build(); + final Library snakeYaml = Library.builder() + .groupId("org.yaml") + .artifactId("snakeyaml") + .version("1.30") + .relocate(dazzleRelocation) + .relocate(snakeYamlRelocation) + .build(); + + manager.loadLibrary(snakeYaml); + manager.loadLibrary(dazzleConf); + manager.loadLibrary(dazzleYaml); + } } diff --git a/common/src/main/java/module-info.java b/common/src/main/java/module-info.java deleted file mode 100644 index 2151432..0000000 --- a/common/src/main/java/module-info.java +++ /dev/null @@ -1,5 +0,0 @@ -module me.adrianed.authmevelocity.common { - requires transitive space.arim.dazzleconf.ext.snakeyaml; - exports me.adrianed.authmevelocity.common; - exports me.adrianed.authmevelocity.common.configuration; -} diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts index 428bdab..2e9c852 100644 --- a/paper/build.gradle.kts +++ b/paper/build.gradle.kts @@ -35,13 +35,10 @@ tasks { shadowJar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE relocate("net.byteflux.libby", "me.adrianed.authmevelocity.libs.libby") + relocate("space.arim.dazzleconf", "me.adrianed.authmevelocity.libs.dazzleconf") configurations = listOf(project.configurations.shadow.get()) } - build { - dependsOn(shadowJar) - } - compileJava { options.encoding = Charsets.UTF_8.name() diff --git a/paper/src/main/java/me/adrianed/authmevelocity/paper/PaperLibraries.java b/paper/src/main/java/me/adrianed/authmevelocity/paper/PaperLibraries.java deleted file mode 100644 index 1165cc3..0000000 --- a/paper/src/main/java/me/adrianed/authmevelocity/paper/PaperLibraries.java +++ /dev/null @@ -1,51 +0,0 @@ -package me.adrianed.authmevelocity.paper; - -import me.adrianed.authmevelocity.common.LibsManager; -import net.byteflux.libby.BukkitLibraryManager; -import net.byteflux.libby.Library; -import net.byteflux.libby.relocation.Relocation; - -public class PaperLibraries implements LibsManager { - private final BukkitLibraryManager manager; - - public PaperLibraries(AuthMeVelocityPlugin plugin) { - this.manager = new BukkitLibraryManager(plugin); - } - - @Override - public void registerRepositories() { - manager.addMavenCentral(); - } - - @Override - public void loadLibraries() { - final Relocation dazzleRelocation - = new Relocation("space.arim.dazzleconf", "me.adrianed.authmevelocity.libs.dazzleconf"); - final Relocation snakeYamlRelocation - = new Relocation("pattern", "me.adrianed.authmevelocity.libs.snake"); - final Library dazzleConf = Library.builder() - .groupId("space.arim.dazzleconf") - .artifactId("dazzleconf-ext-snakeyaml") - .version("1.3.0-M1") - .relocate(dazzleRelocation) - .build(); - final Library dazzleYaml = Library.builder() - .groupId("space.arim.dazzleconf") - .artifactId("dazzleconf-ext-snakeyaml") - .version("1.3.0-M1") - .relocate(dazzleRelocation) - .relocate(snakeYamlRelocation) - .build(); - final Library snakeYaml = Library.builder() - .groupId("org.yaml") - .artifactId("snakeyaml") - .version("1.30") - .relocate(dazzleRelocation) - .relocate(snakeYamlRelocation) - .build(); - - manager.loadLibrary(snakeYaml); - manager.loadLibrary(dazzleConf); - manager.loadLibrary(dazzleYaml); - } -} diff --git a/velocity/build.gradle.kts b/velocity/build.gradle.kts index 3d74e45..9319985 100644 --- a/velocity/build.gradle.kts +++ b/velocity/build.gradle.kts @@ -3,9 +3,9 @@ plugins { } repositories { + maven("https://repo.alessiodp.com/releases/") maven("https://jitpack.io") maven("https://repo.codemc.org/repository/maven-public/") - maven("https://repo.alessiodp.com/releases/") } dependencies { @@ -25,8 +25,11 @@ tasks { options.release.set(17) } - build { - dependsOn(shadowJar) + shadowJar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + relocate("net.byteflux.libby", "me.adrianed.authmevelocity.libs.libby") + relocate("space.arim.dazzleconf", "me.adrianed.authmevelocity.libs.dazzleconf") + configurations = listOf(project.configurations.shadow.get()) } } diff --git a/velocity/src/main/java/me/adrianed/authmevelocity/velocity/AuthMeVelocityPlugin.java b/velocity/src/main/java/me/adrianed/authmevelocity/velocity/AuthMeVelocityPlugin.java index 99ff981..7d47227 100644 --- a/velocity/src/main/java/me/adrianed/authmevelocity/velocity/AuthMeVelocityPlugin.java +++ b/velocity/src/main/java/me/adrianed/authmevelocity/velocity/AuthMeVelocityPlugin.java @@ -6,10 +6,10 @@ 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 me.adrianed.authmevelocity.common.LibsManager; import me.adrianed.authmevelocity.common.configuration.Loader; import me.adrianed.authmevelocity.common.configuration.ProxyConfiguration; 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; @@ -23,20 +23,15 @@ import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.messages.ChannelIdentifier; import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; +import net.byteflux.libby.VelocityLibraryManager; 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; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collections; import java.util.concurrent.ConcurrentHashMap; import java.util.List; -import java.util.Objects; import java.util.Set; import java.util.UUID; @@ -45,6 +40,7 @@ import java.util.UUID; name = "AuthMeVelocity", url = "https://github.com/4drian3d/AuthMeVelocity", description = "This plugin adds the support for AuthMeReloaded to Velocity", + version = "3.0.0", dependencies = { @Dependency( id = "miniplaceholders", @@ -64,7 +60,6 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI { private final Path pluginDirectory; private Loader config; - private final List listeners = new ArrayList<>(3); protected final Set loggedPlayers = ConcurrentHashMap.newKeySet(); @Inject @@ -76,9 +71,10 @@ public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI { @Subscribe public void onProxyInitialization(ProxyInitializeEvent event) { - final VelocityLibraries libraries - = new VelocityLibraries(logger, pluginDirectory, proxy.getPluginManager(), this); - libraries.registerRepositories(); + final LibsManager libraries + = new LibsManager( + new VelocityLibraryManager<>( + logger, pluginDirectory, proxy.getPluginManager(), this)); libraries.loadLibraries(); this.config = Loader.create(pluginDirectory, "config.yml", ProxyConfiguration.class, logger); diff --git a/velocity/src/main/java/me/adrianed/authmevelocity/velocity/VelocityLibraries.java b/velocity/src/main/java/me/adrianed/authmevelocity/velocity/VelocityLibraries.java deleted file mode 100644 index fffa8cb..0000000 --- a/velocity/src/main/java/me/adrianed/authmevelocity/velocity/VelocityLibraries.java +++ /dev/null @@ -1,57 +0,0 @@ -package me.adrianed.authmevelocity.velocity; - -import java.nio.file.Path; - -import org.slf4j.Logger; - -import com.velocitypowered.api.plugin.PluginManager; - -import me.adrianed.authmevelocity.common.LibsManager; -import net.byteflux.libby.Library; -import net.byteflux.libby.VelocityLibraryManager; -import net.byteflux.libby.relocation.Relocation; - -public class VelocityLibraries implements LibsManager { - private final VelocityLibraryManager manager; - - public VelocityLibraries(Logger logger, Path dataDirectory, PluginManager pluginManager, AuthMeVelocityPlugin plugin) { - this.manager = new VelocityLibraryManager( - logger, dataDirectory, pluginManager, plugin); - } - @Override - public void registerRepositories() { - manager.addMavenCentral(); - } - - @Override - public void loadLibraries() { - final Relocation dazzleRelocation - = new Relocation("space.arim.dazzleconf", "me.adrianed.authmevelocity.libs.dazzleconf"); - final Relocation snakeYamlRelocation - = new Relocation("pattern", "me.adrianed.authmevelocity.libs.snake"); - final Library dazzleConf = Library.builder() - .groupId("space.arim.dazzleconf") - .artifactId("dazzleconf-ext-snakeyaml") - .version("1.3.0-M1") - .relocate(dazzleRelocation) - .build(); - final Library dazzleYaml = Library.builder() - .groupId("space.arim.dazzleconf") - .artifactId("dazzleconf-ext-snakeyaml") - .version("1.3.0-M1") - .relocate(dazzleRelocation) - .relocate(snakeYamlRelocation) - .build(); - final Library snakeYaml = Library.builder() - .groupId("org.yaml") - .artifactId("snakeyaml") - .version("1.30") - .relocate(dazzleRelocation) - .relocate(snakeYamlRelocation) - .build(); - - manager.loadLibrary(snakeYaml); - manager.loadLibrary(dazzleConf); - manager.loadLibrary(dazzleYaml); - } -} diff --git a/velocity/src/main/java/me/adrianed/authmevelocity/velocity/listener/ConnectListener.java b/velocity/src/main/java/me/adrianed/authmevelocity/velocity/listener/ConnectListener.java index e6a1263..26944f8 100644 --- a/velocity/src/main/java/me/adrianed/authmevelocity/velocity/listener/ConnectListener.java +++ b/velocity/src/main/java/me/adrianed/authmevelocity/velocity/listener/ConnectListener.java @@ -18,7 +18,6 @@ import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.server.RegisteredServer; import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin; -import me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI; public class ConnectListener { private final ProxyServer proxy; diff --git a/velocity/src/main/java/me/adrianed/authmevelocity/velocity/listener/ProxyListener.java b/velocity/src/main/java/me/adrianed/authmevelocity/velocity/listener/ProxyListener.java index 560430b..711ea05 100644 --- a/velocity/src/main/java/me/adrianed/authmevelocity/velocity/listener/ProxyListener.java +++ b/velocity/src/main/java/me/adrianed/authmevelocity/velocity/listener/ProxyListener.java @@ -12,8 +12,6 @@ import com.velocitypowered.api.event.player.PlayerChatEvent; import com.velocitypowered.api.event.player.TabCompleteEvent; import com.velocitypowered.api.proxy.Player; -import org.jetbrains.annotations.NotNull; - import net.kyori.adventure.text.minimessage.MiniMessage; public final class ProxyListener {