mirror of
https://github.com/xHyroM/lighteco.git
synced 2024-11-21 14:31:09 +01:00
feat: sponge support [WIP]
This commit is contained in:
parent
2163f1614e
commit
22df335df9
13 changed files with 214 additions and 38 deletions
|
@ -12,6 +12,7 @@ public interface Platform {
|
|||
|
||||
enum Type {
|
||||
BUKKIT("Bukkit"),
|
||||
SPONGE("Sponge"),
|
||||
VELOCITY("Velocity"),
|
||||
BUNGEECORD("BungeeCord");
|
||||
|
||||
|
@ -26,7 +27,7 @@ public interface Platform {
|
|||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
return this == BUKKIT;
|
||||
return this == BUKKIT || this == SPONGE;
|
||||
}
|
||||
|
||||
public boolean isProxy() {
|
||||
|
|
|
@ -35,9 +35,6 @@ tasks.shadowJar {
|
|||
relocate("eu.okaeri.configs", "dev.xhyrom.lighteco.libraries.okaeri.configs")
|
||||
relocate("eu.okaeri.validator", "dev.xhyrom.lighteco.libraries.okaeri.validator")
|
||||
|
||||
//relocate("net.kyori.adventure", "dev.xhyrom.lighteco.libraries.net.kyori.adventure")
|
||||
//relocate("net.kyori.examination", "dev.xhyrom.lighteco.libraries.net.kyori.examination")
|
||||
|
||||
relocate("org.yaml.snakeyaml", "dev.xhyrom.lighteco.libraries.org.yaml.snakeyaml")
|
||||
|
||||
relocate("org.mariadb.jdbc", "dev.xhyrom.lighteco.libraries.mariadb")
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package dev.xhyrom.lighteco.bukkit;
|
||||
|
||||
import dev.jorel.commandapi.CommandAPI;
|
||||
import dev.jorel.commandapi.CommandAPIBukkitConfig;
|
||||
import dev.xhyrom.lighteco.bukkit.logger.BukkitLogger;
|
||||
import dev.xhyrom.lighteco.common.plugin.bootstrap.LightEcoBootstrap;
|
||||
import dev.xhyrom.lighteco.common.plugin.bootstrap.LoaderBootstrap;
|
||||
import dev.xhyrom.lighteco.common.plugin.logger.PluginLogger;
|
||||
import dev.xhyrom.lighteco.common.plugin.scheduler.SchedulerAdapter;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
|
@ -17,10 +18,10 @@ import java.util.UUID;
|
|||
|
||||
@Getter
|
||||
public class BukkitLightEcoBootstrap implements LightEcoBootstrap, LoaderBootstrap {
|
||||
private final JavaPlugin loader;
|
||||
@Getter
|
||||
private final BukkitLightEcoPlugin plugin = new BukkitLightEcoPlugin(this);
|
||||
|
||||
@Getter
|
||||
private final JavaPlugin loader;
|
||||
@Getter
|
||||
private final PluginLogger logger;
|
||||
@Getter
|
||||
|
@ -28,7 +29,6 @@ public class BukkitLightEcoBootstrap implements LightEcoBootstrap, LoaderBootstr
|
|||
|
||||
public BukkitLightEcoBootstrap(JavaPlugin loader) {
|
||||
this.loader = loader;
|
||||
|
||||
this.logger = new BukkitLogger(loader.getLogger());
|
||||
this.scheduler = new BukkitSchedulerAdapter(this);
|
||||
}
|
||||
|
@ -36,22 +36,23 @@ public class BukkitLightEcoBootstrap implements LightEcoBootstrap, LoaderBootstr
|
|||
@Override
|
||||
public void onLoad() {
|
||||
this.plugin.load();
|
||||
CommandAPI.onLoad(new CommandAPIBukkitConfig(this.loader)
|
||||
.verboseOutput(this.getPlugin().getConfig().debug)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
CommandAPI.onEnable();
|
||||
this.plugin.enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
CommandAPI.onDisable();
|
||||
this.plugin.disable();
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return this.loader.getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getDataDirectory() {
|
||||
return this.loader.getDataFolder().toPath();
|
||||
|
@ -59,7 +60,7 @@ public class BukkitLightEcoBootstrap implements LightEcoBootstrap, LoaderBootstr
|
|||
|
||||
@Override
|
||||
public List<UUID> getOnlinePlayers() {
|
||||
return getServer().getOnlinePlayers().stream()
|
||||
return this.loader.getServer().getOnlinePlayers().stream()
|
||||
.map(Entity::getUniqueId)
|
||||
.toList();
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package dev.xhyrom.lighteco.bukkit;
|
|||
|
||||
import dev.jorel.commandapi.CommandAPI;
|
||||
import dev.jorel.commandapi.CommandAPIBukkitConfig;
|
||||
import dev.xhyrom.lighteco.bukkit.hooks.PlaceholderAPIExpansion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
// Used inside plugin.yml
|
||||
|
|
|
@ -34,7 +34,7 @@ public class BukkitLightEcoPlugin extends AbstractLightEcoPlugin {
|
|||
|
||||
@Override
|
||||
protected void registerListeners() {
|
||||
this.bootstrap.getServer().getPluginManager().registerEvents(new BukkitConnectionListener(this), this.bootstrap.getLoader());
|
||||
this.bootstrap.getLoader().getServer().getPluginManager().registerEvents(new BukkitConnectionListener(this), this.bootstrap.getLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +47,7 @@ public class BukkitLightEcoPlugin extends AbstractLightEcoPlugin {
|
|||
|
||||
@Override
|
||||
protected void registerApiOnPlatform(LightEco api) {
|
||||
this.getBootstrap().getServer().getServicesManager().register(LightEco.class, api, this.getBootstrap().getLoader(), ServicePriority.Normal);
|
||||
this.getBootstrap().getLoader().getServer().getServicesManager().register(LightEco.class, api, this.getBootstrap().getLoader(), ServicePriority.Normal);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,7 @@ public class BukkitSchedulerAdapter implements SchedulerAdapter {
|
|||
|
||||
public BukkitSchedulerAdapter(BukkitLightEcoBootstrap bootstrap) {
|
||||
this.bootstrap = bootstrap;
|
||||
this.scheduler = bootstrap.getServer().getScheduler();
|
||||
this.scheduler = bootstrap.getLoader().getServer().getScheduler();
|
||||
|
||||
this.async = runnable -> this.scheduler.runTaskAsynchronously(this.bootstrap.getLoader(), runnable);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import dev.xhyrom.lighteco.common.api.LightEcoApi;
|
|||
import dev.xhyrom.lighteco.common.config.Config;
|
||||
import dev.xhyrom.lighteco.common.dependencies.DependencyManager;
|
||||
import dev.xhyrom.lighteco.common.dependencies.DependencyManagerImpl;
|
||||
import dev.xhyrom.lighteco.common.model.user.User;
|
||||
import dev.xhyrom.lighteco.common.storage.Storage;
|
||||
import dev.xhyrom.lighteco.common.storage.StorageFactory;
|
||||
import dev.xhyrom.lighteco.common.task.UserSaveTask;
|
||||
|
|
42
sponge-8/.gitignore
vendored
Normal file
42
sponge-8/.gitignore
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -1,19 +1,32 @@
|
|||
plugins {
|
||||
id("java")
|
||||
}
|
||||
|
||||
group = "dev.xhyrom"
|
||||
version = "0.1.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
id("lighteco.platform-logic")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation(platform("org.junit:junit-bom:5.9.1"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
implementation(project(":lighteco-common"))
|
||||
|
||||
compileOnly("org.spongepowered:spongeapi:8.0.0")
|
||||
|
||||
//implementation("dev.jorel:commandapi-sponge-shade:9.1.0")
|
||||
|
||||
compileOnly("org.projectlombok:lombok:1.18.28")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||
|
||||
compileOnly("org.checkerframework:checker-qual:3.8.0")
|
||||
compileOnly("org.jetbrains:annotations:20.1.0")
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
tasks.shadowJar {
|
||||
relocate("dev.jorel.commandapi", "dev.xhyrom.lighteco.libraries.commandapi")
|
||||
|
||||
// common
|
||||
relocate("eu.okaeri.configs", "dev.xhyrom.lighteco.libraries.okaeri.configs")
|
||||
relocate("eu.okaeri.validator", "dev.xhyrom.lighteco.libraries.okaeri.validator")
|
||||
|
||||
relocate("org.yaml.snakeyaml", "dev.xhyrom.lighteco.libraries.org.yaml.snakeyaml")
|
||||
|
||||
relocate("org.mariadb.jdbc", "dev.xhyrom.lighteco.libraries.mariadb")
|
||||
relocate("com.mysql", "dev.xhyrom.lighteco.libraries.mysql")
|
||||
relocate("org.postgresql", "dev.xhyrom.lighteco.libraries.postgresql")
|
||||
relocate("com.zaxxer.hikari", "dev.xhyrom.lighteco.libraries.hikari")
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package dev.xhyrom;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package dev.xhyrom.lighteco.sponge;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import dev.xhyrom.lighteco.common.plugin.bootstrap.LoaderBootstrap;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.plugin.builtin.jvm.Plugin;
|
||||
|
||||
@Plugin("lighteco-sponge")
|
||||
public class SpongeLightEcoBootstrap implements LoaderBootstrap {
|
||||
private final SpongeLightEcoPlugin plugin;
|
||||
|
||||
@Inject
|
||||
private Logger logger;
|
||||
|
||||
public SpongeLightEcoBootstrap() {
|
||||
this.plugin = new SpongeLightEcoPlugin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
this.plugin.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.plugin.enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.plugin.disable();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package dev.xhyrom.lighteco.sponge;
|
||||
|
||||
import dev.xhyrom.lighteco.api.LightEco;
|
||||
import dev.xhyrom.lighteco.api.manager.CommandManager;
|
||||
import dev.xhyrom.lighteco.api.manager.ContextManager;
|
||||
import dev.xhyrom.lighteco.api.platform.Platform;
|
||||
import dev.xhyrom.lighteco.common.manager.currency.StandardCurrencyManager;
|
||||
import dev.xhyrom.lighteco.common.manager.user.StandardUserManager;
|
||||
import dev.xhyrom.lighteco.common.plugin.AbstractLightEcoPlugin;
|
||||
import lombok.Getter;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
public class SpongeLightEcoPlugin extends AbstractLightEcoPlugin {
|
||||
@Getter
|
||||
private final SpongeLightEcoBootstrap bootstrap;
|
||||
|
||||
@Getter
|
||||
private StandardUserManager userManager;
|
||||
@Getter
|
||||
private StandardCurrencyManager currencyManager;
|
||||
@Getter
|
||||
private CommandManager commandManager;
|
||||
@Getter
|
||||
private ContextManager<Player> contextManager;
|
||||
|
||||
public SpongeLightEcoPlugin(SpongeLightEcoBootstrap bootstrap) {
|
||||
this.bootstrap = bootstrap;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerListeners() {
|
||||
//this.bootstrap.getServer().getPluginManager().registerEvents(new BukkitConnectionListener(this), this.bootstrap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupManagers() {
|
||||
this.userManager = new StandardUserManager(this);
|
||||
this.currencyManager = new StandardCurrencyManager(this);
|
||||
//this.commandManager = new BukkitCommandManager(this);
|
||||
//this.contextManager = new BukkitContextManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerApiOnPlatform(LightEco api) {
|
||||
//this.getBootstrap().getServer().getServicesManager().register(LightEco.class, api, this.getBootstrap(), ServicePriority.Normal);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPlatformHooks() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removePlatformHooks() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Platform.@NonNull Type getPlatformType() {
|
||||
return Platform.Type.SPONGE;
|
||||
}
|
||||
}
|
36
sponge-8/src/main/resources/META-INF/sponge_plugins.json
Normal file
36
sponge-8/src/main/resources/META-INF/sponge_plugins.json
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"loader": {
|
||||
"name": "java_plain",
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"plugins": [
|
||||
{
|
||||
"id": "lighteco-sponge",
|
||||
"name": "LightEco Sponge",
|
||||
"description": "${description}",
|
||||
"version": "${version}",
|
||||
"entrypoint": "dev.xhyrom.lighteco.sponge.SpongeLightEcoBootstrap",
|
||||
"links": {
|
||||
"homepage": "https://modrinth.com/plugin/lighteco",
|
||||
"source": "https://github.com/xHyroM/lighteco",
|
||||
"issues": "https://github.com/xHyroM/lighteco/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "xHyroM",
|
||||
"description": "Developer",
|
||||
"links": {
|
||||
"homepage": "https://xhyrom.dev"
|
||||
}
|
||||
}
|
||||
],
|
||||
"dependencies": [
|
||||
{
|
||||
"id": "spongeapi",
|
||||
"version": "8.0.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue