Prevent a crash involving attributes

By: Thinkofdeath <thinkofdeath@spigotmc.org>
This commit is contained in:
CraftBukkit/Spigot 2014-07-19 19:54:41 +01:00
parent 6578ff97bb
commit 0166f71409

View file

@ -2160,7 +2160,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
AttributeInstance dummy = new AttributeInstance(Attributes.MAX_HEALTH, (attribute) -> { });
dummy.setBaseValue(this.scaledHealth ? this.healthScale : this.getMaxHealth());
// Spigot start
double healthMod = this.scaledHealth ? this.healthScale : this.getMaxHealth();
if ( healthMod >= Float.MAX_VALUE || healthMod <= 0 )
{
healthMod = 20; // Reset health
this.getServer().getLogger().warning( this.getName() + " tried to crash the server with a large health attribute" );
}
dummy.setBaseValue(healthMod);
// Spigot end
collection.add(dummy);
}