Add Lamp command framework
All checks were successful
publish / build (push) Successful in 3m17s

This commit is contained in:
unurled 2024-10-18 17:43:00 +02:00
parent 714a3ca0fb
commit f6763449f1
Signed by: unurled
GPG key ID: EFC5F5E709B47DDD
2 changed files with 26 additions and 1 deletions

View file

@ -1,3 +1,5 @@
import groovy.json.JsonGenerator.Options
plugins {
`java-library`
`maven-publish`
@ -7,9 +9,10 @@ plugins {
}
group = "me.unurled"
version = "0.1.1"
version = "0.1.2"
val mcVersion = "1.21.1-R0.1-SNAPSHOT"
val lampVersion = "4.0.0-beta.17"
val javaVersion = 21
@ -19,6 +22,10 @@ repositories {
dependencies {
paperweight.paperDevBundle(mcVersion)
implementation("io.github.revxrsal:lamp.common:${lampVersion}")
implementation("io.github.revxrsal:lamp.bukkit:${lampVersion}")
implementation("io.github.revxrsal:lamp.brigadier:${lampVersion}")
implementation("io.github.revxrsal:lamp.paper:${lampVersion}")
}
java {
@ -39,6 +46,8 @@ tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
options.compilerArgs.add("-parameters")
if (javaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release.set(javaVersion)
}

View file

@ -5,8 +5,12 @@ import static me.unurled.srcore.utils.ReflectionRegistry.*;
import me.unurled.srcore.utils.ReflectionUtils;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import revxrsal.commands.Lamp;
import revxrsal.commands.bukkit.BukkitLamp;
import revxrsal.commands.bukkit.actor.BukkitCommandActor;
/** The SRCore class is a class that is used to manage the core of the plugin. */
public final class SRCore {
@ -14,6 +18,7 @@ public final class SRCore {
private static SRCore instance;
private final Managers managers;
private Plugin plugin;
private Lamp<BukkitCommandActor> lamp;
private SRCore() {
managers = new Managers();
@ -62,6 +67,7 @@ public final class SRCore {
}
this.plugin = plugin;
lamp = BukkitLamp.builder((JavaPlugin) plugin).build();
}
private @Nullable Plugin tryFindPlugin() {
@ -96,4 +102,14 @@ public final class SRCore {
public void unload() {
managers.unload();
}
/**
* Return Lamp command processor
*
* @return null if {@link SRCore#setPlugin(Plugin)} is not already called
*/
@Nullable
public Lamp<BukkitCommandActor> lamp() {
return lamp;
}
}