From f6fa8ad8f20d039fef44890e8a00c125b97004d1 Mon Sep 17 00:00:00 2001 From: xHyroM Date: Wed, 30 Aug 2023 10:32:53 +0200 Subject: [PATCH] feat: make lighteco-bukkit actually supports bukkit --- bukkit/build.gradle.kts | 7 +++++-- .../bukkit/BukkitLightEcoBootstrap.java | 2 +- .../xhyrom/lighteco/bukkit/hooks/Hooks.java | 2 ++ .../listeners/BukkitConnectionListener.java | 13 ++++++++++-- .../lighteco/bukkit/logger/BukkitLogger.java | 20 ++++++++++--------- bukkit/src/main/resources/plugin.yml | 2 +- currency-money/README.md | 0 .../currency/money/bukkit/BukkitMCLoader.java | 6 +++++- 8 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 currency-money/README.md diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index accca14..32150a6 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -3,8 +3,11 @@ plugins { } repositories { - maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.extendedclip.com/content/repositories/placeholderapi") + + maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") + maven("https://oss.sonatype.org/content/repositories/snapshots") + maven("https://oss.sonatype.org/content/repositories/central") } dependencies { @@ -13,7 +16,7 @@ dependencies { implementation("dev.jorel:commandapi-bukkit-shade:9.1.0") implementation("net.kyori:adventure-platform-bukkit:4.2.0") - compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") + compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT") // PlaceholderAPI compileOnly("me.clip:placeholderapi:2.11.3") 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 bba9b26..fde3d0e 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoBootstrap.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoBootstrap.java @@ -29,7 +29,7 @@ public class BukkitLightEcoBootstrap implements LightEcoBootstrap, LoaderBootstr public BukkitLightEcoBootstrap(JavaPlugin loader) { this.loader = loader; - this.logger = new BukkitLogger(loader.getSLF4JLogger()); + this.logger = new BukkitLogger(loader.getLogger()); this.scheduler = new BukkitSchedulerAdapter(this); } diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/hooks/Hooks.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/hooks/Hooks.java index 9721f71..a820a55 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/hooks/Hooks.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/hooks/Hooks.java @@ -1,8 +1,10 @@ package dev.xhyrom.lighteco.bukkit.hooks; import dev.xhyrom.lighteco.bukkit.BukkitLightEcoPlugin; +import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; +@UtilityClass public class Hooks { private static PlaceholderAPIExpansion placeholderAPIExpansion; diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/listeners/BukkitConnectionListener.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/listeners/BukkitConnectionListener.java index 4c8aaad..c8176b2 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/listeners/BukkitConnectionListener.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/listeners/BukkitConnectionListener.java @@ -2,7 +2,9 @@ package dev.xhyrom.lighteco.bukkit.listeners; import dev.xhyrom.lighteco.bukkit.BukkitLightEcoPlugin; import dev.xhyrom.lighteco.common.model.user.User; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -32,9 +34,16 @@ public class BukkitConnectionListener implements Listener { this.plugin.getBootstrap().getLogger() .error("Failed to load user data for %s (%s)", e, event.getName(), event.getUniqueId()); - event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, miniMessage.deserialize( + Component reason = miniMessage.deserialize( "LightEco Failed to load your data. Contact a staff member for assistance." - )); + ); + + event.disallow( + AsyncPlayerPreLoginEvent.Result.KICK_OTHER, + LegacyComponentSerializer.legacySection().serialize( + reason + ) + ); } } diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/logger/BukkitLogger.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/logger/BukkitLogger.java index 3c9d750..7d4d6f7 100644 --- a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/logger/BukkitLogger.java +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/logger/BukkitLogger.java @@ -1,7 +1,9 @@ package dev.xhyrom.lighteco.bukkit.logger; import dev.xhyrom.lighteco.common.plugin.logger.PluginLogger; -import org.slf4j.Logger; + +import java.util.logging.Level; +import java.util.logging.Logger; public class BukkitLogger implements PluginLogger { private final Logger logger; @@ -22,41 +24,41 @@ public class BukkitLogger implements PluginLogger { @Override public void warn(String message) { - this.logger.warn(message); + this.logger.log(Level.WARNING, message); } @Override public void warn(String message, Object... args) { - this.logger.warn(String.format(message, args)); + this.logger.log(Level.WARNING, String.format(message, args)); } @Override public void warn(String message, Throwable throwable) { - this.logger.warn(message, throwable); + this.logger.log(Level.WARNING, message, throwable); } @Override public void warn(String message, Throwable throwable, Object... args) { - this.logger.warn(String.format(message, args), throwable); + this.logger.log(Level.WARNING, String.format(message, args), throwable); } @Override public void error(String message) { - this.logger.error(message); + this.logger.severe(message); } @Override public void error(String message, Object... args) { - this.logger.error(String.format(message, args)); + this.logger.severe(String.format(message, args)); } @Override public void error(String message, Throwable throwable) { - this.logger.error(message, throwable); + this.logger.log(Level.SEVERE, message, throwable); } @Override public void error(String message, Throwable throwable, Object... args) { - this.logger.error(String.format(message, args), throwable); + this.logger.log(Level.SEVERE, String.format(message, args), throwable); } } diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index dfbae68..0d7f4be 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -3,7 +3,7 @@ description: ${description} version: ${version} main: dev.xhyrom.lighteco.bukkit.BukkitLightEcoLoader author: ${author} -api-version: 1.20 +api-version: 1.16 load: STARTUP softdepend: diff --git a/currency-money/README.md b/currency-money/README.md new file mode 100644 index 0000000..e69de29 diff --git a/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/bukkit/BukkitMCLoader.java b/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/bukkit/BukkitMCLoader.java index 1d531a0..e7256cc 100644 --- a/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/bukkit/BukkitMCLoader.java +++ b/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/bukkit/BukkitMCLoader.java @@ -7,8 +7,12 @@ import dev.xhyrom.lighteco.api.manager.CurrencyManager; import dev.xhyrom.lighteco.api.model.currency.Currency; import dev.xhyrom.lighteco.currency.money.bukkit.hooks.vault.VaultFactory; import dev.xhyrom.lighteco.currency.money.common.MoneyCurrency; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import java.util.UUID; + public class BukkitMCLoader extends JavaPlugin { private VaultFactory vaultFactory; @@ -24,7 +28,7 @@ public class BukkitMCLoader extends JavaPlugin { commandManager.registerCurrencyCommand(currency, true); if (getServer().getPluginManager().getPlugin("Vault") != null) { - getSLF4JLogger().info("Vault found, hooking..."); + getLogger().info("Vault found, hooking..."); this.vaultFactory = new VaultFactory(this); this.vaultFactory.hook();