mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-23 16:08:18 -05:00
Attempt to fix max health issues
This commit is contained in:
parent
152962108a
commit
5c24a9bc44
2 changed files with 5 additions and 13 deletions
|
@ -3,27 +3,19 @@ package pw.kaboom.extras.modules.player;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import org.bukkit.attribute.Attribute;
|
|
||||||
import org.bukkit.attribute.AttributeInstance;
|
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
import org.bukkit.entity.ExperienceOrb;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public final class PlayerDamage implements Listener {
|
public final class PlayerDamage implements Listener {
|
||||||
|
@ -56,10 +48,10 @@ public final class PlayerDamage implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@EventHandler
|
@EventHandler
|
||||||
void onPlayerDeath(final PlayerDeathEvent event) {
|
void onPlayerDeath(final PlayerDeathEvent event) {
|
||||||
final Player player = event.getEntity();
|
final Player player = event.getEntity();
|
||||||
final AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
|
||||||
|
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
onlinePlayer.sendMessage(event.getDeathMessage());
|
onlinePlayer.sendMessage(event.getDeathMessage());
|
||||||
|
@ -79,7 +71,7 @@ public final class PlayerDamage implements Listener {
|
||||||
xp.setExperience(event.getDroppedExp());
|
xp.setExperience(event.getDroppedExp());
|
||||||
}
|
}
|
||||||
|
|
||||||
maxHealth.setBaseValue(20);
|
player.setMaxHealth(20);
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
|
|
||||||
if (player.getBedSpawnLocation() != null) {
|
if (player.getBedSpawnLocation() != null) {
|
||||||
|
@ -100,9 +92,9 @@ public final class PlayerDamage implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
maxHealth.setBaseValue(Double.POSITIVE_INFINITY);
|
player.setMaxHealth(Double.POSITIVE_INFINITY);
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
maxHealth.setBaseValue(20);
|
player.setMaxHealth(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setExp(event.getNewExp());
|
player.setExp(event.getNewExp());
|
||||||
|
|
|
@ -123,7 +123,7 @@ public final class ServerCommand implements Listener {
|
||||||
|
|
||||||
if (sender instanceof BlockCommandSender) {
|
if (sender instanceof BlockCommandSender) {
|
||||||
final CommandBlock commandBlock = (CommandBlock) ((BlockCommandSender) sender).getBlock().getState();
|
final CommandBlock commandBlock = (CommandBlock) ((BlockCommandSender) sender).getBlock().getState();
|
||||||
|
|
||||||
commandBlock.setCommand("");
|
commandBlock.setCommand("");
|
||||||
commandBlock.update();
|
commandBlock.update();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue