Moved the last stuff away from ConfServer.
This commit is contained in:
@ -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
|
||||
// -------------------------------------------- //
|
||||
@ -181,28 +209,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
|
||||
// -------------------------------------------- //
|
||||
@ -100,12 +113,61 @@ public class UConf extends Entity<UConf>
|
||||
Rel.ALLY, new ArrayList<String>(),
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user