add ActionBar with health & mana
This commit is contained in:
parent
75d89e7974
commit
8111b2b8f2
3 changed files with 20 additions and 2 deletions
|
@ -1,19 +1,22 @@
|
|||
package me.unurled.sacredrealms.sr.utils;
|
||||
|
||||
import static me.unurled.sacredrealms.sr.utils.Component.comp;
|
||||
|
||||
import java.util.List;
|
||||
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
|
||||
import me.unurled.sacredrealms.sr.components.player.SRPlayer;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SRPlayerUtils {
|
||||
public static void syncPlayerToSR(Player p, SRPlayer sr) {
|
||||
public static void syncPlayerToSR(@NotNull Player p, @NotNull SRPlayer sr) {
|
||||
sr.setInventory(p.getInventory());
|
||||
sr.setPotionEffects((List<PotionEffect>) p.getActivePotionEffects());
|
||||
}
|
||||
|
||||
public static void syncSRToPlayer(SRPlayer sr, Player p) {
|
||||
public static void syncSRToPlayer(@NotNull SRPlayer sr, @NotNull Player p) {
|
||||
p.getInventory().setContents(sr.getInventory().getContents());
|
||||
|
||||
// agility (speed)
|
||||
|
@ -45,4 +48,12 @@ public class SRPlayerUtils {
|
|||
p.sendHealthUpdate();
|
||||
p.updateInventory();
|
||||
}
|
||||
|
||||
public static void updateActionBar(@NotNull Player p, @NotNull SRPlayer sr) {
|
||||
double health = sr.getAttribute(Attribute.HEALTH);
|
||||
double mana = sr.getAttribute(Attribute.MANA);
|
||||
|
||||
net.kyori.adventure.text.Component text = comp("<red>❤ " + health + " <blue>❈ " + mana);
|
||||
p.sendActionBar(text);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue