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:
2024-03-04 18:24:22 +01:00
parent 7d8d27b1ef
commit 47ade3e0c0
4 changed files with 165 additions and 63 deletions
@@ -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;
}