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
2011-10-12 17:25:01 +02:00
import org.bukkit.Bukkit ;
2011-08-08 11:51:06 +02:00
import org.bukkit.plugin.Plugin ;
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
2011-10-12 17:25:01 +02:00
import com.nijikokun.register.Register ;
import com.nijikokun.register.payment.Method ;
2011-09-22 11:22:24 +02:00
import com.nijikokun.register.payment.Method.MethodAccount ;
2011-10-12 17:25:01 +02:00
import com.nijikokun.register.payment.Methods ;
2011-10-05 12:13:54 +02:00
import com.massivecraft.factions.Conf ;
2011-10-12 17:25:01 +02:00
import com.massivecraft.factions.FPlayer ;
import com.massivecraft.factions.Faction ;
import com.massivecraft.factions.Factions ;
2011-10-08 22:03:44 +02:00
import com.massivecraft.factions.P ;
2011-10-12 17:25:01 +02:00
import com.massivecraft.factions.iface.EconomyParticipator ;
import com.massivecraft.factions.struct.Role ;
import com.massivecraft.factions.util.RelationUtil ;
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
2011-10-10 01:21:05 +02:00
public class Econ
{
2011-10-12 17:25:01 +02:00
private static Register register = null ;
public static Method getMethod ( )
2011-10-10 01:21:05 +02:00
{
2011-10-12 17:25:01 +02:00
if ( ! isSetup ( ) ) return null ;
return Methods . getMethod ( ) ;
2011-08-08 11:51:06 +02:00
}
2011-10-12 17:25:01 +02:00
public static boolean shouldBeUsed ( )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
return Conf . econEnabled & & getMethod ( ) ! = null ;
2011-09-22 11:22:24 +02:00
}
2011-10-12 17:25:01 +02:00
public static boolean isSetup ( )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
return register ! = null & & register . isEnabled ( ) ;
2011-08-04 09:25:12 +02:00
}
2011-10-12 17:25:01 +02:00
public static void doSetup ( )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
if ( isSetup ( ) ) return ;
Plugin plug = Bukkit . getServer ( ) . getPluginManager ( ) . getPlugin ( " Register " ) ;
if ( plug ! = null & & plug . getClass ( ) . getName ( ) . equals ( " com.nijikokun.register.Register " ) & & plug . isEnabled ( ) )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
P . p . log ( " Integration with Register (economy): successful " ) ;
if ( ! Conf . econEnabled )
{
P . p . log ( " NOTE: Economy is disabled. Enable in conf \" econRegisterEnabled \" : true " ) ;
}
2011-08-04 09:25:12 +02:00
}
2011-10-08 22:03:44 +02:00
else
{
2011-10-12 17:25:01 +02:00
P . p . log ( " Integration with Register (economy): failed " ) ;
2011-08-04 09:25:12 +02:00
}
2011-10-12 17:25:01 +02:00
2011-10-10 01:21:05 +02:00
P . p . cmdBase . cmdHelp . updateHelp ( ) ;
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
}
2011-10-12 17:25:01 +02:00
public static MethodAccount getUniverseAccount ( )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
if ( Conf . econUniverseAccount = = null ) return null ;
if ( Conf . econUniverseAccount . length ( ) = = 0 ) return null ;
return getMethod ( ) . getAccount ( Conf . econUniverseAccount ) ;
2011-08-04 09:25:12 +02:00
}
2011-10-12 17:25:01 +02:00
public static void modifyUniverseMoney ( double delta )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
MethodAccount acc = getUniverseAccount ( ) ;
if ( acc = = null ) return ;
acc . add ( delta ) ;
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
}
2011-10-12 17:25:01 +02:00
public static boolean canInvokerTransferFrom ( EconomyParticipator invoker , EconomyParticipator from )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
Faction fInvoker = RelationUtil . getFaction ( invoker ) ;
Faction fFrom = RelationUtil . getFaction ( from ) ;
// This is a system invoker. Accept it.
if ( fInvoker = = null ) return true ;
// Bypassing players can do any kind of transaction
if ( invoker instanceof FPlayer & & ( ( FPlayer ) invoker ) . isAdminBypassing ( ) ) return true ;
// You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again.
if ( invoker = = from ) return true ;
// 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.
if ( invoker = = fInvoker & & fInvoker = = fFrom ) return true ;
// If you are part of the same faction as from and members can withdraw or you are at least moderator... then it is ok.
if ( fInvoker = = fFrom & & ( Conf . bankMembersCanWithdraw | | ( ( FPlayer ) invoker ) . getRole ( ) . value < Role . MODERATOR . value ) ) return true ;
// Otherwise you may not! ;,,;
invoker . msg ( " <h>%s<b> don't have the right to transfer money from <h>%s<b>. " , invoker . describeTo ( invoker , true ) , from . describeTo ( invoker ) ) ;
return false ;
2011-09-22 11:22:24 +02:00
}
2011-10-12 17:25:01 +02:00
public static boolean transferMoney ( EconomyParticipator invoker , EconomyParticipator from , EconomyParticipator to , double amount )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
// The amount must be positive.
// If the amount is negative we must flip and multiply amount with -1.
if ( amount < 0 )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
amount * = - 1 ;
EconomyParticipator temp = from ;
from = to ;
to = temp ;
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
}
2011-10-12 17:25:01 +02:00
// Check the rights
if ( ! canInvokerTransferFrom ( invoker , from ) ) return false ;
//Faction fFrom = RelationUtil.getFaction(from);
//Faction fTo = RelationUtil.getFaction(to);
//Faction fInvoker = RelationUtil.getFaction(invoker);
// Is there enough money for the transaction to happen?
if ( ! from . getAccount ( ) . hasEnough ( amount ) )
{
// There was not enough money to pay
if ( invoker ! = null )
{
invoker . msg ( " <h>%s<b> can't afford to transfer <h>%s<b> to %s. " , from . describeTo ( invoker , true ) , moneyString ( amount ) , to . describeTo ( invoker ) ) ;
}
return false ;
}
// Transfer money
from . getAccount ( ) . subtract ( amount ) ;
to . getAccount ( ) . add ( amount ) ;
// Inform
if ( invoker = = null )
{
from . msg ( " <h>%s<i> was transfered from <h>%s<i> to <h>%s<i>. " , moneyString ( amount ) , from . describeTo ( from ) , to . describeTo ( from ) ) ;
to . msg ( " <h>%s<i> was transfered from <h>%s<i> to <h>%s<i>. " , moneyString ( amount ) , from . describeTo ( to ) , to . describeTo ( to ) ) ;
}
else if ( invoker = = from | | invoker = = to )
{
from . msg ( " <h>%s<i> transfered <h>%s<i> to <h>%s<i>. " , from . describeTo ( from ) , moneyString ( amount ) , to . describeTo ( from ) ) ;
to . msg ( " <h>%s<i> transfered <h>%s<i> to <h>%s<i>. " , from . describeTo ( to ) , moneyString ( amount ) , to . describeTo ( to ) ) ;
}
else
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
from . msg ( " <h>%s<b> was transfered from <h>%s<b> to <h>%s<b> by <h>%s<g>. " , moneyString ( amount ) , from . describeTo ( from ) , to . describeTo ( from ) , invoker . describeTo ( from ) ) ;
to . msg ( " <h>%s<g> was transfered from <h>%s<g> to <h>%s<g> by <h>%s<g>. " , moneyString ( amount ) , from . describeTo ( to ) , to . describeTo ( to ) , invoker . describeTo ( to ) ) ;
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
}
2011-10-12 17:25:01 +02: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
}
2011-10-12 17:25:01 +02:00
public static boolean modifyMoney ( EconomyParticipator ep , double delta , String toDoThis , String forDoingThis )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
MethodAccount acc = ep . getAccount ( ) ;
String You = ep . describeTo ( ep , true ) ;
if ( delta > = 0 )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
// The player should gain money
// There is no risk of failure
acc . add ( delta ) ;
modifyUniverseMoney ( - delta ) ;
ep . msg ( " <h>%<g> gained %s<i> %s. " , You , moneyString ( delta ) , forDoingThis ) ;
return true ;
2011-09-22 11:22:24 +02:00
}
2011-10-12 17:25:01 +02:00
else
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
// The player should loose money
// The player might not have enough.
if ( acc . hasEnough ( - delta ) )
{
// There is enough money to pay
acc . add ( delta ) ;
modifyUniverseMoney ( - delta ) ;
ep . msg ( " <h>%<b> lost %s<i> %s. " , You , moneyString ( - delta ) , forDoingThis ) ;
return true ;
}
else
{
// There was not enough money to pay
ep . msg ( " <h>%<g> can't afford %s<i> %s. " , You , moneyString ( - delta ) , toDoThis ) ;
return false ;
}
2011-09-22 11:22:24 +02:00
}
}
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
2011-10-12 17:25:01 +02:00
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
// format money string based on server's set currency type, like "24 gold" or "$24.50"
2011-10-08 22:03:44 +02:00
public static String moneyString ( double amount )
{
2011-10-12 17:25:01 +02:00
return getMethod ( ) . format ( amount ) ;
}
public static void oldMoneyDoTransfer ( )
{
if ( ! shouldBeUsed ( ) ) return ;
for ( Faction faction : Factions . i . get ( ) )
{
faction . getAccount ( ) . add ( faction . money ) ;
faction . money = 0 ;
}
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
}
// whether a player can afford specified amount
2011-10-12 17:25:01 +02:00
/ * public static boolean canAfford ( String playerName , double amount ) {
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
// if Economy support is not enabled, they can certainly afford to pay nothing
2011-10-08 22:03:44 +02:00
if ( ! enabled ( ) )
{
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
return true ;
}
2011-10-08 22:03:44 +02:00
if ( registerAvailable ( ) )
{
2011-09-22 11:22:24 +02:00
MethodAccount holdings = getRegisterAccount ( playerName ) ;
2011-10-08 22:03:44 +02:00
if ( holdings = = null )
{
2011-09-22 11:22:24 +02:00
return false ;
}
return holdings . hasEnough ( amount ) ;
}
2011-10-08 22:03:44 +02:00
else if ( iConomyUse )
{
2011-08-04 09:25:12 +02:00
Holdings holdings = getIconomyHoldings ( playerName ) ;
2011-10-08 22:03:44 +02:00
if ( holdings = = null )
{
2011-08-04 09:25:12 +02:00
return false ;
}
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
2011-08-04 09:25:12 +02:00
return holdings . hasEnough ( amount ) ;
}
2011-10-08 22:03:44 +02:00
else
{
try
{
2011-08-04 09:25:12 +02:00
return Economy . hasEnough ( playerName , amount ) ;
}
2011-10-08 22:03:44 +02:00
catch ( Exception ex )
{
2011-08-04 09:25:12 +02:00
return false ;
}
}
2011-10-12 17:25:01 +02:00
} * /
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
// deduct money from their account; returns true if successful
2011-10-12 17:25:01 +02:00
/ * public static boolean deductMoney ( String playerName , double amount )
2011-10-08 22:03:44 +02:00
{
if ( ! enabled ( ) )
{
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
return true ;
}
2011-10-08 22:03:44 +02:00
if ( registerAvailable ( ) )
{
2011-09-22 11:22:24 +02:00
MethodAccount holdings = getRegisterAccount ( playerName ) ;
2011-10-08 22:03:44 +02:00
if ( holdings = = null | | ! holdings . hasEnough ( amount ) )
{
2011-09-22 11:22:24 +02:00
return false ;
}
return holdings . subtract ( amount ) ;
}
2011-10-08 22:03:44 +02:00
else if ( iConomyUse )
{
2011-08-04 09:25:12 +02:00
Holdings holdings = getIconomyHoldings ( playerName ) ;
2011-10-08 22:03:44 +02:00
if ( holdings = = null | | ! holdings . hasEnough ( amount ) )
{
2011-08-04 09:25:12 +02:00
return false ;
}
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
2011-08-04 09:25:12 +02:00
holdings . subtract ( amount ) ;
return true ;
}
2011-10-08 22:03:44 +02:00
else
{
try
{
if ( ! Economy . hasEnough ( playerName , amount ) )
{
2011-08-04 09:25:12 +02:00
return false ;
}
Economy . subtract ( playerName , amount ) ;
return true ;
}
2011-10-08 22:03:44 +02:00
catch ( Exception ex )
{
2011-08-04 09:25:12 +02:00
return false ;
}
}
2011-10-12 17:25:01 +02:00
} * /
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
// add money to their account; returns true if successful
2011-10-12 17:25:01 +02:00
/ * public static boolean addMoney ( String playerName , double amount )
2011-10-08 22:03:44 +02:00
{
if ( ! enabled ( ) )
{
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
return true ;
}
2011-10-08 22:03:44 +02:00
if ( registerAvailable ( ) )
{
2011-09-22 11:22:24 +02:00
MethodAccount holdings = getRegisterAccount ( playerName ) ;
2011-10-08 22:03:44 +02:00
if ( holdings = = null )
{
2011-09-22 11:22:24 +02:00
return false ;
}
return holdings . add ( amount ) ;
}
2011-10-08 22:03:44 +02:00
else if ( iConomyUse )
{
2011-08-04 09:25:12 +02:00
Holdings holdings = getIconomyHoldings ( playerName ) ;
2011-10-08 22:03:44 +02:00
if ( holdings = = null )
{
2011-08-04 09:25:12 +02:00
return false ;
}
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
2011-08-04 09:25:12 +02:00
holdings . add ( amount ) ;
return true ;
}
2011-10-08 22:03:44 +02:00
else
{
try
{
2011-08-04 09:25:12 +02:00
Economy . add ( playerName , amount ) ;
return true ;
}
2011-10-08 22:03:44 +02:00
catch ( Exception ex )
{
2011-08-04 09:25:12 +02:00
return false ;
}
}
2011-10-12 17:25:01 +02:00
} * /
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
// calculate the cost for claiming land
2011-10-08 22:03:44 +02:00
public static double calculateClaimCost ( int ownedLand , boolean takingFromAnotherFaction )
{
2011-10-12 17:25:01 +02:00
if ( ! shouldBeUsed ( ) )
2011-10-08 22:03:44 +02:00
{
2011-10-12 17:25:01 +02:00
return 0d ;
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
}
// basic claim cost, plus land inflation cost, minus the potential bonus given for claiming from another faction
return Conf . econCostClaimWilderness
+ ( Conf . econCostClaimWilderness * Conf . econClaimAdditionalMultiplier * ownedLand )
- ( takingFromAnotherFaction ? Conf . econCostClaimFromFactionBonus : 0 ) ;
}
// calculate refund amount for unclaiming land
2011-10-08 22:03:44 +02:00
public static double calculateClaimRefund ( int ownedLand )
{
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
return calculateClaimCost ( ownedLand - 1 , false ) * Conf . econClaimRefundMultiplier ;
}
// calculate value of all owned land
2011-10-08 22:03:44 +02:00
public static double calculateTotalLandValue ( int ownedLand )
{
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
double amount = 0 ;
for ( int x = 0 ; x < ownedLand ; x + + ) {
amount + = calculateClaimCost ( x , false ) ;
}
return amount ;
}
// calculate refund amount for all owned land
2011-10-08 22:03:44 +02:00
public static double calculateTotalLandRefund ( int ownedLand )
{
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
return calculateTotalLandValue ( ownedLand ) * Conf . econClaimRefundMultiplier ;
}
}