Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
GameMode.java
1 package org.bukkit;
2 
3 import java.util.Map;
4 
6 
7 import com.google.common.collect.Maps;
8 
9 /**
10  * Represents the various type of game modes that {@link HumanEntity}s may
11  * have
12  */
13 public enum GameMode {
14  /**
15  * Creative mode may fly, build instantly, become invulnerable and create
16  * free items.
17  */
19 
20  /**
21  * Survival mode is the "normal" gameplay type, with no special features.
22  */
24 
25  /**
26  * Adventure mode cannot break blocks, use chat, use buckets, etc.
27  */
29 
30  private final int value;
31  private final static Map<Integer, GameMode> BY_ID = Maps.newHashMap();
32 
33  private GameMode(final int value) {
34  this.value = value;
35  }
36 
37  /**
38  * Gets the mode value associated with this GameMode
39  *
40  * @return An integer value of this gamemode
41  * @deprecated Magic value
42  */
43  @Deprecated
44  public int getValue() {
45  return value;
46  }
47 
48  /**
49  * Gets the GameMode represented by the specified value
50  *
51  * @param value Value to check
52  * @return Associative {@link GameMode} with the given value, or null if
53  * it doesn't exist
54  * @deprecated Magic value
55  */
56  @Deprecated
57  public static GameMode getByValue(final int value) {
58  return BY_ID.get(value);
59  }
60 
61  static {
62  for (GameMode mode : values()) {
63  BY_ID.put(mode.getValue(), mode);
64  }
65  }
66 }
static GameMode getByValue(final int value)
Definition: GameMode.java:57