Skip to content

Commit

Permalink
Blending changes, need to hide debug next.
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammerDan committed Jun 16, 2017
1 parent 4d88f4c commit 619bb26
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.github.maxopoly.finale.listeners;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.entity.EntityType;
Expand Down Expand Up @@ -49,15 +50,22 @@ public void healthRegen(EntityRegainHealthEvent e) {
&& manager.getPassiveRegenHandler().blockPassiveHealthRegen()) {
// apparently setting to cancelled doesn't prevent the "consumption" of satiation.
Player p = (Player) e.getEntity();

double maxHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
float newExhaustion = (float) (p.getExhaustion() - e.getAmount() * 6.0d);
double spigotRegenExhaustion = ((net.minecraft.server.v1_12_R1.World) ( (org.bukkit.craftbukkit.v1_12_R1.CraftWorld) p.getWorld()).getHandle()).spigotConfig.regenExhaustion;
float newExhaustion = (float) (p.getExhaustion() - e.getAmount() * spigotRegenExhaustion);

if(newExhaustion < 0)
StringBuffer alterHealth = new StringBuffer("SATIATED: " + p.getName());
alterHealth.append(":").append(p.getHealth()).append("<").append(p.getMaxHealth());
alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
alterHealth.append(":").append(p.getFoodLevel());

if(newExhaustion < 0) // not 100% sure this is correct route; intention was restoring what spigot takes, but we'll roll with it
newExhaustion = 0;

p.setExhaustion(newExhaustion);
StringBuffer alterHealth = new StringBuffer(p.getName());
alterHealth.append(":").append(p.getHealth()).append("<").append(maxHealth);

alterHealth.append(" TO ").append(p.getHealth()).append("<").append(p.getMaxHealth());
alterHealth.append(":").append(p.getSaturation()).append(":").append(p.getExhaustion());
alterHealth.append(":").append(p.getFoodLevel());
Finale.getPlugin().getLogger().info(alterHealth.toString());
Expand Down

0 comments on commit 619bb26

Please sign in to comment.