refactor: move to Java 7 style for diamond/multi catch

also brings in Base64 package via gradle rather than a copy/paste
This commit is contained in:
Ryan Dowling 2019-06-12 21:29:46 +10:00
parent 5b4156b44e
commit 033e0ffd73
No known key found for this signature in database
GPG key ID: 5539FCDB88950EFD
58 changed files with 230 additions and 2276 deletions

18
.idea/gradle.xml Normal file
View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
<option name="useAutoImport" value="true" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>
</project>

7
.idea/misc.xml Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

7
.idea/vcs.xml Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/bin" vcs="Git" />
</component>
</project>

View file

@ -27,6 +27,7 @@ dependencies {
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.tukaani:xz:1.5'
compile 'com.mojang:authlib:1.5.21'
implementation 'net.iharder:base64:2.3.9'
testCompile 'junit:junit:4.11'
}

View file

@ -1,5 +1,6 @@
#Wed Jun 12 21:23:41 AEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

View file

@ -61,7 +61,6 @@ import com.atlauncher.gui.theme.Theme;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.utils.HTMLUtils;
import com.atlauncher.utils.Java;
import com.atlauncher.utils.Java;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
@ -191,9 +190,7 @@ public class App {
public static Theme THEME = Theme.DEFAULT_THEME;
static {
/**
* Sets up where all uncaught exceptions go to.
*/
// Sets up where all uncaught exceptions go to.
Thread.setDefaultUncaughtExceptionHandler(new ExceptionStrainer());
}
@ -282,9 +279,9 @@ public class App {
+ "be placed in it's own folder with nothing else in it.<br/><br/>Are you 100% sure "
+ "that's what you've done?");
int returnOption = DialogManager.optionDialog().setParent(null).setTitle("Warning")
.setContent(content).addOption("Yes It's Fine", true)
.addOption("Whoops. I'll Change That Now").setType(DialogManager.ERROR).show();
int returnOption = DialogManager.optionDialog().setTitle("Warning").setContent(content)
.addOption("Yes It's Fine", true).addOption("Whoops. I'll Change That Now")
.setType(DialogManager.ERROR).show();
if (returnOption != 0) {
System.exit(0);

View file

@ -28,7 +28,7 @@ import com.atlauncher.thread.LoggingThread;
import com.atlauncher.utils.Utils;
public final class LogManager {
private static final BlockingQueue<LogEvent> queue = new ArrayBlockingQueue<LogEvent>(128);
private static final BlockingQueue<LogEvent> queue = new ArrayBlockingQueue<>(128);
public static boolean showDebug = false;
/**

View file

@ -33,7 +33,7 @@ public class Update {
File temporaryUpdate = new File(temporaryUpdatePath);
Utils.copyFile(temporaryUpdate, launcher.getParentFile());
List<String> arguments = new ArrayList<String>();
List<String> arguments = new ArrayList<>();
if (OS.isMac() && new File(new File(System.getProperty("user.dir")).getParentFile().getParentFile(), "MacOS")
.exists()) {

View file

@ -28,7 +28,6 @@ import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@ -153,8 +152,8 @@ public class Account implements Serializable {
this.uuid = uuid;
this.remember = remember;
this.isReal = true;
this.collapsedPacks = new ArrayList<String>();
this.collapsedInstances = new ArrayList<String>();
this.collapsedPacks = new ArrayList<>();
this.collapsedInstances = new ArrayList<>();
}
/**
@ -169,8 +168,8 @@ public class Account implements Serializable {
this.uuid = UUID.randomUUID() + "";
this.remember = false;
this.isReal = false;
this.collapsedPacks = new ArrayList<String>();
this.collapsedInstances = new ArrayList<String>();
this.collapsedPacks = new ArrayList<>();
this.collapsedInstances = new ArrayList<>();
}
/**
@ -449,7 +448,7 @@ public class Account implements Serializable {
*/
public List<String> getCollapsedPacks() {
if (this.collapsedPacks == null) {
this.collapsedPacks = new ArrayList<String>();
this.collapsedPacks = new ArrayList<>();
}
return this.collapsedPacks;
}
@ -462,7 +461,7 @@ public class Account implements Serializable {
*/
public List<String> getCollapsedInstances() {
if (this.collapsedInstances == null) {
this.collapsedInstances = new ArrayList<String>();
this.collapsedInstances = new ArrayList<>();
}
return this.collapsedInstances;
}
@ -523,8 +522,6 @@ public class Account implements Serializable {
dialog.setReturnValue(true);
}
}
} catch (MalformedURLException e) {
LogManager.logStackTrace(e);
} catch (IOException e) {
LogManager.logStackTrace(e);
}

View file

@ -55,7 +55,7 @@ public class Downloadable {
public Downloadable(String url, File file, String hash, int size, InstanceInstaller instanceInstaller,
boolean isATLauncherDownload, File copyTo, boolean actuallyCopy) {
if (isATLauncherDownload) {
this.servers = new ArrayList<Server>(App.settings.getServers());
this.servers = new ArrayList<>(App.settings.getServers());
this.server = this.servers.get(0);
for (Server server : this.servers) {
if (server.getName().equals(App.settings.getServer().getName())) {

View file

@ -38,9 +38,9 @@ import javax.swing.SwingConstants;
import com.atlauncher.App;
import com.atlauncher.LogManager;
import com.atlauncher.gui.components.CollapsiblePanel;
import com.atlauncher.utils.Base64;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import net.iharder.Base64;
/**
* @author Kihira
@ -133,7 +133,7 @@ public class DropboxSync extends SyncAbstract {
if (backupDir.exists()) {
File[] files = backupDir.listFiles();
if (files != null) {
List<String> backupList = new ArrayList<String>();
List<String> backupList = new ArrayList<>();
for (File file : files) {
if (file.getName().matches(".*\\.zip")) {
backupList.add(file.getName());

View file

@ -136,7 +136,7 @@ public class HashableDownloadable extends Downloadable {
}
protected void saveFileHash(File fileToHash) {
HashMap<String, String> localHash = new HashMap<String, String>();
HashMap<String, String> localHash = new HashMap<>();
localHash.put("sha1", Utils.getSHA1(fileToHash == null ? this.file : fileToHash));
localHash.put("etag", this.getConnection().getHeaderField("ETag"));

View file

@ -444,7 +444,7 @@ public class Instance implements Cloneable {
* this instance or null if none
*/
public List<DisableableMod> getInstalledSelectedMods() {
List<DisableableMod> mods = new ArrayList<DisableableMod>();
List<DisableableMod> mods = new ArrayList<>();
for (DisableableMod mod : this.mods) {
if (mod.wasSelected()) {
@ -598,7 +598,7 @@ public class Instance implements Cloneable {
*/
public void ignoreUpdate() {
if (this.ignoredUpdates == null) {
this.ignoredUpdates = new ArrayList<String>();
this.ignoredUpdates = new ArrayList<>();
}
String version;
@ -655,7 +655,7 @@ public class Instance implements Cloneable {
List<DisableableMod> selectedMods = this.getInstalledSelectedMods();
if (selectedMods.size() == 0) {
List<DisableableMod> mods = new ArrayList<DisableableMod>();
List<DisableableMod> mods = new ArrayList<>();
for (DisableableMod mod : this.mods) {
mod.setWasSelected(true);
@ -672,7 +672,7 @@ public class Instance implements Cloneable {
// changes to the way libraries are saved and loaded from disk
if (this.dataVersion < 2) {
this.libraries = new ArrayList<String>();
this.libraries = new ArrayList<>();
if (this.librariesNeeded != null) {
for (String filePath : this.librariesNeeded.split(",")) {
@ -1445,7 +1445,7 @@ public class Instance implements Cloneable {
App.settings.getParent().setVisible(false);
}
// Create a note of worlds for auto backup if enabled
HashMap<String, Long> preWorldList = new HashMap<String, Long>();
HashMap<String, Long> preWorldList = new HashMap<>();
if (App.settings.isAdvancedBackupsEnabled() && App.settings.getAutoBackup()) {
if (getSavesDirectory().exists()) {
File[] files = getSavesDirectory().listFiles();
@ -1633,7 +1633,7 @@ public class Instance implements Cloneable {
}
public String addTimePlayed(int time, String version) {
Map<String, Object> request = new HashMap<String, Object>();
Map<String, Object> request = new HashMap<>();
if (App.settings.enableLeaderboards()) {
request.put("username", App.settings.getAccount().getMinecraftUsername());
@ -1681,7 +1681,7 @@ public class Instance implements Cloneable {
}
public List<String> getCustomMods(Type type) {
List<String> customMods = new ArrayList<String>();
List<String> customMods = new ArrayList<>();
for (DisableableMod mod : this.mods) {
if (mod.isUserAdded() && mod.getType() == type) {
customMods.add(mod.getFilename());
@ -1691,7 +1691,7 @@ public class Instance implements Cloneable {
}
public List<DisableableMod> getCustomDisableableMods() {
List<DisableableMod> customMods = new ArrayList<DisableableMod>();
List<DisableableMod> customMods = new ArrayList<>();
for (DisableableMod mod : this.mods) {
if (mod.isUserAdded()) {
customMods.add(mod);
@ -1733,7 +1733,7 @@ public class Instance implements Cloneable {
}
public ArrayList<String> getInstalledOptionalModNames() {
ArrayList<String> installedOptionalMods = new ArrayList<String>();
ArrayList<String> installedOptionalMods = new ArrayList<>();
for (DisableableMod mod : this.getInstalledMods()) {
if (mod.isOptional() && !mod.isUserAdded()) {
@ -1745,12 +1745,12 @@ public class Instance implements Cloneable {
}
public Map<String, Object> getShareCodeData() {
Map<String, Object> data = new HashMap<String, Object>();
Map<String, Object> mods = new HashMap<String, Object>();
List<Map<String, Object>> optional = new ArrayList<Map<String, Object>>();
Map<String, Object> data = new HashMap<>();
Map<String, Object> mods = new HashMap<>();
List<Map<String, Object>> optional = new ArrayList<>();
for (String mod : this.getInstalledOptionalModNames()) {
Map<String, Object> modInfo = new HashMap<String, Object>();
Map<String, Object> modInfo = new HashMap<>();
modInfo.put("name", mod);
modInfo.put("selected", true);
optional.add(modInfo);

View file

@ -31,7 +31,7 @@ import com.atlauncher.LogManager;
public enum Language {
INSTANCE, Language;
private final Map<String, Properties> langs = new HashMap<String, Properties>();
private final Map<String, Properties> langs = new HashMap<>();
private volatile String current;
private Language() {

View file

@ -48,8 +48,8 @@ public class Pack {
private String discordInviteURL;
private String supportURL;
private String websiteURL;
private List<String> testers = new ArrayList<String>();
private List<String> allowedPlayers = new ArrayList<String>();
private List<String> testers = new ArrayList<>();
private List<String> allowedPlayers = new ArrayList<>();
private String json; // The JSON for a version of the pack
private String jsonVersion; // The version the JSON above is for
@ -296,7 +296,7 @@ public class Pack {
}
public String addInstall(String version) {
Map<String, Object> request = new HashMap<String, Object>();
Map<String, Object> request = new HashMap<>();
request.put("username", App.settings.getAccount().getMinecraftUsername());
request.put("version", version);
@ -310,7 +310,7 @@ public class Pack {
}
public String addServerInstall(String version) {
Map<String, Object> request = new HashMap<String, Object>();
Map<String, Object> request = new HashMap<>();
request.put("username", App.settings.getAccount().getMinecraftUsername());
request.put("version", version);
@ -324,7 +324,7 @@ public class Pack {
}
public String addUpdate(String version) {
Map<String, Object> request = new HashMap<String, Object>();
Map<String, Object> request = new HashMap<>();
request.put("username", App.settings.getAccount().getMinecraftUsername());
request.put("version", version);

View file

@ -158,8 +158,8 @@ public class Settings {
private JFrame parent; // Parent JFrame of the actual Launcher
private Properties properties = new Properties(); // Properties to store everything in
private LauncherConsole console; // The Launcher's Console
private List<Server> servers = new ArrayList<Server>(); // Servers for the Launcher
private List<Server> triedServers = new ArrayList<Server>(); // Servers tried to connect to
private List<Server> servers = new ArrayList<>(); // Servers for the Launcher
private List<Server> triedServers = new ArrayList<>(); // Servers tried to connect to
private InstancesTab instancesPanel; // The instances panel
private NewsTab newsPanel; // The news panel
private PacksTab vanillaPacksPanel; // The vanilla packs panel
@ -632,11 +632,7 @@ public class Settings {
try {
this.latestLauncherVersion = Gsons.DEFAULT.fromJson(new FileReader(new File(this.jsonDir, "version.json")),
LauncherVersion.class);
} catch (JsonSyntaxException e) {
LogManager.logStackTrace("Exception when loading latest launcher version!", e);
} catch (JsonIOException e) {
LogManager.logStackTrace("Exception when loading latest launcher version!", e);
} catch (FileNotFoundException e) {
} catch (JsonSyntaxException | FileNotFoundException | JsonIOException e) {
LogManager.logStackTrace("Exception when loading latest launcher version!", e);
}
@ -666,7 +662,7 @@ public class Settings {
}
public void runUpdate(String currentPath, String temporaryUpdatePath) {
List<String> arguments = new ArrayList<String>();
List<String> arguments = new ArrayList<>();
String path = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
if (OS.isWindows()) {
@ -719,7 +715,7 @@ public class Settings {
this.offlineMode = true;
return null;
}
ArrayList<Downloadable> downloads = new ArrayList<Downloadable>();
ArrayList<Downloadable> downloads = new ArrayList<>();
for (DownloadableFile file : this.launcherFiles) {
if (file.isLauncher()) {
continue;
@ -1153,8 +1149,6 @@ public class Settings {
this.server = getServerByName("Auto"); // Server not found, use default of Auto
this.originalServer = this.server;
}
} catch (FileNotFoundException e) {
LogManager.logStackTrace(e);
} catch (IOException e) {
LogManager.logStackTrace(e);
}
@ -1231,8 +1225,6 @@ public class Settings {
if (this.daysOfLogsToKeep < 1 || this.daysOfLogsToKeep > 30) {
this.daysOfLogsToKeep = 7;
}
} catch (FileNotFoundException e) {
LogManager.logStackTrace(e);
} catch (IOException e) {
LogManager.logStackTrace(e);
}
@ -1456,8 +1448,6 @@ public class Settings {
this.autoBackup = Boolean.parseBoolean(properties.getProperty("autobackup", "false"));
this.notifyBackup = Boolean.parseBoolean(properties.getProperty("notifybackup", "true"));
this.dropboxFolderLocation = properties.getProperty("dropboxlocation", "");
} catch (FileNotFoundException e) {
LogManager.logStackTrace(e);
} catch (IOException e) {
LogManager.logStackTrace(e);
}
@ -1517,8 +1507,6 @@ public class Settings {
properties.setProperty("notifybackup", this.notifyBackup ? "true" : "false");
properties.setProperty("dropboxlocation", this.dropboxFolderLocation);
this.properties.store(new FileOutputStream(propertiesFile), Constants.LAUNCHER_NAME + " Settings");
} catch (FileNotFoundException e) {
LogManager.logStackTrace(e);
} catch (IOException e) {
LogManager.logStackTrace(e);
}
@ -1572,7 +1560,7 @@ public class Settings {
* connections to download files
*/
private void setupServers() {
this.servers = new ArrayList<Server>(Arrays.asList(Constants.SERVERS));
this.servers = new ArrayList<>(Arrays.asList(Constants.SERVERS));
}
public boolean disableServerGetNext() {
@ -1589,7 +1577,7 @@ public class Settings {
public void clearTriedServers() {
if (this.triedServers.size() != 0) {
this.triedServers = new ArrayList<Server>(); // Clear the list
this.triedServers = new ArrayList<>(); // Clear the list
this.server = this.originalServer;
}
}
@ -1619,15 +1607,9 @@ public class Settings {
this.news = Gsons.DEFAULT.fromJson(in, type);
in.close();
} catch (JsonSyntaxException e) {
} catch (JsonIOException | UnsupportedEncodingException | FileNotFoundException e) {
LogManager.logStackTrace(e);
} catch (JsonIOException e) {
LogManager.logStackTrace(e);
} catch (FileNotFoundException e) {
LogManager.logStackTrace(e);
} catch (UnsupportedEncodingException e) {
LogManager.logStackTrace(e);
} catch (IOException e) {
} catch (JsonSyntaxException | IOException e) {
LogManager.logStackTrace(e);
}
LogManager.debug("Finished loading news");
@ -1639,7 +1621,7 @@ public class Settings {
private void loadMinecraftVersions() {
LogManager.debug("Loading Minecraft versions");
this.minecraftVersions = new HashMap<String, MinecraftVersion>();
this.minecraftVersions = new HashMap<>();
try {
java.lang.reflect.Type type = new TypeToken<List<MinecraftVersion>>() {
@ -1655,11 +1637,7 @@ public class Settings {
for (MinecraftVersion mv : list) {
this.minecraftVersions.put(mv.getVersion(), mv);
}
} catch (JsonSyntaxException e) {
LogManager.logStackTrace(e);
} catch (JsonIOException e) {
LogManager.logStackTrace(e);
} catch (FileNotFoundException e) {
} catch (JsonSyntaxException | FileNotFoundException | JsonIOException e) {
LogManager.logStackTrace(e);
}
LogManager.debug("Finished loading Minecraft versions");
@ -1674,11 +1652,7 @@ public class Settings {
java.lang.reflect.Type type = new TypeToken<List<Pack>>() {
}.getType();
this.packs = Gsons.DEFAULT.fromJson(new FileReader(new File(getJSONDir(), "packs.json")), type);
} catch (JsonSyntaxException e) {
LogManager.logStackTrace(e);
} catch (JsonIOException e) {
LogManager.logStackTrace(e);
} catch (FileNotFoundException e) {
} catch (JsonSyntaxException | FileNotFoundException | JsonIOException e) {
LogManager.logStackTrace(e);
}
LogManager.debug("Finished loading packs");
@ -1695,9 +1669,7 @@ public class Settings {
java.lang.reflect.Type type = new TypeToken<List<PackUsers>>() {
}.getType();
packUsers = Gsons.DEFAULT.fromJson(download.getContents(), type);
} catch (JsonSyntaxException e) {
LogManager.logStackTrace(e);
} catch (JsonIOException e) {
} catch (JsonSyntaxException | JsonIOException e) {
LogManager.logStackTrace(e);
}
if (packUsers == null) {
@ -1715,7 +1687,7 @@ public class Settings {
*/
private void loadInstances() {
LogManager.debug("Loading instances");
this.instances = new ArrayList<Instance>(); // Reset the instances list
this.instances = new ArrayList<>(); // Reset the instances list
if (instancesDataFile.exists()) {
try {
FileInputStream in = new FileInputStream(instancesDataFile);
@ -1846,9 +1818,7 @@ public class Settings {
}
} catch (EOFException e) {
// Don't log this, it always happens when it gets to the end of the file
} catch (IOException e) {
LogManager.logStackTrace("Exception while trying to read accounts in from file.", e);
} catch (ClassNotFoundException e) {
} catch (IOException | ClassNotFoundException e) {
LogManager.logStackTrace("Exception while trying to read accounts in from file.", e);
} finally {
try {
@ -1911,7 +1881,7 @@ public class Settings {
*/
private void loadCheckingServers() {
LogManager.debug("Loading servers to check");
this.checkingServers = new ArrayList<MinecraftServer>(); // Reset the list
this.checkingServers = new ArrayList<>(); // Reset the list
if (checkingServersFile.exists()) {
FileReader fileReader = null;
try {
@ -2004,7 +1974,7 @@ public class Settings {
* @return The Packs available in the Launcher sorted alphabetically
*/
public List<Pack> getPacksSortedAlphabetically(boolean isFeatured, boolean isVanilla) {
List<Pack> packs = new LinkedList<Pack>();
List<Pack> packs = new LinkedList<>();
for (Pack pack : this.packs) {
if (isFeatured) {
@ -2039,7 +2009,7 @@ public class Settings {
* @return The Packs available in the Launcher sorted by position
*/
public List<Pack> getPacksSortedPositionally(boolean isFeatured, boolean isVanilla) {
List<Pack> packs = new LinkedList<Pack>();
List<Pack> packs = new LinkedList<>();
for (Pack pack : this.packs) {
if (isFeatured) {
@ -2062,8 +2032,7 @@ public class Settings {
Collections.sort(packs, new Comparator<Pack>() {
@Override
public int compare(Pack result1, Pack result2) {
return (result1.getPosition() < result2.getPosition()) ? -1
: ((result1.getPosition() == result2.getPosition()) ? 0 : 1);
return Integer.compare(result1.getPosition(), result2.getPosition());
}
});
return packs;
@ -2122,7 +2091,7 @@ public class Settings {
* @return The Instances available in the Launcher sorted alphabetically
*/
public ArrayList<Instance> getInstancesSorted() {
ArrayList<Instance> instances = new ArrayList<Instance>(this.instances);
ArrayList<Instance> instances = new ArrayList<>(this.instances);
Collections.sort(instances, new Comparator<Instance>() {
@Override
public int compare(Instance result1, Instance result2) {
@ -2265,7 +2234,7 @@ public class Settings {
* @return The Languages available in the Launcher
*/
public List<String> getLanguages() {
List<String> langs = new LinkedList<String>();
List<String> langs = new LinkedList<>();
for (File file : this.getLanguagesDir().listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
@ -3116,18 +3085,22 @@ public class Settings {
}
if (this.proxy == null) {
Type type;
if (this.proxyType.equals("HTTP")) {
type = Proxy.Type.HTTP;
} else if (this.proxyType.equals("SOCKS")) {
type = Proxy.Type.SOCKS;
} else if (this.proxyType.equals("DIRECT")) {
type = Proxy.Type.DIRECT;
} else {
// Oh noes, problem!
LogManager.warn("Tried to set proxy type to " + this.proxyType + " which is not valid! Proxy support "
switch (this.proxyType) {
case "HTTP":
type = Type.HTTP;
break;
case "SOCKS":
type = Type.SOCKS;
break;
case "DIRECT":
type = Type.DIRECT;
break;
default:
// Oh noes, problem!
LogManager.warn("Tried to set proxy type to " + this.proxyType + " which is not valid! Proxy support "
+ "disabled!");
this.enableProxy = false;
return null;
this.enableProxy = false;
return null;
}
this.proxy = new Proxy(type, new InetSocketAddress(this.proxyHost, this.proxyPort));
}
@ -3140,18 +3113,22 @@ public class Settings {
}
if (this.proxy == null) {
Type type;
if (this.proxyType.equals("HTTP")) {
type = Proxy.Type.HTTP;
} else if (this.proxyType.equals("SOCKS")) {
type = Proxy.Type.SOCKS;
} else if (this.proxyType.equals("DIRECT")) {
type = Proxy.Type.DIRECT;
} else {
// Oh noes, problem!
LogManager.warn("Tried to set proxy type to " + this.proxyType + " which is not valid! Proxy support "
switch (this.proxyType) {
case "HTTP":
type = Type.HTTP;
break;
case "SOCKS":
type = Type.SOCKS;
break;
case "DIRECT":
type = Type.DIRECT;
break;
default:
// Oh noes, problem!
LogManager.warn("Tried to set proxy type to " + this.proxyType + " which is not valid! Proxy support "
+ "disabled!");
this.enableProxy = false;
return Proxy.NO_PROXY;
this.enableProxy = false;
return Proxy.NO_PROXY;
}
this.proxy = new Proxy(type, new InetSocketAddress(this.proxyHost, this.proxyPort));
}

View file

@ -29,7 +29,7 @@ import com.atlauncher.gui.components.CollapsiblePanel;
* @author Kihira
*/
public abstract class SyncAbstract {
public static final HashMap<String, SyncAbstract> syncList = new HashMap<String, SyncAbstract>();
public static final HashMap<String, SyncAbstract> syncList = new HashMap<>();
private final String syncName;
public SyncAbstract(String name) {

View file

@ -136,10 +136,10 @@ public class Version {
* exist. If they don't exist, having these here will ensure no NPE's.
*/
public Version() {
this.libraries = new ArrayList<Library>();
this.colours = new HashMap<String, String>();
this.mods = new ArrayList<Mod>();
this.actions = new ArrayList<Action>();
this.libraries = new ArrayList<>();
this.colours = new HashMap<>();
this.mods = new ArrayList<>();
this.actions = new ArrayList<>();
}
/**
@ -251,7 +251,7 @@ public class Version {
}
public List<Mod> getClientInstallMods() {
List<Mod> mods = new ArrayList<Mod>();
List<Mod> mods = new ArrayList<>();
for (Mod mod : this.mods) {
if (mod.installOnClient()) {
mods.add(mod);
@ -261,7 +261,7 @@ public class Version {
}
public List<Mod> getServerInstallMods() {
List<Mod> mods = new ArrayList<Mod>();
List<Mod> mods = new ArrayList<>();
for (Mod mod : this.mods) {
if (mod.installOnServer()) {
mods.add(mod);

View file

@ -139,7 +139,7 @@ public class FabricLoader implements Loader {
@Override
public List<Downloadable> getDownloadableLibraries() {
List<Downloadable> librariesToDownload = new ArrayList<Downloadable>();
List<Downloadable> librariesToDownload = new ArrayList<>();
// We use Fabric installer for servers, so we don't need to worry about
// libraries
@ -223,7 +223,7 @@ public class FabricLoader implements Loader {
}
try {
List<String> arguments = new ArrayList<String>();
List<String> arguments = new ArrayList<>();
String path = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
arguments.add(path);
arguments.add("-jar");
@ -259,7 +259,7 @@ public class FabricLoader implements Loader {
@Override
public List<String> getLibraries() {
FabricInstallProfile installProfile = this.getInstallProfile();
List<String> libraries = new ArrayList<String>();
List<String> libraries = new ArrayList<>();
// We use Fabric installer for servers, so we don't need to worry about
// libraries
@ -274,7 +274,7 @@ public class FabricLoader implements Loader {
@Override
public List<String> getArguments() {
List<String> arguments = new ArrayList<String>();
List<String> arguments = new ArrayList<>();
if (this.getInstallProfile().getArguments() != null
|| this.getInstallProfile().getArguments().containsKey("game")

View file

@ -59,7 +59,7 @@ public class Forge113Loader extends ForgeLoader {
@Override
public List<Downloadable> getDownloadableLibraries() {
List<Downloadable> librariesToDownload = new ArrayList<Downloadable>();
List<Downloadable> librariesToDownload = new ArrayList<>();
File librariesDirectory = this.instanceInstaller.isServer() ? this.instanceInstaller.getLibrariesDirectory()
: App.settings.getGameLibrariesDir();
@ -141,7 +141,7 @@ public class Forge113Loader extends ForgeLoader {
}
public List<String> getLibraries() {
List<String> libraries = new ArrayList<String>();
List<String> libraries = new ArrayList<>();
if (this.instanceInstaller.isServer()) {
for (Library library : this.getInstallProfile().getLibraries()) {

View file

@ -138,7 +138,7 @@ public class ForgeLoader implements Loader {
@Override
public List<Downloadable> getDownloadableLibraries() {
List<Downloadable> librariesToDownload = new ArrayList<Downloadable>();
List<Downloadable> librariesToDownload = new ArrayList<>();
ForgeInstallProfile installProfile = this.getInstallProfile();
@ -207,7 +207,7 @@ public class ForgeLoader implements Loader {
@Override
public List<String> getLibraries() {
ForgeInstallProfile installProfile = this.getInstallProfile();
List<String> libraries = new ArrayList<String>();
List<String> libraries = new ArrayList<>();
for (Library library : installProfile.getLibraries()) {
if (this.instanceInstaller.isServer() && library.getName().equals(installProfile.getInstall().getPath())) {
@ -222,7 +222,7 @@ public class ForgeLoader implements Loader {
@Override
public List<String> getArguments() {
List<String> arguments = new ArrayList<String>();
List<String> arguments = new ArrayList<>();
for (String argument : this.getInstallProfile().getVersionInfo().getMinecraftArguments().split(" ")) {
arguments.add(argument);

View file

@ -89,7 +89,7 @@ public class Processor {
return;
}
List<URL> classpath = new ArrayList<URL>();
List<URL> classpath = new ArrayList<>();
classpath.add(jarPath.toURI().toURL());
for (String classpathItem : this.getClasspath()) {
@ -106,7 +106,7 @@ public class Processor {
classpath.add(classpathFile.toURI().toURL());
}
List<String> args = new ArrayList<String>();
List<String> args = new ArrayList<>();
for (String arg : this.getArgs()) {
LogManager.debug("Processing argument " + arg);

View file

@ -30,7 +30,7 @@ public class AssetIndex {
}
public HashSet<AssetObject> getUniqueObjects() {
return new HashSet<AssetObject>(this.objects.values());
return new HashSet<>(this.objects.values());
}
public boolean isVirtual() {

View file

@ -35,7 +35,7 @@ public class DownloadsTypeAdapter implements JsonDeserializer<Downloads> {
public Downloads deserialize(JsonElement json, Type type, JsonDeserializationContext context)
throws JsonParseException {
DownloadsItem artifact = null;
Map<String, DownloadsItem> classifiers = new HashMap<String, DownloadsItem>();
Map<String, DownloadsItem> classifiers = new HashMap<>();
final JsonObject rootJsonObject = json.getAsJsonObject();

View file

@ -38,7 +38,7 @@ public class EnumTypeAdapterFactory implements TypeAdapterFactory {
if (!type.getRawType().isEnum()) {
return null;
}
final Map<String, T> map = new HashMap<String, T>();
final Map<String, T> map = new HashMap<>();
for (T c : (T[]) type.getRawType().getEnumConstants()) {
map.put(c.toString().toLowerCase(Locale.US), c);
}

View file

@ -33,8 +33,8 @@ public class MojangArgumentsTypeAdapter implements JsonDeserializer<MojangArgume
@Override
public MojangArguments deserialize(JsonElement json, Type type, JsonDeserializationContext context)
throws JsonParseException {
List<ArgumentRule> game = new ArrayList<ArgumentRule>();
List<ArgumentRule> jvm = new ArrayList<ArgumentRule>();
List<ArgumentRule> game = new ArrayList<>();
List<ArgumentRule> jvm = new ArrayList<>();
final JsonObject rootJsonObject = json.getAsJsonObject();
final JsonArray gameArray = rootJsonObject.getAsJsonArray("game");

View file

@ -21,7 +21,7 @@ import java.io.IOException;
import com.atlauncher.Gsons;
import com.atlauncher.annot.Json;
import com.atlauncher.utils.Base64;
import net.iharder.Base64;
@Json
public class UserPropertyRaw {

View file

@ -25,7 +25,7 @@ import javax.swing.SwingUtilities;
import com.atlauncher.evnt.listener.ConsoleCloseListener;
public final class ConsoleCloseManager {
private static final List<ConsoleCloseListener> listeners = new LinkedList<ConsoleCloseListener>();
private static final List<ConsoleCloseListener> listeners = new LinkedList<>();
private ConsoleCloseManager() {
}

View file

@ -25,7 +25,7 @@ import javax.swing.SwingUtilities;
import com.atlauncher.evnt.listener.ConsoleOpenListener;
public final class ConsoleOpenManager {
private static final List<ConsoleOpenListener> listeners = new LinkedList<ConsoleOpenListener>();
private static final List<ConsoleOpenListener> listeners = new LinkedList<>();
public static synchronized void addListener(ConsoleOpenListener listener) {
listeners.add(listener);

View file

@ -25,7 +25,7 @@ import javax.swing.SwingUtilities;
import com.atlauncher.evnt.listener.RelocalizationListener;
public final class RelocalizationManager {
private static final List<RelocalizationListener> listeners = new LinkedList<RelocalizationListener>();
private static final List<RelocalizationListener> listeners = new LinkedList<>();
public static synchronized void addListener(RelocalizationListener listener) {
listeners.add(listener);

View file

@ -26,7 +26,7 @@ import com.atlauncher.evnt.listener.ReskinListener;
@Deprecated
public final class ReskinManager {
private static final List<ReskinListener> listeners = new LinkedList<ReskinListener>();
private static final List<ReskinListener> listeners = new LinkedList<>();
public static synchronized void addListener(ReskinListener listener) {
listeners.add(listener);

View file

@ -25,7 +25,7 @@ import javax.swing.SwingUtilities;
import com.atlauncher.evnt.listener.SettingsListener;
public final class SettingsManager {
private static final List<SettingsListener> listeners = new LinkedList<SettingsListener>();
private static final List<SettingsListener> listeners = new LinkedList<>();
public static synchronized void addListener(SettingsListener listener) {
listeners.add(listener);

View file

@ -25,7 +25,7 @@ import javax.swing.SwingUtilities;
import com.atlauncher.evnt.listener.TabChangeListener;
public final class TabChangeManager {
private static final List<TabChangeListener> listeners = new LinkedList<TabChangeListener>();
private static final List<TabChangeListener> listeners = new LinkedList<>();
public static synchronized void addListener(TabChangeListener listener) {
listeners.add(listener);

View file

@ -26,8 +26,6 @@ import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.WindowConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import com.atlauncher.App;
import com.atlauncher.LogManager;
@ -36,7 +34,6 @@ import com.atlauncher.data.Pack;
import com.atlauncher.data.PackVersion;
import com.atlauncher.evnt.listener.RelocalizationListener;
import com.atlauncher.evnt.manager.RelocalizationManager;
import com.atlauncher.evnt.manager.TabChangeManager;
import com.atlauncher.gui.components.LauncherBottomBar;
import com.atlauncher.gui.dialogs.InstanceInstallerDialog;
import com.atlauncher.gui.tabs.AccountsTab;

View file

@ -165,7 +165,7 @@ public class LauncherBottomBar extends BottomBar implements RelocalizationListen
openFolder = new JButton(Language.INSTANCE.localize("common.openfolder"));
updateData = new JButton(Language.INSTANCE.localize("common.updatedata"));
username = new JComboBox<Account>();
username = new JComboBox<>();
username.setRenderer(new AccountsDropDownRenderer());
fillerAccount = new Account(Language.INSTANCE.localize("account.select"));
username.addItem(fillerAccount);

View file

@ -105,7 +105,7 @@ public class BackupDialog extends JDialog implements ActionListener {
} else {
backupList.setListData(list.toArray(new String[list.size()]));
}
list = new ArrayList<String>();
list = new ArrayList<>();
if (instance.getSavesDirectory().exists()) {
if (instance.getSavesDirectory().exists()) {
File[] files = instance.getSavesDirectory().listFiles();
@ -130,7 +130,7 @@ public class BackupDialog extends JDialog implements ActionListener {
}
private JPanel createBackupPanel() {
List<String> worldData = new ArrayList<String>();
List<String> worldData = new ArrayList<>();
if (instance.getSavesDirectory().exists()) {
if (instance.getSavesDirectory().exists()) {
File[] files = instance.getSavesDirectory().listFiles();

View file

@ -234,8 +234,8 @@ public class EditModsDialog extends JDialog {
private void loadMods() {
List<DisableableMod> mods = instance.getInstalledSelectedMods();
enabledMods = new ArrayList<ModsJCheckBox>();
disabledMods = new ArrayList<ModsJCheckBox>();
enabledMods = new ArrayList<>();
disabledMods = new ArrayList<>();
int dCount = 0;
int eCount = 0;
for (DisableableMod mod : mods) {
@ -253,12 +253,10 @@ public class EditModsDialog extends JDialog {
eCount++;
}
}
for (int i = 0; i < enabledMods.size(); i++) {
ModsJCheckBox checkBox = enabledMods.get(i);
for (ModsJCheckBox checkBox : enabledMods) {
enabledModsPanel.add(checkBox);
}
for (int i = 0; i < disabledMods.size(); i++) {
ModsJCheckBox checkBox = disabledMods.get(i);
for (ModsJCheckBox checkBox : disabledMods) {
disabledModsPanel.add(checkBox);
}
enabledModsPanel.setPreferredSize(new Dimension(0, enabledMods.size() * 20));
@ -266,7 +264,7 @@ public class EditModsDialog extends JDialog {
}
private void enableMods() {
ArrayList<ModsJCheckBox> mods = new ArrayList<ModsJCheckBox>(disabledMods);
ArrayList<ModsJCheckBox> mods = new ArrayList<>(disabledMods);
for (ModsJCheckBox mod : mods) {
if (mod.isSelected()) {
mod.getDisableableMod().enable(instance);
@ -276,7 +274,7 @@ public class EditModsDialog extends JDialog {
}
private void disableMods() {
ArrayList<ModsJCheckBox> mods = new ArrayList<ModsJCheckBox>(enabledMods);
ArrayList<ModsJCheckBox> mods = new ArrayList<>(enabledMods);
for (ModsJCheckBox mod : mods) {
if (mod.isSelected()) {
mod.getDisableableMod().disable(instance);
@ -286,14 +284,14 @@ public class EditModsDialog extends JDialog {
}
private void removeMods() {
ArrayList<ModsJCheckBox> mods = new ArrayList<ModsJCheckBox>(enabledMods);
ArrayList<ModsJCheckBox> mods = new ArrayList<>(enabledMods);
for (ModsJCheckBox mod : mods) {
if (mod.isSelected()) {
instance.removeInstalledMod(mod.getDisableableMod());
enabledMods.remove(mod);
}
}
mods = new ArrayList<ModsJCheckBox>(disabledMods);
mods = new ArrayList<>(disabledMods);
for (ModsJCheckBox mod : mods) {
if (mod.isSelected()) {
instance.removeInstalledMod(mod.getDisableableMod());

View file

@ -140,7 +140,7 @@ public class FileChooserDialog extends JDialog {
gbc.gridx++;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
selector = new JComboBox<String>();
selector = new JComboBox<>();
for (String item : subOptions) {
selector.addItem(item);
}
@ -176,7 +176,7 @@ public class FileChooserDialog extends JDialog {
}
public ArrayList<File> getChosenFiles() {
ArrayList<File> files = new ArrayList<File>();
ArrayList<File> files = new ArrayList<>();
if (this.filesChosen == null) {
return null;
}

View file

@ -71,7 +71,7 @@ public class InstanceInstallerDialog extends JDialog {
private JTextField instanceNameField;
private JLabel versionLabel;
private JComboBox<PackVersion> versionsDropDown;
private ArrayList<PackVersion> versions = new ArrayList<PackVersion>();
private ArrayList<PackVersion> versions = new ArrayList<>();
private JLabel enableUserLockLabel;
private JCheckBox enableUserLock;
@ -152,7 +152,7 @@ public class InstanceInstallerDialog extends JDialog {
gbc.gridx++;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
versionsDropDown = new JComboBox<PackVersion>();
versionsDropDown = new JComboBox<>();
if (pack.isTester()) {
for (PackVersion pv : pack.getDevVersions()) {
if (!isServer || (isServer && pv.getMinecraftVersion().canCreateServer())) {

View file

@ -210,7 +210,7 @@ public class ModsChooser extends JDialog {
});
bottomPanel.add(installButton);
modCheckboxes = new ArrayList<ModsJCheckBox>();
modCheckboxes = new ArrayList<>();
int count1 = 0;
int count2 = 0;
@ -341,8 +341,7 @@ public class ModsChooser extends JDialog {
i++;
}
}
for (int i = 0; i < modCheckboxes.size(); i++) {
ModsJCheckBox checkBox = modCheckboxes.get(i);
for (ModsJCheckBox checkBox : modCheckboxes) {
if ((installer.isServer() ? checkBox.getMod().isServerOptional() : checkBox.getMod().isOptional())) {
checkBoxPanel1.add(checkBox);
} else {
@ -350,7 +349,7 @@ public class ModsChooser extends JDialog {
}
}
sortedOut = new ArrayList<ModsJCheckBox>();
sortedOut = new ArrayList<>();
for (ModsJCheckBox cb : this.modCheckboxes) {
if ((installer.isServer() ? cb.getMod().isServerOptional() : cb.getMod().isOptional()) && cb.isSelected()) {
sortOutMods(cb);
@ -456,7 +455,7 @@ public class ModsChooser extends JDialog {
public void sortOutMods(ModsJCheckBox a, boolean firstGo) {
if (firstGo) {
sortedOut = new ArrayList<ModsJCheckBox>();
sortedOut = new ArrayList<>();
}
if (a.isSelected()) {
@ -528,7 +527,7 @@ public class ModsChooser extends JDialog {
if (wasClosed) {
return null;
}
List<Mod> mods = new ArrayList<Mod>();
List<Mod> mods = new ArrayList<>();
for (ModsJCheckBox check : modCheckboxes) {
if (check.isSelected()) {
mods.add(check.getMod());
@ -541,7 +540,7 @@ public class ModsChooser extends JDialog {
if (wasClosed) {
return null;
}
List<Mod> mods = new ArrayList<Mod>();
List<Mod> mods = new ArrayList<>();
for (ModsJCheckBox check : modCheckboxes) {
if (!check.isSelected()) {
mods.add(check.getMod());

View file

@ -83,7 +83,7 @@ public class SetupDialog extends JDialog {
gbc.gridx++;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
language = new JComboBox<String>(Language.available());
language = new JComboBox<>(Language.available());
language.setSelectedItem(Language.current());
middle.add(language, gbc);

View file

@ -47,7 +47,7 @@ public final class ViewModsDialog extends JDialog {
private final JPanel contentPanel = new JPanel(new GridBagLayout());
private final JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
private final JTextField searchField = new JTextField(16);
private final List<ModCard> cards = new LinkedList<ModCard>();
private final List<ModCard> cards = new LinkedList<>();
public ViewModsDialog(Pack pack) {
super(App.settings.getParent(), Language.INSTANCE.localizeWithReplace("pack.mods", pack.getName()),

View file

@ -124,7 +124,7 @@ public class AccountsTab extends JPanel implements Tab, RelocalizationListener {
fillerAccount = new Account(Language.INSTANCE.localize("account.add"));
accountsComboBox = new JComboBox<Account>();
accountsComboBox = new JComboBox<>();
accountsComboBox.addItem(fillerAccount);
for (Account account : App.settings.getAccounts()) {
accountsComboBox.addItem(account);

View file

@ -66,7 +66,7 @@ public final class PacksTab extends JPanel implements Tab, RelocalizationListene
private boolean isVanilla;
private boolean isFeatured;
private List<PackCard> cards = new LinkedList<PackCard>();
private List<PackCard> cards = new LinkedList<>();
public PacksTab(boolean isFeatured, boolean isVanilla) {
super(new BorderLayout());

View file

@ -60,7 +60,7 @@ public class ServersForCheckerTab extends JPanel implements ActionListener {
CONTEXT_MENU.add(EDIT_BUTTON);
CONTEXT_MENU.add(DELETE_BUTTON);
listModel = new DefaultListModel<MinecraftServer>();
listModel = new DefaultListModel<>();
for (MinecraftServer server : App.settings.getCheckingServers()) {
listModel.addElement(server);
}

View file

@ -70,7 +70,7 @@ public class GeneralSettingsTab extends AbstractSettingsTab implements Relocaliz
gbc.gridx++;
gbc.insets = FIELD_INSETS;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
language = new JComboBox<String>(Language.available());
language = new JComboBox<>(Language.available());
language.setSelectedItem(Language.current());
add(language, gbc);
@ -97,7 +97,7 @@ public class GeneralSettingsTab extends AbstractSettingsTab implements Relocaliz
gbc.gridx++;
gbc.insets = FIELD_INSETS;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
theme = new JComboBox<String>();
theme = new JComboBox<>();
for (String themee : App.settings.getThemesDir().list(Utils.getThemesFileFilter())) {
theme.addItem(themee.replace(".zip", ""));
}
@ -120,7 +120,7 @@ public class GeneralSettingsTab extends AbstractSettingsTab implements Relocaliz
gbc.gridx++;
gbc.insets = FIELD_INSETS;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
dateFormat = new JComboBox<String>();
dateFormat = new JComboBox<>();
dateFormat.addItem("dd/M/yyy");
dateFormat.addItem("M/dd/yyy");
dateFormat.addItem("yyy/M/dd");

View file

@ -194,7 +194,7 @@ public class JavaSettingsTab extends AbstractSettingsTab implements Relocalizati
widthField.setText(App.settings.getWindowWidth() + "");
heightField = new JTextField(4);
heightField.setText(App.settings.getWindowHeight() + "");
commonScreenSizes = new JComboBox<String>();
commonScreenSizes = new JComboBox<>();
commonScreenSizes.addItem("Select An Option");
commonScreenSizes.addItem("854x480");
if (OS.getMaximumWindowWidth() >= 1280 && OS.getMaximumWindowHeight() >= 720) {

View file

@ -67,7 +67,7 @@ public class LoggingSettingsTab extends AbstractSettingsTab implements Relocaliz
gbc.gridx++;
gbc.insets = FIELD_INSETS;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
forgeLoggingLevel = new JComboBox<String>();
forgeLoggingLevel = new JComboBox<>();
forgeLoggingLevel.addItem("SEVERE");
forgeLoggingLevel.addItem("WARNING");
forgeLoggingLevel.addItem("INFO");

View file

@ -72,7 +72,7 @@ public class NetworkSettingsTab extends AbstractSettingsTab implements Relocaliz
gbc.gridx++;
gbc.insets = FIELD_INSETS;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
server = new JComboBox<Server>();
server = new JComboBox<>();
for (Server serverr : App.settings.getServers()) {
if (serverr.isUserSelectable()) {
server.addItem(serverr);
@ -183,7 +183,7 @@ public class NetworkSettingsTab extends AbstractSettingsTab implements Relocaliz
gbc.gridx++;
gbc.insets = FIELD_INSETS;
gbc.anchor = GridBagConstraints.BASELINE_LEADING;
proxyType = new JComboBox<String>();
proxyType = new JComboBox<>();
proxyType.addItem("HTTP");
proxyType.addItem("SOCKS");
proxyType.addItem("DIRECT");

View file

@ -52,7 +52,7 @@ public final class DialogManager {
public Window parent = App.settings.getParent();
public String title;
public Object content;
public List<String> options = new LinkedList<String>();
public List<String> options = new LinkedList<>();
public Icon icon = null;
public int lookAndFeel = DialogManager.DEFAULT_OPTION;
public Integer defaultOption = null;

View file

@ -60,7 +60,7 @@ public class MCLauncher {
File[] jarModFiles = jarMods.listFiles();
if (jarMods.exists() && jarModFiles != null && (instance.hasJarMods() || jarModFiles.length != 0)) {
if (instance.hasJarMods()) {
ArrayList<String> jarmods = new ArrayList<String>(Arrays.asList(instance.getJarOrder().split(",")));
ArrayList<String> jarmods = new ArrayList<>(Arrays.asList(instance.getJarOrder().split(",")));
if (jarmods.size() > 1) {
hasCustomJarMods = true;
}
@ -117,7 +117,7 @@ public class MCLauncher {
cpb.append(instance.getMinecraftJar().getAbsolutePath());
}
List<String> arguments = new ArrayList<String>();
List<String> arguments = new ArrayList<>();
String path = javaPath + File.separator + "bin" + File.separator + "java";
if (OS.isWindows()) {
@ -176,7 +176,7 @@ public class MCLauncher {
arguments.add("-Xdock:name=\"" + instance.getName() + "\"");
}
ArrayList<String> negatedArgs = new ArrayList<String>();
ArrayList<String> negatedArgs = new ArrayList<>();
if (!javaArguments.isEmpty()) {
for (String arg : javaArguments.split(" ")) {
@ -218,7 +218,7 @@ public class MCLauncher {
props = gson.toJson(response.getAuth().getUserProperties());
}
List<String> launchArguments = new ArrayList<String>();
List<String> launchArguments = new ArrayList<>();
if (instance.hasArguments()) {
launchArguments.addAll(instance.getArguments());

View file

@ -43,7 +43,7 @@ public final class GithubIssueReporter {
LogManager.logStackTrace("Exception while uploading paste", e);
return;
}
Map<String, Object> request = new HashMap<String, Object>();
Map<String, Object> request = new HashMap<>();
request.put("issue", new GithubIssue(title, body));
try {

File diff suppressed because it is too large Load diff

View file

@ -234,15 +234,7 @@ public enum OS {
} else {
ram = 1024;
}
} catch (SecurityException e) {
LogManager.logStackTrace(e);
} catch (NoSuchMethodException e) {
LogManager.logStackTrace(e);
} catch (IllegalArgumentException e) {
LogManager.logStackTrace(e);
} catch (IllegalAccessException e) {
LogManager.logStackTrace(e);
} catch (InvocationTargetException e) {
} catch (SecurityException | InvocationTargetException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException e) {
LogManager.logStackTrace(e);
}
return ram;

View file

@ -37,7 +37,7 @@ import com.atlauncher.LogManager;
import com.atlauncher.exceptions.ChunkyException;
public final class Resources {
private static final Map<String, Object> resources = new HashMap<String, Object>();
private static final Map<String, Object> resources = new HashMap<>();
public static final String[] FONT_FAMILIES = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getAvailableFontFamilyNames();

View file

@ -87,6 +87,7 @@ import com.atlauncher.data.mojang.OperatingSystem;
import com.atlauncher.data.openmods.OpenEyeReportResponse;
import com.atlauncher.evnt.LogEvent.LogType;
import net.iharder.Base64;
import org.tukaani.xz.XZInputStream;
public class Utils {
@ -338,18 +339,16 @@ public class Utils {
byte[] mdbytes = md.digest();
sb = new StringBuffer();
for (int i = 0; i < mdbytes.length; i++) {
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
for (byte mdbyte : mdbytes) {
sb.append(Integer.toString((mdbyte & 0xff) + 0x100, 16).substring(1));
}
if (fis != null) {
fis.close();
}
} catch (NoSuchAlgorithmException e) {
LogManager.logStackTrace(e);
} catch (FileNotFoundException e) {
LogManager.logStackTrace(e);
} catch (IOException e) {
} catch (NoSuchAlgorithmException | IOException e) {
LogManager.logStackTrace(e);
}
return sb.toString();
@ -381,18 +380,16 @@ public class Utils {
byte[] mdbytes = md.digest();
sb = new StringBuffer();
for (int i = 0; i < mdbytes.length; i++) {
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
for (byte mdbyte : mdbytes) {
sb.append(Integer.toString((mdbyte & 0xff) + 0x100, 16).substring(1));
}
if (fis != null) {
fis.close();
}
} catch (NoSuchAlgorithmException e) {
LogManager.logStackTrace(e);
} catch (FileNotFoundException e) {
LogManager.logStackTrace(e);
} catch (IOException e) {
} catch (NoSuchAlgorithmException | IOException e) {
LogManager.logStackTrace(e);
}
return sb.toString();
@ -417,12 +414,10 @@ public class Utils {
// convert the byte to hex format method 1
sb = new StringBuffer();
for (int i = 0; i < mdbytes.length; i++) {
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
for (byte mdbyte : mdbytes) {
sb.append(Integer.toString((mdbyte & 0xff) + 0x100, 16).substring(1));
}
} catch (NoSuchAlgorithmException e) {
LogManager.logStackTrace(e);
} catch (IOException e) {
} catch (NoSuchAlgorithmException | IOException e) {
LogManager.logStackTrace(e);
}
return sb.toString();
@ -447,12 +442,10 @@ public class Utils {
// convert the byte to hex format method 1
sb = new StringBuffer();
for (int i = 0; i < mdbytes.length; i++) {
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
for (byte mdbyte : mdbytes) {
sb.append(Integer.toString((mdbyte & 0xff) + 0x100, 16).substring(1));
}
} catch (NoSuchAlgorithmException e) {
LogManager.logStackTrace(e);
} catch (IOException e) {
} catch (NoSuchAlgorithmException | IOException e) {
LogManager.logStackTrace(e);
}
return sb.toString();
@ -625,8 +618,8 @@ public class Utils {
}
String[] children = sourceLocation.list();
for (int i = 0; i < children.length; i++) {
copyDirectory(new File(sourceLocation, children[i]), new File(targetLocation, children[i]));
for (String child : children) {
copyDirectory(new File(sourceLocation, child), new File(targetLocation, child));
}
} else {
@ -716,8 +709,8 @@ public class Utils {
String[] myFiles;
if (file.isDirectory()) {
myFiles = file.list();
for (int i = 0; i < myFiles.length; i++) {
new File(file, myFiles[i]).delete();
for (String myFile : myFiles) {
new File(file, myFile).delete();
}
}
}
@ -840,7 +833,7 @@ public class Utils {
public static void zip(File in, File out) {
try {
URI base = in.toURI();
Deque<File> queue = new LinkedList<File>();
Deque<File> queue = new LinkedList<>();
queue.push(in);
OutputStream stream = new FileOutputStream(out);
Closeable res = stream;
@ -948,11 +941,7 @@ public class Utils {
byte[] decordedValue = Base64.decode(encryptedData);
byte[] decValue = c.doFinal(decordedValue);
decryptedValue = new String(decValue);
} catch (InvalidKeyException e) {
return Utils.decryptOld(encryptedData);
} catch (BadPaddingException e) {
return Utils.decryptOld(encryptedData);
} catch (IllegalBlockSizeException e) {
} catch (InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
return Utils.decryptOld(encryptedData);
} catch (Exception e) {
LogManager.logStackTrace(e);
@ -1212,7 +1201,7 @@ public class Utils {
@Override
public boolean accept(File dir, String name) {
File file = new File(dir, name);
Pattern pattern = Pattern.compile("^pending-crash-[0-9\\-_\\.]+\\.json$");
Pattern pattern = Pattern.compile("^pending-crash-[0-9\\-_.]+\\.json$");
return file.isFile() && pattern.matcher(name).matches();
}
};

View file

@ -101,14 +101,14 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
private boolean extractedResourcePack = false; // If there is an extracted resourcepack
private int permgen = 0;
private int memory = 0;
private List<String> libraries = new ArrayList<String>();
private List<String> arguments = new ArrayList<String>();
private List<String> libraries = new ArrayList<>();
private List<String> arguments = new ArrayList<>();
private String extraArguments = null;
private String mainClass = null;
private int percent = 0; // Percent done installing
private List<Mod> allMods;
private List<Mod> selectedMods;
private List<Mod> unselectedMods = new ArrayList<Mod>();
private List<Mod> unselectedMods = new ArrayList<>();
private int totalDownloads = 0; // Total number of downloads to download
private int doneDownloads = 0; // Total number of downloads downloaded
private int totalBytes = 0; // Total number of bytes to download
@ -116,7 +116,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
private Instance instance = null;
private List<DisableableMod> modsInstalled;
private List<File> serverLibraries;
private List<File> forgeLibraries = new ArrayList<File>();
private List<File> forgeLibraries = new ArrayList<>();
private com.atlauncher.data.loaders.Loader loader;
public InstanceInstaller(String instanceName, Pack pack, PackVersion version, boolean isReinstall, boolean isServer,
@ -129,7 +129,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
this.shareCode = shareCode;
this.showModsChooser = showModsChooser;
if (isServer) {
serverLibraries = new ArrayList<File>();
serverLibraries = new ArrayList<>();
}
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapterFactory(new EnumTypeAdapterFactory());
@ -340,7 +340,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
public List<Mod> getLinkedMods(Mod mod) {
List<Mod> linkedMods = new ArrayList<Mod>();
List<Mod> linkedMods = new ArrayList<>();
for (Mod modd : allMods) {
if (!modd.hasLinked()) {
continue;
@ -353,7 +353,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
public List<Mod> getGroupedMods(Mod mod) {
List<Mod> groupedMods = new ArrayList<Mod>();
List<Mod> groupedMods = new ArrayList<>();
for (Mod modd : allMods) {
if (!modd.hasGroup()) {
continue;
@ -368,7 +368,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
public List<Mod> getModsDependancies(Mod mod) {
List<Mod> dependsMods = new ArrayList<Mod>();
List<Mod> dependsMods = new ArrayList<>();
for (String name : mod.getDepends()) {
inner: {
for (Mod modd : allMods) {
@ -383,7 +383,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
public List<Mod> dependedMods(Mod mod) {
List<Mod> dependedMods = new ArrayList<Mod>();
List<Mod> dependedMods = new ArrayList<>();
for (Mod modd : allMods) {
if (!modd.hasDepends()) {
continue;
@ -476,7 +476,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
private List<Downloadable> getDownloadableMods() {
List<Downloadable> mods = new ArrayList<Downloadable>();
List<Downloadable> mods = new ArrayList<>();
for (Mod mod : this.selectedMods) {
if (mod.getDownload() == DownloadType.server) {
@ -781,7 +781,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
private void organiseLibraries() {
List<String> libraryNamesAdded = new ArrayList<String>();
List<String> libraryNamesAdded = new ArrayList<>();
fireTask(Language.INSTANCE.localize("instance.organisinglibraries"));
fireSubProgressUnknown();
if (!isServer) {
@ -859,7 +859,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
private ArrayList<Downloadable> getResources() {
ArrayList<Downloadable> downloads = new ArrayList<Downloadable>(); // All the files
ArrayList<Downloadable> downloads = new ArrayList<>(); // All the files
File objectsFolder = new File(App.settings.getAssetsDir(), "objects");
File indexesFolder = new File(App.settings.getAssetsDir(), "indexes");
File virtualFolder = new File(App.settings.getAssetsDir(), "virtual");
@ -894,11 +894,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
}
}
} catch (JsonSyntaxException e) {
LogManager.logStackTrace(e);
} catch (JsonIOException e) {
LogManager.logStackTrace(e);
} catch (FileNotFoundException e) {
} catch (JsonSyntaxException | FileNotFoundException | JsonIOException e) {
LogManager.logStackTrace(e);
}
@ -906,8 +902,8 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
public ArrayList<Downloadable> getLibraries() {
ArrayList<Downloadable> libraries = new ArrayList<Downloadable>();
List<String> libraryNamesAdded = new ArrayList<String>();
ArrayList<Downloadable> libraries = new ArrayList<>();
List<String> libraryNamesAdded = new ArrayList<>();
// Now read in the library jars needed from the pack
for (com.atlauncher.data.json.Library library : this.jsonVersion.getLibraries()) {
@ -1219,7 +1215,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
public List<Mod> sortMods(List<Mod> original) {
List<Mod> mods = new ArrayList<Mod>(original);
List<Mod> mods = new ArrayList<>(original);
for (Mod mod : original) {
if (mod.isOptional()) {
@ -1236,7 +1232,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
}
}
List<Mod> modss = new ArrayList<Mod>();
List<Mod> modss = new ArrayList<>();
for (Mod mod : mods) {
if (!mod.isOptional()) {
@ -1380,7 +1376,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> {
if (!hasOptional) {
this.selectedMods = this.allMods;
}
modsInstalled = new ArrayList<DisableableMod>();
modsInstalled = new ArrayList<>();
for (Mod mod : this.selectedMods) {
String file = mod.getFile();
if (this.jsonVersion.getCaseAllFiles() == CaseType.upper) {

View file

@ -1,7 +1,6 @@
package io.github.asyncronous.toast.ui;
import com.atlauncher.utils.Java;
import com.atlauncher.utils.Utils;
import io.github.asyncronous.toast.ToasterConstants;
import io.github.asyncronous.toast.thread.ToastAnimator;