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
|
|
|
|
|
|
|
import org.bukkit.event.Event;
|
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
|
|
|
|
|
|
|
import com.massivecraft.factions.listeners.FactionsServerListener;
|
2011-10-09 20:10:19 +02:00
|
|
|
import com.massivecraft.factions.commands.CmdHelp;
|
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
|
|
|
import com.earth2me.essentials.api.Economy;
|
2011-09-22 11:22:24 +02:00
|
|
|
import com.nijikokun.register.payment.Methods;
|
|
|
|
import com.nijikokun.register.payment.Method.MethodAccount;
|
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
|
|
|
import com.iConomy.*;
|
|
|
|
import com.iConomy.system.*;
|
2011-10-05 12:13:54 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
2011-10-08 22:03:44 +02:00
|
|
|
import com.massivecraft.factions.P;
|
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
|
|
|
|
|
|
|
|
|
|
|
public class Econ {
|
2011-09-22 11:22:24 +02:00
|
|
|
private static boolean registerUse = false;
|
2011-08-04 09:25:12 +02:00
|
|
|
private static boolean iConomyUse = false;
|
|
|
|
private static boolean essEcoUse = 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
|
|
|
|
|
|
|
public static void monitorPlugins() {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.p.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_ENABLE, new FactionsServerListener(P.p), Event.Priority.Monitor, P.p);
|
|
|
|
P.p.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_DISABLE, new FactionsServerListener(P.p), Event.Priority.Monitor, P.p);
|
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-08 22:03:44 +02:00
|
|
|
public static void setup(P factions) {
|
2011-08-08 11:51:06 +02:00
|
|
|
if (enabled()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-08-20 02:41:28 +02:00
|
|
|
|
2011-09-22 11:22:24 +02:00
|
|
|
if (!registerHooked()) {
|
|
|
|
Plugin plug = factions.getServer().getPluginManager().getPlugin("Register");
|
|
|
|
if (plug != null && plug.getClass().getName().equals("com.nijikokun.register.Register") && plug.isEnabled()) {
|
|
|
|
registerSet(true);
|
|
|
|
}
|
|
|
|
}
|
2011-08-20 02:41:28 +02:00
|
|
|
if (!iConomyHooked()) {
|
2011-08-08 11:51:06 +02:00
|
|
|
Plugin plug = factions.getServer().getPluginManager().getPlugin("iConomy");
|
|
|
|
if (plug != null && plug.getClass().getName().equals("com.iConomy.iConomy") && plug.isEnabled()) {
|
|
|
|
iConomySet(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!essentialsEcoHooked()) {
|
|
|
|
Plugin plug = factions.getServer().getPluginManager().getPlugin("Essentials");
|
|
|
|
if (plug != null && plug.isEnabled()) {
|
|
|
|
essentialsEcoSet(true);
|
|
|
|
}
|
2011-08-20 02:41:28 +02:00
|
|
|
}
|
2011-08-08 11:51:06 +02:00
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public static void registerSet(boolean enable)
|
|
|
|
{
|
2011-09-22 11:22:24 +02:00
|
|
|
registerUse = enable;
|
|
|
|
if (enable) {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.p.log("Register hook available, "+(Conf.econRegisterEnabled ? "and interface is enabled" : "but disabled (\"econRegisterEnabled\": false)")+".");
|
2011-09-22 11:22:24 +02:00
|
|
|
}
|
|
|
|
else {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.p.log("Un-hooked from Register.");
|
2011-09-22 11:22:24 +02:00
|
|
|
}
|
2011-10-09 20:10:19 +02:00
|
|
|
CmdHelp.updateHelp();
|
2011-09-22 11:22:24 +02:00
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public static void iConomySet(boolean enable)
|
|
|
|
{
|
2011-08-04 09:25:12 +02:00
|
|
|
iConomyUse = enable;
|
2011-09-22 11:22:24 +02:00
|
|
|
if (enable && !registerUse) {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.p.log("iConomy hook available, "+(Conf.econIConomyEnabled ? "and interface is enabled" : "but disabled (\"econIConomyEnabled\": false)")+".");
|
2011-08-04 09:25:12 +02:00
|
|
|
}
|
|
|
|
else {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.p.log("Un-hooked from iConomy.");
|
2011-08-04 09:25:12 +02:00
|
|
|
}
|
2011-10-09 20:10:19 +02:00
|
|
|
CmdHelp.updateHelp();
|
2011-08-04 09:25:12 +02:00
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public static void essentialsEcoSet(boolean enable)
|
|
|
|
{
|
2011-08-04 09:25:12 +02:00
|
|
|
essEcoUse = enable;
|
2011-10-08 22:03:44 +02:00
|
|
|
if (enable && !registerUse)
|
|
|
|
{
|
|
|
|
P.p.log("EssentialsEco hook available, "+(Conf.econEssentialsEcoEnabled ? "and interface is enabled" : "but disabled (\"econEssentialsEcoEnabled\": false)")+".");
|
2011-08-04 09:25:12 +02:00
|
|
|
}
|
2011-10-08 22:03:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
P.p.log("Un-hooked from EssentialsEco.");
|
2011-08-04 09:25:12 +02:00
|
|
|
}
|
2011-10-09 20:10:19 +02:00
|
|
|
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-08 22:03:44 +02:00
|
|
|
public static boolean registerHooked()
|
|
|
|
{
|
2011-09-22 11:22:24 +02:00
|
|
|
return registerUse;
|
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public static boolean iConomyHooked()
|
|
|
|
{
|
2011-08-04 09:25:12 +02:00
|
|
|
return iConomyUse;
|
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public static boolean essentialsEcoHooked()
|
|
|
|
{
|
2011-08-04 09:25:12 +02:00
|
|
|
return essEcoUse;
|
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-08 22:03:44 +02:00
|
|
|
public static boolean registerAvailable()
|
|
|
|
{
|
2011-09-22 11:22:24 +02:00
|
|
|
return Conf.econRegisterEnabled && registerUse && Methods.hasMethod();
|
|
|
|
}
|
|
|
|
|
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 is enabled in conf.json, and we're successfully hooked into an economy plugin
|
2011-10-08 22:03:44 +02:00
|
|
|
public static boolean enabled()
|
|
|
|
{
|
|
|
|
return (Conf.econRegisterEnabled && registerUse && Methods.hasMethod())
|
2011-09-22 11:22:24 +02:00
|
|
|
|| (Conf.econIConomyEnabled && iConomyUse)
|
|
|
|
|| (Conf.econEssentialsEcoEnabled && essEcoUse);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// mainly for internal use, for a little less code repetition
|
2011-10-08 22:03:44 +02:00
|
|
|
public static Holdings getIconomyHoldings(String playerName)
|
|
|
|
{
|
|
|
|
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 null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Account account = iConomy.getAccount(playerName);
|
2011-10-08 22:03:44 +02:00
|
|
|
if (account == null)
|
|
|
|
{
|
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 null;
|
|
|
|
}
|
|
|
|
Holdings holdings = account.getHoldings();
|
|
|
|
return holdings;
|
|
|
|
}
|
2011-10-08 22:03:44 +02:00
|
|
|
public static MethodAccount getRegisterAccount(String playerName)
|
|
|
|
{
|
|
|
|
if (!enabled())
|
|
|
|
{
|
2011-09-22 11:22:24 +02:00
|
|
|
return null;
|
|
|
|
}
|
2011-10-08 22:03:44 +02:00
|
|
|
if (!Methods.getMethod().hasAccount(playerName))
|
|
|
|
{
|
2011-09-22 11:22:24 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
MethodAccount account = Methods.getMethod().getAccount(playerName);
|
|
|
|
return account;
|
|
|
|
}
|
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-09-22 11:22:24 +02:00
|
|
|
return registerAvailable() ? Methods.getMethod().format(amount)
|
|
|
|
: (iConomyUse ? iConomy.format(amount) : Economy.format(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
|
|
|
}
|
|
|
|
|
|
|
|
// whether a player can afford specified amount
|
|
|
|
public static boolean canAfford(String playerName, double amount) {
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
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-08 22:03:44 +02:00
|
|
|
public static boolean deductMoney(String playerName, double amount)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
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-08 22:03:44 +02:00
|
|
|
public static boolean addMoney(String playerName, double amount)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
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 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|