diff --git a/platform/krypton/pom.xml b/platform/krypton/pom.xml new file mode 100644 index 00000000..561e3c8e --- /dev/null +++ b/platform/krypton/pom.xml @@ -0,0 +1,93 @@ + + + 4.0.0 + + me.lokka30 + treasury-parent + 2.0.1-SNAPSHOT + ../../pom.xml + + + treasury-krypton + + Treasury-Krypton + + + true + true + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.0 + + false + + + com.mrivanplays.annotationconfig + me.lokka30.treasury.plugin.shade.annotationconfig + + + com.mrivanplays.process + me.lokka30.treasury.plugin.shade.process + + + + + + package + + shade + + + + + + + + src/main/resources + true + + + + + + + krypton + https://repo.kryptonmc.org/releases + + + + + + me.lokka30 + treasury-core + ${project.version} + compile + + + org.snakeyaml + snakeyaml + + + + + org.kryptonmc + krypton-api + ${krypton.version} + provided + + + io.github.miniplaceholders + miniplaceholders-api + ${miniplaceholders.version} + provided + + + + diff --git a/platform/krypton/src/main/java/me/lokka30/treasury/plugin/krypton/KryptonCommandSource.java b/platform/krypton/src/main/java/me/lokka30/treasury/plugin/krypton/KryptonCommandSource.java new file mode 100644 index 00000000..20cad540 --- /dev/null +++ b/platform/krypton/src/main/java/me/lokka30/treasury/plugin/krypton/KryptonCommandSource.java @@ -0,0 +1,42 @@ +/* + * This file is/was part of Treasury. To read more information about Treasury such as its licensing, see . + */ + +package me.lokka30.treasury.plugin.krypton; + +import me.lokka30.treasury.api.common.Cause; +import me.lokka30.treasury.plugin.core.command.CommandSource; +import net.kyori.adventure.identity.Identity; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.jetbrains.annotations.NotNull; +import org.kryptonmc.api.command.ConsoleSender; +import org.kryptonmc.api.command.Sender; + +public class KryptonCommandSource implements CommandSource { + + private final Sender handle; + private final Cause cause; + + public KryptonCommandSource(Sender handle) { + this.handle = handle; + this.cause = handle instanceof ConsoleSender ? Cause.SERVER : Cause.player(handle + .get(Identity.UUID) + .get()); + } + + @Override + public void sendMessage(@NotNull String message) { + handle.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(message)); + } + + @Override + public boolean hasPermission(@NotNull String node) { + return handle instanceof ConsoleSender || handle.hasPermission(node); + } + + @Override + public @NotNull Cause getAsCause() { + return this.cause; + } + +} diff --git a/platform/krypton/src/main/java/me/lokka30/treasury/plugin/krypton/KryptonTreasuryPlugin.java b/platform/krypton/src/main/java/me/lokka30/treasury/plugin/krypton/KryptonTreasuryPlugin.java new file mode 100644 index 00000000..38361ee0 --- /dev/null +++ b/platform/krypton/src/main/java/me/lokka30/treasury/plugin/krypton/KryptonTreasuryPlugin.java @@ -0,0 +1,115 @@ +package me.lokka30.treasury.plugin.krypton; + +import java.nio.file.Path; +import me.lokka30.treasury.plugin.core.Platform; +import me.lokka30.treasury.plugin.core.TreasuryPlugin; +import me.lokka30.treasury.plugin.core.config.ConfigAdapter; +import me.lokka30.treasury.plugin.core.config.messaging.Messages; +import me.lokka30.treasury.plugin.core.config.settings.Settings; +import me.lokka30.treasury.plugin.core.logging.Logger; +import me.lokka30.treasury.plugin.core.schedule.Scheduler; +import me.lokka30.treasury.plugin.core.utils.PluginVersion; +import org.jetbrains.annotations.NotNull; +import org.kryptonmc.api.scheduling.ExecutionType; +import org.kryptonmc.api.scheduling.TaskTime; + +public class KryptonTreasuryPlugin extends TreasuryPlugin implements Logger, Scheduler, + ConfigAdapter { + + private final TreasuryKrypton plugin; + private final Platform platform; + private final PluginVersion version; + + public KryptonTreasuryPlugin(TreasuryKrypton plugin) { + this.plugin = plugin; + this.platform = new Platform("Krypton", ""); + this.version = new PluginVersion( + plugin.server().getPluginManager().fromInstance(plugin).getDescription().version(), + this + ); + } + + @Override + public @NotNull PluginVersion getVersion() { + return this.version; + } + + @Override + public @NotNull Platform platform() { + return this.platform; + } + + @Override + public @NotNull Path pluginsFolder() { + return null; + } + + @Override + public @NotNull Logger logger() { + return this; + } + + @Override + public @NotNull Scheduler scheduler() { + return this; + } + + @Override + public @NotNull ConfigAdapter configAdapter() { + return this; + } + + @Override + public void reload() { + + } + + @Override + public @NotNull Messages getMessages() { + return null; + } + + @Override + public @NotNull Settings getSettings() { + return null; + } + + @Override + public void info(final String message) { + plugin.logger().info(message); + } + + @Override + public void warn(final String message) { + plugin.logger().warn(message); + } + + @Override + public void error(final String message) { + plugin.logger().error(message); + } + + @Override + public void error(final String message, final Throwable t) { + plugin.logger().error(message, t); + } + + @Override + public void runSync(final Runnable task) { + plugin.server().getScheduler().scheduleTask(task, + TaskTime.zero(), + TaskTime.zero(), + ExecutionType.SYNCHRONOUS + ); + } + + @Override + public void runAsync(final Runnable task) { + plugin.server().getScheduler().scheduleTask(task, + TaskTime.zero(), + TaskTime.zero(), + ExecutionType.ASYNCHRONOUS + ); + } + +} diff --git a/platform/krypton/src/main/java/me/lokka30/treasury/plugin/krypton/TreasuryKrypton.java b/platform/krypton/src/main/java/me/lokka30/treasury/plugin/krypton/TreasuryKrypton.java new file mode 100644 index 00000000..d6daff91 --- /dev/null +++ b/platform/krypton/src/main/java/me/lokka30/treasury/plugin/krypton/TreasuryKrypton.java @@ -0,0 +1,37 @@ +/* + * This file is/was part of Treasury. To read more information about Treasury such as its licensing, see . + */ + +package me.lokka30.treasury.plugin.krypton; + +import com.google.inject.Inject; +import org.apache.logging.log4j.Logger; +import org.kryptonmc.api.Server; +import org.kryptonmc.api.event.Listener; +import org.kryptonmc.api.event.server.ServerStartEvent; + +public class TreasuryKrypton { + + private final Server server; + private final Logger logger; + + @Inject + public TreasuryKrypton(Server server, Logger logger) { + this.server = server; + this.logger = logger; + } + + @Listener + public void onStart(ServerStartEvent event) { + + } + + public Server server() { + return server; + } + + public Logger logger() { + return logger; + } + +} diff --git a/platform/krypton/src/main/resources/krypton-plugin-meta.json b/platform/krypton/src/main/resources/krypton-plugin-meta.json new file mode 100644 index 00000000..d88cf573 --- /dev/null +++ b/platform/krypton/src/main/resources/krypton-plugin-meta.json @@ -0,0 +1,16 @@ +{ + "id": "treasury", + "name": "Treasury", + "version": "${plugin.version}-${git.commit.id.abbrev}-${plugin.specificationVersion}", + "authors": [ + "lokka30", "MrIvanPlays", "Jikoo" + ], + "description": "A modern, multi-platform library facilitating the interaction between 'provider' plugins on your server.", + "dependencies": [ + { + "id": "miniplaceholders", + "optional": true + } + ], + "main": "me.lokka30.treasury.plugin.krypton.TreasuryKrypton" +} diff --git a/pom.xml b/pom.xml index 83b37fc7..cb02d3ae 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,7 @@ platform/velocity platform/sponge platform/minestom + platform/krypton pom @@ -66,6 +67,7 @@ code, seek help! --> 954e8b3915 + 041f6b8894