aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0059-Be-a-bit-more-informative-in-maxHealth-exception.patch
blob: 489c881a1ab6136813e821c057b3e5c795db9a6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc>
Date: Thu, 3 Mar 2016 02:18:39 -0600
Subject: [PATCH] Be a bit more informative in maxHealth exception


diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index adeb3b9a3d65d2ef71ea4fd6f0f4679a88d0ba87..e6c68fd9a5fcd374cd7feca081189c9ba9225743 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -102,7 +102,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
     @Override
     public void setHealth(double health) {
         health = (float) health;
-        Preconditions.checkArgument(health >= 0 && health <= this.getMaxHealth(), "Health value (%s) must be between 0 and %s", health, this.getMaxHealth());
+        // Paper start - Be more informative
+        Preconditions.checkArgument(health >= 0 && health <= this.getMaxHealth(),
+            "Health value (%s) must be between 0 and %s. (attribute base value: %s%s)",
+            health, this.getMaxHealth(), this.getHandle().getAttribute(Attributes.MAX_HEALTH).getBaseValue(), this instanceof CraftPlayer ? ", player: " + this.getName() : ""
+        );
+        // Paper end
 
         // during world generation, we don't want to run logic for dropping items and xp
         if (this.getHandle().generation && health == 0) {