mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-12 13:26:56 +00:00
Refactor PreventStabby plugin to enhance PvP and environment controls
Reconfiguration of the PreventStabby plugin involved removal of PlayerDamageListener and the introduction of two new listeners: EnvironmentalListener and PvpListener. This restructuring allows more efficient management of entity damage and environmental interactions. EnvironmentalListener specifically caters for dangerous situations such as bucket spills and block fires. PvpListener effectively manages PvP related activities including damages, splash potion effects, cloud area effects, and fishing events ensuring a more streamlined control and response for better PvP gameplay.
This commit is contained in:
@@ -53,7 +53,7 @@ public class PlayerData {
|
||||
}
|
||||
|
||||
protected boolean isCacheExpired() {
|
||||
return System.currentTimeMillis() - lastAccessTimestamp > PreventStabby.getPlugin().getConfigCache().cache_time * 1000;
|
||||
return System.currentTimeMillis() - lastAccessTimestamp > 60000;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,6 +85,7 @@ public class PlayerData {
|
||||
*/
|
||||
public void markInCombat() {
|
||||
refreshCacheTime();
|
||||
if (PreventStabby.getPlugin().getConfigCache().combat_time <= 0) return;
|
||||
this.combatStartTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ public class PlayerData {
|
||||
public long getSecondsLeftUntilCombatEnd() {
|
||||
if (combatStartTimestamp == null) return -1;
|
||||
long timeSinceCombatStart = System.currentTimeMillis() - combatStartTimestamp;
|
||||
long combatTimeConfigured = PreventStabby.getPlugin().getConfigCache().combat_time * 1000;
|
||||
long combatTimeConfigured = (long) (PreventStabby.getPlugin().getConfigCache().combat_time * 1000);
|
||||
return (timeSinceCombatStart < combatTimeConfigured) ? (combatTimeConfigured - timeSinceCombatStart) / 1000 : -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user