Paper/CraftBukkit-Patches/0156-Prevent-a-crash-involving-attributes.patch
Zach Brown cab333b217 Rebase (Update) from upstream SpigotMC
Don't send requests of every player was found in the global api cache SpigotMC/Spigot@841270ff1e
Correctly set the response code for the cached lookups and return the ... SpigotMC/Spigot@f170b7899c
Don't try and re-set the global api cache on reload SpigotMC/Spigot@b410a00a66
Use a compile time sneaky throw hack. SpigotMC/Spigot@508462b96b
Fix a missed rename in WorldGenGroundBush SpigotMC/Spigot@0614d8fae9
2014-11-28 14:19:07 -06:00

31 lines
1.4 KiB
Diff

From 80ddf0886e3309efbfc551db05b5af628c3baea0 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 27d3715..e7569c6 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1287,7 +1287,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
break;
}
}
- collection.add(new AttributeModifiable(getHandle().getAttributeMap(), (new AttributeRanged("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("generic.maxHealth", healthMod, 0.0D, Float.MAX_VALUE)).a("Max Health").a(true)));
+ // Spigot end
}
// Spigot start
--
1.9.1