Archiviert
13
0

Add methods to convert NativeGameMode to and from GameMode

Fixes #45
Dieser Commit ist enthalten in:
Dan Mulloy 2015-02-05 16:20:02 -05:00
Ursprung 391970b185
Commit ac54cef2fd

Datei anzeigen

@ -46,6 +46,7 @@ public abstract class EnumWrappers {
* Represents a native game mode in Minecraft. * Represents a native game mode in Minecraft.
* <p> * <p>
* Not to be confused with {@link GameMode} in Bukkit. * Not to be confused with {@link GameMode} in Bukkit.
*
* @author Kristian * @author Kristian
*/ */
public enum NativeGameMode { public enum NativeGameMode {
@ -59,6 +60,49 @@ public abstract class EnumWrappers {
* @deprecated Replaced by NOT_SET * @deprecated Replaced by NOT_SET
*/ */
NONE; NONE;
/**
* Gets this NativeGameMode's Bukkit equivalent.
* <p>
* Note: There is not a Bukkit equivalent for NOT_SET or NONE
*
* @return The Bukkit equivalent, or null if one does not exist.
*/
public GameMode toBukkit() {
switch (this) {
case ADVENTURE:
return GameMode.ADVENTURE;
case CREATIVE:
return GameMode.CREATIVE;
case SPECTATOR:
return GameMode.SPECTATOR;
case SURVIVAL:
return GameMode.SURVIVAL;
default:
return null;
}
}
/**
* Obtains the given GameMode's NativeGameMode equivalent.
*
* @param mode Bukkit GameMode
* @return The NativeGameMode equivalent, or null if one does not exist.
*/
public static NativeGameMode fromBukkit(GameMode mode) {
switch (mode) {
case ADVENTURE:
return ADVENTURE;
case CREATIVE:
return CREATIVE;
case SPECTATOR:
return SPECTATOR;
case SURVIVAL:
return SURVIVAL;
default:
return null;
}
}
} }
public enum ResourcePackStatus { public enum ResourcePackStatus {