diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-10-28 10:07:11 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2012-10-28 10:07:11 -0500 |
commit | 0fb806c566594317df6b14ab13c825db88eba60f (patch) | |
tree | 4073b307580f2fce1dc7c8c94a0feeed50bd0ce3 /src | |
parent | 37a0d6757d66e5051de58d5e2f85cd74ab02f57d (diff) | |
download | craftbukkit-0fb806c566594317df6b14ab13c825db88eba60f.tar craftbukkit-0fb806c566594317df6b14ab13c825db88eba60f.tar.gz craftbukkit-0fb806c566594317df6b14ab13c825db88eba60f.tar.lz craftbukkit-0fb806c566594317df6b14ab13c825db88eba60f.tar.xz craftbukkit-0fb806c566594317df6b14ab13c825db88eba60f.zip |
Clamp difficulty levels to prevent invalid values
Some features added in 1.4.2 use the difficulty value as an index to an
array so while before having it set to an invalid value would do nothing
or maybe cause an odd side effect somewhere it now crashes the server. This
patch ensures difficulty values are clamped between 0 and 3, inclusive.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/DedicatedServer.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java index 0c748614..4bf7f9c8 100644 --- a/src/main/java/net/minecraft/server/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/DedicatedServer.java @@ -182,7 +182,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer } public int getDifficulty() { - return this.propertyManager.getInt("difficulty", 1); + return Math.max(0, Math.min(3, this.propertyManager.getInt("difficulty", 1))); // CraftBukkit - clamp values } public boolean isHardcore() { |