mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-12 05:16:55 +00:00
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:
@@ -0,0 +1,41 @@
|
||||
package me.youhavetrouble.preventstabby.data;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @param ableToDamage Result of the damage check
|
||||
* @param feedbackForAttacker Feedback to send to the attacker
|
||||
* @param feedbackForVictim Feedback to send to the victim
|
||||
* @param attackerId UUID of attacker player
|
||||
* @param victimId UUID of victim player
|
||||
*/
|
||||
public record DamageCheckResult(
|
||||
boolean ableToDamage,
|
||||
@Nullable UUID attackerId,
|
||||
@Nullable UUID victimId,
|
||||
@Nullable String feedbackForAttacker,
|
||||
@Nullable String feedbackForVictim
|
||||
) {
|
||||
|
||||
public static DamageCheckResult positive() {
|
||||
return new DamageCheckResult(
|
||||
true,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
public static DamageCheckResult positive(UUID attackerId, UUID victimId) {
|
||||
return new DamageCheckResult(
|
||||
true,
|
||||
attackerId,
|
||||
victimId,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user