feat: Added Paper plugins compatibility

resolves #87
This commit is contained in:
Adrian 2023-05-24 15:12:24 -05:00
parent 8641bb59f0
commit d597b1e33e
No known key found for this signature in database
GPG Key ID: FB8EF84DCE1BE452
6 changed files with 79 additions and 7 deletions

View File

@ -31,7 +31,7 @@ authme = { module = "fr.xephi:authme", version.ref = "authme" }
libby-core = { group = "net.byteflux", name = "libby-core", version.ref = "libby" } libby-core = { group = "net.byteflux", name = "libby-core", version.ref = "libby" }
libby-bukkit = { group = "net.byteflux", name = "libby-bukkit", version.ref = "libby" } libby-bukkit = { group = "net.byteflux", name = "libby-bukkit", version.ref = "libby" }
#libby-paper = "TODO" libby-paper = { group = "net.byteflux", name = "libby-paper", version.ref = "libby" }
libby-velocity = { group = "net.byteflux", name = "libby-velocity", 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" } miniplaceholders = { group = "io.github.miniplaceholders", name = "miniplaceholders-api", version.ref = "miniplaceholders" }

View File

@ -27,7 +27,7 @@ dependencies {
implementation(projects.authmevelocityApiPaper) implementation(projects.authmevelocityApiPaper)
implementation(libs.libby.bukkit) implementation(libs.libby.bukkit)
//implementation(libs.libby.paper) implementation(libs.libby.paper)
} }
tasks { tasks {

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2023 AuthMeVelocity Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package io.github._4drian3d.authmevelocity.paper;
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 PluginProviderContext context) {
}
@Override
public @NotNull JavaPlugin createPlugin(@NotNull PluginProviderContext context) {
return new AuthMeVelocityPlugin(context.getDataDirectory());
}
}

View File

@ -26,25 +26,44 @@ import io.github._4drian3d.authmevelocity.common.configuration.PaperConfiguratio
import io.github._4drian3d.authmevelocity.paper.listeners.AuthMeListener; import io.github._4drian3d.authmevelocity.paper.listeners.AuthMeListener;
import io.github._4drian3d.authmevelocity.paper.listeners.MessageListener; import io.github._4drian3d.authmevelocity.paper.listeners.MessageListener;
import net.byteflux.libby.BukkitLibraryManager; import net.byteflux.libby.BukkitLibraryManager;
import net.byteflux.libby.LibraryManager;
import net.byteflux.libby.PaperLibraryManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.nio.file.Path;
import java.util.logging.Level; import java.util.logging.Level;
public final class AuthMeVelocityPlugin extends JavaPlugin { public final class AuthMeVelocityPlugin extends JavaPlugin {
private static final String CHANNEL = "authmevelocity:main"; private static final String CHANNEL = "authmevelocity:main";
private final Path dataFolder;
private ConfigurationContainer<PaperConfiguration> config; private ConfigurationContainer<PaperConfiguration> config;
@SuppressWarnings("unused")
public AuthMeVelocityPlugin() {
this.dataFolder = getDataFolder().toPath();
}
public AuthMeVelocityPlugin(final Path dataFolder) {
this.dataFolder = dataFolder;
}
@Override @Override
public void onEnable() { public void onEnable() {
new LibsManager(new BukkitLibraryManager(this)).loadLibraries(); LibraryManager libraryManager;
try {
Class.forName("io.papermc.paper.plugin.bootstrap.PluginBootstrap");
libraryManager = new PaperLibraryManager(this);
} catch (ClassNotFoundException e) {
libraryManager = new BukkitLibraryManager(this);
}
new LibsManager(libraryManager).loadLibraries();
try { try {
this.config = ConfigurationContainer.load(getDataFolder().toPath(), PaperConfiguration.class); this.config = ConfigurationContainer.load(dataFolder, PaperConfiguration.class);
} catch (Exception e) { } catch (Throwable e) {
getLogger().log(Level.SEVERE, "Could not load config.conf file", e); getLogger().log(Level.SEVERE, "Could not load config.conf file", e);
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
return; return;

View File

@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull;
public final class MessageListener implements PluginMessageListener { public final class MessageListener implements PluginMessageListener {
private final AuthMeVelocityPlugin plugin; private final AuthMeVelocityPlugin plugin;
public MessageListener(AuthMeVelocityPlugin plugin) { public MessageListener(final AuthMeVelocityPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
} }

View File

@ -0,0 +1,17 @@
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
api-version: '1.19'
folia-supported: true
dependencies:
- name: MiniPlaceholders
required: false
bootstrap: false
- name: AuthMe
required: true
bootstrap: false