Removing the feature where there is no PVP for a few seconds after login. We do not handle teleportation which could also be a form of suprise-attack. For this reason more complex logic should be implemented in a sepparate plugin. Not in Factions.

This commit is contained in:
Olof Larsson 2013-04-18 12:25:05 +02:00
parent 8c00268015
commit 9a8f2071e0
6 changed files with 10 additions and 54 deletions

View File

@ -168,8 +168,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;
public static boolean permanentFactionsDisableLeaderPromotion = false;

View File

@ -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<FPlayer> 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<FPlayer> 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<FPlayer> 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
// -------------------------------------------- //

View File

@ -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<FPlayer>
@ -110,17 +112,17 @@ public class FPlayerColl extends SenderColl<FPlayer>
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.");

View File

@ -253,12 +253,6 @@ public class FactionsEntityListener implements Listener
if (ConfServer.playersWhoBypassAllProtection.contains(attacker.getName())) return true;
if (attacker.hasLoginPvpDisabled())
{
if (notify) attacker.msg("<i>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?

View File

@ -27,7 +27,6 @@ public class FactionsExploitListener implements Listener
block.setTypeId(0);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void enderPearlTeleport(PlayerTeleportEvent event)
{

View File

@ -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)
@ -74,9 +71,6 @@ public class FactionsPlayerListener implements Listener
// 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);
}