mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-01-23 15:21:20 +01:00
✨ Added CoinsEngine support ✨
This commit is contained in:
parent
3d071e0144
commit
82ac56badf
@ -0,0 +1,52 @@
|
||||
package ca.tweetzy.auctionhouse.impl.currency;
|
||||
|
||||
import ca.tweetzy.auctionhouse.api.currency.IconableCurrency;
|
||||
import ca.tweetzy.flight.comp.enums.CompMaterial;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import su.nightexpress.coinsengine.api.CoinsEngineAPI;
|
||||
import su.nightexpress.coinsengine.api.currency.Currency;
|
||||
|
||||
public final class CoinEngineCurrency extends IconableCurrency {
|
||||
|
||||
private final Currency currency;
|
||||
|
||||
public CoinEngineCurrency(String currencyName) {
|
||||
super("CoinsEngine", currencyName, "", CompMaterial.PAPER.parseItem());
|
||||
this.currency = CoinsEngineAPI.getCurrency(currencyName);
|
||||
|
||||
if (this.currency != null) {
|
||||
setDisplayName(this.currency.getName());
|
||||
setIcon(this.currency.getIcon());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(OfflinePlayer player, double amount) {
|
||||
if (this.currency == null)
|
||||
return false;
|
||||
|
||||
return CoinsEngineAPI.getBalance(player.getUniqueId(), this.currency) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean withdraw(OfflinePlayer player, double amount) {
|
||||
if (this.currency == null)
|
||||
return false;
|
||||
|
||||
return CoinsEngineAPI.removeBalance(player.getUniqueId(), this.currency, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deposit(OfflinePlayer player, double amount) {
|
||||
if (this.currency == null)
|
||||
return false;
|
||||
|
||||
return CoinsEngineAPI.addBalance(player.getUniqueId(), this.currency, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(OfflinePlayer player) {
|
||||
return CoinsEngineAPI.getBalance(player.getUniqueId(), this.currency);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package ca.tweetzy.auctionhouse.model.currency;
|
||||
|
||||
import ca.tweetzy.auctionhouse.api.currency.AbstractCurrency;
|
||||
import ca.tweetzy.auctionhouse.impl.currency.CoinEngineCurrency;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import su.nightexpress.coinsengine.api.CoinsEngineAPI;
|
||||
import su.nightexpress.coinsengine.api.currency.Currency;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class CoinEngineEconomyLoader extends CurrencyLoader {
|
||||
|
||||
public CoinEngineEconomyLoader() {
|
||||
super("CoinsEngine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractCurrency> getCurrencies() {
|
||||
final List<AbstractCurrency> currencies = new ArrayList<>();
|
||||
|
||||
for (Currency currency : CoinsEngineAPI.getCurrencyManager().getCurrencies()) {
|
||||
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.getId()))
|
||||
blackListed = true;
|
||||
|
||||
}
|
||||
|
||||
if (!blackListed)
|
||||
currencies.add(new CoinEngineCurrency(currency.getId()));
|
||||
}
|
||||
|
||||
return currencies;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import ca.tweetzy.auctionhouse.api.manager.ListManager;
|
||||
import ca.tweetzy.auctionhouse.impl.currency.AllCurrency;
|
||||
import ca.tweetzy.auctionhouse.impl.currency.ItemCurrency;
|
||||
import ca.tweetzy.auctionhouse.impl.currency.VaultCurrency;
|
||||
import ca.tweetzy.auctionhouse.model.currency.CoinEngineEconomyLoader;
|
||||
import ca.tweetzy.auctionhouse.model.currency.EcoBitsEconomyLoader;
|
||||
import ca.tweetzy.auctionhouse.model.currency.FundsEconomyLoader;
|
||||
import ca.tweetzy.auctionhouse.model.currency.UltraEconomyLoader;
|
||||
@ -154,5 +155,8 @@ public final class CurrencyManager extends ListManager<AbstractCurrency> {
|
||||
|
||||
if (Bukkit.getServer().getPluginManager().isPluginEnabled("EcoBits"))
|
||||
new EcoBitsEconomyLoader().getCurrencies().forEach(this::add);
|
||||
|
||||
if (Bukkit.getServer().getPluginManager().isPluginEnabled("CoinsEngine"))
|
||||
new CoinEngineEconomyLoader().getCurrencies().forEach(this::add);
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,10 @@ public class Settings {
|
||||
public static final ConfigSetting LISTING_PRIORITY_TIME_ALLOW_MULTI_BOOST = new ConfigSetting(config, "auction setting.listing priority.allow multiple boost", false, "If true players can boost an item multiple times before it runs out. (ex. if they have a boost active they can extend by paying before it expires)");
|
||||
public static final ConfigSetting LISTING_PRIORITY_TIME_COST_PER_BOOST = new ConfigSetting(config, "auction setting.listing priority.cost per boost", 1000, "How much should it cost the player to boost their item each time");
|
||||
|
||||
// Timed Usage
|
||||
public static final ConfigSetting TIMED_USAGE = new ConfigSetting(config, "auction setting.access hours.use access hours", false, "If true, the auction house will be only accessible");
|
||||
|
||||
|
||||
public static final ConfigSetting SHOW_LISTING_ERROR_IN_CONSOLE = new ConfigSetting(config, "auction setting.show listing error in console", false, "If true, an exception will be thrown and shown in the console if something goes wrong during item listing");
|
||||
public static final ConfigSetting STORE_PAYMENTS_FOR_MANUAL_COLLECTION = new ConfigSetting(config, "auction setting.store payments for manual collection", false, "If true, auction house will store the payments to be manually collected rather than automatically given to the player");
|
||||
public static final ConfigSetting MANUAL_PAYMENTS_ONLY_FOR_OFFLINE_USERS = new ConfigSetting(config, "auction setting.use stored payments for offline only", false, "If true, the usage of the manual payment collection will only be done if the user is offline");
|
||||
|
@ -5,4 +5,4 @@ main: ca.tweetzy.auctionhouse.AuctionHouse
|
||||
description: Auction House is a premium auction solution for your server.
|
||||
website: https://discord.tweetzy.ca/
|
||||
authors: [ Kiran Hart ]
|
||||
softdepend: [ Vault, PlayerPoints, PlaceholderAPI, MMOItemsHook, UltraEconomy, CMI, Essentials, ChestShop, EcoEnchants, EcoBits, Funds ]
|
||||
softdepend: [ Vault, PlayerPoints, PlaceholderAPI, MMOItemsHook, UltraEconomy, CMI, Essentials, ChestShop, EcoEnchants, EcoBits, Funds, CoinsEngine ]
|
||||
|
Loading…
Reference in New Issue
Block a user