Moved the last stuff away from ConfServer.

This commit is contained in:
Olof Larsson 2013-04-24 08:39:26 +02:00
parent d9a23241ec
commit 825d937c84
22 changed files with 195 additions and 200 deletions

View File

@ -16,86 +16,10 @@ public class ConfServer extends SimpleConfig
public ConfServer() { super(Factions.get()); } public ConfServer() { super(Factions.get()); }
// -------------------------------------------- // // -------------------------------------------- //
// CORE // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
public static List<String> baseCommandAliases = MUtil.list("f"); public static List<String> baseCommandAliases = MUtil.list("f");
public static String dburi = "default"; public static String dburi = "default";
// -------------------------------------------- //
// AUTO LEAVE
// -------------------------------------------- //
public static double autoLeaveAfterDaysOfInactivity = 10.0;
public static double autoLeaveRoutineRunsEveryXMinutes = 5.0;
public static boolean removePlayerDataWhenBanned = true;
// -------------------------------------------- //
// CLAIMS
// -------------------------------------------- //
public static boolean claimsMustBeConnected = false;
public static boolean claimingFromOthersAllowed = true;
public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true;
public static int claimsRequireMinFactionMembers = 1;
public static int claimedLandsMax = 0;
// if someone is doing a radius claim and the process fails to claim land this many times in a row, it will exit
public static int radiusClaimFailureLimit = 9;
// -------------------------------------------- //
// INTEGRATION: WORLD GUARD
// -------------------------------------------- //
public static boolean worldGuardChecking = false;
// -------------------------------------------- //
// INTEGRATION: ECONOMY
// -------------------------------------------- //
public static int econLandRewardTaskRunsEveryXMinutes = 20;
public static boolean econEnabled = false;
// TODO: Rename to include unit.
public static double econLandReward = 0.00;
public static String econUniverseAccount = "";
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 econClaimUnconnectedFee = 0.0;
public static double econCostCreate = 100.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 econCostDeinvite = 0.0;
public static double econCostHome = 0.0;
public static double econCostTag = 0.0;
public static double econCostDescription = 0.0;
public static double econCostTitle = 0.0;
public static double econCostOpen = 0.0;
public static double econCostAlly = 0.0;
public static double econCostTruce = 0.0;
public static double econCostNeutral = 0.0;
public static double econCostEnemy = 0.0;
//Faction banks, to pay for land claiming and other costs instead of individuals paying for them
public static boolean bankEnabled = true;
//public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
public static boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
public static boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
} }

View File

@ -34,7 +34,7 @@ import com.massivecraft.factions.listeners.FactionsListenerMain;
import com.massivecraft.factions.listeners.TodoFactionsPlayerListener; import com.massivecraft.factions.listeners.TodoFactionsPlayerListener;
import com.massivecraft.factions.mixin.PowerMixin; import com.massivecraft.factions.mixin.PowerMixin;
import com.massivecraft.factions.mixin.PowerMixinDefault; import com.massivecraft.factions.mixin.PowerMixinDefault;
import com.massivecraft.factions.task.AutoLeaveTask; import com.massivecraft.factions.task.RemovePlayerDataTask;
import com.massivecraft.factions.task.EconRewardTask; import com.massivecraft.factions.task.EconRewardTask;
import com.massivecraft.factions.task.PowerUpdateTask; import com.massivecraft.factions.task.PowerUpdateTask;
@ -137,7 +137,7 @@ public class Factions extends MPlugin
// Schedule recurring non-tps-dependent tasks // Schedule recurring non-tps-dependent tasks
PowerUpdateTask.get().schedule(this); PowerUpdateTask.get().schedule(this);
AutoLeaveTask.get().schedule(this); RemovePlayerDataTask.get().schedule(this);
EconRewardTask.get().schedule(this); EconRewardTask.get().schedule(this);
// Register built in chat modifiers // Register built in chat modifiers
@ -160,11 +160,7 @@ public class Factions extends MPlugin
this.integrate(HerochatFeatures.get()); this.integrate(HerochatFeatures.get());
LWCFeatures.setup(); LWCFeatures.setup();
if (ConfServer.worldGuardChecking)
{
Worldguard.init(this); Worldguard.init(this);
}
postEnable(); postEnable();
} }

View File

@ -157,17 +157,4 @@ public enum Rel
return ""; return "";
} }
// TODO: ADD TRUCE!!!!
// TODO.... or remove it...
public double getRelationCost()
{
if (this == ENEMY)
return ConfServer.econCostEnemy;
else if (this == ALLY)
return ConfServer.econCostAlly;
else if (this == TRUCE)
return ConfServer.econCostTruce;
else
return ConfServer.econCostNeutral;
}
} }

View File

@ -1,9 +1,9 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.task.SpiralTask; import com.massivecraft.factions.task.SpiralTask;
import com.massivecraft.mcore.cmd.arg.ARInteger; import com.massivecraft.mcore.cmd.arg.ARInteger;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -59,7 +59,7 @@ public class CmdFactionsClaim extends FCommand
new SpiralTask(PS.valueOf(me), radius) new SpiralTask(PS.valueOf(me), radius)
{ {
private int failCount = 0; private int failCount = 0;
private final int limit = ConfServer.radiusClaimFailureLimit - 1; private final int limit = UConf.get(me).radiusClaimFailureLimit - 1;
@Override @Override
public boolean work() public boolean work()

View File

@ -18,7 +18,7 @@ public class CmdFactionsLeave extends FCommand {
@Override @Override
public void perform() public void perform()
{ {
fme.leave(true); fme.leave();
} }
} }

View File

@ -5,8 +5,8 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
@ -65,7 +65,8 @@ public class CmdFactionsShow extends FCommand
if (Econ.isEnabled(faction)) if (Econ.isEnabled(faction))
{ {
double value = Econ.calculateTotalLandValue(faction.getLandCount()); double value = Econ.calculateTotalLandValue(faction.getLandCount());
double refund = value * ConfServer.econClaimRefundMultiplier;
double refund = value * UConf.get(faction).econClaimRefundMultiplier;
if (value > 0) if (value > 0)
{ {
String stringValue = Money.format(faction, value); String stringValue = Money.format(faction, value);
@ -73,8 +74,8 @@ public class CmdFactionsShow extends FCommand
msg("<a>Total land value: <i>" + stringValue + stringRefund); msg("<a>Total land value: <i>" + stringValue + stringRefund);
} }
//Show bank contents // Show bank contents
if(ConfServer.bankEnabled) if(UConf.get(faction).bankEnabled)
{ {
msg("<a>Bank contains: <i>"+Money.format(faction, Money.get(faction))); msg("<a>Bank contains: <i>"+Money.format(faction, Money.get(faction)));
} }

View File

@ -1,9 +1,9 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.FactionsEventLandUnclaim; import com.massivecraft.factions.event.FactionsEventLandUnclaim;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
@ -43,7 +43,7 @@ public class CmdFactionsUnclaim extends FCommand
{ {
double refund = Econ.calculateClaimRefund(myFaction); double refund = Econ.calculateClaimRefund(myFaction);
if (ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts) if (UConf.get(myFaction).bankEnabled && UConf.get(myFaction).bankFactionPaysLandCosts)
{ {
if ( ! Econ.modifyMoney(myFaction, refund, "unclaim this land")) return; if ( ! Econ.modifyMoney(myFaction, refund, "unclaim this land")) return;
} }

View File

@ -1,12 +1,12 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.FactionsEventLandUnclaimAll; import com.massivecraft.factions.event.FactionsEventLandUnclaimAll;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -28,7 +28,8 @@ public class CmdFactionsUnclaimall extends FCommand
if (Econ.isEnabled(myFaction)) if (Econ.isEnabled(myFaction))
{ {
double refund = Econ.calculateTotalLandRefund(myFaction.getLandCount()); double refund = Econ.calculateTotalLandRefund(myFaction.getLandCount());
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts)
if (UConf.get(myFaction).bankEnabled && UConf.get(myFaction).bankFactionPaysLandCosts)
{ {
if ( ! Econ.modifyMoney(myFaction, refund, "unclaim all faction land")) return; if ( ! Econ.modifyMoney(myFaction, refund, "unclaim all faction land")) return;
} }

View File

@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.entity.UConf;
import com.massivecraft.mcore.cmd.MCommand; import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.req.ReqAbstract; import com.massivecraft.mcore.cmd.req.ReqAbstract;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
@ -25,17 +25,16 @@ public class ReqBankCommandsEnabled extends ReqAbstract
@Override @Override
public boolean apply(CommandSender sender, MCommand command) public boolean apply(CommandSender sender, MCommand command)
{ {
return ConfServer.econEnabled && ConfServer.bankEnabled; return UConf.get(sender).econEnabled && UConf.get(sender).bankEnabled;
} }
@Override @Override
public String createErrorMessage(CommandSender sender, MCommand command) public String createErrorMessage(CommandSender sender, MCommand command)
{ {
if (!ConfServer.bankEnabled) if (!UConf.get(sender).bankEnabled)
{ {
return Txt.parse("<b>The Factions bank system is disabled on this server."); return Txt.parse("<b>The Factions bank system is disabled on this server.");
} }
return Txt.parse("<b>The Factions economy features are disabled on this server."); return Txt.parse("<b>The Factions economy features are disabled on this server.");
} }

View File

@ -111,7 +111,7 @@ public class Board extends Entity<Board> implements BoardInterface
{ {
// TODO: Listen to an event instead! // TODO: Listen to an event instead!
// NOTE: And this is probably the place where the event should be triggered! // NOTE: And this is probably the place where the event should be triggered!
if (UConf.get(ps).onUnclaimResetLwcLocks && LWCFeatures.getEnabled()) if (UConf.get(ps).lwcRemoveOnUnclaim && LWCFeatures.getEnabled())
{ {
LWCFeatures.clearAllProtections(ps); LWCFeatures.clearAllProtections(ps);
} }

View File

@ -120,6 +120,34 @@ public class FactionColl extends Coll<Faction>
return this.get(Const.FACTIONID_NONE); return this.get(Const.FACTIONID_NONE);
} }
// -------------------------------------------- //
// LAND REWARD
// -------------------------------------------- //
public void econLandRewardRoutine()
{
if (!Econ.isEnabled(this.getUniverse())) return;
double econLandReward = UConf.get(this).econLandReward;
if (econLandReward == 0.0) return;
Factions.get().log("Running econLandRewardRoutine...");
for (Faction faction : this.getAll())
{
int landCount = faction.getLandCount();
if (!faction.getFlag(FFlag.PEACEFUL) && landCount > 0)
{
List<UPlayer> players = faction.getUPlayers();
int playerCount = players.size();
double reward = econLandReward * landCount / playerCount;
for (UPlayer player : players)
{
Econ.modifyMoney(player, reward, "own " + landCount + " faction land divided among " + playerCount + " members");
}
}
}
}
// -------------------------------------------- // // -------------------------------------------- //
// FACTION TAG // FACTION TAG
// -------------------------------------------- // // -------------------------------------------- //
@ -182,28 +210,6 @@ public class FactionColl extends Coll<Faction>
return this.getByTag(str) != null; return this.getByTag(str) != null;
} }
public void econLandRewardRoutine()
{
if (!Econ.isEnabled(this.getUniverse())) return;
if (ConfServer.econLandReward == 0.0) return;
Factions.get().log("Running econLandRewardRoutine...");
for (Faction faction : this.getAll())
{
int landCount = faction.getLandCount();
if (!faction.getFlag(FFlag.PEACEFUL) && landCount > 0)
{
List<UPlayer> players = faction.getUPlayers();
int playerCount = players.size();
double reward = ConfServer.econLandReward * landCount / playerCount;
for (UPlayer player : players)
{
Econ.modifyMoney(player, reward, "own " + landCount + " faction land divided among " + playerCount + " members");
}
}
}
}
// -------------------------------------------- // // -------------------------------------------- //
// CREATE DEFAULT FACTIONS // CREATE DEFAULT FACTIONS
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -35,10 +35,19 @@ public class MConf extends Entity<MConf>
} }
// -------------------------------------------- // // -------------------------------------------- //
// POWER // TASKS
// -------------------------------------------- // // -------------------------------------------- //
public long powerTaskMillis = TimeUnit.MILLIS_PER_MINUTE; public long taskPowerMillis = TimeUnit.MILLIS_PER_MINUTE;
public long taskEconMillis = 20 * TimeUnit.MILLIS_PER_MINUTE;
public long taskAutoLeaveMillis = 5 * TimeUnit.MILLIS_PER_MINUTE;
// -------------------------------------------- //
// REMOVE DATA
// -------------------------------------------- //
public boolean removePlayerDataWhenBanned = true;
public double removePlayerDataAfterInactiveDays = 20.0;
// -------------------------------------------- // // -------------------------------------------- //
// CHAT // CHAT

View File

@ -73,6 +73,19 @@ public class UConf extends Entity<UConf>
public boolean canLeaveWithNegativePower = true; public boolean canLeaveWithNegativePower = true;
// -------------------------------------------- //
// CLAIMS
// -------------------------------------------- //
public boolean claimsMustBeConnected = false;
public boolean claimingFromOthersAllowed = true;
public boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true;
public int claimsRequireMinFactionMembers = 1;
public int claimedLandsMax = 0;
// if someone is doing a radius claim and the process fails to claim land this many times in a row, it will exit
public int radiusClaimFailureLimit = 9;
// -------------------------------------------- // // -------------------------------------------- //
// HOMES // HOMES
// -------------------------------------------- // // -------------------------------------------- //
@ -101,11 +114,60 @@ public class UConf extends Entity<UConf>
Rel.MEMBER, new ArrayList<String>() Rel.MEMBER, new ArrayList<String>()
); );
// -------------------------------------------- //
// INTEGRATION: WORLD GUARD
// -------------------------------------------- //
public boolean worldGuardChecking = false;
// -------------------------------------------- // // -------------------------------------------- //
// INTEGRATION: LWC // INTEGRATION: LWC
// -------------------------------------------- // // -------------------------------------------- //
public boolean onUnclaimResetLwcLocks = false; public boolean lwcRemoveOnUnclaim = false;
public boolean onCaptureResetLwcLocks = false; public boolean lwcRemoveOnCapture = false;
// -------------------------------------------- //
// INTEGRATION: ECONOMY
// -------------------------------------------- //
public boolean econEnabled = false;
// TODO: Rename to include unit.
public double econLandReward = 0.00;
public String econUniverseAccount = "";
public double econCostClaimWilderness = 30.0;
public double econCostClaimFromFactionBonus = 30.0;
public double econClaimAdditionalMultiplier = 0.5;
public double econClaimRefundMultiplier = 0.7;
public double econClaimUnconnectedFee = 0.0;
public double econCostCreate = 100.0;
public double econCostSethome = 0.0;
public double econCostJoin = 0.0;
public double econCostLeave = 0.0;
public double econCostKick = 0.0;
public double econCostInvite = 0.0;
public double econCostDeinvite = 0.0;
public double econCostHome = 0.0;
public double econCostTag = 0.0;
public double econCostDescription = 0.0;
public double econCostTitle = 0.0;
public double econCostOpen = 0.0;
public Map<Rel, Double> econRelCost = MUtil.map(
Rel.ENEMY, 0.0,
Rel.ALLY, 0.0,
Rel.TRUCE, 0.0,
Rel.NEUTRAL, 0.0
);
//Faction banks, to pay for land claiming and other costs instead of individuals paying for them
public boolean bankEnabled = true;
//public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction
public boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome
public boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs.
} }

View File

@ -6,7 +6,6 @@ import java.util.Set;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Const; import com.massivecraft.factions.Const;
import com.massivecraft.factions.EconomyParticipator; import com.massivecraft.factions.EconomyParticipator;
import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FFlag;
@ -487,7 +486,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
// ACTIONS // ACTIONS
// -------------------------------------------- // // -------------------------------------------- //
public void leave(boolean makePay) public void leave()
{ {
Faction myFaction = this.getFaction(); Faction myFaction = this.getFaction();
@ -559,7 +558,9 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
Faction currentFaction = BoardColls.get().getFactionAt(ps); Faction currentFaction = BoardColls.get().getFactionAt(ps);
int ownedLand = forFaction.getLandCount(); int ownedLand = forFaction.getLandCount();
if (ConfServer.worldGuardChecking && Worldguard.checkForRegionsInChunk(ps)) UConf uconf = UConf.get(ps);
if (uconf.worldGuardChecking && Worldguard.checkForRegionsInChunk(ps))
{ {
// Checks for WorldGuard regions in the chunk attempting to be claimed // Checks for WorldGuard regions in the chunk attempting to be claimed
error = Txt.parse("<b>This land is protected"); error = Txt.parse("<b>This land is protected");
@ -580,19 +581,19 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
{ {
return false; return false;
} }
else if (forFaction.getUPlayers().size() < ConfServer.claimsRequireMinFactionMembers) else if (forFaction.getUPlayers().size() < uconf.claimsRequireMinFactionMembers)
{ {
error = Txt.parse("Factions must have at least <h>%s<b> members to claim land.", ConfServer.claimsRequireMinFactionMembers); error = Txt.parse("Factions must have at least <h>%s<b> members to claim land.", uconf.claimsRequireMinFactionMembers);
} }
else if (ownedLand >= forFaction.getPowerRounded()) else if (ownedLand >= forFaction.getPowerRounded())
{ {
error = Txt.parse("<b>You can't claim more land! You need more power!"); error = Txt.parse("<b>You can't claim more land! You need more power!");
} }
else if (ConfServer.claimedLandsMax != 0 && ownedLand >= ConfServer.claimedLandsMax && ! forFaction.getFlag(FFlag.INFPOWER)) else if (uconf.claimedLandsMax != 0 && ownedLand >= uconf.claimedLandsMax && ! forFaction.getFlag(FFlag.INFPOWER))
{ {
error = Txt.parse("<b>Limit reached. You can't claim more land!"); error = Txt.parse("<b>Limit reached. You can't claim more land!");
} }
else if ( ! ConfServer.claimingFromOthersAllowed && currentFaction.isNormal()) else if ( ! uconf.claimingFromOthersAllowed && currentFaction.isNormal())
{ {
error = Txt.parse("<b>You may not claim land from others."); error = Txt.parse("<b>You may not claim land from others.");
} }
@ -602,14 +603,14 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
} }
else if else if
( (
ConfServer.claimsMustBeConnected uconf.claimsMustBeConnected
&& ! this.isUsingAdminMode() && ! this.isUsingAdminMode()
&& myFaction.getLandCountInWorld(ps.getWorld()) > 0 && myFaction.getLandCountInWorld(ps.getWorld()) > 0
&& !BoardColls.get().isConnectedPs(ps, myFaction) && !BoardColls.get().isConnectedPs(ps, myFaction)
&& (!ConfServer.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal()) && (!uconf.claimsCanBeUnconnectedIfOwnedByOtherFaction || !currentFaction.isNormal())
) )
{ {
if (ConfServer.claimsCanBeUnconnectedIfOwnedByOtherFaction) if (uconf.claimsCanBeUnconnectedIfOwnedByOtherFaction)
error = Txt.parse("<b>You can only claim additional land which is connected to your first claim or controlled by another faction!"); error = Txt.parse("<b>You can only claim additional land which is connected to your first claim or controlled by another faction!");
else else
error = Txt.parse("<b>You can only claim additional land which is connected to your first claim!"); error = Txt.parse("<b>You can only claim additional land which is connected to your first claim!");
@ -653,14 +654,15 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
// TODO: The economy integration should cancel the event above! // TODO: The economy integration should cancel the event above!
// Calculate the cost to claim the area // Calculate the cost to claim the area
double cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal()); double cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal());
if (ConfServer.econClaimUnconnectedFee != 0.0 && forFaction.getLandCountInWorld(psChunk.getWorld()) > 0 && !BoardColls.get().isConnectedPs(psChunk, forFaction))
if (UConf.get(psChunk).econClaimUnconnectedFee != 0.0 && forFaction.getLandCountInWorld(psChunk.getWorld()) > 0 && !BoardColls.get().isConnectedPs(psChunk, forFaction))
{ {
cost += ConfServer.econClaimUnconnectedFee; cost += UConf.get(psChunk).econClaimUnconnectedFee;
} }
if (Econ.payForAction(cost, this, "claim this land")) return false; if (Econ.payForAction(cost, this, "claim this land")) return false;
// TODO: The LWC integration should listen to Monitor for the claim event. // TODO: The LWC integration should listen to Monitor for the claim event.
if (LWCFeatures.getEnabled() && forFaction.isNormal() && UConf.get(forFaction).onCaptureResetLwcLocks) if (LWCFeatures.getEnabled() && forFaction.isNormal() && UConf.get(forFaction).lwcRemoveOnCapture)
{ {
LWCFeatures.clearOtherProtections(psChunk, this.getFaction()); LWCFeatures.clearOtherProtections(psChunk, this.getFaction());
} }

View File

@ -69,12 +69,12 @@ public class UPlayerColl extends SenderColl<UPlayer>
} }
} }
public void autoLeaveOnInactivityRoutine() public void removePlayerDataAfterInactiveDaysRoutine()
{ {
if (ConfServer.autoLeaveAfterDaysOfInactivity <= 0.0) return; if (MConf.get().removePlayerDataAfterInactiveDays <= 0.0) return;
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
double toleranceMillis = ConfServer.autoLeaveAfterDaysOfInactivity * TimeUnit.MILLIS_PER_DAY; double toleranceMillis = MConf.get().removePlayerDataAfterInactiveDays * TimeUnit.MILLIS_PER_DAY;
for (UPlayer uplayer : this.getAll()) for (UPlayer uplayer : this.getAll())
{ {
@ -99,7 +99,7 @@ public class UPlayerColl extends SenderColl<UPlayer>
} }
} }
uplayer.leave(false); uplayer.resetFactionData();
uplayer.detach(); uplayer.detach();
} }
} }

View File

@ -8,6 +8,7 @@ import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.EconomyParticipator; import com.massivecraft.factions.EconomyParticipator;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.factions.util.RelationUtil;
@ -23,7 +24,7 @@ public class Econ
// TODO: Could we not have it enabled as long as Money.enabled is true? // TODO: Could we not have it enabled as long as Money.enabled is true?
public static boolean isEnabled(Object universe) public static boolean isEnabled(Object universe)
{ {
return ConfServer.econEnabled && Money.enabled(universe); return UConf.get(universe).econEnabled && Money.enabled(universe);
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -36,9 +37,10 @@ public class Econ
if (cost == 0D) return true; if (cost == 0D) return true;
if (fsender.isUsingAdminMode()) return true; if (fsender.isUsingAdminMode()) return true;
UConf uconf = UConf.get(fsender);
Faction fsenderFaction = fsender.getFaction(); Faction fsenderFaction = fsender.getFaction();
if (ConfServer.bankEnabled && ConfServer.bankFactionPaysCosts && fsenderFaction.isNormal()) if (uconf.bankEnabled && uconf.bankFactionPaysCosts && fsenderFaction.isNormal())
{ {
return modifyMoney(fsenderFaction, -cost, actionDescription); return modifyMoney(fsenderFaction, -cost, actionDescription);
} }
@ -55,13 +57,14 @@ public class Econ
public static void modifyUniverseMoney(Object universe, double delta) public static void modifyUniverseMoney(Object universe, double delta)
{ {
if (!isEnabled(universe)) return; if (!isEnabled(universe)) return;
UConf uconf = UConf.get(universe);
if (ConfServer.econUniverseAccount == null) return; if (uconf.econUniverseAccount == null) return;
if (ConfServer.econUniverseAccount.length() == 0) return; if (uconf.econUniverseAccount.length() == 0) return;
if (!Money.exists(universe, ConfServer.econUniverseAccount)) return; if (!Money.exists(universe, uconf.econUniverseAccount)) return;
Money.add(universe, ConfServer.econUniverseAccount, delta); Money.add(universe, uconf.econUniverseAccount, delta);
} }
public static void sendBalanceInfo(UPlayer to, EconomyParticipator about) public static void sendBalanceInfo(UPlayer to, EconomyParticipator about)
@ -282,6 +285,11 @@ public class Econ
} }
} }
// -------------------------------------------- //
// LAND VALUE
// -------------------------------------------- //
// TODO: Clean up!
// calculate the cost for claiming land // calculate the cost for claiming land
public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction) public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction)
{ {

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.integration; package com.massivecraft.factions.integration;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.ps.PS;
import java.util.ArrayList; import java.util.ArrayList;
@ -61,12 +62,10 @@ public class Worldguard
// True: PVP is allowed // True: PVP is allowed
// False: PVP is disallowed // False: PVP is disallowed
public static boolean isPVP(Player player) public static boolean isPVP(Player player)
{
if ( ! enabled)
{ {
// No WG hooks so we'll always bypass this check. // No WG hooks so we'll always bypass this check.
return true; if (!enabled) return true;
} if (!UConf.get(player).worldGuardChecking) return true;
Location loc = player.getLocation(); Location loc = player.getLocation();
World world = loc.getWorld(); World world = loc.getWorld();
@ -85,6 +84,7 @@ public class Worldguard
{ {
// No WG hooks so we'll always bypass this check. // No WG hooks so we'll always bypass this check.
if (!enabled) return false; if (!enabled) return false;
if (!UConf.get(psChunk).worldGuardChecking) return true;
World world = null; World world = null;
Chunk chunk = null; Chunk chunk = null;

View File

@ -5,8 +5,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.FactionsEventAbstractSender; import com.massivecraft.factions.event.FactionsEventAbstractSender;
import com.massivecraft.factions.event.FactionsEventCreate; import com.massivecraft.factions.event.FactionsEventCreate;
import com.massivecraft.factions.event.FactionsEventDescriptionChange; import com.massivecraft.factions.event.FactionsEventDescriptionChange;
@ -60,56 +60,60 @@ public class FactionsListenerEcon implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(FactionsEventHomeChange event) public void payForCommand(FactionsEventHomeChange event)
{ {
payForCommand(event, ConfServer.econCostSethome, Factions.get().getOuterCmdFactions().cmdFactionsSethome); payForCommand(event, UConf.get(event.getSender()).econCostSethome, Factions.get().getOuterCmdFactions().cmdFactionsSethome);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(FactionsEventCreate event) public void payForCommand(FactionsEventCreate event)
{ {
payForCommand(event, ConfServer.econCostCreate, Factions.get().getOuterCmdFactions().cmdFactionsCreate); payForCommand(event, UConf.get(event.getSender()).econCostCreate, Factions.get().getOuterCmdFactions().cmdFactionsCreate);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(FactionsEventDescriptionChange event) public void payForCommand(FactionsEventDescriptionChange event)
{ {
payForCommand(event, ConfServer.econCostDescription, Factions.get().getOuterCmdFactions().cmdFactionsDescription); payForCommand(event, UConf.get(event.getSender()).econCostDescription, Factions.get().getOuterCmdFactions().cmdFactionsDescription);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(FactionsEventTagChange event) public void payForCommand(FactionsEventTagChange event)
{ {
payForCommand(event, ConfServer.econCostTag, Factions.get().getOuterCmdFactions().cmdFactionsTag); payForCommand(event, UConf.get(event.getSender()).econCostTag, Factions.get().getOuterCmdFactions().cmdFactionsTag);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(FactionsEventTitleChange event) public void payForCommand(FactionsEventTitleChange event)
{ {
payForCommand(event, ConfServer.econCostTitle, Factions.get().getOuterCmdFactions().cmdFactionsTitle); payForCommand(event, UConf.get(event.getSender()).econCostTitle, Factions.get().getOuterCmdFactions().cmdFactionsTitle);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(FactionsEventRelationChange event) public void payForCommand(FactionsEventRelationChange event)
{ {
payForCommand(event, event.getNewRelation().getRelationCost(), Factions.get().getOuterCmdFactions().cmdFactionsRelationNeutral); Double cost = UConf.get(event.getSender()).econRelCost.get(event.getNewRelation());
if (cost == null) return;
if (cost == 0) return;
payForCommand(event, cost, Factions.get().getOuterCmdFactions().cmdFactionsRelationNeutral);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(FactionsEventOpenChange event) public void payForCommand(FactionsEventOpenChange event)
{ {
payForCommand(event, ConfServer.econCostOpen, Factions.get().getOuterCmdFactions().cmdFactionsOpen); payForCommand(event, UConf.get(event.getSender()).econCostOpen, Factions.get().getOuterCmdFactions().cmdFactionsOpen);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(FactionsEventInvitedChange event) public void payForCommand(FactionsEventInvitedChange event)
{ {
double cost = event.isNewInvited() ? ConfServer.econCostInvite : ConfServer.econCostDeinvite; double cost = event.isNewInvited() ? UConf.get(event.getSender()).econCostInvite : UConf.get(event.getSender()).econCostDeinvite;
payForCommand(event, cost, Factions.get().getOuterCmdFactions().cmdFactionsInvite); payForCommand(event, cost, Factions.get().getOuterCmdFactions().cmdFactionsInvite);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void payForCommand(FactionsEventHomeTeleport event) public void payForCommand(FactionsEventHomeTeleport event)
{ {
payForCommand(event, ConfServer.econCostHome, Factions.get().getOuterCmdFactions().cmdFactionsHome); payForCommand(event, UConf.get(event.getSender()).econCostHome, Factions.get().getOuterCmdFactions().cmdFactionsHome);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
@ -120,17 +124,17 @@ public class FactionsListenerEcon implements Listener
if (event.getReason() == MembershipChangeReason.JOIN) if (event.getReason() == MembershipChangeReason.JOIN)
{ {
cost = ConfServer.econCostJoin; cost = UConf.get(event.getSender()).econCostJoin;
command = Factions.get().getOuterCmdFactions().cmdFactionsJoin; command = Factions.get().getOuterCmdFactions().cmdFactionsJoin;
} }
else if (event.getReason() == MembershipChangeReason.LEAVE) else if (event.getReason() == MembershipChangeReason.LEAVE)
{ {
cost = ConfServer.econCostLeave; cost = UConf.get(event.getSender()).econCostLeave;
command = Factions.get().getOuterCmdFactions().cmdFactionsLeave; command = Factions.get().getOuterCmdFactions().cmdFactionsLeave;
} }
else if (event.getReason() == MembershipChangeReason.KICK) else if (event.getReason() == MembershipChangeReason.KICK)
{ {
cost = ConfServer.econCostKick; cost = UConf.get(event.getSender()).econCostKick;
command = Factions.get().getOuterCmdFactions().cmdFactionsKick; command = Factions.get().getOuterCmdFactions().cmdFactionsKick;
} }
else else

View File

@ -44,7 +44,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.Const; import com.massivecraft.factions.Const;
import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
@ -301,16 +300,15 @@ public class FactionsListenerMain implements Listener
if (!event.getReason().equals("Banned by admin.")) return; if (!event.getReason().equals("Banned by admin.")) return;
// ... and we remove player data when banned ... // ... and we remove player data when banned ...
if (!ConfServer.removePlayerDataWhenBanned) return; if (!MConf.get().removePlayerDataWhenBanned) return;
// ... get rid of their stored info. // ... get rid of their stored info.
if (uplayer.getRole() == Rel.LEADER) if (uplayer.getRole() == Rel.LEADER)
{ {
uplayer.getFaction().promoteNewLeader(); uplayer.getFaction().promoteNewLeader();
} }
uplayer.leave(false); uplayer.leave();
uplayer.detach(); uplayer.detach();
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -1,10 +1,9 @@
package com.massivecraft.factions.task; package com.massivecraft.factions.task;
import com.massivecraft.factions.ConfServer;
import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.mcore.ModuloRepeatTask; import com.massivecraft.mcore.ModuloRepeatTask;
import com.massivecraft.mcore.util.TimeUnit;
public class EconRewardTask extends ModuloRepeatTask public class EconRewardTask extends ModuloRepeatTask
{ {
@ -22,13 +21,13 @@ public class EconRewardTask extends ModuloRepeatTask
@Override @Override
public long getDelayMillis() public long getDelayMillis()
{ {
return (long) (ConfServer.econLandRewardTaskRunsEveryXMinutes * TimeUnit.MILLIS_PER_MINUTE); return MConf.get().taskEconMillis;
} }
@Override @Override
public void setDelayMillis(long delayMillis) public void setDelayMillis(long delayMillis)
{ {
throw new RuntimeException("operation not supported"); MConf.get().taskEconMillis = delayMillis;
} }
@Override @Override

View File

@ -26,13 +26,13 @@ public class PowerUpdateTask extends ModuloRepeatTask
@Override @Override
public long getDelayMillis() public long getDelayMillis()
{ {
return MConf.get().powerTaskMillis; return MConf.get().taskPowerMillis;
} }
@Override @Override
public void setDelayMillis(long delayMillis) public void setDelayMillis(long delayMillis)
{ {
MConf.get().powerTaskMillis = delayMillis; MConf.get().taskPowerMillis = delayMillis;
} }
@Override @Override

View File

@ -1,19 +1,18 @@
package com.massivecraft.factions.task; package com.massivecraft.factions.task;
import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UPlayerColl; import com.massivecraft.factions.entity.UPlayerColl;
import com.massivecraft.factions.entity.UPlayerColls; import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.mcore.ModuloRepeatTask; import com.massivecraft.mcore.ModuloRepeatTask;
import com.massivecraft.mcore.util.TimeUnit;
public class AutoLeaveTask extends ModuloRepeatTask public class RemovePlayerDataTask extends ModuloRepeatTask
{ {
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
private static AutoLeaveTask i = new AutoLeaveTask(); private static RemovePlayerDataTask i = new RemovePlayerDataTask();
public static AutoLeaveTask get() { return i; } public static RemovePlayerDataTask get() { return i; }
// -------------------------------------------- // // -------------------------------------------- //
// OVERRIDE: MODULO REPEAT TASK // OVERRIDE: MODULO REPEAT TASK
@ -22,13 +21,13 @@ public class AutoLeaveTask extends ModuloRepeatTask
@Override @Override
public long getDelayMillis() public long getDelayMillis()
{ {
return (long) (ConfServer.autoLeaveRoutineRunsEveryXMinutes * TimeUnit.MILLIS_PER_MINUTE); return MConf.get().taskAutoLeaveMillis;
} }
@Override @Override
public void setDelayMillis(long delayMillis) public void setDelayMillis(long delayMillis)
{ {
throw new RuntimeException("operation not supported"); MConf.get().taskAutoLeaveMillis = delayMillis;
} }
@Override @Override
@ -36,7 +35,7 @@ public class AutoLeaveTask extends ModuloRepeatTask
{ {
for (UPlayerColl coll : UPlayerColls.get().getColls()) for (UPlayerColl coll : UPlayerColls.get().getColls())
{ {
coll.autoLeaveOnInactivityRoutine(); coll.removePlayerDataAfterInactiveDaysRoutine();
} }
} }