diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseLauncherActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseLauncherActivity.java index 447c376fe..a73ea744d 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseLauncherActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/BaseLauncherActivity.java @@ -20,6 +20,7 @@ import net.kdt.pojavlaunch.fragments.*; import net.kdt.pojavlaunch.multirt.MultiRTConfigDialog; import net.kdt.pojavlaunch.multirt.MultiRTUtils; import net.kdt.pojavlaunch.prefs.*; +import net.kdt.pojavlaunch.profiles.ProfileConstants; import net.kdt.pojavlaunch.tasks.*; import androidx.appcompat.app.AlertDialog; @@ -133,7 +134,7 @@ public abstract class BaseLauncherActivity extends BaseActivity { } public static String getVersionId(String input) { - Map lReleaseMaps = (Map)ExtraCore.getValue("release_table"); + Map lReleaseMaps = (Map)ExtraCore.getValue(ProfileConstants.RELEASE_TABLE); if(lReleaseMaps == null || lReleaseMaps.isEmpty()) return input; switch(input) { case "latest-release": diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java index d23d68a23..9053210c7 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/PojavLauncherActivity.java @@ -39,6 +39,7 @@ import net.kdt.pojavlaunch.fragments.LauncherFragment; import net.kdt.pojavlaunch.prefs.LauncherPreferences; import net.kdt.pojavlaunch.prefs.screens.LauncherPreferenceFragment; import net.kdt.pojavlaunch.profiles.ProfileAdapter; +import net.kdt.pojavlaunch.profiles.ProfileConstants; import net.kdt.pojavlaunch.profiles.ProfileEditor; import net.kdt.pojavlaunch.profiles.ProfileIconCache; import net.kdt.pojavlaunch.value.MinecraftAccount; @@ -273,7 +274,7 @@ public class PojavLauncherActivity extends BaseLauncherActivity } finally { basicVersionList = versions.toArray(new String[0]); - ExtraCore.setValue("lac_version_list",versions); + ExtraCore.setValue(ProfileConstants.VERSION_LIST,versions); } } private void pickAccount() { diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileConstants.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileConstants.java new file mode 100644 index 000000000..9e03b46ae --- /dev/null +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileConstants.java @@ -0,0 +1,9 @@ +package net.kdt.pojavlaunch.profiles; + +public class ProfileConstants { + /* ExtraCore constant: a HashMap for converting values such as latest-snapshot or latest-release to actual game version names */ + public static final String RELEASE_TABLE = "release_table"; + /* ExtraCore constant: an ArrayList of Strings, where each String is a Minecraft version name */ + public static final String VERSION_LIST= "lac_version_list"; + +} diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileEditor.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileEditor.java index 96cb9ece2..ec0beb0df 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileEditor.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/ProfileEditor.java @@ -114,7 +114,7 @@ public class ProfileEditor implements ExtraListener> { } javaRuntimeSpinner.setSelection(jvmIndex); rendererSpinner.setSelection(rendererIndex); - ExtraCore.addExtraListener("lac_version_list",this); + ExtraCore.addExtraListener(ProfileConstants.VERSION_LIST,this); profileNameView.setText(minecraftProfile.name); Bitmap profileIcon = ProfileIconCache.getCachedIcon(profile); if(profileIcon == null) { @@ -124,7 +124,7 @@ public class ProfileEditor implements ExtraListener> { if(minecraftProfile.lastVersionId != null && !"latest-release".equals(minecraftProfile.lastVersionId) && !"latest-snapshot".equals(minecraftProfile.lastVersionId)) selectedVersionId = minecraftProfile.lastVersionId; else if(minecraftProfile.lastVersionId != null) { - Map releaseTable = (Map)ExtraCore.getValue("release_table"); + Map releaseTable = (Map)ExtraCore.getValue(ProfileConstants.RELEASE_TABLE); if(releaseTable != null) { switch (minecraftProfile.lastVersionId) { case "latest-release": @@ -141,7 +141,7 @@ public class ProfileEditor implements ExtraListener> { selectedVersionId = PojavLauncherActivity.basicVersionList[0]; } } - ArrayList versions = (ArrayList) ExtraCore.getValue("lac_version_list"); + ArrayList versions = (ArrayList) ExtraCore.getValue(ProfileConstants.VERSION_LIST); BaseLauncherActivity.updateVersionSpinner(context,versions,versionSpinner, selectedVersionId); dialog.show(); return true; @@ -180,7 +180,7 @@ public class ProfileEditor implements ExtraListener> { destroy(dialog); } public void destroy(@NonNull DialogInterface dialog) { - ExtraCore.removeExtraListenerFromValue("lac_version_list",this); + ExtraCore.removeExtraListenerFromValue(ProfileConstants.VERSION_LIST,this); editingProfile = null; selectedVersionId = null; } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/StringCRC64.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/StringCRC64.java deleted file mode 100644 index 7a7fd565d..000000000 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/profiles/StringCRC64.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.kdt.pojavlaunch.profiles; - -import java.nio.charset.StandardCharsets; - -public class StringCRC64 { - private final static long POLY = 0xc96c5795d7870f42L; // ECMA-182 - private final static long[][] table; - static - { - table = new long[8][256]; - - for (int n = 0; n < 256; n++) - { - long crc = n; - for (int k = 0; k < 8; k++) - { - if ((crc & 1) == 1) - { - crc = (crc >>> 1) ^ POLY; - } - else - { - crc = (crc >>> 1); - } - } - table[0][n] = crc; - } - for (int n = 0; n < 256; n++) - { - long crc = table[0][n]; - for (int k = 1; k < 8; k++) - { - crc = table[0][(int) (crc & 0xff)] ^ (crc >>> 8); - table[k][n] = crc; - } - } - } - public static long strhash(String str) { - byte[] b = str.getBytes(StandardCharsets.US_ASCII); - long value = 0; - int idx = 0; - int len = b.length; - while (len >= 8) - { - value = table[7][(int) (value & 0xff ^ (b[idx] & 0xff))] - ^ table[6][(int) ((value >>> 8) & 0xff ^ (b[idx + 1] & 0xff))] - ^ table[5][(int) ((value >>> 16) & 0xff ^ (b[idx + 2] & 0xff))] - ^ table[4][(int) ((value >>> 24) & 0xff ^ (b[idx + 3] & 0xff))] - ^ table[3][(int) ((value >>> 32) & 0xff ^ (b[idx + 4] & 0xff))] - ^ table[2][(int) ((value >>> 40) & 0xff ^ (b[idx + 5] & 0xff))] - ^ table[1][(int) ((value >>> 48) & 0xff ^ (b[idx + 6] & 0xff))] - ^ table[0][(int) ((value >>> 56) ^ b[idx + 7] & 0xff)]; - idx += 8; - len -= 8; - } - while (len > 0) - { - value = table[0][(int) ((value ^ b[idx]) & 0xff)] ^ (value >>> 8); - idx++; - len--; - } - return ~value; - } -} diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/RefreshVersionListTask.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/RefreshVersionListTask.java index 9239efa00..e040215e4 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/RefreshVersionListTask.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/tasks/RefreshVersionListTask.java @@ -18,6 +18,7 @@ import net.kdt.pojavlaunch.extra.ExtraListener; import net.kdt.pojavlaunch.multirt.MultiRTUtils; import net.kdt.pojavlaunch.multirt.RTSpinnerAdapter; import net.kdt.pojavlaunch.prefs.*; +import net.kdt.pojavlaunch.profiles.ProfileConstants; import net.kdt.pojavlaunch.utils.*; import net.kdt.pojavlaunch.value.PerVersionConfig; @@ -43,8 +44,8 @@ public class RefreshVersionListTask extends AsyncTask result) { super.onPostExecute(result); - ExtraCore.setValue("lac_version_list",result); + ExtraCore.setValue(ProfileConstants.VERSION_LIST,result); } private ArrayList filter(JMinecraftVersionList.Version[] list1, File[] list2) {