Merge branch 'development' into issue-288/fix-runtime-error

This commit is contained in:
Jeroen Ketelaar
2018-11-26 12:13:10 -06:00
committed by GitHub
3 changed files with 27 additions and 1 deletions
+8
View File
@@ -1,6 +1,7 @@
package org.parabot;
import org.parabot.api.translations.TranslationHelper;
import org.parabot.core.Context;
import org.parabot.core.Core;
import org.parabot.core.Directories;
import org.parabot.core.forum.AccountManager;
@@ -9,6 +10,7 @@ import org.parabot.core.network.proxy.ProxySocket;
import org.parabot.core.network.proxy.ProxyType;
import org.parabot.core.ui.BotUI;
import org.parabot.core.ui.ServerSelector;
import org.parabot.core.ui.utils.UILog;
import javax.swing.*;
import java.io.File;
@@ -25,8 +27,14 @@ public final class Landing {
private static String username;
private static String password;
public static void main(String... args) throws IOException {
if (Context.getJavaVersion() >= 9){
UILog.log("Parabot", "Parabot doesn't support Java 9+ currently. Please downgrade to Java 8 to ensure Parabot is working correctly.");
System.exit(0);
}
parseArgs(args);
Directories.validate();
@@ -70,6 +70,13 @@ public class Context {
this.defaultErr = System.err;
}
public static double getJavaVersion() {
String version = System.getProperty("java.version");
int pos = version.indexOf('.');
pos = version.indexOf('.', pos+1);
return Double.parseDouble(version.substring (0, pos));
}
/**
* Returns the instance of this class, based on a given ServerProvider
*
@@ -105,7 +105,18 @@ public class Timer {
* @return hourly gains
*/
public int getPerHour(final int gained) {
return (int) ((gained) * 3600000D / (System.currentTimeMillis() - start));
return getPerHour(gained, 0);
}
/**
* Calculates hourly gains based on given variable, with variable start amount
*
* @param gained total gained amount
* @param startAmount start amount
* @return hourly gains
*/
public int getPerHour(final int gained, final int startAmount) {
return (int) (((gained - startAmount) * 3600000D) / (System.currentTimeMillis() - start));
}
/**