Properties

This commit is contained in:
Clisprail
2014-08-26 15:24:19 +02:00
parent 8beed569f9
commit 6c0b552f57
@@ -7,11 +7,12 @@ import org.parabot.core.ui.utils.UILog;
import org.parabot.environment.api.utils.WebUtil; import org.parabot.environment.api.utils.WebUtil;
import javax.swing.*; import javax.swing.*;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties;
/** /**
* Gets the information for the selected server provider * Gets the information for the selected server provider
@@ -20,10 +21,10 @@ import java.util.Map;
* *
*/ */
public class ServerProviderInfo { public class ServerProviderInfo {
private HashMap<String, String> properties; private Properties properties;
public ServerProviderInfo(URL providerInfo, String username, String password) { public ServerProviderInfo(URL providerInfo, String username, String password) {
this.properties = new HashMap<>(); this.properties = new Properties();
try { try {
String line; String line;
Core.verbose("Reading info: " + providerInfo); Core.verbose("Reading info: " + providerInfo);
@@ -51,7 +52,7 @@ public class ServerProviderInfo {
public URL getClient() { public URL getClient() {
try { try {
return new URL(properties.get("client")); return new URL(properties.getProperty("client"));
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -69,7 +70,7 @@ public class ServerProviderInfo {
public URL getHookFile() { public URL getHookFile() {
try { try {
return new URL(properties.get("hooks")); return new URL(properties.getProperty("hooks"));
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -77,30 +78,30 @@ public class ServerProviderInfo {
} }
public String getClientClass() { public String getClientClass() {
return properties.get("clientClass"); return properties.getProperty("clientClass");
} }
public String getServerName() { public String getServerName() {
return properties.get("serverName"); return properties.getProperty("serverName");
} }
public long getCRC32() { public long getCRC32() {
if (properties.get("crc32") != null) { if (properties.get("crc32") != null) {
return Long.parseLong(properties.get("crc32")); return Long.parseLong(properties.getProperty("crc32"));
} else { } else {
return System.currentTimeMillis() / 1000 / 60 / 60 / 24; return System.currentTimeMillis() / 1000 / 60 / 60 / 24;
} }
} }
public long getClientCRC32() { public long getClientCRC32() {
return Long.parseLong(properties.get("clientCrc32")); return Long.parseLong(properties.getProperty("clientCrc32"));
} }
public int getBankTabs() { public int getBankTabs() {
return Integer.parseInt(properties.get("bankTabs")); return Integer.parseInt(properties.getProperty("bankTabs"));
} }
public HashMap<String, String> getProperties() { public Properties getProperties() {
return this.properties; return this.properties;
} }
} }