mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-09-02 10:52:37 +02:00
Sponge use jar-in-jar loader
This commit is contained in:
32
sponge/loader/build.gradle
Normal file
32
sponge/loader/build.gradle
Normal file
@@ -0,0 +1,32 @@
|
||||
plugins {
|
||||
id 'com.github.johnrengelman.shadow'
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url 'https://repo.spongepowered.org/repository/maven-public/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.spongepowered:spongeapi:8.0.0'
|
||||
|
||||
implementation project(':api')
|
||||
implementation project(':common:loader-utils')
|
||||
}
|
||||
|
||||
processResources {
|
||||
filesMatching('META-INF/sponge_plugins.json') {
|
||||
expand 'pluginVersion': project.ext.fullVersion
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = "LuckPerms-Sponge-${project.ext.fullVersion}.jar"
|
||||
|
||||
from {
|
||||
project(':sponge').tasks.shadowJar.archiveFile
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives shadowJar
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.sponge.loader;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import me.lucko.luckperms.common.loader.JarInJarClassLoader;
|
||||
import me.lucko.luckperms.common.loader.LoaderBootstrap;
|
||||
|
||||
import org.spongepowered.api.Server;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.Order;
|
||||
import org.spongepowered.api.event.lifecycle.ConstructPluginEvent;
|
||||
import org.spongepowered.api.event.lifecycle.StoppingEngineEvent;
|
||||
import org.spongepowered.plugin.builtin.jvm.Plugin;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Plugin("luckperms")
|
||||
public class SpongeLoaderPlugin implements Supplier<Injector> {
|
||||
private static final String JAR_NAME = "luckperms-sponge.jarinjar";
|
||||
private static final String BOOTSTRAP_CLASS = "me.lucko.luckperms.sponge.LPSpongeBootstrap";
|
||||
|
||||
private final LoaderBootstrap plugin;
|
||||
private final Injector injector;
|
||||
|
||||
@Inject
|
||||
public SpongeLoaderPlugin(Injector injector) {
|
||||
this.injector = injector;
|
||||
|
||||
JarInJarClassLoader loader = new JarInJarClassLoader(getClass().getClassLoader(), JAR_NAME);
|
||||
this.plugin = loader.instantiatePlugin(BOOTSTRAP_CLASS, Supplier.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injector get() {
|
||||
return this.injector;
|
||||
}
|
||||
|
||||
@Listener(order = Order.FIRST)
|
||||
public void onEnable(ConstructPluginEvent event) {
|
||||
this.plugin.onLoad();
|
||||
this.plugin.onEnable();
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onDisable(StoppingEngineEvent<Server> event) {
|
||||
this.plugin.onDisable();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"loader": {
|
||||
"name": "java_plain",
|
||||
"version": "1.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"plugins": [
|
||||
{
|
||||
"id": "luckperms",
|
||||
"name": "LuckPerms",
|
||||
"version": "${pluginVersion}",
|
||||
"entrypoint": "me.lucko.luckperms.sponge.loader.SpongeLoaderPlugin",
|
||||
"description": "A permissions plugin",
|
||||
"links": {
|
||||
"homepage": "https://luckperms.net"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Luck",
|
||||
"description": "Developer"
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
{
|
||||
"id": "spongeapi",
|
||||
"version": "8.0.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user