Refactor damage source checking and restructure player management

The source of damage detection for PvP interactions has been updated to improve accuracy and flexibility. A 'Target' sub-class has been implemented in the PlayerManager class, removing the need for a separate DamageCheck class. The PlayerManager class was also moved to the 'data' package. Distribution of feedback messages has been simplified using the new DamageCheckResult class.
This commit is contained in:
2024-02-24 19:23:54 +01:00
parent b9e2aefc40
commit 1aeb245666
16 changed files with 266 additions and 167 deletions
@@ -1,7 +1,9 @@
package me.youhavetrouble.preventstabby.api;
import me.youhavetrouble.preventstabby.PreventStabby;
import me.youhavetrouble.preventstabby.data.DamageCheckResult;
import me.youhavetrouble.preventstabby.util.PvpState;
import org.bukkit.entity.Entity;
public class PreventStabbyAPI {
@@ -19,5 +21,9 @@ public class PreventStabbyAPI {
PreventStabby.getPlugin().getPlayerManager().setForcedPvpState(newForcedPvpState);
}
public static DamageCheckResult canDamage(Entity attacker, Entity victim) {
return PreventStabby.getPlugin().getPlayerManager().canDamage(attacker, victim);
}
}