utils
This commit is contained in:
parent
241feba114
commit
932a74dc42
4 changed files with 144 additions and 14 deletions
|
@ -0,0 +1,34 @@
|
|||
package me.unurled.sacredrealms.sr.utils;
|
||||
|
||||
import java.util.List;
|
||||
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
|
||||
import me.unurled.sacredrealms.sr.components.player.SRPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
public class SRPlayerUtils {
|
||||
public static void syncPlayerToSR(Player p, SRPlayer sr) {
|
||||
sr.setInventory(p.getInventory());
|
||||
sr.setPotionEffects((List<PotionEffect>) p.getActivePotionEffects());
|
||||
}
|
||||
|
||||
public static void syncSRToPlayer(SRPlayer sr, Player p) {
|
||||
p.getInventory().setContents(sr.getInventory().getContents());
|
||||
|
||||
// agility (speed)
|
||||
// default is 100 so 0.2
|
||||
float value = (float) (sr.getAttribute(Attribute.AGILITY) / 500.0);
|
||||
p.setFlySpeed(value);
|
||||
p.setWalkSpeed(value);
|
||||
|
||||
for (PotionEffect pe : sr.getPotionEffects()) {
|
||||
p.addPotionEffect(pe);
|
||||
}
|
||||
|
||||
// health
|
||||
// default is 100 so 20
|
||||
p.setHealth(sr.getAttribute(Attribute.HEALTH) / 5);
|
||||
p.sendHealthUpdate();
|
||||
p.updateInventory();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue