Fix GameMode#getById behaviour in 1.8->1.9 (#3947)

Vanilla fallbacks to SURVIVAL and doesn't throw any errors,
also NOT_SET was missing previously.
This commit is contained in:
EnZaXD 2024-06-16 22:28:50 +02:00 committed by GitHub
parent 8bec05ed38
commit 824ff375d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.minecraft;
public enum GameMode {
NOT_SET(""),
SURVIVAL("Survival Mode"),
CREATIVE("Creative Mode"),
ADVENTURE("Adventure Mode"),
@ -41,11 +42,11 @@ public enum GameMode {
public static GameMode getById(int id) {
return switch (id) {
case 0 -> SURVIVAL;
case -1 -> NOT_SET;
case 1 -> CREATIVE;
case 2 -> ADVENTURE;
case 3 -> SPECTATOR;
default -> throw new IllegalArgumentException("Unknown gamemode id: " + id);
default /*0*/ -> SURVIVAL;
};
}
}