mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-17 05:03:55 -07:00
@@ -1,5 +1,8 @@
|
||||
package org.bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
|
||||
/**
|
||||
@@ -9,10 +12,42 @@ public enum GameMode {
|
||||
/**
|
||||
* Creative mode may fly, build instantly, become invulnerable and create free items
|
||||
*/
|
||||
CREATIVE,
|
||||
|
||||
CREATIVE(1),
|
||||
|
||||
/**
|
||||
* Survival mode is the "normal" gameplay type, with no special features.
|
||||
*/
|
||||
SURVIVAL;
|
||||
SURVIVAL(0);
|
||||
|
||||
private final int value;
|
||||
private final static Map<Integer, GameMode> modes = new HashMap<Integer, GameMode>();
|
||||
|
||||
private GameMode(final int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mode value associated with this GameMode
|
||||
*
|
||||
* @return An integer value of this gamemode
|
||||
*/
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the GameMode represented by the specified value
|
||||
*
|
||||
* @param value Value to check
|
||||
* @return Associative {@link GameMode} with the given value, or null if it doesn't exist
|
||||
*/
|
||||
public static GameMode getByValue(final int value) {
|
||||
return modes.get(value);
|
||||
}
|
||||
|
||||
static {
|
||||
for (GameMode mode : GameMode.values()) {
|
||||
modes.put(mode.getValue(), mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user