Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MemberLimitBoost and ClaimLimitBoost to Faction #1442

Open
wants to merge 1 commit into
base: 1.6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/com/massivecraft/factions/Faction.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ default boolean isNone() {

void setPowerBoost(double powerBoost);

int getMemberLimitBoost();

void setMemberLimitBoost(int memberLimitBoost);

int getClaimLimitBoost();

void setClaimLimitBoost(int claimLimitBoost);

boolean hasLandInflation();

boolean isPowerFrozen();
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/massivecraft/factions/cmd/CmdJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ public void perform(CommandContext context) {
return;
}

if (FactionsPlugin.getInstance().conf().factions().other().getFactionMemberLimit() > 0 && faction.getFPlayers().size() >= FactionsPlugin.getInstance().conf().factions().other().getFactionMemberLimit()) {
context.msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(context.fPlayer), FactionsPlugin.getInstance().conf().factions().other().getFactionMemberLimit(), fplayer.describeTo(context.fPlayer, false));
int memberLimit = FactionsPlugin.getInstance().conf().factions().other().getFactionMemberLimit() + faction.getMemberLimitBoost();
if (memberLimit > 0 && faction.getFPlayers().size() >= memberLimit) {
context.msg(TL.COMMAND_JOIN_ATLIMIT, faction.getTag(context.fPlayer), memberLimit, fplayer.describeTo(context.fPlayer, false));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ public boolean canClaimForFactionAtLocation(Faction forFaction, FLocation flocat
} else if (plugin.getLandRaidControl() instanceof DTRControl && ownedLand >= plugin.getLandRaidControl().getLandLimit(forFaction)) {
// Already own at least as much land as land limit (DTR)
denyReason = plugin.txt().parse(TL.CLAIM_DTR_LAND.toString());
} else if (plugin.conf().factions().claims().getLandsMax() != 0 && ownedLand >= plugin.conf().factions().claims().getLandsMax() && forFaction.isNormal()) {
} else if (plugin.conf().factions().claims().getLandsMax() + forFaction.getClaimLimitBoost() != 0 && ownedLand >= plugin.conf().factions().claims().getLandsMax() + forFaction.getClaimLimitBoost() && forFaction.isNormal()) {
// Land limit reached
denyReason = plugin.txt().parse(TL.CLAIM_LIMIT.toString());
} else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) {
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/massivecraft/factions/data/MemoryFaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
protected long foundedDate;
protected transient long lastPlayerLoggedOffTime;
protected double powerBoost;
protected int memberLimitBoost;
protected int claimLimitBoost;
protected Map<String, Relation> relationWish = new HashMap<>();
protected Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<>();
protected transient Set<FPlayer> fplayers = new HashSet<>();
Expand Down Expand Up @@ -471,6 +473,8 @@ public MemoryFaction(MemoryFaction old) {
home = old.home;
lastPlayerLoggedOffTime = old.lastPlayerLoggedOffTime;
powerBoost = old.powerBoost;
memberLimitBoost = old.memberLimitBoost;
claimLimitBoost = old.claimLimitBoost;
relationWish = old.relationWish;
claimOwnership = old.claimOwnership;
fplayers = new HashSet<>();
Expand Down Expand Up @@ -683,6 +687,22 @@ public void setPowerBoost(double powerBoost) {
this.powerBoost = powerBoost;
}

public int getMemberLimitBoost() {
return this.memberLimitBoost;
}

public void setMemberLimitBoost(int memberLimitBoost) {
this.memberLimitBoost = memberLimitBoost;
}

public int getClaimLimitBoost() {
return this.claimLimitBoost;
}

public void setClaimLimitBoost(int claimLimitBoost) {
this.claimLimitBoost = claimLimitBoost;
}

public boolean isPowerFrozen() {
int freezeSeconds = FactionsPlugin.getInstance().conf().factions().landRaidControl().power().getPowerFreeze();
return freezeSeconds != 0 && System.currentTimeMillis() - lastDeath < freezeSeconds * 1000L;
Expand Down