Represents the various difficulty levels that are available.
| 8 | * Represents the various difficulty levels that are available. |
| 9 | */ |
| 10 | public enum Difficulty implements net.kyori.adventure.translation.Translatable { // Paper - Adventure translations |
| 11 | /** |
| 12 | * Players regain health over time, hostile mobs don't spawn, the hunger |
| 13 | * bar does not deplete. |
| 14 | */ |
| 15 | PEACEFUL(0), |
| 16 | |
| 17 | /** |
| 18 | * Hostile mobs spawn, enemies deal less damage than on normal difficulty, |
| 19 | * the hunger bar does deplete and starving deals up to 5 hearts of |
| 20 | * damage. (Default value) |
| 21 | */ |
| 22 | EASY(1), |
| 23 | |
| 24 | /** |
| 25 | * Hostile mobs spawn, enemies deal normal amounts of damage, the hunger |
| 26 | * bar does deplete and starving deals up to 9.5 hearts of damage. |
| 27 | */ |
| 28 | NORMAL(2), |
| 29 | |
| 30 | /** |
| 31 | * Hostile mobs spawn, enemies deal greater damage than on normal |
| 32 | * difficulty, the hunger bar does deplete and starving can kill players. |
| 33 | */ |
| 34 | HARD(3); |
| 35 | |
| 36 | private final int value; |
| 37 | private static final Map<Integer, Difficulty> BY_ID = Maps.newHashMap(); |
| 38 | |
| 39 | private Difficulty(final int value) { |
| 40 | this.value = value; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Gets the difficulty value associated with this Difficulty. |
| 45 | * |
| 46 | * @return An integer value of this difficulty |
| 47 | * @apiNote Internal Use Only |
| 48 | */ |
| 49 | @org.jetbrains.annotations.ApiStatus.Internal // Paper |
| 50 | public int getValue() { |
| 51 | return value; |
| 52 | } |
| 53 | |
| 54 | // Paper start |
| 55 | @Override |
| 56 | public @org.jetbrains.annotations.NotNull String translationKey() { |
| 57 | return "options.difficulty." + this.name().toLowerCase(java.util.Locale.ENGLISH); |
| 58 | } |
| 59 | // Paper end |
| 60 | /** |
| 61 | * Gets the Difficulty represented by the specified value |
| 62 | * |
| 63 | * @param value Value to check |
| 64 | * @return Associative {@link Difficulty} with the given value, or null if |
| 65 | * it doesn't exist |
| 66 | * @apiNote Internal Use Only |
| 67 | */ |
nothing calls this directly
no test coverage detected