mirror of
https://github.com/xHyroM/lighteco.git
synced 2024-11-23 23:31:05 +01:00
Merge 15e23dd047
into a2be61eb95
This commit is contained in:
commit
f2bc6db040
10 changed files with 153 additions and 30 deletions
|
@ -5,7 +5,7 @@ sequenceOf(
|
||||||
"common",
|
"common",
|
||||||
"bukkit",
|
"bukkit",
|
||||||
"bukkittest",
|
"bukkittest",
|
||||||
"sponge-8",
|
"sponge-9",
|
||||||
"currency-money"
|
"currency-money"
|
||||||
).forEach {
|
).forEach {
|
||||||
include("lighteco-$it")
|
include("lighteco-$it")
|
||||||
|
|
0
sponge-8/.gitignore → sponge-9/.gitignore
vendored
0
sponge-8/.gitignore → sponge-9/.gitignore
vendored
|
@ -5,9 +5,7 @@ plugins {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":lighteco-common"))
|
implementation(project(":lighteco-common"))
|
||||||
|
|
||||||
compileOnly("org.spongepowered:spongeapi:8.0.0")
|
compileOnly("org.spongepowered:spongeapi:9.0.0")
|
||||||
|
|
||||||
//implementation("dev.jorel:commandapi-sponge-shade:9.1.0")
|
|
||||||
|
|
||||||
compileOnly("org.projectlombok:lombok:1.18.28")
|
compileOnly("org.projectlombok:lombok:1.18.28")
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||||
|
@ -17,8 +15,6 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.shadowJar {
|
tasks.shadowJar {
|
||||||
relocate("dev.jorel.commandapi", "dev.xhyrom.lighteco.libraries.commandapi")
|
|
||||||
|
|
||||||
// common
|
// common
|
||||||
relocate("eu.okaeri.configs", "dev.xhyrom.lighteco.libraries.okaeri.configs")
|
relocate("eu.okaeri.configs", "dev.xhyrom.lighteco.libraries.okaeri.configs")
|
||||||
relocate("eu.okaeri.validator", "dev.xhyrom.lighteco.libraries.okaeri.validator")
|
relocate("eu.okaeri.validator", "dev.xhyrom.lighteco.libraries.okaeri.validator")
|
|
@ -1,27 +1,31 @@
|
||||||
package dev.xhyrom.lighteco.sponge;
|
package dev.xhyrom.lighteco.sponge;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import dev.xhyrom.lighteco.common.plugin.bootstrap.LightEcoBootstrap;
|
import dev.xhyrom.lighteco.common.plugin.bootstrap.LightEcoBootstrap;
|
||||||
import dev.xhyrom.lighteco.common.plugin.bootstrap.LoaderBootstrap;
|
import dev.xhyrom.lighteco.common.plugin.bootstrap.LoaderBootstrap;
|
||||||
import dev.xhyrom.lighteco.common.plugin.logger.PluginLogger;
|
import dev.xhyrom.lighteco.common.plugin.logger.PluginLogger;
|
||||||
import dev.xhyrom.lighteco.common.plugin.scheduler.SchedulerAdapter;
|
import dev.xhyrom.lighteco.common.plugin.scheduler.SchedulerAdapter;
|
||||||
import org.apache.logging.log4j.Logger;
|
import dev.xhyrom.lighteco.sponge.logger.SpongeLogger;
|
||||||
import org.spongepowered.plugin.builtin.jvm.Plugin;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Plugin("lighteco-sponge")
|
|
||||||
public class SpongeLightEcoBootstrap implements LightEcoBootstrap, LoaderBootstrap {
|
public class SpongeLightEcoBootstrap implements LightEcoBootstrap, LoaderBootstrap {
|
||||||
private final SpongeLightEcoPlugin plugin;
|
private final SpongeLightEcoPlugin plugin = new SpongeLightEcoPlugin(this);
|
||||||
|
|
||||||
@Inject
|
@Getter
|
||||||
private Logger logger;
|
private final SpongeLightEcoLoader loader;
|
||||||
|
@Getter
|
||||||
|
private final PluginLogger logger;
|
||||||
|
@Getter
|
||||||
|
private final SchedulerAdapter scheduler;
|
||||||
|
|
||||||
public SpongeLightEcoBootstrap() {
|
public SpongeLightEcoBootstrap(SpongeLightEcoLoader loader) {
|
||||||
this.plugin = new SpongeLightEcoPlugin(this);
|
this.loader = loader;
|
||||||
|
this.logger = new SpongeLogger(loader.logger);
|
||||||
|
this.scheduler = new SpongeSchedulerAdapter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,21 +43,6 @@ public class SpongeLightEcoBootstrap implements LightEcoBootstrap, LoaderBootstr
|
||||||
this.plugin.disable();
|
this.plugin.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getLoader() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PluginLogger getLogger() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SchedulerAdapter getScheduler() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getDataDirectory() {
|
public Path getDataDirectory() {
|
||||||
return null;
|
return null;
|
|
@ -0,0 +1,33 @@
|
||||||
|
package dev.xhyrom.lighteco.sponge;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Plugin("lighteco-sponge")
|
||||||
|
public class SpongeLightEcoLoader {
|
||||||
|
private final SpongeLightEcoBootstrap bootstrap;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public Logger logger;
|
||||||
|
|
||||||
|
public SpongeLightEcoLoader() {
|
||||||
|
this.bootstrap = new SpongeLightEcoBootstrap(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Listener(order = Order.FIRST)
|
||||||
|
public void onEnable(ConstructPluginEvent event) {
|
||||||
|
this.bootstrap.onLoad();
|
||||||
|
this.bootstrap.onEnable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Listener
|
||||||
|
public void onDisable(StoppingEngineEvent<Server> event) {
|
||||||
|
this.bootstrap.onDisable();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package dev.xhyrom.lighteco.sponge;
|
||||||
|
|
||||||
|
import dev.xhyrom.lighteco.common.plugin.scheduler.SchedulerAdapter;
|
||||||
|
import dev.xhyrom.lighteco.common.plugin.scheduler.SchedulerTask;
|
||||||
|
import org.spongepowered.api.Sponge;
|
||||||
|
import org.spongepowered.api.scheduler.ScheduledTask;
|
||||||
|
import org.spongepowered.api.scheduler.Task;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class SpongeSchedulerAdapter implements SchedulerAdapter {
|
||||||
|
private final Executor async;
|
||||||
|
|
||||||
|
protected SpongeSchedulerAdapter(SpongeLightEcoBootstrap bootstrap) {
|
||||||
|
this.plugin = bootstrap.getLoader();
|
||||||
|
|
||||||
|
this.async = runnable -> Sponge.asyncScheduler().submit(Task.builder().execute(runnable).build());
|
||||||
|
}
|
||||||
|
|
||||||
|
private SchedulerTask submitAsyncTask(Runnable runnable, Consumer<Task.Builder> config) {
|
||||||
|
Task.Builder builder = Task.builder();
|
||||||
|
config.accept(builder);
|
||||||
|
|
||||||
|
Task task = builder
|
||||||
|
.execute(runnable)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ScheduledTask scheduledTask = Sponge.asyncScheduler().submit(task);
|
||||||
|
return scheduledTask::cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SchedulerTask asyncLater(Runnable runnable, long delay, TimeUnit unit) {
|
||||||
|
return submitAsyncTask(runnable, builder -> builder.delay(delay, unit));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SchedulerTask asyncRepeating(Runnable runnable, long interval, TimeUnit unit) {
|
||||||
|
return submitAsyncTask(runnable, builder -> builder.delay(interval, unit).interval(interval, unit));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package dev.xhyrom.lighteco.sponge.logger;
|
||||||
|
|
||||||
|
import dev.xhyrom.lighteco.common.plugin.logger.PluginLogger;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
public class SpongeLogger implements PluginLogger {
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
|
public SpongeLogger(Logger logger) {
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(String message) {
|
||||||
|
this.logger.info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void info(String message, Object... args) {
|
||||||
|
this.logger.info(message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message) {
|
||||||
|
this.logger.warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, Object... args) {
|
||||||
|
this.logger.warn(message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, Throwable throwable) {
|
||||||
|
this.logger.warn(message, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warn(String message, Throwable throwable, Object... args) {
|
||||||
|
this.logger.warn(String.format(message, args), throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message) {
|
||||||
|
this.logger.error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, Object... args) {
|
||||||
|
this.logger.error(message, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, Throwable throwable) {
|
||||||
|
this.logger.error(message, throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String message, Throwable throwable, Object... args) {
|
||||||
|
this.logger.error(String.format(message, args), throwable);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue