mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Prevent a crash involving attributes
By: Thinkofdeath <thinkofdeath@spigotmc.org>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user