diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ccfb353..6a58fe2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sat Jan 13 22:44:56 CST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-8.8-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/CurrencyPlugin.java b/src/main/java/cn/hamster3/mc/plugin/currency/CurrencyPlugin.java index 7684d87..d873fcc 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/CurrencyPlugin.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/CurrencyPlugin.java @@ -1,7 +1,7 @@ package cn.hamster3.mc.plugin.currency; import cn.hamster3.mc.plugin.ball.common.api.BallAPI; -import cn.hamster3.mc.plugin.currency.command.currency.ParentCurrencyCommand; +import cn.hamster3.mc.plugin.currency.command.ParentCurrencyCommand; import cn.hamster3.mc.plugin.currency.core.CurrencyConfigManager; import cn.hamster3.mc.plugin.currency.core.CurrencyDataManager; import cn.hamster3.mc.plugin.currency.core.CurrencyMessage; @@ -53,7 +53,7 @@ public class CurrencyPlugin extends JavaPlugin { e.printStackTrace(); } - if (Bukkit.getPluginManager().getPlugin("Vault") != null) { + if (Bukkit.getPluginManager().isPluginEnabled("Vault")) { logger.info("检测到 Vault 已安装"); Bukkit.getServicesManager().register(Economy.class, VaultEconomyHook.INSTANCE, this, ServicePriority.Normal); CurrencyType type = CurrencyDataManager.getVaultCurrencyType(); @@ -62,13 +62,10 @@ public class CurrencyPlugin extends JavaPlugin { } else { logger.warning("已挂接 Vault 系统,但未找到 Vault 货币类型,请检查配置文件或创建货币类型: " + CurrencyConfigManager.getVaultCurrencyID()); } - if (CurrencyConfigManager.isEnableVaultCommands()) { - logger.info("本插件暂不支持 vault 指令"); - } } else { logger.info("未找到 Vault 插件! 取消注册 Vault 经济系统"); } - if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { + if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) { logger.info("检测到 PlaceholderAPI 已安装"); if (PlaceholderHook.INSTANCE.register()) { logger.info("已挂载 PlaceholderAPI 变量"); diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/api/CurrencyAPI.java b/src/main/java/cn/hamster3/mc/plugin/currency/api/CurrencyAPI.java index 44909c7..0a5f161 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/api/CurrencyAPI.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/api/CurrencyAPI.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; -@SuppressWarnings({"unused", "UnusedReturnValue"}) public final class CurrencyAPI { private CurrencyAPI() { } diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyCreateCommand.java b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyCreateCommand.java similarity index 98% rename from src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyCreateCommand.java rename to src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyCreateCommand.java index 8dfa193..72d1824 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyCreateCommand.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyCreateCommand.java @@ -1,4 +1,4 @@ -package cn.hamster3.mc.plugin.currency.command.currency; +package cn.hamster3.mc.plugin.currency.command; import cn.hamster3.mc.plugin.core.bukkit.command.ChildCommand; import cn.hamster3.mc.plugin.currency.CurrencyPlugin; diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyDeleteCommand.java b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyDeleteCommand.java similarity index 97% rename from src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyDeleteCommand.java rename to src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyDeleteCommand.java index bdf64b0..0e72de9 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyDeleteCommand.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyDeleteCommand.java @@ -1,4 +1,4 @@ -package cn.hamster3.mc.plugin.currency.command.currency; +package cn.hamster3.mc.plugin.currency.command; import cn.hamster3.mc.plugin.core.bukkit.command.ChildCommand; import cn.hamster3.mc.plugin.currency.CurrencyPlugin; diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyGiveCommand.java b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyGiveCommand.java similarity index 91% rename from src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyGiveCommand.java rename to src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyGiveCommand.java index a42a864..a9711ce 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyGiveCommand.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyGiveCommand.java @@ -1,4 +1,4 @@ -package cn.hamster3.mc.plugin.currency.command.currency; +package cn.hamster3.mc.plugin.currency.command; import cn.hamster3.mc.plugin.ball.common.api.BallAPI; import cn.hamster3.mc.plugin.ball.common.entity.BallPlayerInfo; @@ -59,8 +59,9 @@ public class CurrencyGiveCommand extends ChildCommand { return true; } double amount = Double.parseDouble(args[2]); - CurrencyAPI.givePlayerCurrency(playerInfo.getUuid(), type.getId(), amount); - CurrencyMessage.CURRENCY_GIVE_SUCCESS.show(sender); + CurrencyAPI.givePlayerCurrency(playerInfo.getUuid(), type.getId(), amount) + .onFailed(throwable -> CurrencyMessage.ERROR_EXCEPTION_ADMIN.show(sender)) + .onSuccess(unused -> CurrencyMessage.CURRENCY_GIVE_SUCCESS.show(sender)); return true; } diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyPayCommand.java b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyPayCommand.java similarity index 98% rename from src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyPayCommand.java rename to src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyPayCommand.java index b30a9d3..1c8963c 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyPayCommand.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyPayCommand.java @@ -1,4 +1,4 @@ -package cn.hamster3.mc.plugin.currency.command.currency; +package cn.hamster3.mc.plugin.currency.command; import cn.hamster3.mc.plugin.ball.common.api.BallAPI; import cn.hamster3.mc.plugin.ball.common.entity.BallPlayerInfo; diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyResetCommand.java b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyResetCommand.java similarity index 98% rename from src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyResetCommand.java rename to src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyResetCommand.java index 1e2974a..6bca2bf 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyResetCommand.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyResetCommand.java @@ -1,4 +1,4 @@ -package cn.hamster3.mc.plugin.currency.command.currency; +package cn.hamster3.mc.plugin.currency.command; import cn.hamster3.mc.plugin.core.bukkit.command.ChildCommand; import cn.hamster3.mc.plugin.currency.CurrencyPlugin; diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencySeeCommand.java b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencySeeCommand.java similarity index 98% rename from src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencySeeCommand.java rename to src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencySeeCommand.java index c2c03e0..7a91ca0 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencySeeCommand.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencySeeCommand.java @@ -1,4 +1,4 @@ -package cn.hamster3.mc.plugin.currency.command.currency; +package cn.hamster3.mc.plugin.currency.command; import cn.hamster3.mc.plugin.ball.common.api.BallAPI; import cn.hamster3.mc.plugin.ball.common.entity.BallPlayerInfo; diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencySetCommand.java b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencySetCommand.java similarity index 98% rename from src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencySetCommand.java rename to src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencySetCommand.java index 18cd5f0..e10ad6e 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencySetCommand.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencySetCommand.java @@ -1,4 +1,4 @@ -package cn.hamster3.mc.plugin.currency.command.currency; +package cn.hamster3.mc.plugin.currency.command; import cn.hamster3.mc.plugin.ball.common.api.BallAPI; import cn.hamster3.mc.plugin.ball.common.entity.BallPlayerInfo; diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyTakeCommand.java b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyTakeCommand.java similarity index 89% rename from src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyTakeCommand.java rename to src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyTakeCommand.java index 1b7a2eb..21a3135 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/CurrencyTakeCommand.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/command/CurrencyTakeCommand.java @@ -1,4 +1,4 @@ -package cn.hamster3.mc.plugin.currency.command.currency; +package cn.hamster3.mc.plugin.currency.command; import cn.hamster3.mc.plugin.ball.common.api.BallAPI; import cn.hamster3.mc.plugin.ball.common.entity.BallPlayerInfo; @@ -53,14 +53,15 @@ public class CurrencyTakeCommand extends ChildCommand { CurrencyMessage.PLAYER_NOT_FOUND.show(sender); return true; } - CurrencyType type = CurrencyAPI .getCurrencyType(args[1]); + CurrencyType type = CurrencyAPI.getCurrencyType(args[1]); if (type == null) { CurrencyMessage.CURRENCY_TYPE_NOT_EXIST.show(sender); return true; } double amount = Double.parseDouble(args[2]); - CurrencyAPI.takePlayerCurrency(playerInfo.getUuid(), type.getId(), amount); - CurrencyMessage.CURRENCY_TAKE_SUCCESS.show(sender); + CurrencyAPI.takePlayerCurrency(playerInfo.getUuid(), type.getId(), amount) + .onFailed(throwable -> CurrencyMessage.ERROR_EXCEPTION_ADMIN.show(sender)) + .onSuccess(unused -> CurrencyMessage.CURRENCY_TAKE_SUCCESS.show(sender)); return true; } diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/ParentCurrencyCommand.java b/src/main/java/cn/hamster3/mc/plugin/currency/command/ParentCurrencyCommand.java similarity index 95% rename from src/main/java/cn/hamster3/mc/plugin/currency/command/currency/ParentCurrencyCommand.java rename to src/main/java/cn/hamster3/mc/plugin/currency/command/ParentCurrencyCommand.java index 7f50c56..42c1268 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/command/currency/ParentCurrencyCommand.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/command/ParentCurrencyCommand.java @@ -1,4 +1,4 @@ -package cn.hamster3.mc.plugin.currency.command.currency; +package cn.hamster3.mc.plugin.currency.command; import cn.hamster3.mc.plugin.core.bukkit.command.ParentCommand; import cn.hamster3.mc.plugin.currency.CurrencyPlugin; diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/command/vault/BalanceCommand.java b/src/main/java/cn/hamster3/mc/plugin/currency/command/vault/BalanceCommand.java deleted file mode 100644 index d72fd9a..0000000 --- a/src/main/java/cn/hamster3/mc/plugin/currency/command/vault/BalanceCommand.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.hamster3.mc.plugin.currency.command.vault; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabExecutor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public class BalanceCommand implements TabExecutor { - @Override - public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - return false; - } - - @Nullable - @Override - public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { - return null; - } -} diff --git a/src/main/java/cn/hamster3/mc/plugin/currency/core/CurrencyConfigManager.java b/src/main/java/cn/hamster3/mc/plugin/currency/core/CurrencyConfigManager.java index 13a9960..08d3624 100644 --- a/src/main/java/cn/hamster3/mc/plugin/currency/core/CurrencyConfigManager.java +++ b/src/main/java/cn/hamster3/mc/plugin/currency/core/CurrencyConfigManager.java @@ -5,8 +5,6 @@ import lombok.Getter; import org.bukkit.configuration.file.FileConfiguration; public class CurrencyConfigManager { - @Getter - private static boolean enableVaultCommands; @Getter private static String vaultCurrencyID; @Getter @@ -21,7 +19,6 @@ public class CurrencyConfigManager { FileConfiguration pluginConfig = plugin.getConfig(); - enableVaultCommands = pluginConfig.getBoolean("enable-vault-commands", true); vaultCurrencyID = pluginConfig.getString("vault-settings.currency-id", "money"); vaultNamePlural = pluginConfig.getString("vault-settings.currency-name-plural", "金币"); vaultNameSingular = pluginConfig.getString("vault-settings.currency-name-singular", "金币"); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 10fb10a..1b5b8f7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,19 +1,6 @@ -# 是否启用 vault 默认的指令 -enable-vault-commands: true - # VaultAPI 相关配置 vault-settings: # Vault 显示货币名称(单数) currency-name-singular: 金币 # Vault 显示货币名称(复数) currency-name-plural: 金币 - -# 是否提前加载玩家数据 -# ALL:对于所有货币类型都进行提前 -# VAULT:只对绑定于 VaultAPI 的货币进行提前 -# NONE:对任何货币都不进行提前 -# 提前是指服务端启动时将数据库中所有玩家的货币余额都从数据库中加载到内存 -# 开启提前加载时,如果玩家数量过多,则可能会减慢服务器启动速度 -# 一般来说,设置为 VAULT 即可 -# 该功能暂未实现 -pre-load-data: VAULT