rename readAsset function to readAssetResource

This commit is contained in:
Bixilon 2021-02-10 16:24:45 +01:00
parent bd5f1d19bd
commit d7df53fced
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
6 changed files with 14 additions and 14 deletions

View File

@ -128,7 +128,7 @@ public final class Minosoft {
taskWorker.addTask(new Task(progress -> {
Log.info("Loading versions.json...");
long mappingStartLoadingTime = System.currentTimeMillis();
Versions.loadAvailableVersions(Util.readJsonAsset("mapping/versions.json"));
Versions.loadAvailableVersions(Util.readJsonAssetResource("mapping/versions.json"));
Log.info(String.format("Loaded %d versions in %dms", Versions.getVersionIdMap().size(), (System.currentTimeMillis() - mappingStartLoadingTime)));
Resources.load();
Log.info("Loaded all resources!");

View File

@ -308,7 +308,7 @@ public class AssetsManager {
}
public String readStringAsset(String name) throws IOException {
return Util.readFile(new BufferedReader(readAsset(name)), true);
return Util.readReader(new BufferedReader(readAsset(name)), true);
}
public InputStream readAssetAsStream(String name) throws IOException {

View File

@ -14,7 +14,7 @@ public class Resources {
private static final HashBiMap<Version, AssetVersion> ASSETS_VERSIONS = HashBiMap.create();
public static void load() throws IOException {
JsonObject json = Util.readJsonAsset("mapping/resources.json");
JsonObject json = Util.readJsonAssetResource("mapping/resources.json");
JsonObject versions = json.getAsJsonObject("versions");
for (Map.Entry<String, JsonElement> versionEntry : versions.entrySet()) {

View File

@ -48,7 +48,7 @@ public class LocaleManager {
}
private static Language loadLanguage(String language) throws IOException {
return new Language(language, Util.readJsonAsset(String.format("locale/%s.json", language)));
return new Language(language, Util.readJsonAssetResource(String.format("locale/%s.json", language)));
}
public static void load(String language) {

View File

@ -19,7 +19,7 @@ public class ShaderUtil {
throw new ShaderLoadingException();
}
ARBShaderObjects.glShaderSourceARB(shaderId, Util.readAsset("/rendering/shader/" + shaderPath));
ARBShaderObjects.glShaderSourceARB(shaderId, Util.readAssetResource("/rendering/shader/" + shaderPath));
ARBShaderObjects.glCompileShaderARB(shaderId);
if (ARBShaderObjects.glGetObjectParameteriARB(shaderId, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) {

View File

@ -183,14 +183,14 @@ public final class Util {
HashMap<String, String> ret = new HashMap<>();
TarArchiveEntry entry;
while ((entry = tarArchiveInputStream.getNextTarEntry()) != null) {
ret.put(entry.getName(), readFile(new BufferedReader(new InputStreamReader(tarArchiveInputStream)), false));
ret.put(entry.getName(), readReader(new BufferedReader(new InputStreamReader(tarArchiveInputStream)), false));
}
tarArchiveInputStream.close();
return ret;
}
public static String readFile(BufferedReader reader, boolean closeStream) throws IOException {
public static String readReader(BufferedReader reader, boolean closeStream) throws IOException {
StringBuilder stringBuilder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
@ -216,18 +216,18 @@ public final class Util {
return ret;
}
public static JsonObject readJsonAsset(String path) throws IOException {
return readJsonAsset(path, Util.class);
public static JsonObject readJsonAssetResource(String path) throws IOException {
return readJsonAssetResource(path, Util.class);
}
public static JsonObject readJsonAsset(String path, Class<?> clazz) throws IOException {
InputStreamReader reader = readAsset(path, clazz);
public static JsonObject readJsonAssetResource(String path, Class<?> clazz) throws IOException {
InputStreamReader reader = readAssetResource(path, clazz);
JsonObject json = JsonParser.parseReader(reader).getAsJsonObject();
reader.close();
return json;
}
public static InputStreamReader readAsset(String path, Class<?> clazz) {
public static InputStreamReader readAssetResource(String path, Class<?> clazz) {
return new InputStreamReader(clazz.getResourceAsStream("/assets/" + path));
}
@ -307,8 +307,8 @@ public final class Util {
return result.substring(0, result.indexOf(second));
}
public static String readAsset(String path) throws IOException {
return readFile(new BufferedReader(readAsset(path, Util.class)), true);
public static String readAssetResource(String path) throws IOException {
return readReader(new BufferedReader(readAssetResource(path, Util.class)), true);
}
public static boolean doesStringContainsUppercaseLetters(String string) {