3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-19 21:10:10 +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.
Dieser Commit ist enthalten in:
Travis Watkins 2012-10-28 10:07:11 -05:00
Ursprung 37a0d6757d
Commit 0fb806c566

Datei anzeigen

@ -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() {