perf: 优化代码
This commit is contained in:
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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
|
||||
|
@@ -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 变量");
|
||||
|
@@ -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() {
|
||||
}
|
||||
|
@@ -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;
|
@@ -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;
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
@@ -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;
|
@@ -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;
|
@@ -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;
|
@@ -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 CurrencyTakeCommand extends ChildCommand {
|
||||
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;
|
||||
}
|
||||
|
@@ -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;
|
@@ -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<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -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", "金币");
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user