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

@ -167,8 +167,6 @@ public class ConfServer extends SimpleConfig
public static boolean disablePVPForFactionlessPlayers = false; public static boolean disablePVPForFactionlessPlayers = false;
public static boolean enablePVPAgainstFactionlessInAttackersLand = false; public static boolean enablePVPAgainstFactionlessInAttackersLand = false;
public static int noPVPDamageToOthersForXSecondsAfterLogin = 3;
//public static boolean peacefulMembersDisablePowerLoss = true; //public static boolean peacefulMembersDisablePowerLoss = true;

View File

@ -20,7 +20,6 @@ import com.massivecraft.factions.util.RelationUtil;
import com.massivecraft.mcore.mixin.Mixin; import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.ps.PS;
import com.massivecraft.mcore.store.SenderEntity; import com.massivecraft.mcore.store.SenderEntity;
import com.massivecraft.mcore.util.TimeDiffUtil;
import com.massivecraft.mcore.util.TimeUnit; import com.massivecraft.mcore.util.TimeUnit;
import com.massivecraft.mcore.util.Txt; 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; } public void setUsingAdminMode(boolean val) { this.usingAdminMode = val; }
// FIELD: loginPvpDisabled // FIELD: loginPvpDisabled
private transient boolean loginPvpDisabled; //private transient boolean loginPvpDisabled;
// FIELD: account // FIELD: account
public String getAccountId() { return this.getId(); } public String getAccountId() { return this.getId(); }
@ -147,7 +146,6 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
this.resetFactionData(false); this.resetFactionData(false);
this.power = ConfServer.powerStarting; this.power = ConfServer.powerStarting;
this.lastPowerUpdateTime = System.currentTimeMillis(); this.lastPowerUpdateTime = System.currentTimeMillis();
this.loginPvpDisabled = (ConfServer.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false;
if ( ! ConfServer.newPlayerStartingFactionID.equals(Const.FACTIONID_NONE) && FactionColl.get().containsId(ConfServer.newPlayerStartingFactionID)) 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()); 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 // 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;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.store.MStore; import com.massivecraft.mcore.store.MStore;
import com.massivecraft.mcore.store.SenderColl; import com.massivecraft.mcore.store.SenderColl;
import com.massivecraft.mcore.util.DiscUtil; import com.massivecraft.mcore.util.DiscUtil;
import com.massivecraft.mcore.util.TimeUnit;
import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; import com.massivecraft.mcore.xlib.gson.reflect.TypeToken;
public class FPlayerColl extends SenderColl<FPlayer> public class FPlayerColl extends SenderColl<FPlayer>
@ -110,17 +112,17 @@ public class FPlayerColl extends SenderColl<FPlayer>
public void autoLeaveOnInactivityRoutine() public void autoLeaveOnInactivityRoutine()
{ {
if (ConfServer.autoLeaveAfterDaysOfInactivity <= 0.0) if (ConfServer.autoLeaveAfterDaysOfInactivity <= 0.0) return;
{
return;
}
long now = System.currentTimeMillis(); 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()) 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) if (ConfServer.logFactionLeave || ConfServer.logFactionKick)
Factions.get().log("Player "+fplayer.getName()+" was auto-removed due to inactivity."); 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 (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)); 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? // 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); block.setTypeId(0);
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void enderPearlTeleport(PlayerTeleportEvent event) public void enderPearlTeleport(PlayerTeleportEvent event)
{ {

View File

@ -58,9 +58,6 @@ public class FactionsPlayerListener implements Listener
{ {
fplayer.sendFactionHereMessage(); fplayer.sendFactionHereMessage();
} }
// Update the lastLoginTime for this fplayer
fplayer.setLastLoginTime(System.currentTimeMillis());
} }
@EventHandler(priority = EventPriority.NORMAL) @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. // 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! // TODO: When I setup universes I must do this for all universe instance of the player that logs off!
fplayer.recalculatePower(true); 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); SpoutFeatures.playerDisconnect(fplayer);
} }