Moved the last stuff away from ConfServer.
This commit is contained in:
parent
d9a23241ec
commit
825d937c84
@ -16,86 +16,10 @@ public class ConfServer extends SimpleConfig
|
||||
public ConfServer() { super(Factions.get()); }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CORE
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static List<String> baseCommandAliases = MUtil.list("f");
|
||||
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.
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ import com.massivecraft.factions.listeners.FactionsListenerMain;
|
||||
import com.massivecraft.factions.listeners.TodoFactionsPlayerListener;
|
||||
import com.massivecraft.factions.mixin.PowerMixin;
|
||||
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.PowerUpdateTask;
|
||||
|
||||
@ -137,7 +137,7 @@ public class Factions extends MPlugin
|
||||
|
||||
// Schedule recurring non-tps-dependent tasks
|
||||
PowerUpdateTask.get().schedule(this);
|
||||
AutoLeaveTask.get().schedule(this);
|
||||
RemovePlayerDataTask.get().schedule(this);
|
||||
EconRewardTask.get().schedule(this);
|
||||
|
||||
// Register built in chat modifiers
|
||||
@ -160,11 +160,7 @@ public class Factions extends MPlugin
|
||||
this.integrate(HerochatFeatures.get());
|
||||
|
||||
LWCFeatures.setup();
|
||||
|
||||
if (ConfServer.worldGuardChecking)
|
||||
{
|
||||
Worldguard.init(this);
|
||||
}
|
||||
Worldguard.init(this);
|
||||
|
||||
postEnable();
|
||||
}
|
||||
|
@ -157,17 +157,4 @@ public enum Rel
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.UConf;
|
||||
import com.massivecraft.factions.task.SpiralTask;
|
||||
import com.massivecraft.mcore.cmd.arg.ARInteger;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
@ -59,7 +59,7 @@ public class CmdFactionsClaim extends FCommand
|
||||
new SpiralTask(PS.valueOf(me), radius)
|
||||
{
|
||||
private int failCount = 0;
|
||||
private final int limit = ConfServer.radiusClaimFailureLimit - 1;
|
||||
private final int limit = UConf.get(me).radiusClaimFailureLimit - 1;
|
||||
|
||||
@Override
|
||||
public boolean work()
|
||||
|
@ -18,7 +18,7 @@ public class CmdFactionsLeave extends FCommand {
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
fme.leave(true);
|
||||
fme.leave();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.UConf;
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
@ -65,7 +65,8 @@ public class CmdFactionsShow extends FCommand
|
||||
if (Econ.isEnabled(faction))
|
||||
{
|
||||
double value = Econ.calculateTotalLandValue(faction.getLandCount());
|
||||
double refund = value * ConfServer.econClaimRefundMultiplier;
|
||||
|
||||
double refund = value * UConf.get(faction).econClaimRefundMultiplier;
|
||||
if (value > 0)
|
||||
{
|
||||
String stringValue = Money.format(faction, value);
|
||||
@ -73,8 +74,8 @@ public class CmdFactionsShow extends FCommand
|
||||
msg("<a>Total land value: <i>" + stringValue + stringRefund);
|
||||
}
|
||||
|
||||
//Show bank contents
|
||||
if(ConfServer.bankEnabled)
|
||||
// Show bank contents
|
||||
if(UConf.get(faction).bankEnabled)
|
||||
{
|
||||
msg("<a>Bank contains: <i>"+Money.format(faction, Money.get(faction)));
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.entity.BoardColls;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.UConf;
|
||||
import com.massivecraft.factions.event.FactionsEventLandUnclaim;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
@ -43,7 +43,7 @@ public class CmdFactionsUnclaim extends FCommand
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||
import com.massivecraft.factions.entity.BoardColls;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.UConf;
|
||||
import com.massivecraft.factions.event.FactionsEventLandUnclaimAll;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
@ -28,7 +28,8 @@ public class CmdFactionsUnclaimall extends FCommand
|
||||
if (Econ.isEnabled(myFaction))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd.req;
|
||||
|
||||
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.req.ReqAbstract;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
@ -25,17 +25,16 @@ public class ReqBankCommandsEnabled extends ReqAbstract
|
||||
@Override
|
||||
public boolean apply(CommandSender sender, MCommand command)
|
||||
{
|
||||
return ConfServer.econEnabled && ConfServer.bankEnabled;
|
||||
return UConf.get(sender).econEnabled && UConf.get(sender).bankEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 economy features are disabled on this server.");
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class Board extends Entity<Board> implements BoardInterface
|
||||
{
|
||||
// TODO: Listen to an event instead!
|
||||
// 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);
|
||||
}
|
||||
|
@ -120,6 +120,34 @@ public class FactionColl extends Coll<Faction>
|
||||
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
|
||||
// -------------------------------------------- //
|
||||
@ -182,28 +210,6 @@ public class FactionColl extends Coll<Faction>
|
||||
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
|
||||
// -------------------------------------------- //
|
||||
|
@ -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
|
||||
|
@ -73,6 +73,19 @@ public class UConf extends Entity<UConf>
|
||||
|
||||
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
|
||||
// -------------------------------------------- //
|
||||
@ -101,11 +114,60 @@ public class UConf extends Entity<UConf>
|
||||
Rel.MEMBER, new ArrayList<String>()
|
||||
);
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INTEGRATION: WORLD GUARD
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean worldGuardChecking = false;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INTEGRATION: LWC
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean onUnclaimResetLwcLocks = false;
|
||||
public boolean onCaptureResetLwcLocks = false;
|
||||
public boolean lwcRemoveOnUnclaim = 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.
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import java.util.Set;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Const;
|
||||
import com.massivecraft.factions.EconomyParticipator;
|
||||
import com.massivecraft.factions.FFlag;
|
||||
@ -487,7 +486,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
// ACTIONS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void leave(boolean makePay)
|
||||
public void leave()
|
||||
{
|
||||
Faction myFaction = this.getFaction();
|
||||
|
||||
@ -559,7 +558,9 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
Faction currentFaction = BoardColls.get().getFactionAt(ps);
|
||||
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
|
||||
error = Txt.parse("<b>This land is protected");
|
||||
@ -580,19 +581,19 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
{
|
||||
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())
|
||||
{
|
||||
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!");
|
||||
}
|
||||
else if ( ! ConfServer.claimingFromOthersAllowed && currentFaction.isNormal())
|
||||
else if ( ! uconf.claimingFromOthersAllowed && currentFaction.isNormal())
|
||||
{
|
||||
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
|
||||
(
|
||||
ConfServer.claimsMustBeConnected
|
||||
uconf.claimsMustBeConnected
|
||||
&& ! this.isUsingAdminMode()
|
||||
&& myFaction.getLandCountInWorld(ps.getWorld()) > 0
|
||||
&& !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!");
|
||||
else
|
||||
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!
|
||||
// Calculate the cost to claim the area
|
||||
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;
|
||||
|
||||
// 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());
|
||||
}
|
||||
|
@ -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();
|
||||
double toleranceMillis = ConfServer.autoLeaveAfterDaysOfInactivity * TimeUnit.MILLIS_PER_DAY;
|
||||
double toleranceMillis = MConf.get().removePlayerDataAfterInactiveDays * TimeUnit.MILLIS_PER_DAY;
|
||||
|
||||
for (UPlayer uplayer : this.getAll())
|
||||
{
|
||||
@ -99,7 +99,7 @@ public class UPlayerColl extends SenderColl<UPlayer>
|
||||
}
|
||||
}
|
||||
|
||||
uplayer.leave(false);
|
||||
uplayer.resetFactionData();
|
||||
uplayer.detach();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.EconomyParticipator;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.entity.UConf;
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
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?
|
||||
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 (fsender.isUsingAdminMode()) return true;
|
||||
UConf uconf = UConf.get(fsender);
|
||||
Faction fsenderFaction = fsender.getFaction();
|
||||
|
||||
if (ConfServer.bankEnabled && ConfServer.bankFactionPaysCosts && fsenderFaction.isNormal())
|
||||
if (uconf.bankEnabled && uconf.bankFactionPaysCosts && fsenderFaction.isNormal())
|
||||
{
|
||||
return modifyMoney(fsenderFaction, -cost, actionDescription);
|
||||
}
|
||||
@ -55,13 +57,14 @@ public class Econ
|
||||
public static void modifyUniverseMoney(Object universe, double delta)
|
||||
{
|
||||
if (!isEnabled(universe)) return;
|
||||
UConf uconf = UConf.get(universe);
|
||||
|
||||
if (ConfServer.econUniverseAccount == null) return;
|
||||
if (ConfServer.econUniverseAccount.length() == 0) return;
|
||||
if (uconf.econUniverseAccount == null) 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)
|
||||
@ -282,6 +285,11 @@ public class Econ
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// LAND VALUE
|
||||
// -------------------------------------------- //
|
||||
// TODO: Clean up!
|
||||
|
||||
// calculate the cost for claiming land
|
||||
public static double calculateClaimCost(int ownedLand, boolean takingFromAnotherFaction)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.integration;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.entity.UConf;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -62,11 +63,9 @@ public class Worldguard
|
||||
// False: PVP is disallowed
|
||||
public static boolean isPVP(Player player)
|
||||
{
|
||||
if ( ! enabled)
|
||||
{
|
||||
// No WG hooks so we'll always bypass this check.
|
||||
return true;
|
||||
}
|
||||
// No WG hooks so we'll always bypass this check.
|
||||
if (!enabled) return true;
|
||||
if (!UConf.get(player).worldGuardChecking) return true;
|
||||
|
||||
Location loc = player.getLocation();
|
||||
World world = loc.getWorld();
|
||||
@ -85,6 +84,7 @@ public class Worldguard
|
||||
{
|
||||
// No WG hooks so we'll always bypass this check.
|
||||
if (!enabled) return false;
|
||||
if (!UConf.get(psChunk).worldGuardChecking) return true;
|
||||
|
||||
World world = null;
|
||||
Chunk chunk = null;
|
||||
|
@ -5,8 +5,8 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.entity.UConf;
|
||||
import com.massivecraft.factions.event.FactionsEventAbstractSender;
|
||||
import com.massivecraft.factions.event.FactionsEventCreate;
|
||||
import com.massivecraft.factions.event.FactionsEventDescriptionChange;
|
||||
@ -60,56 +60,60 @@ public class FactionsListenerEcon implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
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)
|
||||
@ -120,17 +124,17 @@ public class FactionsListenerEcon implements Listener
|
||||
|
||||
if (event.getReason() == MembershipChangeReason.JOIN)
|
||||
{
|
||||
cost = ConfServer.econCostJoin;
|
||||
cost = UConf.get(event.getSender()).econCostJoin;
|
||||
command = Factions.get().getOuterCmdFactions().cmdFactionsJoin;
|
||||
}
|
||||
else if (event.getReason() == MembershipChangeReason.LEAVE)
|
||||
{
|
||||
cost = ConfServer.econCostLeave;
|
||||
cost = UConf.get(event.getSender()).econCostLeave;
|
||||
command = Factions.get().getOuterCmdFactions().cmdFactionsLeave;
|
||||
}
|
||||
else if (event.getReason() == MembershipChangeReason.KICK)
|
||||
{
|
||||
cost = ConfServer.econCostKick;
|
||||
cost = UConf.get(event.getSender()).econCostKick;
|
||||
command = Factions.get().getOuterCmdFactions().cmdFactionsKick;
|
||||
}
|
||||
else
|
||||
|
@ -44,7 +44,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.Const;
|
||||
import com.massivecraft.factions.FFlag;
|
||||
import com.massivecraft.factions.FPerm;
|
||||
@ -301,16 +300,15 @@ public class FactionsListenerMain implements Listener
|
||||
if (!event.getReason().equals("Banned by admin.")) return;
|
||||
|
||||
// ... and we remove player data when banned ...
|
||||
if (!ConfServer.removePlayerDataWhenBanned) return;
|
||||
if (!MConf.get().removePlayerDataWhenBanned) return;
|
||||
|
||||
// ... get rid of their stored info.
|
||||
if (uplayer.getRole() == Rel.LEADER)
|
||||
{
|
||||
uplayer.getFaction().promoteNewLeader();
|
||||
}
|
||||
uplayer.leave(false);
|
||||
uplayer.leave();
|
||||
uplayer.detach();
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.massivecraft.factions.task;
|
||||
|
||||
import com.massivecraft.factions.ConfServer;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.factions.entity.FactionColls;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.mcore.ModuloRepeatTask;
|
||||
import com.massivecraft.mcore.util.TimeUnit;
|
||||
|
||||
public class EconRewardTask extends ModuloRepeatTask
|
||||
{
|
||||
@ -22,13 +21,13 @@ public class EconRewardTask extends ModuloRepeatTask
|
||||
@Override
|
||||
public long getDelayMillis()
|
||||
{
|
||||
return (long) (ConfServer.econLandRewardTaskRunsEveryXMinutes * TimeUnit.MILLIS_PER_MINUTE);
|
||||
return MConf.get().taskEconMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDelayMillis(long delayMillis)
|
||||
{
|
||||
throw new RuntimeException("operation not supported");
|
||||
MConf.get().taskEconMillis = delayMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,13 +26,13 @@ public class PowerUpdateTask extends ModuloRepeatTask
|
||||
@Override
|
||||
public long getDelayMillis()
|
||||
{
|
||||
return MConf.get().powerTaskMillis;
|
||||
return MConf.get().taskPowerMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDelayMillis(long delayMillis)
|
||||
{
|
||||
MConf.get().powerTaskMillis = delayMillis;
|
||||
MConf.get().taskPowerMillis = delayMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,19 +1,18 @@
|
||||
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.UPlayerColls;
|
||||
import com.massivecraft.mcore.ModuloRepeatTask;
|
||||
import com.massivecraft.mcore.util.TimeUnit;
|
||||
|
||||
public class AutoLeaveTask extends ModuloRepeatTask
|
||||
public class RemovePlayerDataTask extends ModuloRepeatTask
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static AutoLeaveTask i = new AutoLeaveTask();
|
||||
public static AutoLeaveTask get() { return i; }
|
||||
private static RemovePlayerDataTask i = new RemovePlayerDataTask();
|
||||
public static RemovePlayerDataTask get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: MODULO REPEAT TASK
|
||||
@ -22,13 +21,13 @@ public class AutoLeaveTask extends ModuloRepeatTask
|
||||
@Override
|
||||
public long getDelayMillis()
|
||||
{
|
||||
return (long) (ConfServer.autoLeaveRoutineRunsEveryXMinutes * TimeUnit.MILLIS_PER_MINUTE);
|
||||
return MConf.get().taskAutoLeaveMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDelayMillis(long delayMillis)
|
||||
{
|
||||
throw new RuntimeException("operation not supported");
|
||||
MConf.get().taskAutoLeaveMillis = delayMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -36,7 +35,7 @@ public class AutoLeaveTask extends ModuloRepeatTask
|
||||
{
|
||||
for (UPlayerColl coll : UPlayerColls.get().getColls())
|
||||
{
|
||||
coll.autoLeaveOnInactivityRoutine();
|
||||
coll.removePlayerDataAfterInactiveDaysRoutine();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user