Paper/CraftBukkit-Patches/0138-Prevent-a-crash-involving-attributes.patch
Zach Brown c55b9c30d7 Update from upstream SpigotMC
66af3b310e0
a969bf6c85d
95d56229d8f
87c1d0c8b7c
baf01cc7f84
38b8866783d [M]
2014-12-02 00:02:15 -06:00

31 lines
1.4 KiB
Diff

From a19334167ae4751278c8d15b3f55027e25b5db46 Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thinkofdeath@spigotmc.org>
Date: Sat, 19 Jul 2014 19:54:41 +0100
Subject: [PATCH] Prevent a crash involving attributes
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 5480607..d1f69dc 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1310,7 +1310,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
break;
}
}
- collection.add(new AttributeModifiable(getHandle().getAttributeMap(), (new AttributeRanged(null, "generic.maxHealth", scaledHealth ? healthScale : getMaxHealth(), 0.0D, Float.MAX_VALUE)).a("Max Health").a(true)));
+ // Spigot start
+ double healthMod = scaledHealth ? healthScale : getMaxHealth();
+ if ( healthMod >= Float.MAX_VALUE || healthMod <= 0 )
+ {
+ healthMod = 20; // Reset health
+ getServer().getLogger().warning( getName() + " tried to crash the server with a large health attribute" );
+ }
+ collection.add(new AttributeModifiable(getHandle().getAttributeMap(), (new AttributeRanged(null, "generic.maxHealth", healthMod, 0.0D, Float.MAX_VALUE)).a("Max Health").a(true)));
+ // Spigot end
}
// Spigot start
--
2.1.0