2021-10-23 03:56:59 +02:00
|
|
|
package net.knarcraft.stargate.config;
|
2021-02-07 03:37:25 +01:00
|
|
|
|
2021-02-22 20:26:10 +01:00
|
|
|
import net.knarcraft.stargate.Stargate;
|
2021-09-19 15:05:19 +02:00
|
|
|
import net.knarcraft.stargate.portal.Portal;
|
2021-11-15 00:35:28 +01:00
|
|
|
import net.knarcraft.stargate.portal.PortalSignDrawer;
|
2021-11-04 00:07:03 +01:00
|
|
|
import net.knarcraft.stargate.portal.property.gate.Gate;
|
2021-10-23 03:56:59 +02:00
|
|
|
import net.knarcraft.stargate.utility.PermissionHelper;
|
2021-02-07 03:37:25 +01:00
|
|
|
import net.milkbowl.vault.economy.Economy;
|
|
|
|
import org.bukkit.Bukkit;
|
2021-11-15 00:35:28 +01:00
|
|
|
import org.bukkit.ChatColor;
|
2021-02-07 03:37:25 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
2021-10-23 03:56:59 +02:00
|
|
|
import org.bukkit.plugin.ServicesManager;
|
2021-02-07 03:37:25 +01:00
|
|
|
|
2021-11-09 15:40:10 +01:00
|
|
|
import java.util.Map;
|
2021-02-07 03:37:25 +01:00
|
|
|
import java.util.UUID;
|
|
|
|
|
2021-02-08 14:30:14 +01:00
|
|
|
/**
|
2021-10-23 03:56:59 +02:00
|
|
|
* The economy config keeps track of economy config values and performs economy actions such as payment for using a gate
|
2021-02-08 14:30:14 +01:00
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public final class EconomyConfig {
|
|
|
|
|
|
|
|
private boolean economyEnabled = false;
|
|
|
|
private Economy economy = null;
|
|
|
|
private Plugin vault = null;
|
|
|
|
private int useCost = 0;
|
|
|
|
private int createCost = 0;
|
|
|
|
private int destroyCost = 0;
|
|
|
|
private boolean toOwner = false;
|
|
|
|
private boolean chargeFreeDestination = true;
|
2021-11-15 00:35:28 +01:00
|
|
|
private boolean freeGatesColored = false;
|
2021-10-23 03:56:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new economy config
|
|
|
|
*
|
2021-11-09 15:40:10 +01:00
|
|
|
* @param configOptions <p>The loaded config options to read</p>
|
2021-10-23 03:56:59 +02:00
|
|
|
*/
|
2021-11-09 15:40:10 +01:00
|
|
|
public EconomyConfig(Map<ConfigOption, Object> configOptions) {
|
|
|
|
loadEconomyConfig(configOptions);
|
2021-10-23 03:56:59 +02:00
|
|
|
}
|
2021-02-07 03:37:25 +01:00
|
|
|
|
2021-02-22 20:26:10 +01:00
|
|
|
/**
|
|
|
|
* Gets the cost of using a gate without a specified cost
|
|
|
|
*
|
|
|
|
* @return <p>The gate use cost</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public int getDefaultUseCost() {
|
2021-02-22 20:26:10 +01:00
|
|
|
return useCost;
|
|
|
|
}
|
|
|
|
|
2021-10-23 03:56:59 +02:00
|
|
|
/**
|
|
|
|
* Gets whether economy is enabled
|
|
|
|
*
|
|
|
|
* @return <p>Whether economy is enabled</p>
|
|
|
|
*/
|
|
|
|
public boolean isEconomyEnabled() {
|
|
|
|
return economyEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the economy object to use for transactions
|
|
|
|
*
|
|
|
|
* @return <p>An economy object, or null if economy is disabled or not initialized</p>
|
|
|
|
*/
|
|
|
|
public Economy getEconomy() {
|
|
|
|
return economy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets an instance of the Vault plugin
|
|
|
|
*
|
|
|
|
* @return <p>An instance of the Vault plugin, or null if Vault is not loaded</p>
|
|
|
|
*/
|
|
|
|
public Plugin getVault() {
|
|
|
|
return vault;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Disables economy support by clearing relevant values
|
|
|
|
*/
|
|
|
|
public void disableEconomy() {
|
|
|
|
this.economy = null;
|
|
|
|
this.vault = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-11-15 00:35:28 +01:00
|
|
|
* Gets whether free portals should be marked with a different coloring
|
2021-10-23 03:56:59 +02:00
|
|
|
*
|
2021-11-15 00:35:28 +01:00
|
|
|
* @return <p>Whether free portals should be colored</p>
|
2021-10-23 03:56:59 +02:00
|
|
|
*/
|
2021-11-15 00:35:28 +01:00
|
|
|
public boolean drawFreePortalsColored() {
|
|
|
|
return freeGatesColored;
|
2021-10-23 03:56:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether a gate whose destination is a free gate is still charged
|
|
|
|
*
|
|
|
|
* <p>If teleporting from a free portal, it's free regardless of destination. If chargeFreeDestination is disabled,
|
|
|
|
* it's also free to teleport back to the free portal. If chargeFreeDestination is enabled, it's only free to
|
|
|
|
* teleport back if teleporting from another free portal.</p>
|
|
|
|
*
|
|
|
|
* @return <p>Whether to charge for free destinations</p>
|
|
|
|
*/
|
|
|
|
public boolean chargeFreeDestination() {
|
|
|
|
return chargeFreeDestination;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets whether payments should be sent to the owner of the used portal
|
|
|
|
*
|
|
|
|
* @return <p>Whether to send payments to the portal owner</p>
|
|
|
|
*/
|
|
|
|
public boolean sendPaymentToOwner() {
|
|
|
|
return toOwner;
|
|
|
|
}
|
|
|
|
|
2021-02-22 20:26:10 +01:00
|
|
|
/**
|
|
|
|
* Sets the cost of using a gate without a specified cost
|
|
|
|
*
|
|
|
|
* <p>The use cost cannot be negative.</p>
|
|
|
|
*
|
|
|
|
* @param useCost <p>The gate use cost</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public void setDefaultUseCost(int useCost) {
|
2021-02-22 20:26:10 +01:00
|
|
|
if (useCost < 0) {
|
|
|
|
throw new IllegalArgumentException("Using a gate cannot cost a negative amount");
|
|
|
|
}
|
2021-10-23 03:56:59 +02:00
|
|
|
this.useCost = useCost;
|
2021-02-22 20:26:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the cost of creating a gate without a specified cost
|
|
|
|
*
|
|
|
|
* @return <p>The gate creation cost</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public int getDefaultCreateCost() {
|
2021-02-22 20:26:10 +01:00
|
|
|
return createCost;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the cost of creating a gate without a specified cost
|
|
|
|
*
|
|
|
|
* <p>The gate create cost cannot be negative</p>
|
|
|
|
*
|
|
|
|
* @param createCost <p>The gate creation cost</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public void setDefaultCreateCost(int createCost) {
|
|
|
|
this.createCost = createCost;
|
2021-02-22 20:26:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the cost of destroying a gate without a specified cost
|
|
|
|
*
|
|
|
|
* @return <p>The gate destruction cost</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public int getDefaultDestroyCost() {
|
2021-02-22 20:26:10 +01:00
|
|
|
return destroyCost;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the cost of destroying a gate without a specified cost
|
|
|
|
*
|
|
|
|
* @param destroyCost <p>The gate destruction cost</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public void setDefaultDestroyCost(int destroyCost) {
|
|
|
|
this.destroyCost = destroyCost;
|
2021-02-22 20:26:10 +01:00
|
|
|
}
|
|
|
|
|
2021-02-08 14:30:14 +01:00
|
|
|
/**
|
2021-09-19 15:05:19 +02:00
|
|
|
* Charges the player for an action, if required
|
2021-09-20 13:56:30 +02:00
|
|
|
*
|
2021-09-19 15:05:19 +02:00
|
|
|
* @param player <p>The player to take money from</p>
|
2021-09-20 13:56:30 +02:00
|
|
|
* @param cost <p>The cost of the transaction</p>
|
2021-09-19 15:05:19 +02:00
|
|
|
* @return <p>True if the player was charged successfully</p>
|
2021-02-08 14:30:14 +01:00
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public boolean chargePlayerIfNecessary(Player player, int cost) {
|
2021-09-19 15:05:19 +02:00
|
|
|
if (skipPayment(cost)) {
|
|
|
|
return true;
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|
2021-10-15 19:25:31 +02:00
|
|
|
//Charge player
|
2021-10-23 03:56:59 +02:00
|
|
|
return chargePlayer(player, cost);
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|
|
|
|
|
2021-10-18 03:36:56 +02:00
|
|
|
/**
|
|
|
|
* Checks whether the given player can afford the given fee
|
|
|
|
*
|
|
|
|
* @param player <p>The player to check</p>
|
2021-10-18 18:38:36 +02:00
|
|
|
* @param cost <p>The fee to pay</p>
|
2021-10-18 03:36:56 +02:00
|
|
|
* @return <p>True if the player can afford to pay the fee</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public boolean canAffordFee(Player player, int cost) {
|
2021-10-18 03:36:56 +02:00
|
|
|
return economy.getBalance(player) > cost;
|
|
|
|
}
|
|
|
|
|
2021-02-08 14:30:14 +01:00
|
|
|
/**
|
2021-09-19 15:05:19 +02:00
|
|
|
* Charges the player for an action, if required
|
2021-09-20 13:56:30 +02:00
|
|
|
*
|
2021-09-19 15:05:19 +02:00
|
|
|
* @param player <p>The player to take money from</p>
|
|
|
|
* @param target <p>The target to pay</p>
|
2021-09-20 13:56:30 +02:00
|
|
|
* @param cost <p>The cost of the transaction</p>
|
2021-09-19 15:05:19 +02:00
|
|
|
* @return <p>True if the player was charged successfully</p>
|
2021-02-08 14:30:14 +01:00
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public boolean chargePlayerIfNecessary(Player player, UUID target, int cost) {
|
2021-09-19 15:05:19 +02:00
|
|
|
if (skipPayment(cost)) {
|
|
|
|
return true;
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|
2021-10-15 19:25:31 +02:00
|
|
|
//Charge player
|
2021-10-23 03:56:59 +02:00
|
|
|
return chargePlayer(player, target, cost);
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|
|
|
|
|
2021-02-08 14:30:14 +01:00
|
|
|
/**
|
|
|
|
* Gets a formatted string for an amount, adding the name of the currency
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-08 14:30:14 +01:00
|
|
|
* @param amount <p>The amount to display</p>
|
|
|
|
* @return <p>A formatted text string describing the amount</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public String format(int amount) {
|
2021-02-07 03:37:25 +01:00
|
|
|
if (economyEnabled) {
|
2021-02-08 14:30:14 +01:00
|
|
|
return economy.format(amount);
|
|
|
|
} else {
|
|
|
|
return "";
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-08 14:30:14 +01:00
|
|
|
/**
|
|
|
|
* Sets up economy by initializing vault and the vault economy provider
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-08 14:30:14 +01:00
|
|
|
* @param pluginManager <p>The plugin manager to get plugins from</p>
|
|
|
|
* @return <p>True if economy was enabled</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public boolean setupEconomy(PluginManager pluginManager) {
|
2021-02-08 14:30:14 +01:00
|
|
|
if (!economyEnabled) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-10-15 19:25:31 +02:00
|
|
|
//Check if vault is loaded
|
2021-02-08 14:30:14 +01:00
|
|
|
Plugin vault = pluginManager.getPlugin("Vault");
|
|
|
|
if (vault != null && vault.isEnabled()) {
|
2021-10-29 18:35:20 +02:00
|
|
|
ServicesManager servicesManager = Stargate.getInstance().getServer().getServicesManager();
|
2021-10-23 03:56:59 +02:00
|
|
|
RegisteredServiceProvider<Economy> economyProvider = servicesManager.getRegistration(Economy.class);
|
2021-02-07 03:37:25 +01:00
|
|
|
if (economyProvider != null) {
|
|
|
|
economy = economyProvider.getProvider();
|
2021-10-23 03:56:59 +02:00
|
|
|
this.vault = vault;
|
2021-02-07 03:37:25 +01:00
|
|
|
return true;
|
2021-02-09 20:09:49 +01:00
|
|
|
} else {
|
2021-10-26 15:05:05 +02:00
|
|
|
Stargate.logInfo(Stargate.getString("ecoLoadError"));
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|
2021-02-09 20:09:49 +01:00
|
|
|
} else {
|
2021-10-26 15:05:05 +02:00
|
|
|
Stargate.logInfo(Stargate.getString("vaultLoadError"));
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|
|
|
|
economyEnabled = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-02-08 14:30:14 +01:00
|
|
|
/**
|
|
|
|
* Gets whether to use economy
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-08 14:30:14 +01:00
|
|
|
* @return <p>True if the user has turned on economy and economy is available</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public boolean useEconomy() {
|
2021-02-07 03:37:25 +01:00
|
|
|
return economyEnabled && economy != null;
|
|
|
|
}
|
|
|
|
|
2021-09-19 15:05:19 +02:00
|
|
|
/**
|
|
|
|
* Checks whether a payment transaction should be skipped
|
2021-09-20 13:56:30 +02:00
|
|
|
*
|
2021-09-19 15:05:19 +02:00
|
|
|
* @param cost <p>The cost of the transaction</p>
|
|
|
|
* @return <p>True if the transaction should be skipped</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
private boolean skipPayment(int cost) {
|
|
|
|
return cost == 0 || !useEconomy();
|
2021-09-19 15:05:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines the cost of using a gate
|
|
|
|
*
|
2021-09-20 13:56:30 +02:00
|
|
|
* @param player <p>The player trying to use the gate</p>
|
|
|
|
* @param source <p>The source/entry portal</p>
|
2021-09-19 15:05:19 +02:00
|
|
|
* @param destination <p>The destination portal</p>
|
|
|
|
* @return <p>The cost of using the portal</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public int getUseCost(Player player, Portal source, Portal destination) {
|
2021-09-19 15:05:19 +02:00
|
|
|
//No payment required
|
2021-10-23 03:56:59 +02:00
|
|
|
if (!useEconomy() || source.getOptions().isFree()) {
|
2021-09-19 15:05:19 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//Not charging for free destinations
|
2021-10-23 03:56:59 +02:00
|
|
|
if (destination != null && !chargeFreeDestination && destination.getOptions().isFree()) {
|
2021-09-19 15:05:19 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//Cost is 0 if the player owns this gate and funds go to the owner
|
|
|
|
if (source.getGate().getToOwner() && source.isOwner(player)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//Player gets free gate use
|
2021-10-28 18:29:33 +02:00
|
|
|
if (PermissionHelper.hasPermission(player, "stargate.free.use")) {
|
2021-09-19 15:05:19 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return source.getGate().getUseCost();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the cost of creating the given gate
|
2021-09-20 13:56:30 +02:00
|
|
|
*
|
2021-09-19 15:05:19 +02:00
|
|
|
* @param player <p>The player creating the gate</p>
|
2021-09-20 13:56:30 +02:00
|
|
|
* @param gate <p>The gate type used</p>
|
2021-09-19 15:05:19 +02:00
|
|
|
* @return <p>The cost of creating the gate</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public int getCreateCost(Player player, Gate gate) {
|
2021-09-19 15:05:19 +02:00
|
|
|
if (isFree(player, "create")) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return gate.getCreateCost();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the cost of destroying the given gate
|
2021-09-20 13:56:30 +02:00
|
|
|
*
|
2021-09-19 15:05:19 +02:00
|
|
|
* @param player <p>The player creating the gate</p>
|
2021-09-20 13:56:30 +02:00
|
|
|
* @param gate <p>The gate type used</p>
|
2021-09-19 15:05:19 +02:00
|
|
|
* @return <p>The cost of destroying the gate</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
public int getDestroyCost(Player player, Gate gate) {
|
2021-09-19 15:05:19 +02:00
|
|
|
if (isFree(player, "destroy")) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return gate.getDestroyCost();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-23 03:56:59 +02:00
|
|
|
/**
|
|
|
|
* Loads all config values related to economy
|
|
|
|
*
|
2021-11-09 15:40:10 +01:00
|
|
|
* @param configOptions <p>The loaded config options to get values from</p>
|
2021-10-23 03:56:59 +02:00
|
|
|
*/
|
2021-11-09 15:40:10 +01:00
|
|
|
private void loadEconomyConfig(Map<ConfigOption, Object> configOptions) {
|
|
|
|
economyEnabled = (boolean) configOptions.get(ConfigOption.USE_ECONOMY);
|
|
|
|
setDefaultCreateCost((Integer) configOptions.get(ConfigOption.CREATE_COST));
|
|
|
|
setDefaultDestroyCost((Integer) configOptions.get(ConfigOption.DESTROY_COST));
|
|
|
|
setDefaultUseCost((Integer) configOptions.get(ConfigOption.USE_COST));
|
|
|
|
toOwner = (boolean) configOptions.get(ConfigOption.TO_OWNER);
|
|
|
|
chargeFreeDestination = (boolean) configOptions.get(ConfigOption.CHARGE_FREE_DESTINATION);
|
2021-11-15 00:35:28 +01:00
|
|
|
freeGatesColored = (boolean) configOptions.get(ConfigOption.FREE_GATES_COLORED);
|
|
|
|
|
|
|
|
try {
|
|
|
|
String freeColor = (String) configOptions.get(ConfigOption.FREE_GATES_COLOR);
|
|
|
|
PortalSignDrawer.setFreeColor(ChatColor.valueOf(freeColor.toUpperCase()));
|
|
|
|
} catch (IllegalArgumentException | NullPointerException ignored) {
|
|
|
|
PortalSignDrawer.setFreeColor(ChatColor.DARK_GREEN);
|
|
|
|
}
|
2021-10-23 03:56:59 +02:00
|
|
|
}
|
|
|
|
|
2021-09-19 15:05:19 +02:00
|
|
|
/**
|
|
|
|
* Determines if a player can do a gate action for free
|
2021-09-20 13:56:30 +02:00
|
|
|
*
|
|
|
|
* @param player <p>The player to check</p>
|
2021-09-19 15:05:19 +02:00
|
|
|
* @param permissionNode <p>The free.permissionNode necessary to allow free gate {action}</p>
|
|
|
|
* @return <p></p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
private boolean isFree(Player player, String permissionNode) {
|
2021-10-28 18:29:33 +02:00
|
|
|
return !useEconomy() || PermissionHelper.hasPermission(player, "stargate.free." + permissionNode);
|
2021-09-19 15:05:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Charges a player
|
|
|
|
*
|
|
|
|
* @param player <p>The player to charge</p>
|
|
|
|
* @param amount <p>The amount to charge</p>
|
|
|
|
* @return <p>True if the payment succeeded, or if no payment was necessary</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
private boolean chargePlayer(Player player, double amount) {
|
2021-09-19 15:05:19 +02:00
|
|
|
if (economyEnabled && economy != null) {
|
|
|
|
if (!economy.has(player, amount)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
economy.withdrawPlayer(player, amount);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Charges a player, giving the charge to a target
|
|
|
|
*
|
|
|
|
* @param player <p>The player to charge</p>
|
|
|
|
* @param target <p>The UUID of the player to pay</p>
|
|
|
|
* @param amount <p>The amount to charge</p>
|
|
|
|
* @return <p>True if the payment succeeded, or if no payment was necessary</p>
|
|
|
|
*/
|
2021-10-23 03:56:59 +02:00
|
|
|
private boolean chargePlayer(Player player, UUID target, double amount) {
|
2021-09-19 15:05:19 +02:00
|
|
|
if (economyEnabled && player.getUniqueId().compareTo(target) != 0 && economy != null) {
|
|
|
|
if (!economy.has(player, amount)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//Take money from the user and give to the owner
|
|
|
|
economy.withdrawPlayer(player, amount);
|
|
|
|
economy.depositPlayer(Bukkit.getOfflinePlayer(target), amount);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|