mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-23 02:35:22 +01: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.
This commit is contained in:
parent
c0676c3548
commit
2154b89005
BIN
lib/iConomy.jar
Normal file
BIN
lib/iConomy.jar
Normal file
Binary file not shown.
@ -23,12 +23,12 @@ public class Conf {
|
||||
public static ChatColor colorParameter = ChatColor.DARK_AQUA;
|
||||
|
||||
// Power
|
||||
public static double powerPlayerMax = 10;
|
||||
public static double powerPlayerMin = -10;
|
||||
public static double powerPlayerMax = 10.0;
|
||||
public static double powerPlayerMin = -10.0;
|
||||
public static double powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power
|
||||
public static double powerPerDeath = 4; // A death makes you lose 4 power
|
||||
public static double powerPerDeath = 4.0; // A death makes you lose 4 power
|
||||
public static boolean powerRegenOffline = false; // does player power regenerate even while they're offline?
|
||||
public static double powerFactionMax = 0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts)
|
||||
public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts)
|
||||
|
||||
public static String prefixAdmin = "**";
|
||||
public static String prefixMod = "*";
|
||||
@ -59,7 +59,7 @@ public class Conf {
|
||||
|
||||
public static boolean allowNoSlashCommand = true;
|
||||
|
||||
public static double autoLeaveAfterDaysOfInactivity = 14;
|
||||
public static double autoLeaveAfterDaysOfInactivity = 14.0;
|
||||
|
||||
public static boolean homesEnabled = true;
|
||||
public static boolean homesMustBeInClaimedTerritory = true;
|
||||
@ -68,7 +68,7 @@ public class Conf {
|
||||
public static boolean homesTeleportCommandEnabled = true;
|
||||
public static boolean homesTeleportAllowedFromEnemyTerritory = true;
|
||||
public static boolean homesTeleportAllowedFromDifferentWorld = true;
|
||||
public static double homesTeleportAllowedEnemyDistance = 32;
|
||||
public static double homesTeleportAllowedEnemyDistance = 32.0;
|
||||
public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
|
||||
|
||||
public static boolean disablePVPBetweenNeutralFactions = false;
|
||||
@ -79,7 +79,7 @@ public class Conf {
|
||||
public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true;
|
||||
public static int claimsRequireMinFactionMembers = 1;
|
||||
|
||||
public static double considerFactionsReallyOfflineAfterXMinutes = 0;
|
||||
public static double considerFactionsReallyOfflineAfterXMinutes = 0.0;
|
||||
|
||||
public static double territoryShieldFactor = 0.3;
|
||||
public static boolean territoryDenyBuild = true;
|
||||
@ -133,6 +133,32 @@ public class Conf {
|
||||
public static Set<Material> territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class);
|
||||
|
||||
public static transient Set<CreatureType> safeZoneNerfedCreatureTypes = EnumSet.noneOf(CreatureType.class);
|
||||
|
||||
// Economy settings
|
||||
public static boolean econIConomyEnabled = false;
|
||||
public static double econCostClaimWilderness = 30.0;
|
||||
public static double econCostClaimFromFactionBonus = 30.0;
|
||||
public static double econClaimAdditionalMultiplier = 0.5;
|
||||
public static double econClaimRefundMultiplier = 0.7;
|
||||
public static double econCostCreate = 100.0;
|
||||
public static double econCostOwner = 15.0;
|
||||
public static double econCostSethome = 30.0;
|
||||
public static double econCostJoin = 0.0;
|
||||
public static double econCostLeave = 0.0;
|
||||
public static double econCostKick = 0.0;
|
||||
public static double econCostInvite = 0.0;
|
||||
public static double econCostHome = 0.0;
|
||||
public static double econCostTag = 0.0;
|
||||
public static double econCostDesc = 0.0;
|
||||
public static double econCostTitle = 0.0;
|
||||
public static double econCostList = 0.0;
|
||||
public static double econCostMap = 0.0;
|
||||
public static double econCostPower = 0.0;
|
||||
public static double econCostShow = 0.0;
|
||||
public static double econCostOpen = 0.0;
|
||||
public static double econCostAlly = 0.0;
|
||||
public static double econCostEnemy = 0.0;
|
||||
public static double econCostNeutral = 0.0;
|
||||
|
||||
public static Set<String> worldsNoClaiming = new HashSet<String>();
|
||||
public static Set<String> worldsNoPowerLoss = new HashSet<String>();
|
||||
@ -182,7 +208,7 @@ public class Conf {
|
||||
// track players with admin access who have enabled "admin bypass" mode, and should therefore be able to build anywhere
|
||||
// not worth saving between server restarts, I think
|
||||
public static transient Set<String> adminBypassPlayers = Collections.synchronizedSet(new HashSet<String>());
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Persistance
|
||||
// -------------------------------------------- //
|
||||
|
128
src/com/massivecraft/factions/Econ.java
Normal file
128
src/com/massivecraft/factions/Econ.java
Normal file
@ -0,0 +1,128 @@
|
||||
package com.massivecraft.factions;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import com.massivecraft.factions.listeners.FactionsServerListener;
|
||||
|
||||
import com.iConomy.*;
|
||||
import com.iConomy.system.*;
|
||||
|
||||
|
||||
public class Econ {
|
||||
private static iConomy iConomyPlugin;
|
||||
|
||||
public static void monitorPlugins() {
|
||||
Factions.instance.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_ENABLE, new FactionsServerListener(), Event.Priority.Monitor, Factions.instance);
|
||||
Factions.instance.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_DISABLE, new FactionsServerListener(), Event.Priority.Monitor, Factions.instance);
|
||||
}
|
||||
|
||||
public static void iConomySet(iConomy instance) {
|
||||
iConomyPlugin = instance;
|
||||
}
|
||||
|
||||
public static boolean iConomyHooked() {
|
||||
return iConomyPlugin != null;
|
||||
}
|
||||
|
||||
// If economy is enabled in conf.json, and we're successfully hooked into an economy plugin
|
||||
public static boolean enabled() {
|
||||
return Conf.econIConomyEnabled && iConomyPlugin != null;
|
||||
}
|
||||
|
||||
// mainly for internal use, for a little less code repetition
|
||||
public static Holdings getIconomyHoldings(String playerName) {
|
||||
if (!enabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Account account = iConomy.getAccount(playerName);
|
||||
if (account == null) {
|
||||
return null;
|
||||
}
|
||||
Holdings holdings = account.getHoldings();
|
||||
return holdings;
|
||||
}
|
||||
|
||||
|
||||
// format money string based on server's set currency type, like "24 gold" or "$24.50"
|
||||
public static String moneyString(double amount) {
|
||||
return iConomy.format(amount);
|
||||
}
|
||||
|
||||
// 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
|
||||
if (!enabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Holdings holdings = getIconomyHoldings(playerName);
|
||||
if (holdings == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return holdings.hasEnough(amount);
|
||||
}
|
||||
|
||||
// deduct money from their account; returns true if successful
|
||||
public static boolean deductMoney(String playerName, double amount) {
|
||||
if (!enabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Holdings holdings = getIconomyHoldings(playerName);
|
||||
if (holdings == null || !holdings.hasEnough(amount)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
// add money to their account; returns true if successful
|
||||
public static boolean addMoney(String playerName, double amount) {
|
||||
if (!enabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Holdings holdings = getIconomyHoldings(playerName);
|
||||
if (holdings == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// calculate the cost for claiming land
|
||||
public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction) {
|
||||
if (!enabled()) {
|
||||
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
|
||||
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) {
|
||||
double amount = 0;
|
||||
for (int x = 0; x < ownedLand; x++) {
|
||||
amount += calculateClaimCost(x, false);
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
// calculate refund amount for all owned land
|
||||
public static double calculateTotalLandRefund(int ownedLand) {
|
||||
return calculateTotalLandValue(ownedLand) * Conf.econClaimRefundMultiplier;
|
||||
}
|
||||
}
|
@ -434,7 +434,7 @@ public class FPlayer {
|
||||
// Actions
|
||||
// -------------------------------
|
||||
|
||||
public void leave() {
|
||||
public void leave(boolean makePay) {
|
||||
Faction myFaction = this.getFaction();
|
||||
|
||||
if (this.getRole() == Role.ADMIN && myFaction.getFPlayers().size() > 1) {
|
||||
@ -446,7 +446,27 @@ public class FPlayer {
|
||||
sendMessage("You cannot leave until your power is positive.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled and they're not on the bypass list, make 'em pay
|
||||
if (makePay && Econ.enabled() && !Conf.adminBypassPlayers.contains(this.playerName)) {
|
||||
double cost = Conf.econCostLeave;
|
||||
// pay up
|
||||
if (cost > 0.0) {
|
||||
String costString = Econ.moneyString(cost);
|
||||
if (!Econ.deductMoney(this.getName(), cost)) {
|
||||
sendMessage("It costs "+costString+" to leave your faction, which you can't currently afford.");
|
||||
return;
|
||||
}
|
||||
sendMessage("You have paid "+costString+" to leave your faction.");
|
||||
}
|
||||
// wait... we pay you to leave?
|
||||
else if (cost < 0.0) {
|
||||
String costString = Econ.moneyString(-cost);
|
||||
Econ.addMoney(this.getName(), -cost);
|
||||
sendMessage("You have been paid "+costString+" for leaving your faction.");
|
||||
}
|
||||
}
|
||||
|
||||
if (myFaction.isNormal()) {
|
||||
myFaction.sendMessage(this.getNameAndRelevant(myFaction) + Conf.colorSystem + " left your faction.");
|
||||
}
|
||||
@ -502,7 +522,8 @@ public class FPlayer {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (myFaction.getLandRounded() >= myFaction.getPowerRounded()) {
|
||||
int ownedLand = myFaction.getLandRounded();
|
||||
if (ownedLand >= myFaction.getPowerRounded()) {
|
||||
sendMessage("You can't claim more land! You need more power!");
|
||||
return false;
|
||||
}
|
||||
@ -527,10 +548,7 @@ public class FPlayer {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (otherFaction.isNone()) {
|
||||
myFaction.sendMessage(this.getNameAndRelevant(myFaction)+Conf.colorSystem+" claimed some new land :D");
|
||||
} else { //if (otherFaction.isNormal()) {
|
||||
|
||||
if (otherFaction.isNormal()) {
|
||||
if ( ! otherFaction.hasLandInflation()) {
|
||||
// TODO more messages WARN current faction most importantly
|
||||
sendMessage(this.getRelationColor(otherFaction)+otherFaction.getTag()+Conf.colorSystem+" owns this land and is strong enough to keep it.");
|
||||
@ -541,12 +559,29 @@ public class FPlayer {
|
||||
sendMessage("You must start claiming land at the border of the territory.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if economy is enabled and they're not on the bypass list, make 'em pay
|
||||
if (Econ.enabled() && !Conf.adminBypassPlayers.contains(this.playerName)) {
|
||||
double cost = Econ.calculateClaimCost(ownedLand, otherFaction.isNormal());
|
||||
String costString = Econ.moneyString(cost);
|
||||
if (!Econ.deductMoney(this.playerName, cost)) {
|
||||
sendMessage("Claiming this land will cost "+costString+", which you can't currently afford.");
|
||||
return false;
|
||||
}
|
||||
sendMessage("You have paid "+costString+" to claim this land.");
|
||||
}
|
||||
|
||||
// announce success
|
||||
if (otherFaction.isNormal()) {
|
||||
// ASDF claimed some of your land 450 blocks NNW of you.
|
||||
// ASDf claimed some land from FACTION NAME
|
||||
otherFaction.sendMessage(this.getNameAndRelevant(otherFaction)+Conf.colorSystem+" stole some of your land :O");
|
||||
myFaction.sendMessage(this.getNameAndRelevant(myFaction)+Conf.colorSystem+" claimed some land from "+otherFaction.getTag(myFaction));
|
||||
}
|
||||
else {
|
||||
myFaction.sendMessage(this.getNameAndRelevant(myFaction)+Conf.colorSystem+" claimed some new land :D");
|
||||
}
|
||||
|
||||
Board.setFactionAt(myFaction, flocation);
|
||||
return true;
|
||||
@ -687,7 +722,7 @@ public class FPlayer {
|
||||
|
||||
for (FPlayer fplayer : FPlayer.getAll()) {
|
||||
if (now - fplayer.getLastLoginTime() > toleranceMillis) {
|
||||
fplayer.leave();
|
||||
fplayer.leave(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,6 +147,8 @@ public class Factions extends JavaPlugin {
|
||||
setupPermissions();
|
||||
integrateEssentialsChat();
|
||||
|
||||
Econ.monitorPlugins();
|
||||
|
||||
// Register events
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Event.Priority.Highest, this);
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
@ -234,6 +235,32 @@ public class FBaseCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if economy is enabled and they're not on the bypass list, make 'em pay; returns true unless person can't afford the cost
|
||||
public boolean payForCommand(double cost) {
|
||||
if (!Econ.enabled() || this.me == null || cost == 0.0 || Conf.adminBypassPlayers.contains(me.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String desc = this.helpDescription.toLowerCase();
|
||||
|
||||
// pay up
|
||||
if (cost > 0.0) {
|
||||
String costString = Econ.moneyString(cost);
|
||||
if (!Econ.deductMoney(me.getName(), cost)) {
|
||||
sendMessage("It costs "+costString+" to "+desc+", which you can't currently afford.");
|
||||
return false;
|
||||
}
|
||||
sendMessage("You have paid "+costString+" to "+desc+".");
|
||||
}
|
||||
// wait... we pay you to use this command?
|
||||
else {
|
||||
String costString = Econ.moneyString(-cost);
|
||||
Econ.addMoney(me.getName(), -cost);
|
||||
sendMessage("You have been paid "+costString+" to "+desc+".");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final List<String> aliasTrue = new ArrayList<String>(Arrays.asList("true", "yes", "y", "ok", "on", "+"));
|
||||
public static final List<String> aliasFalse = new ArrayList<String>(Arrays.asList("false", "no", "n", "off", "-"));
|
||||
|
||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
@ -51,7 +52,12 @@ public class FCommandCreate extends FBaseCommand {
|
||||
sendMessage(tagValidationErrors);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostCreate)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Faction faction = Faction.create();
|
||||
faction.setTag(tag);
|
||||
me.setRole(Role.ADMIN);
|
||||
|
@ -29,7 +29,12 @@ public class FCommandDescription extends FBaseCommand {
|
||||
if ( ! assertMinRole(Role.MODERATOR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostDesc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
me.getFaction().setDescription(TextUtil.implode(parameters));
|
||||
|
||||
// Broadcast the description to everyone
|
||||
|
@ -58,9 +58,9 @@ public class FCommandHome extends FBaseCommand {
|
||||
|
||||
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
|
||||
if (
|
||||
Conf.homesTeleportAllowedEnemyDistance > 0
|
||||
&& !faction.isSafeZone()
|
||||
&& (!me.isInOwnTerritory() || (me.isInOwnTerritory() && !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory))
|
||||
Conf.homesTeleportAllowedEnemyDistance > 0
|
||||
&& !faction.isSafeZone()
|
||||
&& (!me.isInOwnTerritory() || (me.isInOwnTerritory() && !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory))
|
||||
) {
|
||||
Location loc = player.getLocation();
|
||||
World w = loc.getWorld();
|
||||
@ -91,7 +91,12 @@ public class FCommandHome extends FBaseCommand {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostHome)) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.teleport(myFaction.getHome());
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,12 @@ public class FCommandInvite extends FBaseCommand {
|
||||
sendMessage("You might want to: " + new FCommandKick().getUseageTemplate(false));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostInvite)) {
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.invite(you);
|
||||
|
||||
you.sendMessage(me.getNameAndRelevant(you)+Conf.colorSystem+" invited you to "+myFaction.getTag(you));
|
||||
|
@ -54,6 +54,11 @@ public class FCommandJoin extends FBaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostJoin)) {
|
||||
return;
|
||||
}
|
||||
|
||||
me.sendMessage(Conf.colorSystem+"You successfully joined "+faction.getTag(me));
|
||||
faction.sendMessage(me.getNameAndRelevant(faction)+Conf.colorSystem+" joined your faction.");
|
||||
|
||||
|
@ -57,6 +57,11 @@ public class FCommandKick extends FBaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostKick)) {
|
||||
return;
|
||||
}
|
||||
|
||||
yourFaction.sendMessage(me.getNameAndRelevant(yourFaction)+Conf.colorSystem+" kicked "+you.getNameAndRelevant(yourFaction)+Conf.colorSystem+" from the faction! :O");
|
||||
you.sendMessage(me.getNameAndRelevant(you)+Conf.colorSystem+" kicked you from "+yourFaction.getTag(you)+Conf.colorSystem+"! :O");
|
||||
if (yourFaction != myFaction) {
|
||||
|
@ -26,7 +26,7 @@ public class FCommandLeave extends FBaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
me.leave();
|
||||
me.leave(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,11 @@ public class FCommandList extends FBaseCommand {
|
||||
FactionList.remove(Faction.getSafeZone());
|
||||
FactionList.remove(Faction.getWarZone());
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int page = 1;
|
||||
if (parameters.size() > 0) {
|
||||
try {
|
||||
|
@ -3,6 +3,7 @@ package com.massivecraft.factions.commands;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
|
||||
|
||||
@ -27,6 +28,12 @@ public class FCommandMap extends FBaseCommand {
|
||||
String mapAutoUpdating = parameters.get(0);
|
||||
if (parseBool(mapAutoUpdating)) {
|
||||
// Turn on
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostMap)) {
|
||||
return;
|
||||
}
|
||||
|
||||
me.setMapAutoUpdating(true);
|
||||
sendMessage("Map auto update ENABLED.");
|
||||
|
||||
@ -38,6 +45,11 @@ public class FCommandMap extends FBaseCommand {
|
||||
sendMessage("Map auto update DISABLED.");
|
||||
}
|
||||
} else {
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostMap)) {
|
||||
return;
|
||||
}
|
||||
|
||||
showMap();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,12 @@ public class FCommandOpen extends FBaseCommand {
|
||||
if ( ! assertMinRole(Role.MODERATOR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostOpen)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
myFaction.setOpen( ! me.getFaction().getOpen());
|
||||
|
||||
|
@ -94,6 +94,11 @@ public class FCommandOwner extends FBaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostOwner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.setPlayerAsOwner(playerName, flocation);
|
||||
me.sendMessage("You have added "+playerName+" to the owner list for this claimed land.");
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class FCommandPower extends FBaseCommand {
|
||||
}
|
||||
target = findFPlayer(parameters.get(0), false);
|
||||
} else if (!(sender instanceof Player)) {
|
||||
sendMessage("From the command line, you must specify a player (f power <player name>).");
|
||||
sendMessage("From the console, you must specify a player (f power <player name>).");
|
||||
return;
|
||||
} else {
|
||||
target = me;
|
||||
@ -45,7 +45,12 @@ public class FCommandPower extends FBaseCommand {
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostPower)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendMessage(target.getNameAndRelevant(me)+Conf.colorChrome+" - Power / Maxpower: "+Conf.colorSystem+target.getPowerRounded()+" / "+target.getPowerMaxRounded());
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,12 @@ public class FCommandSethome extends FBaseCommand {
|
||||
me.sendMessage("Sorry, your faction home can only be set inside your own claimed territory.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostSethome)) {
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.setHome(player.getLocation());
|
||||
|
||||
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" set the home for your faction. You can now use:");
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
@ -45,7 +46,12 @@ public class FCommandShow extends FBaseCommand {
|
||||
if (faction == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostShow)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
|
||||
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
||||
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
|
||||
@ -62,7 +68,18 @@ public class FCommandShow extends FBaseCommand {
|
||||
sendMessage(Conf.colorChrome+"Joining: "+Conf.colorSystem+"invitation is required");
|
||||
}
|
||||
sendMessage(Conf.colorChrome+"Land / Power / Maxpower: "+Conf.colorSystem+ faction.getLandRounded()+" / "+faction.getPowerRounded()+" / "+faction.getPowerMaxRounded());
|
||||
|
||||
|
||||
// show the land value
|
||||
if (Econ.enabled()) {
|
||||
double value = Econ.calculateTotalLandValue(faction.getLandRounded());
|
||||
double refund = value * Conf.econClaimRefundMultiplier;
|
||||
if (value > 0) {
|
||||
String stringValue = Econ.moneyString(value);
|
||||
String stringRefund = (refund > 0.0) ? (" ("+Econ.moneyString(refund)+" depreciated)") : "";
|
||||
sendMessage(Conf.colorChrome+"Total land value: " + Conf.colorSystem + stringValue + stringRefund);
|
||||
}
|
||||
}
|
||||
|
||||
String listpart;
|
||||
|
||||
// List relation
|
||||
|
@ -48,6 +48,11 @@ public class FCommandTag extends FBaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostTag)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
|
||||
String oldtag = myFaction.getTag();
|
||||
|
@ -40,7 +40,12 @@ public class FCommandTitle extends FBaseCommand {
|
||||
if ( ! canIAdministerYou(me, you)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostTitle)) {
|
||||
return;
|
||||
}
|
||||
|
||||
you.setTitle(title);
|
||||
|
||||
// Inform
|
||||
|
@ -2,6 +2,7 @@ package com.massivecraft.factions.commands;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
@ -69,10 +70,31 @@ public class FCommandUnclaim extends FBaseCommand {
|
||||
sendMessage("You don't own this land.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String moneyBack = "";
|
||||
if (Econ.enabled()) {
|
||||
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
||||
// a real refund
|
||||
if (refund > 0.0) {
|
||||
Econ.addMoney(player.getName(), refund);
|
||||
moneyBack = " They received a refund of "+Econ.moneyString(refund)+".";
|
||||
}
|
||||
// wait, you're charging people to unclaim land? outrageous
|
||||
else if (refund < 0.0) {
|
||||
if (!Econ.deductMoney(player.getName(), -refund)) {
|
||||
sendMessage("Unclaiming this land will cost "+Econ.moneyString(-refund)+", which you can't currently afford.");
|
||||
return;
|
||||
}
|
||||
moneyBack = " It cost them "+Econ.moneyString(refund)+".";
|
||||
}
|
||||
// no refund
|
||||
else {
|
||||
moneyBack = "";
|
||||
}
|
||||
}
|
||||
|
||||
Board.removeAt(flocation);
|
||||
|
||||
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed some land.");
|
||||
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed some land."+moneyBack);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.massivecraft.factions.commands;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
|
||||
@ -28,11 +29,33 @@ public class FCommandUnclaimall extends FBaseCommand {
|
||||
if ( ! assertMinRole(Role.MODERATOR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
|
||||
|
||||
String moneyBack = "";
|
||||
if (Econ.enabled()) {
|
||||
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
|
||||
// a real refund
|
||||
if (refund > 0.0) {
|
||||
Econ.addMoney(player.getName(), refund);
|
||||
moneyBack = " They received a refund of "+Econ.moneyString(refund)+".";
|
||||
}
|
||||
// wait, you're charging people to unclaim land? outrageous
|
||||
else if (refund < 0.0) {
|
||||
if (!Econ.deductMoney(player.getName(), -refund)) {
|
||||
sendMessage("Unclaiming all faction land will cost "+Econ.moneyString(-refund)+", which you can't currently afford.");
|
||||
return;
|
||||
}
|
||||
moneyBack = " It cost them "+Econ.moneyString(refund)+".";
|
||||
}
|
||||
// no refund
|
||||
else {
|
||||
moneyBack = "";
|
||||
}
|
||||
}
|
||||
|
||||
Board.unclaimAll(myFaction.getId());
|
||||
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed ALL of your factions land.");
|
||||
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" unclaimed ALL of your factions land."+moneyBack);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,13 @@ public class FRelationCommand extends FBaseCommand {
|
||||
sendMessage("Nope! You can't declare a relation to yourself :)");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
double cost = whishedRelation.isAlly() ? Conf.econCostAlly : (whishedRelation.isEnemy() ? Conf.econCostEnemy : Conf.econCostNeutral);
|
||||
if (!payForCommand(cost)) {
|
||||
return;
|
||||
}
|
||||
|
||||
myFaction.setRelationWish(otherFaction, whishedRelation);
|
||||
Relation currentRelation = myFaction.getRelation(otherFaction);
|
||||
ChatColor currentRelationColor = currentRelation.getColor();
|
||||
|
@ -21,6 +21,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
@ -159,13 +160,14 @@ public class FactionsPlayerListener extends PlayerListener{
|
||||
|
||||
if (me.autoClaimEnabled()) {
|
||||
Faction myFaction = me.getFaction();
|
||||
FLocation flocation = new FLocation(me);
|
||||
Faction otherFaction = Board.getFactionAt(to);
|
||||
double cost = Econ.calculateClaimCost(myFaction.getLandRounded(), otherFaction.isNormal());
|
||||
|
||||
if (me.getRole().value < Role.MODERATOR.value) {
|
||||
me.sendMessage("You must be "+Role.MODERATOR+" to claim land.");
|
||||
me.enableAutoClaim(false);
|
||||
}
|
||||
else if (Conf.worldsNoClaiming.contains(flocation.getWorldName())) {
|
||||
else if (Conf.worldsNoClaiming.contains(to.getWorldName())) {
|
||||
me.sendMessage("Sorry, this world has land claiming disabled.");
|
||||
me.enableAutoClaim(false);
|
||||
}
|
||||
@ -173,6 +175,11 @@ public class FactionsPlayerListener extends PlayerListener{
|
||||
me.sendMessage("You can't claim more land! You need more power!");
|
||||
me.enableAutoClaim(false);
|
||||
}
|
||||
else if (!Econ.canAfford(player.getName(), cost)) {
|
||||
String costString = Econ.moneyString(cost);
|
||||
me.sendMessage("Claiming this land will cost "+costString+", which you can't currently afford.");
|
||||
me.enableAutoClaim(false);
|
||||
}
|
||||
else
|
||||
me.attemptClaim(false);
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.massivecraft.factions.listeners;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Econ;
|
||||
import com.massivecraft.factions.Factions;
|
||||
|
||||
import com.iConomy.*;
|
||||
|
||||
|
||||
public class FactionsServerListener extends ServerListener {
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (Econ.iConomyHooked()) {
|
||||
if (event.getPlugin().getDescription().getName().equals("iConomy")) {
|
||||
Econ.iConomySet(null);
|
||||
Factions.log("Un-hooked from iConomy.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (!Econ.iConomyHooked()) {
|
||||
Plugin iConomy = Factions.instance.getServer().getPluginManager().getPlugin("iConomy");
|
||||
|
||||
if (iConomy != null) {
|
||||
if (iConomy.isEnabled() && iConomy.getClass().getName().equals("com.iConomy.iConomy")) {
|
||||
Econ.iConomySet((iConomy)iConomy);
|
||||
Factions.log("Hooked into iConomy, "+(Conf.econIConomyEnabled ? "and interface is enabled" : "but interface is currently disabled (\"econIConomyEnabled\": false)")+".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ softdepend:
|
||||
- HeroChat
|
||||
- iChat
|
||||
- LocalAreaChat
|
||||
- iConomy
|
||||
commands:
|
||||
f:
|
||||
description: All of the Factions commands
|
||||
|
Loading…
Reference in New Issue
Block a user