Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
Difficulty.java
1 package org.bukkit;
2 
3 import java.util.Map;
4 
5 import com.google.common.collect.Maps;
6 
7 /**
8  * Represents the various difficulty levels that are available.
9  */
10 public enum Difficulty {
11  /**
12  * Players regain health over time, hostile mobs don't spawn, the hunger
13  * bar does not deplete.
14  */
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 final static 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  * @deprecated Magic value
48  */
49  @Deprecated
50  public int getValue() {
51  return value;
52  }
53 
54  /**
55  * Gets the Difficulty represented by the specified value
56  *
57  * @param value Value to check
58  * @return Associative {@link Difficulty} with the given value, or null if
59  * it doesn't exist
60  * @deprecated Magic value
61  */
62  @Deprecated
63  public static Difficulty getByValue(final int value) {
64  return BY_ID.get(value);
65  }
66 
67  static {
68  for (Difficulty diff : values()) {
69  BY_ID.put(diff.value, diff);
70  }
71  }
72 }
static Difficulty getByValue(final int value)
Definition: Difficulty.java:63