Fix GameMode integer ids.

This commit is contained in:
Olof Larsson 2015-12-16 12:37:14 +01:00
parent d3c025b288
commit bbf974f348

View File

@ -28,10 +28,32 @@ public class TypeGameMode extends TypeEnum<GameMode>
{ {
Set<String> ret = new MassiveSet<String>(super.getIdsInner(value)); Set<String> ret = new MassiveSet<String>(super.getIdsInner(value));
String id = String.valueOf(value.ordinal()); int idInt = getIntegerId(value);
ret.add(id); String idString = String.valueOf(idInt);
ret.add(idString);
return ret; return ret;
} }
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
// The reason we can not simply do ".ordinal()" is Survival and Creative has the wrong order.
public static int getIntegerId(GameMode gameMode)
{
if (gameMode == null) throw new NullPointerException("gameMode");
switch (gameMode)
{
case SURVIVAL: return 0;
case CREATIVE: return 1;
case ADVENTURE: return 2;
case SPECTATOR: return 3;
}
return gameMode.ordinal();
}
} }