Updated to V2.04

Including database server providers - loading
This commit is contained in:
Jeroen Ketelaar
2014-02-16 15:31:53 +01:00
parent a5b1977731
commit dc08dd5777
8 changed files with 47 additions and 34 deletions
+2
View File
@@ -44,3 +44,5 @@ parabotv2/src/META-INF/MANIFEST.MF
*.idx3
/bin
.idea/uiDesigner.xml
@@ -9,8 +9,9 @@ public class Configuration {
public static final String LOGIN_SERVER = "http://www.parabot.org/community/api/login.php?username=%s&password=%s";
public static final String SDN_SCRIPTS = "http://sdn.parabot.org/scripts.php?user=%s";
public static final String GET_SDN_SCRIPT = "http://sdn.parabot.org/getscript.php?user=%s&pass=%s&scriptid=%d";
public static final String GET_SERVER_PROVIDERS = "http://sdn.parabot.org/list/providers.php";
public static final String GET_SERVER_PROVIDER = "http://sdn.parabot.org/providers/%s";
public static final String GET_SERVER_PROVIDERS = "http://sdn.parabot.org/providers/index.php";
public static final String GET_SERVER_PROVIDER = "http://sdn.parabot.org/providers/provider.php?id=";
public static final String GET_SERVER_PROVIDER_INFO = "http://sdn.parabot.org/providers/getInformation.php?id=";
public static final String GET_BOT_VERSION = "http://bot.parabot.org/version.txt";
public static final double BOT_VERSION = 2.04; // BETA
-1
View File
@@ -98,5 +98,4 @@ public class Core {
Core.verbose("Updates available...");
return false;
}
}
@@ -1,8 +1,5 @@
package org.parabot.core.forum;
import java.net.URLEncoder;
import java.util.ArrayList;
import org.parabot.core.Configuration;
import org.parabot.core.Core;
import org.parabot.core.parsers.scripts.SDNScripts;
@@ -10,6 +7,9 @@ import org.parabot.core.ui.LoginUI;
import org.parabot.environment.api.utils.WebUtil;
import org.parabot.environment.scripts.SDNScriptExecuter;
import java.net.URLEncoder;
import java.util.ArrayList;
/**
* Handles logging in to parabot forum, only certain classes may use this class.
*
@@ -60,9 +60,9 @@ public final class AccountManager {
String contents = null;
try {
contents = WebUtil.getContents(String.format(
Configuration.LOGIN_SERVER,
URLEncoder.encode(user, "UTF-8"),
URLEncoder.encode(pass, "UTF-8")));
Configuration.LOGIN_SERVER,
URLEncoder.encode(user, "UTF-8"),
URLEncoder.encode(pass, "UTF-8")));
} catch (Throwable t) {
t.printStackTrace();
return false;
@@ -71,7 +71,7 @@ public final class AccountManager {
if (contents.equals("correct")) {
account = new Account(user, pass);
return true;
}
}
return false;
}
@@ -43,7 +43,7 @@ public class PublicServers extends ServerParser {
version = Double.parseDouble(line);
break;
case 0:
// jarName
// serverID
ServerDescription desc = new ServerDescription(name,
author, version);
SERVER_CACHE.put(desc, new PublicServerExecuter(name, line));
+2 -1
View File
@@ -1,5 +1,6 @@
package org.parabot.core.ui;
import org.parabot.core.Configuration;
import org.parabot.core.ui.components.BotToolbar;
import org.parabot.core.ui.components.GamePanel;
import org.parabot.core.ui.components.LogArea;
@@ -84,7 +85,7 @@ public class BotUI extends JFrame implements ActionListener {
SwingUtil.finalize(this);
LogArea.log("parabot v2.03 started");
LogArea.log("parabot " + Configuration.BOT_VERSION +" started");
}
@Override
@@ -1,12 +1,5 @@
package org.parabot.environment.servers;
import java.io.File;
import java.lang.reflect.Constructor;
import java.net.URL;
import java.net.URLEncoder;
import javax.swing.JOptionPane;
import org.parabot.core.Configuration;
import org.parabot.core.Core;
import org.parabot.core.Directories;
@@ -17,6 +10,11 @@ import org.parabot.core.ui.utils.UILog;
import org.parabot.environment.api.utils.WebUtil;
import org.parabot.environment.servers.loader.ServerLoader;
import javax.swing.*;
import java.io.File;
import java.lang.reflect.Constructor;
import java.net.URL;
/**
*
* Fetches a server provider from the parabot sdn
@@ -26,26 +24,38 @@ import org.parabot.environment.servers.loader.ServerLoader;
*/
public class PublicServerExecuter extends ServerExecuter {
private String serverName = null;
private String jarName = null;
private String serverID = null;
public PublicServerExecuter(final String serverName, final String jarName) {
public PublicServerExecuter(final String serverName, final String serverID) {
this.serverName = serverName;
this.jarName = jarName;
this.serverID = serverID;
}
@Override
public void run(ThreadGroup tg) {
try {
final File destination = new File(Directories.getCachePath(),
this.jarName);
final String jarUrl = String.format(
Configuration.GET_SERVER_PROVIDER,
URLEncoder.encode(this.jarName, "UTF-8"));
this.serverID);
final String jarUrl = Configuration.GET_SERVER_PROVIDER + this.serverID;
final String providerInfo = Configuration.GET_SERVER_PROVIDER_INFO + this.serverID;
try{
Integer.parseInt(this.serverID);
}catch(NumberFormatException e){
UILog.log(
"Error",
"Failed to parse the server ID for the server provider, error: [Server ID is not an integer.]",
JOptionPane.ERROR_MESSAGE);
}
Core.verbose("Downloading: " + jarUrl + " ...");
WebUtil.downloadFile(new URL(jarUrl), destination,
VerboseLoader.get());
WebUtil.downloadFile(new URL(providerInfo),
new File(System.getProperty("user.home") + "/serverProvider.pb"),
VerboseLoader.get());
Core.verbose("Server provider downloaded...");
@@ -1,10 +1,5 @@
package org.parabot.environment.servers;
import java.applet.Applet;
import java.applet.AppletStub;
import java.net.URL;
import javax.swing.JMenuBar;
import org.objectweb.asm.Opcodes;
import org.parabot.core.Context;
import org.parabot.core.asm.interfaces.Injectable;
@@ -13,6 +8,11 @@ import org.parabot.environment.input.Keyboard;
import org.parabot.environment.input.Mouse;
import org.parabot.environment.scripts.Script;
import javax.swing.*;
import java.applet.Applet;
import java.applet.AppletStub;
import java.net.URL;
/**
* Provides a server to the bot
*
@@ -62,8 +62,8 @@ public abstract class ServerProvider implements Opcodes {
/**
* Add custom items to the bot menu bar
*
* @param menu
* bar to add items on
* @param bar
* menu bar to add items on
*/
public void addMenuItems(JMenuBar bar) {
}