diff --git a/src/com/massivecraft/factions/ConfServer.java b/src/com/massivecraft/factions/ConfServer.java index 32c9e483..13e4e664 100644 --- a/src/com/massivecraft/factions/ConfServer.java +++ b/src/com/massivecraft/factions/ConfServer.java @@ -167,8 +167,6 @@ public class ConfServer extends SimpleConfig public static boolean disablePVPForFactionlessPlayers = false; public static boolean enablePVPAgainstFactionlessInAttackersLand = false; - - public static int noPVPDamageToOthersForXSecondsAfterLogin = 3; //public static boolean peacefulMembersDisablePowerLoss = true; diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 647bee63..04387c54 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -20,7 +20,6 @@ import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.mcore.mixin.Mixin; import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.store.SenderEntity; -import com.massivecraft.mcore.util.TimeDiffUtil; import com.massivecraft.mcore.util.TimeUnit; import com.massivecraft.mcore.util.Txt; @@ -132,7 +131,7 @@ public class FPlayer extends SenderEntity implements EconomyParticipato public void setUsingAdminMode(boolean val) { this.usingAdminMode = val; } // FIELD: loginPvpDisabled - private transient boolean loginPvpDisabled; + //private transient boolean loginPvpDisabled; // FIELD: account public String getAccountId() { return this.getId(); } @@ -147,7 +146,6 @@ public class FPlayer extends SenderEntity implements EconomyParticipato this.resetFactionData(false); this.power = ConfServer.powerStarting; this.lastPowerUpdateTime = System.currentTimeMillis(); - this.loginPvpDisabled = (ConfServer.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false; if ( ! ConfServer.newPlayerStartingFactionID.equals(Const.FACTIONID_NONE) && FactionColl.get().containsId(ConfServer.newPlayerStartingFactionID)) { @@ -492,35 +490,6 @@ public class FPlayer extends SenderEntity implements EconomyParticipato return (int) Math.round(this.getPowerMin()); } - // -------------------------------------------- // - // FIELD: loginPvpDisabled - // -------------------------------------------- // - // TODO - - @Deprecated - public void setLastLoginTime(long lastLoginTime) - { - this.lastPowerUpdateTime = lastLoginTime; - if (ConfServer.noPVPDamageToOthersForXSecondsAfterLogin > 0) - { - this.loginPvpDisabled = true; - } - } - - public boolean hasLoginPvpDisabled() - { - if (!loginPvpDisabled) - { - return false; - } - if (this.lastLoginTime + (ConfServer.noPVPDamageToOthersForXSecondsAfterLogin * 1000) < System.currentTimeMillis()) - { - this.loginPvpDisabled = false; - return false; - } - return true; - } - // -------------------------------------------- // // TITLE, NAME, FACTION TAG AND CHAT // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/FPlayerColl.java b/src/com/massivecraft/factions/FPlayerColl.java index af86c37a..db08a9cd 100644 --- a/src/com/massivecraft/factions/FPlayerColl.java +++ b/src/com/massivecraft/factions/FPlayerColl.java @@ -5,9 +5,11 @@ import java.lang.reflect.Type; import java.util.Map; import java.util.Map.Entry; +import com.massivecraft.mcore.mixin.Mixin; import com.massivecraft.mcore.store.MStore; import com.massivecraft.mcore.store.SenderColl; import com.massivecraft.mcore.util.DiscUtil; +import com.massivecraft.mcore.util.TimeUnit; import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; public class FPlayerColl extends SenderColl @@ -110,17 +112,17 @@ public class FPlayerColl extends SenderColl public void autoLeaveOnInactivityRoutine() { - if (ConfServer.autoLeaveAfterDaysOfInactivity <= 0.0) - { - return; - } - + if (ConfServer.autoLeaveAfterDaysOfInactivity <= 0.0) return; + long now = System.currentTimeMillis(); - double toleranceMillis = ConfServer.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000; + double toleranceMillis = ConfServer.autoLeaveAfterDaysOfInactivity * TimeUnit.MILLIS_PER_DAY; for (FPlayer fplayer : this.getAll()) { - if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis) + Long lastPlayed = Mixin.getLastPlayed(fplayer.getId()); + if (lastPlayed == null) continue; + + if (fplayer.isOffline() && now - lastPlayed > toleranceMillis) { if (ConfServer.logFactionLeave || ConfServer.logFactionKick) Factions.get().log("Player "+fplayer.getName()+" was auto-removed due to inactivity."); diff --git a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java index d1a84005..98a6934a 100644 --- a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -253,12 +253,6 @@ public class FactionsEntityListener implements Listener if (ConfServer.playersWhoBypassAllProtection.contains(attacker.getName())) return true; - if (attacker.hasLoginPvpDisabled()) - { - if (notify) attacker.msg("You can't hurt other players for " + ConfServer.noPVPDamageToOthersForXSecondsAfterLogin + " seconds after logging in."); - return false; - } - Faction locFaction = BoardColl.get().getFactionAt(PS.valueOf(damager)); // so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be? diff --git a/src/com/massivecraft/factions/listeners/FactionsExploitListener.java b/src/com/massivecraft/factions/listeners/FactionsExploitListener.java index 59ae13e8..f115557d 100644 --- a/src/com/massivecraft/factions/listeners/FactionsExploitListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsExploitListener.java @@ -27,7 +27,6 @@ public class FactionsExploitListener implements Listener block.setTypeId(0); } - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void enderPearlTeleport(PlayerTeleportEvent event) { diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 7d19c67c..cded6260 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -58,9 +58,6 @@ public class FactionsPlayerListener implements Listener { fplayer.sendFactionHereMessage(); } - - // Update the lastLoginTime for this fplayer - fplayer.setLastLoginTime(System.currentTimeMillis()); } @EventHandler(priority = EventPriority.NORMAL) @@ -73,9 +70,6 @@ public class FactionsPlayerListener implements Listener // This is required since we recalculate as if the player were offline when they log back in. // TODO: When I setup universes I must do this for all universe instance of the player that logs off! fplayer.recalculatePower(true); - - // and update their last login time to point to when the logged off, for auto-remove routine - fplayer.setLastLoginTime(System.currentTimeMillis()); SpoutFeatures.playerDisconnect(fplayer); }