mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-12-01 06:23:22 +01:00
d6bdb0486a
- Formatting - Warning about old Bukkit version - Renamed "TOWNY_CANNOT_CREATE_SHOP_HERE" to "CANNOT_CREATE_SHOP_HERE" to avoid confusion - Renamed "NOT_ENOUGH_LWC_PROTECTIONS" to "NOT_ENOUGH_PROTECTIONS" and changed its message - Fixed armour enchantments - Logging shop location - Fixed Heroes for the newest version - Removed redutant plugin object - Added dev-url for CraftBukkitUpToDate - Removed redutant plugins from softdepend - Fixed a bug when the player interacts with a shop with a sign in hand
59 lines
1.7 KiB
Java
59 lines
1.7 KiB
Java
package com.Acrobot.ChestShop.Economy;
|
|
|
|
import com.Acrobot.ChestShop.Config.Config;
|
|
import com.Acrobot.ChestShop.Config.Property;
|
|
import com.Acrobot.ChestShop.Utils.uLongName;
|
|
|
|
/**
|
|
* @author Acrobot
|
|
* Economy management
|
|
*/
|
|
public class Economy {
|
|
public static EcoPlugin economy;
|
|
|
|
public static boolean hasAccount(String p) {
|
|
return economy.hasAccount(uLongName.getName(p));
|
|
}
|
|
|
|
public static void add(String name, float amount) {
|
|
String account = Config.getString(Property.SERVER_ECONOMY_ACCOUNT);
|
|
if (!account.isEmpty()) {
|
|
float tax = getTax(Property.TAX_AMOUNT, amount);
|
|
economy.add(account, tax);
|
|
amount = amount - tax;
|
|
}
|
|
|
|
economy.add(uLongName.getName(name), amount);
|
|
}
|
|
|
|
public static void addServer(String name, float amount) {
|
|
String account = Config.getString(Property.SERVER_ECONOMY_ACCOUNT);
|
|
if (!account.isEmpty()) {
|
|
float tax = getTax(Property.SERVER_TAX_AMOUNT, amount);
|
|
economy.add(account, tax);
|
|
amount = amount - tax;
|
|
}
|
|
economy.add(uLongName.getName(name), amount);
|
|
}
|
|
|
|
public static float getTax(Property tax, float price) {
|
|
return (Config.getFloat(tax) / 100F) * price;
|
|
}
|
|
|
|
public static void subtract(String name, float amount) {
|
|
economy.subtract(uLongName.getName(name), amount);
|
|
}
|
|
|
|
public static boolean hasEnough(String name, float amount) {
|
|
return economy.hasEnough(uLongName.getName(name), amount);
|
|
}
|
|
|
|
public static double balance(String name) {
|
|
return economy.balance(uLongName.getName(name));
|
|
}
|
|
|
|
public static String formatBalance(double amount) {
|
|
return economy.format(amount);
|
|
}
|
|
}
|