-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Check game_type instead of featured mod everywhere
- Loading branch information
Showing
14 changed files
with
120 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/faforever/client/remote/domain/GameType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.faforever.client.remote.domain; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.HashMap; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
@Slf4j | ||
public enum GameType { | ||
|
||
UNKNOWN("unknown"), | ||
CUSTOM("custom"), | ||
MATCHMAKER("matchmaker"), | ||
COOP("coop"), | ||
TUTORIAL("tutorial"); | ||
|
||
private static final Map<String, GameType> fromString; | ||
|
||
static { | ||
fromString = new HashMap<>(); | ||
for (GameType gameType : values()) { | ||
fromString.put(gameType.string, gameType); | ||
} | ||
} | ||
|
||
private final String string; | ||
|
||
GameType(String string) { | ||
this.string = string; | ||
} | ||
|
||
public static GameType fromString(String string) { | ||
GameType gameType = fromString.get(string != null ? string.toLowerCase(Locale.US) : null); | ||
if (gameType == null) { | ||
log.warn("Unknown game type: {}", string); | ||
return UNKNOWN; | ||
} | ||
return gameType; | ||
} | ||
|
||
public String getString() { | ||
return string; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/faforever/client/remote/gson/GameTypeTypeAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.faforever.client.remote.gson; | ||
|
||
import com.faforever.client.remote.domain.GameType; | ||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonWriter; | ||
|
||
import java.io.IOException; | ||
|
||
public final class GameTypeTypeAdapter extends TypeAdapter<GameType> { | ||
|
||
public static final GameTypeTypeAdapter INSTANCE = new GameTypeTypeAdapter(); | ||
|
||
private GameTypeTypeAdapter() { | ||
// private | ||
} | ||
|
||
@Override | ||
public void write(JsonWriter out, GameType value) throws IOException { | ||
if (value == null) { | ||
out.value(GameType.UNKNOWN.getString()); | ||
} else { | ||
out.value(value.getString()); | ||
} | ||
} | ||
|
||
@Override | ||
public GameType read(JsonReader in) throws IOException { | ||
return GameType.fromString(in.nextString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters