forked from Upstream/mmocore
Fixed resource regen event spam, removed useless event calls
This commit is contained in:
parent
f0224967c8
commit
e06f70e158
@ -240,7 +240,7 @@ public class MMOCore extends JavaPlugin {
|
|||||||
resource.regen(player, d);
|
resource.regen(player, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimerAsynchronously(MMOCore.plugin, 100, 20);
|
}.runTaskTimer(MMOCore.plugin, 100, 20);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For the sake of the lord, make sure they aren't using MMOItems Mana
|
* For the sake of the lord, make sure they aren't using MMOItems Mana
|
||||||
|
@ -398,12 +398,16 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void heal(double heal) {
|
public void heal(double heal) {
|
||||||
|
double current = player.getHealth(), newest = Math.max(0, Math.min(player.getHealth() + heal, player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
|
||||||
|
if (current == newest)
|
||||||
|
return;
|
||||||
|
|
||||||
PlayerRegenResourceEvent event = new PlayerRegenResourceEvent(this, PlayerResource.HEALTH, heal);
|
PlayerRegenResourceEvent event = new PlayerRegenResourceEvent(this, PlayerResource.HEALTH, heal);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
getPlayer().setHealth(Math.max(0, Math.min(player.getHealth() + heal, player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())));
|
getPlayer().setHealth(newest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFriend(UUID uuid) {
|
public void addFriend(UUID uuid) {
|
||||||
@ -542,30 +546,42 @@ public class PlayerData extends OfflinePlayerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void giveMana(double amount) {
|
public void giveMana(double amount) {
|
||||||
|
double newest = Math.max(0, Math.min(getStats().getStat(StatType.MAX_MANA), mana + amount));
|
||||||
|
if (mana == newest)
|
||||||
|
return;
|
||||||
|
|
||||||
PlayerRegenResourceEvent event = new PlayerRegenResourceEvent(this, PlayerResource.MANA, amount);
|
PlayerRegenResourceEvent event = new PlayerRegenResourceEvent(this, PlayerResource.MANA, amount);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mana = Math.max(0, Math.min(getStats().getStat(StatType.MAX_MANA), mana + amount));
|
mana = newest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void giveStamina(double amount) {
|
public void giveStamina(double amount) {
|
||||||
|
double newest = Math.max(0, Math.min(getStats().getStat(StatType.MAX_STAMINA), stamina + amount));
|
||||||
|
if (stamina == newest)
|
||||||
|
return;
|
||||||
|
|
||||||
PlayerRegenResourceEvent event = new PlayerRegenResourceEvent(this, PlayerResource.STAMINA, amount);
|
PlayerRegenResourceEvent event = new PlayerRegenResourceEvent(this, PlayerResource.STAMINA, amount);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stamina = Math.max(0, Math.min(getStats().getStat(StatType.MAX_STAMINA), stamina + amount));
|
stamina = newest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void giveStellium(double amount) {
|
public void giveStellium(double amount) {
|
||||||
|
double newest = Math.max(0, Math.min(getStats().getStat(StatType.MAX_STELLIUM), stellium + amount));
|
||||||
|
if (stellium == newest)
|
||||||
|
return;
|
||||||
|
|
||||||
PlayerRegenResourceEvent event = new PlayerRegenResourceEvent(this, PlayerResource.STELLIUM, amount);
|
PlayerRegenResourceEvent event = new PlayerRegenResourceEvent(this, PlayerResource.STELLIUM, amount);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stellium = Math.max(0, Math.min(getStats().getStat(StatType.MAX_STELLIUM), stellium + amount));
|
stellium = newest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMana() {
|
public double getMana() {
|
||||||
|
Loading…
Reference in New Issue
Block a user