Adds DTR freeze functionality from #229.

This commit is contained in:
drtshock 2015-01-28 10:13:23 -06:00
parent 8fdcb51183
commit 1636708cef
4 changed files with 30 additions and 1 deletions

View File

@ -111,6 +111,10 @@ public interface Faction extends EconomyParticipator {
public boolean isPlayerFreeType(); public boolean isPlayerFreeType();
public boolean isPowerFrozen();
public void setLastDeath(long time);
// ------------------------------- // -------------------------------
// Relation and relation colors // Relation and relation colors
// ------------------------------- // -------------------------------

View File

@ -486,6 +486,8 @@ public abstract class MemoryFPlayer implements FPlayer {
if (!Conf.powerRegenOffline) { if (!Conf.powerRegenOffline) {
return; return;
} }
} else if (hasFaction() && getFaction().isPowerFrozen()) {
return; // Don't let power regen if faction power is frozen.
} }
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
long millisPassed = now - this.lastPowerUpdateTime; long millisPassed = now - this.lastPowerUpdateTime;
@ -517,6 +519,9 @@ public abstract class MemoryFPlayer implements FPlayer {
public void onDeath() { public void onDeath() {
this.updatePower(); this.updatePower();
this.alterPower(-Conf.powerPerDeath); this.alterPower(-Conf.powerPerDeath);
if (hasFaction()) {
getFaction().setLastDeath(System.currentTimeMillis());
}
} }
//----------------------------------------------// //----------------------------------------------//

View File

@ -40,6 +40,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
protected Set<String> invites = new HashSet<String>(); protected Set<String> invites = new HashSet<String>();
protected HashMap<String, List<String>> announcements = new HashMap<String, List<String>>(); protected HashMap<String, List<String>> announcements = new HashMap<String, List<String>>();
protected ConcurrentHashMap<String, LazyLocation> warps = new ConcurrentHashMap<String, LazyLocation>(); protected ConcurrentHashMap<String, LazyLocation> warps = new ConcurrentHashMap<String, LazyLocation>();
protected long lastDeath;
public HashMap<String, List<String>> getAnnouncements() { public HashMap<String, List<String>> getAnnouncements() {
return this.announcements; return this.announcements;
@ -247,6 +248,19 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
this.powerBoost = powerBoost; this.powerBoost = powerBoost;
} }
public boolean isPowerFrozen() {
int freezeSeconds = P.p.getConfig().getInt("hcf.powerfreeze", 0);
if (freezeSeconds == 0) {
return false;
}
return System.currentTimeMillis() - lastDeath < freezeSeconds * 1000;
}
public void setLastDeath(long time) {
this.lastDeath = time;
}
// -------------------------------------------- // // -------------------------------------------- //
// Construct // Construct
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -183,3 +183,9 @@ hcf:
# Should we allow Factions to over claim if they are raidable (above has no effect on this)? # Should we allow Factions to over claim if they are raidable (above has no effect on this)?
# This has always been true, allowing factions to over claim others. # This has always been true, allowing factions to over claim others.
overclaim: true overclaim: true
# Power Freeze
# After a player dies, how long should the faction not be able to regen power?
# This resets on each death but does not accumulate.
# Set to 0 for no freeze. Time is in seconds.
powerfreeze: 0