testserver/CraftBukkit-Patches/0121-Prevent-a-crash-involv...

31 lines
1.4 KiB
Diff
Raw Normal View History

2016-03-02 21:28:13 +00:00
From f96164c1f3d6856df8008b2be6afc7ac1ce03a17 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
2016-03-02 21:28:13 +00:00
index 92e14d4..8fefb1f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2016-03-02 21:28:13 +00:00
@@ -1304,7 +1304,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
break;
}
}
2014-11-28 01:17:45 +00:00
- 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" );
+ }
2014-11-28 01:17:45 +00:00
+ collection.add(new AttributeModifiable(getHandle().getAttributeMap(), (new AttributeRanged(null, "generic.maxHealth", healthMod, 0.0D, Float.MAX_VALUE)).a("Max Health").a(true)));
+ // Spigot end
}
2015-06-08 23:16:01 +00:00
@Override
--
2016-02-29 21:33:06 +00:00
2.5.0