This commit is contained in:
parent
1380e7479a
commit
5ffb921150
7 changed files with 174 additions and 78 deletions
|
@ -3,6 +3,7 @@ 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.attribute.AttributeInstance;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
|
@ -17,7 +18,17 @@ public class SRPlayerUtils {
|
|||
|
||||
// agility (speed)
|
||||
// default is 100 so 0.2
|
||||
float value = (float) (sr.getAttribute(Attribute.AGILITY) / 500.0);
|
||||
double items = sr.getTotalItemAttribute(Attribute.AGILITY);
|
||||
double speed = sr.getAttribute(Attribute.AGILITY);
|
||||
float value = (float) ((speed + items) / 500.0f);
|
||||
value = Math.min(value, 1.0f);
|
||||
value = Math.max(value, 0f);
|
||||
AttributeInstance attribute1 =
|
||||
p.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MOVEMENT_SPEED);
|
||||
if (attribute1 != null) attribute1.setBaseValue(value);
|
||||
AttributeInstance attribute2 =
|
||||
p.getAttribute(org.bukkit.attribute.Attribute.GENERIC_FLYING_SPEED);
|
||||
if (attribute2 != null) attribute2.setBaseValue(value);
|
||||
p.setFlySpeed(value);
|
||||
p.setWalkSpeed(value);
|
||||
|
||||
|
@ -27,7 +38,10 @@ public class SRPlayerUtils {
|
|||
|
||||
// health
|
||||
// default is 100 so 20
|
||||
p.setHealth(sr.getAttribute(Attribute.HEALTH) / 5);
|
||||
double health =
|
||||
(sr.getAttribute(Attribute.HEALTH) + sr.getTotalItemAttribute(Attribute.HEALTH)) / 5;
|
||||
AttributeInstance attribute = p.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH);
|
||||
if (attribute != null) attribute.setBaseValue(health);
|
||||
p.sendHealthUpdate();
|
||||
p.updateInventory();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue