forked from Upstream/mmocore
fixed health regen issue
This commit is contained in:
parent
1a130e25b9
commit
2016945a2c
@ -330,7 +330,8 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Avoid calling an useless event
|
// Avoid calling an useless event
|
||||||
double newest = Math.max(0, Math.min(getPlayer().getHealth() + heal, getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
|
double max = getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||||
|
double newest = Math.max(0, Math.min(getPlayer().getHealth() + heal, max));
|
||||||
if (getPlayer().getHealth() == newest)
|
if (getPlayer().getHealth() == newest)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -340,7 +341,7 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Use updated amount from event
|
// Use updated amount from event
|
||||||
getPlayer().setHealth(getPlayer().getHealth() + event.getAmount());
|
getPlayer().setHealth(Math.max(0, Math.min(getPlayer().getHealth() + event.getAmount(), max)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFriend(UUID uuid) {
|
public void addFriend(UUID uuid) {
|
||||||
@ -529,7 +530,8 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
public void giveMana(double amount, PlayerResourceUpdateEvent.UpdateReason reason) {
|
public void giveMana(double amount, PlayerResourceUpdateEvent.UpdateReason reason) {
|
||||||
|
|
||||||
// Avoid calling useless event
|
// Avoid calling useless event
|
||||||
double newest = Math.max(0, Math.min(getStats().getStat(StatType.MAX_MANA), mana + amount));
|
double max = getStats().getStat(StatType.MAX_MANA);
|
||||||
|
double newest = Math.max(0, Math.min(mana + amount, max));
|
||||||
if (mana == newest)
|
if (mana == newest)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -539,7 +541,7 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Use updated amount from Bukkit event
|
// Use updated amount from Bukkit event
|
||||||
setMana(mana + event.getAmount());
|
mana = Math.max(0, Math.min(mana + event.getAmount(), max));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -553,7 +555,8 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
public void giveStamina(double amount, PlayerResourceUpdateEvent.UpdateReason reason) {
|
public void giveStamina(double amount, PlayerResourceUpdateEvent.UpdateReason reason) {
|
||||||
|
|
||||||
// Avoid calling useless event
|
// Avoid calling useless event
|
||||||
double newest = Math.max(0, Math.min(getStats().getStat(StatType.MAX_STAMINA), stamina + amount));
|
double max = getStats().getStat(StatType.MAX_STAMINA);
|
||||||
|
double newest = Math.max(0, Math.min(stamina + amount, max));
|
||||||
if (stamina == newest)
|
if (stamina == newest)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -564,6 +567,7 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
|
|
||||||
// Use updated amount from Bukkit event
|
// Use updated amount from Bukkit event
|
||||||
setStamina(stamina + event.getAmount());
|
setStamina(stamina + event.getAmount());
|
||||||
|
stamina = Math.max(0, Math.min(stamina + event.getAmount(), max));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -577,7 +581,8 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
public void giveStellium(double amount, PlayerResourceUpdateEvent.UpdateReason reason) {
|
public void giveStellium(double amount, PlayerResourceUpdateEvent.UpdateReason reason) {
|
||||||
|
|
||||||
// Avoid calling useless event
|
// Avoid calling useless event
|
||||||
double newest = Math.max(0, Math.min(getStats().getStat(StatType.MAX_STELLIUM), stellium + amount));
|
double max = getStats().getStat(StatType.MAX_STELLIUM);
|
||||||
|
double newest = Math.max(0, Math.min(stellium + amount, max));
|
||||||
if (stellium == newest)
|
if (stellium == newest)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -587,7 +592,7 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Use updated amount from Bukkit event
|
// Use updated amount from Bukkit event
|
||||||
setStellium(stellium + event.getAmount());
|
stellium = Math.max(0, Math.min(stellium + event.getAmount(), max));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMana() {
|
public double getMana() {
|
||||||
|
Loading…
Reference in New Issue
Block a user