absorption expires on drinking milk

master
Benjamin Kraft 3 years ago
parent 65bfc3fde5
commit 4e19417553
  1. 4
      src/main/java/com/benjocraeft/sharehealth/HealthManager.java
  2. 12
      src/main/java/com/benjocraeft/sharehealth/PlayerListeners.java
  3. 6
      src/main/java/com/benjocraeft/sharehealth/Sharehealth.java

@ -87,6 +87,8 @@ public class HealthManager {
absorptionManager.create(duration, amount); absorptionManager.create(duration, amount);
} }
void onMilkBucketConsumed(){
absorptionManager.expire(false);
}
} }

@ -1,5 +1,6 @@
package com.benjocraeft.sharehealth; package com.benjocraeft.sharehealth;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -9,6 +10,7 @@ import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -130,4 +132,14 @@ public class PlayerListeners implements Listener{
} }
} }
} }
@EventHandler
public void onPlayerItemConsumed(final PlayerItemConsumeEvent event){
Player consumer = event.getPlayer();
if (!Sharehealth.GetPlayers().contains(consumer))
return;
if (event.getItem().getType().equals(Material.MILK_BUCKET))
Sharehealth.Instance.onMilkBucketConsumed();
}
} }

@ -196,6 +196,12 @@ public class Sharehealth extends JavaPlugin {
saveStatus(); saveStatus();
} }
void onMilkBucketConsumed(){
healthManager.onMilkBucketConsumed();
saveStatus();
}
private void failed(Player cause){ private void failed(Player cause){
if (isFailed) if (isFailed)
return; return;

Loading…
Cancel
Save