2011-10-03 01:25:39 -04:00
|
|
|
package org.bukkit;
|
|
|
|
|
2012-01-29 11:10:40 +01:00
|
|
|
import com.google.common.collect.Maps;
|
2019-04-23 14:33:57 +10:00
|
|
|
import java.util.Map;
|
2019-03-13 17:42:57 +11:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2012-01-29 11:10:40 +01:00
|
|
|
|
2011-10-03 01:25:39 -04:00
|
|
|
/**
|
|
|
|
* Represents the various difficulty levels that are available.
|
|
|
|
*/
|
|
|
|
public enum Difficulty {
|
|
|
|
/**
|
2013-12-15 01:07:43 -05:00
|
|
|
* Players regain health over time, hostile mobs don't spawn, the hunger
|
|
|
|
* bar does not deplete.
|
2011-10-03 01:25:39 -04:00
|
|
|
*/
|
|
|
|
PEACEFUL(0),
|
|
|
|
|
|
|
|
/**
|
2013-12-15 01:07:43 -05:00
|
|
|
* Hostile mobs spawn, enemies deal less damage than on normal difficulty,
|
|
|
|
* the hunger bar does deplete and starving deals up to 5 hearts of
|
|
|
|
* damage. (Default value)
|
2011-10-03 01:25:39 -04:00
|
|
|
*/
|
|
|
|
EASY(1),
|
|
|
|
|
|
|
|
/**
|
2013-12-15 01:07:43 -05:00
|
|
|
* Hostile mobs spawn, enemies deal normal amounts of damage, the hunger
|
|
|
|
* bar does deplete and starving deals up to 9.5 hearts of damage.
|
2011-10-03 01:25:39 -04:00
|
|
|
*/
|
|
|
|
NORMAL(2),
|
|
|
|
|
|
|
|
/**
|
2013-12-15 01:07:43 -05:00
|
|
|
* Hostile mobs spawn, enemies deal greater damage than on normal
|
|
|
|
* difficulty, the hunger bar does deplete and starving can kill players.
|
2011-10-03 01:25:39 -04:00
|
|
|
*/
|
|
|
|
HARD(3);
|
|
|
|
|
|
|
|
private final int value;
|
2019-04-23 14:00:20 +10:00
|
|
|
private static final Map<Integer, Difficulty> BY_ID = Maps.newHashMap();
|
2011-10-03 01:25:39 -04:00
|
|
|
|
|
|
|
private Difficulty(final int value) {
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the difficulty value associated with this Difficulty.
|
|
|
|
*
|
|
|
|
* @return An integer value of this difficulty
|
2013-08-19 13:32:18 -05:00
|
|
|
* @deprecated Magic value
|
2011-10-03 01:25:39 -04:00
|
|
|
*/
|
2013-08-19 13:32:18 -05:00
|
|
|
@Deprecated
|
2011-10-03 01:25:39 -04:00
|
|
|
public int getValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the Difficulty represented by the specified value
|
|
|
|
*
|
|
|
|
* @param value Value to check
|
2013-12-15 01:07:43 -05:00
|
|
|
* @return Associative {@link Difficulty} with the given value, or null if
|
|
|
|
* it doesn't exist
|
2013-08-19 13:32:18 -05:00
|
|
|
* @deprecated Magic value
|
2011-10-03 01:25:39 -04:00
|
|
|
*/
|
2013-08-19 13:32:18 -05:00
|
|
|
@Deprecated
|
2019-03-13 17:42:57 +11:00
|
|
|
@Nullable
|
2011-10-03 01:25:39 -04:00
|
|
|
public static Difficulty getByValue(final int value) {
|
2012-01-29 11:10:40 +01:00
|
|
|
return BY_ID.get(value);
|
2011-10-03 01:25:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static {
|
2012-01-29 11:10:40 +01:00
|
|
|
for (Difficulty diff : values()) {
|
|
|
|
BY_ID.put(diff.value, diff);
|
2011-10-03 01:25:39 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|