2011-10-05 12:13:54 +02:00
package com.massivecraft.factions.integration ;
Added basic support for iConomy, where most Factions commands can be made to cost (or give) money. For claiming land, there are some extra features. Each additional land claimed by default costs more than the last, with the multiplier being configurable. For example, the first claim might cost $30, the 2nd $45, the third $60, and so forth. When land is claimed from a weakened faction, there is a configurable bonus amount of money deducted from the cost of claiming the land, as an incentive; this number can be changed to a negative value to instead make it cost more to claim such land. When land is unclaimed, a configurable percentage of the cost of claiming the land can be refunded (defaults to 70% of the cost). The total value of a faction's claimed land is now shown in the info given by /f who [faction tag], along with the depreciated (refund) value.
2011-08-02 01:05:01 +02:00
2014-11-06 01:36:47 +01:00
import com.massivecraft.factions.Conf ;
import com.massivecraft.factions.FPlayer ;
import com.massivecraft.factions.Faction ;
import com.massivecraft.factions.P ;
2011-10-12 17:25:01 +02:00
import com.massivecraft.factions.iface.EconomyParticipator ;
2011-10-13 16:07:07 +02:00
import com.massivecraft.factions.struct.Permission ;
2011-10-12 17:25:01 +02:00
import com.massivecraft.factions.struct.Role ;
import com.massivecraft.factions.util.RelationUtil ;
2018-01-02 10:37:12 +01:00
import com.massivecraft.factions.zcore.util.TL ;
2012-01-17 02:36:32 +01:00
import net.milkbowl.vault.economy.Economy ;
2013-01-04 16:54:00 +01:00
import net.milkbowl.vault.economy.EconomyResponse ;
2014-04-04 20:55:21 +02:00
import org.bukkit.Bukkit ;
2014-08-05 13:23:21 +02:00
import org.bukkit.OfflinePlayer ;
2014-04-04 20:55:21 +02:00
import org.bukkit.plugin.RegisteredServiceProvider ;
2014-10-16 02:56:02 +02:00
import java.text.DecimalFormat ;
2014-04-04 20:55:21 +02:00
import java.util.HashSet ;
import java.util.Set ;
2014-08-05 13:23:21 +02:00
import java.util.UUID ;
2014-04-04 20:55:21 +02:00
import java.util.logging.Level ;
public class Econ {
2014-08-05 17:17:27 +02:00
2014-04-04 20:55:21 +02:00
private static Economy econ = null ;
public static void setup ( ) {
2014-07-01 22:10:18 +02:00
if ( isSetup ( ) ) {
return ;
}
2014-04-04 20:55:21 +02:00
String integrationFail = " Economy integration is " + ( Conf . econEnabled ? " enabled, but " : " disabled, and " ) + " the plugin \" Vault \" " ;
if ( Bukkit . getServer ( ) . getPluginManager ( ) . getPlugin ( " Vault " ) = = null ) {
2014-07-01 22:10:18 +02:00
P . p . log ( integrationFail + " is not installed. " ) ;
return ;
2014-04-04 20:55:21 +02:00
}
RegisteredServiceProvider < Economy > rsp = Bukkit . getServer ( ) . getServicesManager ( ) . getRegistration ( Economy . class ) ;
if ( rsp = = null ) {
2014-07-01 22:10:18 +02:00
P . p . log ( integrationFail + " is not hooked into an economy plugin. " ) ;
return ;
}
econ = rsp . getProvider ( ) ;
2014-04-04 20:55:21 +02:00
P . p . log ( " Economy integration through Vault plugin successful. " ) ;
2014-07-01 21:49:42 +02:00
if ( ! Conf . econEnabled ) {
2014-04-04 20:55:21 +02:00
P . p . log ( " NOTE: Economy is disabled. You can enable it with the command: f config econEnabled true " ) ;
2014-07-01 21:49:42 +02:00
}
2014-04-04 20:55:21 +02:00
P . p . cmdBase . cmdHelp . updateHelp ( ) ;
}
public static boolean shouldBeUsed ( ) {
return Conf . econEnabled & & econ ! = null & & econ . isEnabled ( ) ;
}
public static boolean isSetup ( ) {
return econ ! = null ;
}
public static void modifyUniverseMoney ( double delta ) {
2014-07-01 22:10:18 +02:00
if ( ! shouldBeUsed ( ) ) {
return ;
}
2014-04-04 20:55:21 +02:00
2014-07-01 22:10:18 +02:00
if ( Conf . econUniverseAccount = = null ) {
return ;
}
if ( Conf . econUniverseAccount . length ( ) = = 0 ) {
return ;
}
if ( ! econ . hasAccount ( Conf . econUniverseAccount ) ) {
return ;
}
2014-04-04 20:55:21 +02:00
modifyBalance ( Conf . econUniverseAccount , delta ) ;
}
public static void sendBalanceInfo ( FPlayer to , EconomyParticipator about ) {
if ( ! shouldBeUsed ( ) ) {
2014-07-01 22:10:18 +02:00
P . p . log ( Level . WARNING , " Vault does not appear to be hooked into an economy plugin. " ) ;
return ;
2014-04-04 20:55:21 +02:00
}
to . msg ( " <a>%s's<i> balance is <h>%s<i>. " , about . describeTo ( to , true ) , Econ . moneyString ( econ . getBalance ( about . getAccountId ( ) ) ) ) ;
}
2012-01-17 02:36:32 +01:00
2014-04-04 20:55:21 +02:00
public static boolean canIControllYou ( EconomyParticipator i , EconomyParticipator you ) {
2014-07-01 22:10:18 +02:00
Faction fI = RelationUtil . getFaction ( i ) ;
Faction fYou = RelationUtil . getFaction ( you ) ;
Added basic support for iConomy, where most Factions commands can be made to cost (or give) money. For claiming land, there are some extra features. Each additional land claimed by default costs more than the last, with the multiplier being configurable. For example, the first claim might cost $30, the 2nd $45, the third $60, and so forth. When land is claimed from a weakened faction, there is a configurable bonus amount of money deducted from the cost of claiming the land, as an incentive; this number can be changed to a negative value to instead make it cost more to claim such land. When land is unclaimed, a configurable percentage of the cost of claiming the land can be refunded (defaults to 70% of the cost). The total value of a faction's claimed land is now shown in the info given by /f who [faction tag], along with the depreciated (refund) value.
2011-08-02 01:05:01 +02:00
2014-04-04 20:55:21 +02:00
// This is a system invoker. Accept it.
2014-07-01 22:10:18 +02:00
if ( fI = = null ) {
return true ;
}
2014-04-04 20:55:21 +02:00
// Bypassing players can do any kind of transaction
2014-07-01 22:10:18 +02:00
if ( i instanceof FPlayer & & ( ( FPlayer ) i ) . isAdminBypassing ( ) ) {
return true ;
}
2014-04-04 20:55:21 +02:00
// Players with the any withdraw can do.
2014-07-01 22:10:18 +02:00
if ( i instanceof FPlayer & & Permission . MONEY_WITHDRAW_ANY . has ( ( ( FPlayer ) i ) . getPlayer ( ) ) ) {
return true ;
}
2014-04-04 20:55:21 +02:00
// You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again.
2014-07-01 22:10:18 +02:00
if ( i = = you ) {
return true ;
}
2014-04-04 20:55:21 +02:00
// A faction can always transfer away the money of it's members and its own money...
// This will however probably never happen as a faction does not have free will.
// Ohh by the way... Yes it could. For daily rent to the faction.
2014-07-01 22:10:18 +02:00
if ( i = = fI & & fI = = fYou ) {
return true ;
}
2014-04-04 20:55:21 +02:00
// Factions can be controlled by members that are moderators... or any member if any member can withdraw.
2014-07-01 21:49:42 +02:00
if ( you instanceof Faction & & fI = = fYou & & ( Conf . bankMembersCanWithdraw | | ( ( FPlayer ) i ) . getRole ( ) . value > = Role . MODERATOR . value ) ) {
2014-04-04 20:55:21 +02:00
return true ;
2014-07-01 21:49:42 +02:00
}
2014-04-04 20:55:21 +02:00
// Otherwise you may not! ;,,;
i . msg ( " <h>%s<i> lacks permission to control <h>%s's<i> money. " , i . describeTo ( i , true ) , you . describeTo ( i ) ) ;
return false ;
}
public static boolean transferMoney ( EconomyParticipator invoker , EconomyParticipator from , EconomyParticipator to , double amount ) {
return transferMoney ( invoker , from , to , amount , true ) ;
}
public static boolean transferMoney ( EconomyParticipator invoker , EconomyParticipator from , EconomyParticipator to , double amount , boolean notify ) {
2014-07-01 22:10:18 +02:00
if ( ! shouldBeUsed ( ) ) {
return false ;
}
2014-04-04 20:55:21 +02:00
// The amount must be positive.
// If the amount is negative we must flip and multiply amount with -1.
if ( amount < 0 ) {
2014-07-01 22:10:18 +02:00
amount * = - 1 ;
EconomyParticipator temp = from ;
from = to ;
to = temp ;
2014-04-04 20:55:21 +02:00
}
// Check the rights
2014-07-01 22:10:18 +02:00
if ( ! canIControllYou ( invoker , from ) ) {
return false ;
}
2014-04-04 20:55:21 +02:00
2014-11-06 01:36:47 +01:00
OfflinePlayer fromAcc ;
OfflinePlayer toAcc ;
2014-08-05 13:23:21 +02:00
2014-11-06 01:36:47 +01:00
if ( isUUID ( from . getAccountId ( ) ) ) {
fromAcc = Bukkit . getOfflinePlayer ( UUID . fromString ( from . getAccountId ( ) ) ) ;
2015-01-10 22:12:06 +01:00
if ( fromAcc . getName ( ) = = null ) {
return false ;
}
2014-11-06 01:36:47 +01:00
} else {
fromAcc = Bukkit . getOfflinePlayer ( from . getAccountId ( ) ) ;
}
2014-08-05 13:23:21 +02:00
2014-11-06 01:36:47 +01:00
if ( isUUID ( to . getAccountId ( ) ) ) {
toAcc = Bukkit . getOfflinePlayer ( UUID . fromString ( to . getAccountId ( ) ) ) ;
2015-01-10 22:12:06 +01:00
if ( toAcc . getName ( ) = = null ) {
return false ;
}
2014-11-06 01:36:47 +01:00
} else {
toAcc = Bukkit . getOfflinePlayer ( to . getAccountId ( ) ) ;
}
2014-08-05 13:23:21 +02:00
2014-04-04 20:55:21 +02:00
// Is there enough money for the transaction to happen?
2014-08-05 13:23:21 +02:00
if ( ! econ . has ( fromAcc , amount ) ) {
2014-04-04 20:55:21 +02:00
// There was not enough money to pay
2014-07-01 21:49:42 +02:00
if ( invoker ! = null & & notify ) {
2014-04-04 20:55:21 +02:00
invoker . msg ( " <h>%s<b> can't afford to transfer <h>%s<b> to %s<b>. " , from . describeTo ( invoker , true ) , moneyString ( amount ) , to . describeTo ( invoker ) ) ;
2014-07-01 21:49:42 +02:00
}
2014-04-04 20:55:21 +02:00
return false ;
}
// Transfer money
2014-08-05 13:23:21 +02:00
EconomyResponse erw = econ . withdrawPlayer ( fromAcc , amount ) ;
2014-04-04 20:55:21 +02:00
if ( erw . transactionSuccess ( ) ) {
2014-08-05 13:23:21 +02:00
EconomyResponse erd = econ . depositPlayer ( toAcc , amount ) ;
2014-07-01 22:10:18 +02:00
if ( erd . transactionSuccess ( ) ) {
if ( notify ) {
sendTransferInfo ( invoker , from , to , amount ) ;
}
return true ;
2014-07-01 21:52:40 +02:00
} else {
2014-04-04 20:55:21 +02:00
// transaction failed, refund account
2014-08-05 13:23:21 +02:00
econ . depositPlayer ( fromAcc , amount ) ;
2014-04-04 20:55:21 +02:00
}
}
// if we get here something with the transaction failed
2014-07-01 21:49:42 +02:00
if ( notify ) {
2014-04-04 20:55:21 +02:00
invoker . msg ( " Unable to transfer %s<b> to <h>%s<b> from <h>%s<b>. " , moneyString ( amount ) , to . describeTo ( invoker ) , from . describeTo ( invoker , true ) ) ;
2014-07-01 21:49:42 +02:00
}
2014-04-04 20:55:21 +02:00
return false ;
}
public static Set < FPlayer > getFplayers ( EconomyParticipator ep ) {
2017-12-19 11:18:13 +01:00
Set < FPlayer > fplayers = new HashSet < > ( ) ;
2014-04-04 20:55:21 +02:00
2014-08-05 13:23:21 +02:00
if ( ep ! = null ) {
2014-11-06 01:36:47 +01:00
if ( ep instanceof FPlayer ) {
fplayers . add ( ( FPlayer ) ep ) ;
} else if ( ep instanceof Faction ) {
fplayers . addAll ( ( ( Faction ) ep ) . getFPlayers ( ) ) ;
}
2014-04-04 20:55:21 +02:00
}
return fplayers ;
}
public static void sendTransferInfo ( EconomyParticipator invoker , EconomyParticipator from , EconomyParticipator to , double amount ) {
2017-12-19 11:18:13 +01:00
Set < FPlayer > recipients = new HashSet < > ( ) ;
2014-07-01 22:10:18 +02:00
recipients . addAll ( getFplayers ( invoker ) ) ;
recipients . addAll ( getFplayers ( from ) ) ;
recipients . addAll ( getFplayers ( to ) ) ;
2014-04-04 20:55:21 +02:00
if ( invoker = = null ) {
for ( FPlayer recipient : recipients ) {
2014-10-13 23:25:32 +02:00
recipient . msg ( " <h>%s<i> was transferred from <h>%s<i> to <h>%s<i>. " , moneyString ( amount ) , from . describeTo ( recipient ) , to . describeTo ( recipient ) ) ;
2014-04-04 20:55:21 +02:00
}
2014-07-01 21:52:40 +02:00
} else if ( invoker = = from ) {
2014-04-04 20:55:21 +02:00
for ( FPlayer recipient : recipients ) {
recipient . msg ( " <h>%s<i> <h>gave %s<i> to <h>%s<i>. " , from . describeTo ( recipient , true ) , moneyString ( amount ) , to . describeTo ( recipient ) ) ;
}
2014-07-01 21:52:40 +02:00
} else if ( invoker = = to ) {
2014-04-04 20:55:21 +02:00
for ( FPlayer recipient : recipients ) {
recipient . msg ( " <h>%s<i> <h>took %s<i> from <h>%s<i>. " , to . describeTo ( recipient , true ) , moneyString ( amount ) , from . describeTo ( recipient ) ) ;
}
2014-07-01 21:52:40 +02:00
} else {
2014-04-04 20:55:21 +02:00
for ( FPlayer recipient : recipients ) {
2014-10-13 23:25:32 +02:00
recipient . msg ( " <h>%s<i> transferred <h>%s<i> from <h>%s<i> to <h>%s<i>. " , invoker . describeTo ( recipient , true ) , moneyString ( amount ) , from . describeTo ( recipient ) , to . describeTo ( recipient ) ) ;
2014-04-04 20:55:21 +02:00
}
}
}
public static boolean hasAtLeast ( EconomyParticipator ep , double delta , String toDoThis ) {
2014-07-01 22:10:18 +02:00
if ( ! shouldBeUsed ( ) ) {
return true ;
}
2014-04-04 20:55:21 +02:00
2014-11-06 01:36:47 +01:00
// going the hard way round as econ.has refuses to work.
boolean affordable = false ;
double currentBalance ;
2014-08-05 13:23:21 +02:00
2014-11-06 01:36:47 +01:00
if ( isUUID ( ep . getAccountId ( ) ) ) {
2015-01-10 22:12:06 +01:00
OfflinePlayer offline = Bukkit . getOfflinePlayer ( UUID . fromString ( ep . getAccountId ( ) ) ) ;
if ( offline . getName ( ) ! = null ) {
currentBalance = econ . getBalance ( Bukkit . getOfflinePlayer ( UUID . fromString ( ep . getAccountId ( ) ) ) ) ;
} else {
currentBalance = 0 ;
}
2014-11-06 01:36:47 +01:00
} else {
2015-01-09 18:44:15 +01:00
currentBalance = econ . getBalance ( ep . getAccountId ( ) ) ;
2014-11-06 01:36:47 +01:00
}
2014-08-05 13:23:21 +02:00
2014-11-06 01:36:47 +01:00
if ( currentBalance > = delta ) {
affordable = true ;
}
2014-08-05 13:23:21 +02:00
if ( ! affordable ) {
2014-07-01 21:49:42 +02:00
if ( toDoThis ! = null & & ! toDoThis . isEmpty ( ) ) {
2014-04-04 20:55:21 +02:00
ep . msg ( " <h>%s<i> can't afford <h>%s<i> %s. " , ep . describeTo ( ep , true ) , moneyString ( delta ) , toDoThis ) ;
2014-07-01 22:10:18 +02:00
}
return false ;
}
return true ;
2014-04-04 20:55:21 +02:00
}
public static boolean modifyMoney ( EconomyParticipator ep , double delta , String toDoThis , String forDoingThis ) {
2014-07-01 22:10:18 +02:00
if ( ! shouldBeUsed ( ) ) {
return false ;
}
2014-04-04 20:55:21 +02:00
2014-08-05 13:23:21 +02:00
OfflinePlayer acc ;
2014-11-06 01:36:47 +01:00
if ( isUUID ( ep . getAccountId ( ) ) ) {
acc = Bukkit . getOfflinePlayer ( UUID . fromString ( ep . getAccountId ( ) ) ) ;
2015-01-10 22:12:06 +01:00
if ( acc . getName ( ) = = null ) {
return false ;
}
2014-11-06 01:36:47 +01:00
} else {
acc = Bukkit . getOfflinePlayer ( ep . getAccountId ( ) ) ;
}
2014-08-05 13:23:21 +02:00
2014-07-01 22:10:18 +02:00
String You = ep . describeTo ( ep , true ) ;
2014-04-04 20:55:21 +02:00
if ( delta = = 0 ) {
// no money actually transferred?
2012-01-31 18:07:48 +01:00
// ep.msg("<h>%s<i> didn't have to pay anything %s.", You, forDoingThis); // might be for gains, might be for losses
2014-04-04 20:55:21 +02:00
return true ;
}
if ( delta > 0 ) {
// The player should gain money
// The account might not have enough space
2014-07-01 22:10:18 +02:00
EconomyResponse er = econ . depositPlayer ( acc , delta ) ;
if ( er . transactionSuccess ( ) ) {
modifyUniverseMoney ( - delta ) ;
if ( forDoingThis ! = null & & ! forDoingThis . isEmpty ( ) ) {
2014-04-04 20:55:21 +02:00
ep . msg ( " <h>%s<i> gained <h>%s<i> %s. " , You , moneyString ( delta ) , forDoingThis ) ;
2014-07-01 22:10:18 +02:00
}
return true ;
2014-07-01 21:52:40 +02:00
} else {
2014-04-04 20:55:21 +02:00
// transfer to account failed
2014-07-01 21:49:42 +02:00
if ( forDoingThis ! = null & & ! forDoingThis . isEmpty ( ) ) {
2014-04-04 20:55:21 +02:00
ep . msg ( " <h>%s<i> would have gained <h>%s<i> %s, but the deposit failed. " , You , moneyString ( delta ) , forDoingThis ) ;
2014-07-01 22:10:18 +02:00
}
return false ;
2014-04-04 20:55:21 +02:00
}
2014-07-01 21:52:40 +02:00
} else {
2014-04-04 20:55:21 +02:00
// The player should loose money
// The player might not have enough.
if ( econ . has ( acc , - delta ) & & econ . withdrawPlayer ( acc , - delta ) . transactionSuccess ( ) ) {
// There is enough money to pay
2014-07-01 22:10:18 +02:00
modifyUniverseMoney ( - delta ) ;
if ( forDoingThis ! = null & & ! forDoingThis . isEmpty ( ) ) {
2014-04-04 20:55:21 +02:00
ep . msg ( " <h>%s<i> lost <h>%s<i> %s. " , You , moneyString ( - delta ) , forDoingThis ) ;
2014-07-01 22:10:18 +02:00
}
return true ;
2014-07-01 21:52:40 +02:00
} else {
2014-04-04 20:55:21 +02:00
// There was not enough money to pay
2014-07-01 21:49:42 +02:00
if ( toDoThis ! = null & & ! toDoThis . isEmpty ( ) ) {
2014-04-04 20:55:21 +02:00
ep . msg ( " <h>%s<i> can't afford <h>%s<i> %s. " , You , moneyString ( - delta ) , toDoThis ) ;
2014-07-01 22:10:18 +02:00
}
return false ;
2014-04-04 20:55:21 +02:00
}
}
}
public static String moneyString ( double amount ) {
2018-01-02 10:37:12 +01:00
return format . format ( amount ) ;
2014-04-04 20:55:21 +02:00
}
// calculate the cost for claiming land
public static double calculateClaimCost ( int ownedLand , boolean takingFromAnotherFaction ) {
if ( ! shouldBeUsed ( ) ) {
return 0d ;
}
// basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction
2014-07-01 21:52:40 +02:00
return Conf . econCostClaimWilderness + ( Conf . econCostClaimWilderness * Conf . econClaimAdditionalMultiplier * ownedLand ) - ( takingFromAnotherFaction ? Conf . econCostClaimFromFactionBonus : 0 ) ;
2014-04-04 20:55:21 +02:00
}
// calculate refund amount for unclaiming land
public static double calculateClaimRefund ( int ownedLand ) {
return calculateClaimCost ( ownedLand - 1 , false ) * Conf . econClaimRefundMultiplier ;
}
// calculate value of all owned land
public static double calculateTotalLandValue ( int ownedLand ) {
2014-07-01 22:10:18 +02:00
double amount = 0 ;
for ( int x = 0 ; x < ownedLand ; x + + ) {
2014-04-04 20:55:21 +02:00
amount + = calculateClaimCost ( x , false ) ;
2014-07-01 22:10:18 +02:00
}
return amount ;
2014-04-04 20:55:21 +02:00
}
// calculate refund amount for all owned land
public static double calculateTotalLandRefund ( int ownedLand ) {
return calculateTotalLandValue ( ownedLand ) * Conf . econClaimRefundMultiplier ;
}
// -------------------------------------------- //
// Standard account management methods
// -------------------------------------------- //
public static boolean hasAccount ( String name ) {
2015-01-09 18:44:15 +01:00
return econ . hasAccount ( name ) ;
2014-04-04 20:55:21 +02:00
}
public static double getBalance ( String account ) {
2015-01-09 18:44:15 +01:00
return econ . getBalance ( account ) ;
2014-04-04 20:55:21 +02:00
}
2018-01-02 10:37:12 +01:00
private static final DecimalFormat format = new DecimalFormat ( TL . ECON_FORMAT . toString ( ) ) ;
2014-10-16 02:56:02 +02:00
public static String getFriendlyBalance ( UUID uuid ) {
2015-01-10 22:12:06 +01:00
OfflinePlayer offline = Bukkit . getOfflinePlayer ( uuid ) ;
2015-01-09 18:44:15 +01:00
if ( offline . getName ( ) = = null ) {
return " 0 " ;
}
return format . format ( econ . getBalance ( offline ) ) ;
2014-11-13 20:49:13 +01:00
}
2015-01-10 22:12:06 +01:00
public static String getFriendlyBalance ( FPlayer player ) {
return getFriendlyBalance ( UUID . fromString ( player . getId ( ) ) ) ;
}
2014-04-04 20:55:21 +02:00
public static boolean setBalance ( String account , double amount ) {
2015-01-09 18:44:15 +01:00
double current = econ . getBalance ( account ) ;
2014-07-01 22:10:18 +02:00
if ( current > amount ) {
2015-01-09 18:44:15 +01:00
return econ . withdrawPlayer ( account , current - amount ) . transactionSuccess ( ) ;
2014-07-01 22:10:18 +02:00
} else {
2015-01-09 18:44:15 +01:00
return econ . depositPlayer ( account , amount - current ) . transactionSuccess ( ) ;
2014-07-01 21:52:40 +02:00
}
2014-04-04 20:55:21 +02:00
}
public static boolean modifyBalance ( String account , double amount ) {
2014-07-01 22:10:18 +02:00
if ( amount < 0 ) {
2015-01-09 18:44:15 +01:00
return econ . withdrawPlayer ( account , - amount ) . transactionSuccess ( ) ;
2014-07-01 22:10:18 +02:00
} else {
2015-01-09 18:44:15 +01:00
return econ . depositPlayer ( account , amount ) . transactionSuccess ( ) ;
2014-07-01 21:52:40 +02:00
}
2014-04-04 20:55:21 +02:00
}
public static boolean deposit ( String account , double amount ) {
2015-01-09 18:44:15 +01:00
return econ . depositPlayer ( account , amount ) . transactionSuccess ( ) ;
2014-04-04 20:55:21 +02:00
}
public static boolean withdraw ( String account , double amount ) {
2015-01-09 18:44:15 +01:00
return econ . withdrawPlayer ( account , amount ) . transactionSuccess ( ) ;
2014-04-04 20:55:21 +02:00
}
2014-08-05 13:23:21 +02:00
2014-11-06 01:36:47 +01:00
// ---------------------------------------
// Helpful Utilities
// ---------------------------------------
2014-08-05 13:23:21 +02:00
2014-11-06 01:36:47 +01:00
public static boolean isUUID ( String uuid ) {
try {
UUID . fromString ( uuid ) ;
} catch ( IllegalArgumentException ex ) {
return false ;
}
2014-08-05 13:23:21 +02:00
2014-11-06 01:36:47 +01:00
return true ;
}
Added basic support for iConomy, where most Factions commands can be made to cost (or give) money. For claiming land, there are some extra features. Each additional land claimed by default costs more than the last, with the multiplier being configurable. For example, the first claim might cost $30, the 2nd $45, the third $60, and so forth. When land is claimed from a weakened faction, there is a configurable bonus amount of money deducted from the cost of claiming the land, as an incentive; this number can be changed to a negative value to instead make it cost more to claim such land. When land is unclaimed, a configurable percentage of the cost of claiming the land can be refunded (defaults to 70% of the cost). The total value of a faction's claimed land is now shown in the info given by /f who [faction tag], along with the depreciated (refund) value.
2011-08-02 01:05:01 +02:00
}