mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +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
1 changed files with 1 additions and 1 deletions
|
@ -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 a new issue