diff --git a/api/src/main/java/dev/xhyrom/lighteco/api/platform/Platform.java b/api/src/main/java/dev/xhyrom/lighteco/api/platform/Platform.java index 0a77057..0ede153 100644 --- a/api/src/main/java/dev/xhyrom/lighteco/api/platform/Platform.java +++ b/api/src/main/java/dev/xhyrom/lighteco/api/platform/Platform.java @@ -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() { diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index 32150a6..cbefc31 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -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") diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoBootstrap.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoBootstrap.java index fde3d0e..743379c 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoBootstrap.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoBootstrap.java @@ -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 getOnlinePlayers() { - return getServer().getOnlinePlayers().stream() + return this.loader.getServer().getOnlinePlayers().stream() .map(Entity::getUniqueId) .toList(); } diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoLoader.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoLoader.java index ebf03b4..da91c69 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoLoader.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoLoader.java @@ -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 diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoPlugin.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoPlugin.java index 5eee4cb..63b5ce3 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoPlugin.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoPlugin.java @@ -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 diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitSchedulerAdapter.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitSchedulerAdapter.java index fd1c8d4..0312ffd 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitSchedulerAdapter.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitSchedulerAdapter.java @@ -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); } diff --git a/common/src/main/java/dev/xhyrom/lighteco/common/plugin/AbstractLightEcoPlugin.java b/common/src/main/java/dev/xhyrom/lighteco/common/plugin/AbstractLightEcoPlugin.java index 89c8aa9..62530aa 100644 --- a/common/src/main/java/dev/xhyrom/lighteco/common/plugin/AbstractLightEcoPlugin.java +++ b/common/src/main/java/dev/xhyrom/lighteco/common/plugin/AbstractLightEcoPlugin.java @@ -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; diff --git a/sponge-8/.gitignore b/sponge-8/.gitignore new file mode 100644 index 0000000..b63da45 --- /dev/null +++ b/sponge-8/.gitignore @@ -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 \ No newline at end of file diff --git a/sponge-8/build.gradle.kts b/sponge-8/build.gradle.kts index e17e5d8..0984a16 100644 --- a/sponge-8/build.gradle.kts +++ b/sponge-8/build.gradle.kts @@ -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") } \ No newline at end of file diff --git a/sponge-8/src/main/java/dev/xhyrom/Main.java b/sponge-8/src/main/java/dev/xhyrom/Main.java deleted file mode 100644 index aec9966..0000000 --- a/sponge-8/src/main/java/dev/xhyrom/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package dev.xhyrom; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/sponge-8/src/main/java/dev/xhyrom/lighteco/sponge/SpongeLightEcoBootstrap.java b/sponge-8/src/main/java/dev/xhyrom/lighteco/sponge/SpongeLightEcoBootstrap.java new file mode 100644 index 0000000..87795bb --- /dev/null +++ b/sponge-8/src/main/java/dev/xhyrom/lighteco/sponge/SpongeLightEcoBootstrap.java @@ -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(); + } +} diff --git a/sponge-8/src/main/java/dev/xhyrom/lighteco/sponge/SpongeLightEcoPlugin.java b/sponge-8/src/main/java/dev/xhyrom/lighteco/sponge/SpongeLightEcoPlugin.java new file mode 100644 index 0000000..4aefad7 --- /dev/null +++ b/sponge-8/src/main/java/dev/xhyrom/lighteco/sponge/SpongeLightEcoPlugin.java @@ -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 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; + } +} diff --git a/sponge-8/src/main/resources/META-INF/sponge_plugins.json b/sponge-8/src/main/resources/META-INF/sponge_plugins.json new file mode 100644 index 0000000..c7bfe23 --- /dev/null +++ b/sponge-8/src/main/resources/META-INF/sponge_plugins.json @@ -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" + } + ] + } + ] +} \ No newline at end of file