mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 11:59:26 +00:00
Auction System Implementation
This commit is contained in:
1 parent
9cbd9fd3eb
commit
5afa1c8959
60 files changed
+6187
-589
No files matched your search
@@ -0,0 +1,49 @@
|
||||
package noppes.npcs.controllers;
|
||||
|
||||
import kamkeel.npcs.util.VaultUtil;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.config.ConfigMarket;
|
||||
|
||||
/**
|
||||
* Server-side utility for syncing auction configuration to clients.
|
||||
* Handles Vault integration for currency name resolution.
|
||||
*
|
||||
* This class is SERVER-SIDE ONLY. Client reads via AuctionClientConfig.
|
||||
*/
|
||||
public class AuctionConfigSync {
|
||||
|
||||
/**
|
||||
* Write auction config to NBT for sending to client.
|
||||
* Called on server side when building login packet.
|
||||
*
|
||||
* Currency name is resolved from Vault if enabled and available,
|
||||
* otherwise falls back to ConfigMarket.CurrencyName.
|
||||
*/
|
||||
public static NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setBoolean("AuctionEnabled", ConfigMarket.AuctionEnabled);
|
||||
compound.setLong("ListingFee", ConfigMarket.ListingFee);
|
||||
compound.setString("CurrencyName", getEffectiveCurrencyName());
|
||||
compound.setInteger("AuctionDurationHours", ConfigMarket.AuctionDurationHours);
|
||||
compound.setDouble("MinBidIncrement", ConfigMarket.MinBidIncrementPercent);
|
||||
compound.setInteger("MaxActiveListings", ConfigMarket.DefaultMaxListings);
|
||||
compound.setInteger("ClaimExpirationDays", ConfigMarket.ClaimExpirationDays);
|
||||
return compound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective currency name for display.
|
||||
* Uses Vault currency name if Vault is enabled and available,
|
||||
* otherwise uses ConfigMarket.CurrencyName.
|
||||
*
|
||||
* @return The currency name to display
|
||||
*/
|
||||
public static String getEffectiveCurrencyName() {
|
||||
if (ConfigMarket.UseVault && VaultUtil.isEnabled()) {
|
||||
String vaultName = VaultUtil.getCurrencyNamePlural();
|
||||
if (vaultName != null && !vaultName.isEmpty() && !vaultName.equals("coins")) {
|
||||
return vaultName;
|
||||
}
|
||||
}
|
||||
return ConfigMarket.CurrencyName;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user