-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
685 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Recx | ||
|
||
Recx /rekts/ is a 2D sandbox game. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2023 XenFork Union | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
|
||
package recx.client; | ||
|
||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParser; | ||
import recx.util.FileUtil; | ||
import recx.util.JsonHelper; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* @author squid233 | ||
* @since 0.1.0 | ||
*/ | ||
public final class GameVersion { | ||
private static GameVersion instance; | ||
private final String version; | ||
private final boolean isSnapshot; | ||
|
||
private GameVersion(String version, boolean isSnapshot) { | ||
this.version = version; | ||
this.isSnapshot = isSnapshot; | ||
} | ||
|
||
public static GameVersion getInstance() { | ||
if (instance == null) { | ||
instance = load(); | ||
} | ||
return instance; | ||
} | ||
|
||
private static GameVersion load() { | ||
try { | ||
final JsonObject object = JsonParser.parseString(FileUtil.readString("version.json")).getAsJsonObject(); | ||
return new GameVersion( | ||
JsonHelper.getString(object, "version"), | ||
Boolean.parseBoolean(JsonHelper.getString(object, "isSnapshot")) | ||
); | ||
} catch (IOException e) { | ||
// todo: log | ||
e.printStackTrace(); | ||
return new GameVersion("Version Unknown", true); | ||
} | ||
} | ||
|
||
public String version() { | ||
return version; | ||
} | ||
|
||
public boolean isSnapshot() { | ||
return isSnapshot; | ||
} | ||
} |
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
Oops, something went wrong.