mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
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.
This commit is contained in:
parent
37a0d6757d
commit
0fb806c566
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user