mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-30 14:13:52 +01:00
Added conf.json option "noPVPDamageToOthersForXSecondsAfterLogin" (defaults to 3 seconds) which keeps players from being able to do PvP damage for a few seconds after logging in (to counteract the exploitable 3-second PvP protection given to players when they log in); Fix for "claimsMustBeConnected" bug which prevented factions from making their initial first claim
This commit is contained in:
parent
6035b204dc
commit
094486676a
@ -67,6 +67,7 @@ public class Conf {
|
|||||||
public static double homesTeleportAllowedEnemyDistance = 32;
|
public static double homesTeleportAllowedEnemyDistance = 32;
|
||||||
|
|
||||||
public static boolean disablePVPForFactionlessPlayers = false;
|
public static boolean disablePVPForFactionlessPlayers = false;
|
||||||
|
public static int noPVPDamageToOthersForXSecondsAfterLogin = 3;
|
||||||
|
|
||||||
public static boolean claimsMustBeConnected = false;
|
public static boolean claimsMustBeConnected = false;
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ public class FPlayer {
|
|||||||
private transient boolean autoClaimEnabled;
|
private transient boolean autoClaimEnabled;
|
||||||
private transient boolean autoSafeZoneEnabled;
|
private transient boolean autoSafeZoneEnabled;
|
||||||
private transient boolean autoWarZoneEnabled;
|
private transient boolean autoWarZoneEnabled;
|
||||||
|
private transient boolean loginPvpDisabled;
|
||||||
private boolean factionChatting;
|
private boolean factionChatting;
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -63,6 +64,7 @@ public class FPlayer {
|
|||||||
this.autoClaimEnabled = false;
|
this.autoClaimEnabled = false;
|
||||||
this.autoSafeZoneEnabled = false;
|
this.autoSafeZoneEnabled = false;
|
||||||
this.autoWarZoneEnabled = false;
|
this.autoWarZoneEnabled = false;
|
||||||
|
this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetFactionData() {
|
public void resetFactionData() {
|
||||||
@ -177,6 +179,9 @@ public class FPlayer {
|
|||||||
public void setLastLoginTime(long lastLoginTime) {
|
public void setLastLoginTime(long lastLoginTime) {
|
||||||
this.lastLoginTime = lastLoginTime;
|
this.lastLoginTime = lastLoginTime;
|
||||||
this.lastPowerUpdateTime = lastLoginTime;
|
this.lastPowerUpdateTime = lastLoginTime;
|
||||||
|
if (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) {
|
||||||
|
this.loginPvpDisabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMapAutoUpdating() {
|
public boolean isMapAutoUpdating() {
|
||||||
@ -187,6 +192,17 @@ public class FPlayer {
|
|||||||
this.mapAutoUpdating = mapAutoUpdating;
|
this.mapAutoUpdating = mapAutoUpdating;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasLoginPvpDisabled() {
|
||||||
|
if (!loginPvpDisabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.lastLoginTime + (Conf.noPVPDamageToOthersForXSecondsAfterLogin * 1000) < System.currentTimeMillis()) {
|
||||||
|
this.loginPvpDisabled = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public FLocation getLastStoodAt() {
|
public FLocation getLastStoodAt() {
|
||||||
return this.lastStoodAt;
|
return this.lastStoodAt;
|
||||||
}
|
}
|
||||||
@ -490,7 +506,7 @@ public class FPlayer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Conf.claimsMustBeConnected && !Board.isConnectedLocation(flocation, myFaction)) {
|
if (Conf.claimsMustBeConnected && myFaction.getLandRounded() > 0 && !Board.isConnectedLocation(flocation, myFaction)) {
|
||||||
sendMessage("You can only claim additional land which is connected to your first claim!");
|
sendMessage("You can only claim additional land which is connected to your first claim!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,11 @@ public class FactionsEntityListener extends EntityListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attacker.hasLoginPvpDisabled()) {
|
||||||
|
attacker.sendMessage("You can't hurt other players for " + Conf.noPVPDamageToOthersForXSecondsAfterLogin + " seconds after logging in.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Faction locFaction = Board.getFactionAt(new FLocation(attacker));
|
Faction locFaction = Board.getFactionAt(new FLocation(attacker));
|
||||||
|
|
||||||
// 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?
|
||||||
|
Loading…
Reference in New Issue
Block a user