feat: code

This commit is contained in:
2026-02-12 00:29:35 -08:00
parent ce7b7f50ab
commit bade441923
5 changed files with 39 additions and 18 deletions

View File

@@ -34,7 +34,7 @@ tasks {
}
shadowJar {
archiveFileName.set("mineroo-paper.jar")
archiveFileName.set("MinerooCore-Paper.jar")
}
withType<Jar> {

View File

@@ -149,11 +149,17 @@ public class Config {
}
public static class CurrenciesSection {
private final boolean enable;
private final String primary;
public CurrenciesSection(FileConfiguration config) {
this.enable = config.getBoolean("currencies.enable", true);
this.primary = config.getString("currencies.primary", "money");
}
public boolean isEnable() {
return enable;
}
public String getPrimary() {
return primary;
}

View File

@@ -54,7 +54,8 @@ public class MinerooCore extends JavaPlugin implements Listener {
}
// register vault
if (getServer().getPluginManager().getPlugin("Vault") != null) {
if (getServer().getPluginManager().getPlugin("Vault") != null
&& config.getCurrencies().isEnable()) {
MinerooEconomy economy = new MinerooEconomy(this);
getServer().getServicesManager().register(

View File

@@ -114,8 +114,6 @@ public class MinerooEconomy extends AbstractEconomy {
return has(player, amount);
}
// --- 核心:扣款 (Withdraw) ---
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
return withdrawPlayer(Bukkit.getOfflinePlayer(playerName), amount);
@@ -139,13 +137,20 @@ public class MinerooEconomy extends AbstractEconomy {
currency().modifyCachedBalance(player.getUniqueId(), PRIMARY_CURRENCY, -amount);
long deltaCents = (long) (-amount * 100);
currency().ModifyPlayerCurrency(
deltaCents,
player.getUniqueId(),
UUID.randomUUID().toString(),
PRIMARY_CURRENCY,
"Plugin Withdraw"
);
currency()
.ModifyPlayerCurrency(
deltaCents,
player.getUniqueId(),
UUID.randomUUID().toString(),
PRIMARY_CURRENCY,
"Plugin Withdraw"
)
.thenAccept(resp -> {
if (!resp.isSuccess()) {
plugin.getLogger().severe("Sync failed: " + resp.getMessage());
currency().modifyCachedBalance(player.getUniqueId(), PRIMARY_CURRENCY, amount);
}
});
return new EconomyResponse(
amount, balance - amount, EconomyResponse.ResponseType.SUCCESS, null
@@ -180,13 +185,20 @@ public class MinerooEconomy extends AbstractEconomy {
currency().modifyCachedBalance(player.getUniqueId(), PRIMARY_CURRENCY, amount);
long deltaCents = (long) (amount * 100);
currency().ModifyPlayerCurrency(
deltaCents,
player.getUniqueId(),
UUID.randomUUID().toString(),
PRIMARY_CURRENCY,
"Plugin Deposit"
);
currency()
.ModifyPlayerCurrency(
deltaCents,
player.getUniqueId(),
UUID.randomUUID().toString(),
PRIMARY_CURRENCY,
"Plugin Deposit"
)
.thenAccept(resp -> {
if (!resp.isSuccess()) {
plugin.getLogger().severe("Sync failed: " + resp.getMessage());
currency().modifyCachedBalance(player.getUniqueId(), PRIMARY_CURRENCY, amount);
}
});
return new EconomyResponse(
amount, getBalance(player), EconomyResponse.ResponseType.SUCCESS, null

View File

@@ -13,6 +13,8 @@ server:
token: "get token from `mineroo.online/resources/servers` page!"
currencies:
enable: true
# which currency slug should bound into `VaultApi`
primary: "money"