Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Krypton support #288

Draft
wants to merge 2 commits into
base: dev/v2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions platform/krypton/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>me.lokka30</groupId>
<artifactId>treasury-parent</artifactId>
<version>2.0.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>treasury-krypton</artifactId>

<name>Treasury-Krypton</name>

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>com.mrivanplays.annotationconfig</pattern>
<shadedPattern>me.lokka30.treasury.plugin.shade.annotationconfig</shadedPattern>
</relocation>
<relocation>
<pattern>com.mrivanplays.process</pattern>
<shadedPattern>me.lokka30.treasury.plugin.shade.process</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<repositories>
<repository>
<id>krypton</id>
<url>https://repo.kryptonmc.org/releases</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>me.lokka30</groupId>
<artifactId>treasury-core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.snakeyaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.kryptonmc</groupId>
<artifactId>krypton-api</artifactId>
<version>${krypton.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.miniplaceholders</groupId>
<artifactId>miniplaceholders-api</artifactId>
<version>${miniplaceholders.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This file is/was part of Treasury. To read more information about Treasury such as its licensing, see <https://github.com/ArcanePlugins/Treasury>.
*/

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;
}

}
Original file line number Diff line number Diff line change
@@ -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
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* This file is/was part of Treasury. To read more information about Treasury such as its licensing, see <https://github.com/ArcanePlugins/Treasury>.
*/

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;
}

}
16 changes: 16 additions & 0 deletions platform/krypton/src/main/resources/krypton-plugin-meta.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<module>platform/velocity</module>
<module>platform/sponge</module>
<module>platform/minestom</module>
<module>platform/krypton</module>
</modules>

<packaging>pom</packaging>
Expand Down Expand Up @@ -66,6 +67,7 @@
code, seek help!
-->
<minestom.version>954e8b3915</minestom.version>
<krypton.version>041f6b8894</krypton.version>
</properties>

<licenses>
Expand Down