mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-21 05:15:11 +01:00
💎 ecobits support
Took 3 minutes
This commit is contained in:
parent
a87a249321
commit
fc06ad7f44
@ -0,0 +1,59 @@
|
||||
package ca.tweetzy.auctionhouse.impl.currency;
|
||||
|
||||
import ca.tweetzy.auctionhouse.api.currency.IconableCurrency;
|
||||
import ca.tweetzy.flight.comp.enums.CompMaterial;
|
||||
import com.willfp.ecobits.currencies.Currencies;
|
||||
import com.willfp.ecobits.currencies.Currency;
|
||||
import com.willfp.ecobits.currencies.CurrencyUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public final class EcoBitsCurrency extends IconableCurrency {
|
||||
|
||||
private final Currency currency;
|
||||
|
||||
public EcoBitsCurrency(String currencyName) {
|
||||
super("EcoBits", currencyName, "", CompMaterial.PAPER.parseItem());
|
||||
this.currency = Currencies.getByID(currencyName.toLowerCase());
|
||||
|
||||
if (this.currency != null) {
|
||||
setDisplayName(this.currency.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(OfflinePlayer player, double amount) {
|
||||
if (this.currency == null)
|
||||
return false;
|
||||
|
||||
return CurrencyUtils.getBalance(player, currency).doubleValue() >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean withdraw(OfflinePlayer player, double amount) {
|
||||
if (this.currency == null)
|
||||
return false;
|
||||
|
||||
CurrencyUtils.setBalance(player, currency, BigDecimal.valueOf(CurrencyUtils.getBalance(player, currency).doubleValue() - amount));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deposit(OfflinePlayer player, double amount) {
|
||||
if (this.currency == null)
|
||||
return false;
|
||||
|
||||
CurrencyUtils.setBalance(player, currency, BigDecimal.valueOf(CurrencyUtils.getBalance(player, currency).doubleValue() + amount));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(OfflinePlayer player) {
|
||||
if (this.currency == null)
|
||||
return 0;
|
||||
|
||||
return CurrencyUtils.getBalance(player, currency).doubleValue();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package ca.tweetzy.auctionhouse.model.currency;
|
||||
|
||||
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
|
||||
import ca.tweetzy.auctionhouse.impl.currency.EcoBitsCurrency;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import com.willfp.ecobits.currencies.Currencies;
|
||||
import com.willfp.ecobits.currencies.Currency;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class EcoBitsEconomyLoader extends CurrencyLoader {
|
||||
|
||||
public EcoBitsEconomyLoader() {
|
||||
super("EcoBits");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AbstractCurrency> getCurrencies() {
|
||||
final List<AbstractCurrency> currencies = new ArrayList<>();
|
||||
|
||||
for (Currency currency : Currencies.values()) {
|
||||
boolean blackListed = false;
|
||||
|
||||
for (String blacklisted : Settings.CURRENCY_BLACKLISTED.getStringList()) {
|
||||
final String[] blacklistSplit = blacklisted.split(":");
|
||||
|
||||
if (blacklistSplit.length != 2) continue;
|
||||
if (!blacklistSplit[0].equalsIgnoreCase(this.owningPlugin)) continue;
|
||||
|
||||
if (blacklistSplit[1].equalsIgnoreCase(currency.getName()))
|
||||
blackListed = true;
|
||||
|
||||
}
|
||||
|
||||
if (!blackListed)
|
||||
currencies.add(new EcoBitsCurrency(currency.getId()));
|
||||
}
|
||||
|
||||
return currencies;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
|
||||
import ca.tweetzy.auctionhouse.api.manager.ListManager;
|
||||
import ca.tweetzy.auctionhouse.impl.currency.ItemCurrency;
|
||||
import ca.tweetzy.auctionhouse.impl.currency.VaultCurrency;
|
||||
import ca.tweetzy.auctionhouse.model.currency.EcoBitsEconomyLoader;
|
||||
import ca.tweetzy.auctionhouse.model.currency.FundsEconomyLoader;
|
||||
import ca.tweetzy.auctionhouse.model.currency.UltraEconomyLoader;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
@ -123,5 +124,8 @@ public final class CurrencyManager extends ListManager<AbstractCurrency> {
|
||||
|
||||
if (Bukkit.getServer().getPluginManager().isPluginEnabled("Funds"))
|
||||
new FundsEconomyLoader().getCurrencies().forEach(this::add);
|
||||
|
||||
if (Bukkit.getServer().getPluginManager().isPluginEnabled("EcoBits"))
|
||||
new EcoBitsEconomyLoader().getCurrencies().forEach(this::add);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,6 @@ version: maven-version-number
|
||||
api-version: 1.13
|
||||
main: ca.tweetzy.auctionhouse.AuctionHouse
|
||||
description: Auction House is a premium auction solution for your server.
|
||||
website: https://tweetzy.ca/
|
||||
website: https://discord.tweetzy.ca/
|
||||
authors: [ Kiran Hart ]
|
||||
softdepend: [ Vault, PlayerPoints, PlaceholderAPI, MMOItemsHook, UltraEconomy, CMI, Essentials, ChestShop, EcoEnchants ]
|
||||
softdepend: [ Vault, PlayerPoints, PlaceholderAPI, MMOItemsHook, UltraEconomy, CMI, Essentials, ChestShop, EcoEnchants, EcoBits, Funds ]
|
||||
|
Loading…
Reference in New Issue
Block a user