mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-12 13:26:56 +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:
@@ -2,6 +2,7 @@ package me.youhavetrouble.preventstabby.util;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||
import me.youhavetrouble.preventstabby.data.DamageCheckResult;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
@@ -69,6 +70,15 @@ public class PluginMessages {
|
||||
Bukkit.broadcast(parseMessage(message));
|
||||
}
|
||||
|
||||
public static void sendOutMessages(DamageCheckResult damageCheckResult) {
|
||||
if (damageCheckResult.victimId() != null && damageCheckResult.feedbackForVictim() != null) {
|
||||
sendActionBar(damageCheckResult.victimId(), damageCheckResult.feedbackForVictim());
|
||||
}
|
||||
if (damageCheckResult.attackerId() != null && damageCheckResult.feedbackForAttacker() != null) {
|
||||
sendActionBar(damageCheckResult.attackerId(), damageCheckResult.feedbackForAttacker());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps most legacy color codes to adventure minimessage tags.
|
||||
* @param symbol Usually '&'.
|
||||
|
||||
Reference in New Issue
Block a user