Some More Cleanup For 2006Scape

This commit is contained in:
Dark98
2021-11-12 00:32:22 +00:00
parent 85768a984a
commit e490fb003f
20 changed files with 23 additions and 236 deletions
@@ -1,5 +1,6 @@
package org.parabot.core;
package org.parabot;
import org.parabot.core.ProjectProperties;
import org.parabot.environment.api.utils.Version;
/**
@@ -7,19 +8,7 @@ import org.parabot.environment.api.utils.Version;
*
* @author Everel
*/
public class Configuration extends org.parabot.api.Configuration {
public static final String WEBSITE_LINK = "https://2006Scape.org/";
public static final String SDN_PAGE = "https://2006Scape.org/sdn/";
public static final String GET_RANDOMS = "https://2006Scape.org/Downloads/bot/Randoms-0.26.1.jar";
public static final String GET_SERVER_PROVIDER_TYPE = "http://v3.bdn.parabot.org/api/bot/server/type?server=%s";
public static final String SERVER_PROVIDER_INFO = "http://v3.bdn.parabot.org/api/bot/list/%s?latest=true";
public static final String DATA_API = "http://bdn.parabot.org/api/v2/data/";
public static final String ITEM_API = DATA_API + "items/";
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
public class Configuration {
public static final String serverName = "2006Scape";
public static final String clientJar = "https://2006scape.org/Downloads/client.jar";
public static final String hooksFile = "https://2006scape.org/Downloads/bot/2006Scape_hooks.xml";
@@ -27,4 +16,12 @@ public class Configuration extends org.parabot.api.Configuration {
public static final String clientClass = "Game";
public static final Double clientVersion = 1.0;
public static final String BOT_TITLE = serverName + " Bot";
public static final String BOT_SLOGAN = "The best RuneScape private server bot";
public static final Version BOT_VERSION = ProjectProperties.getProjectVersion();
public static final String WEBSITE_LINK = "https://2006Scape.org/";
public static final String SDN_PAGE = "https://2006Scape.org/sdn/";
public static final String GET_RANDOMS = "https://2006Scape.org/Downloads/bot/Randoms-0.26.1.jar";
}
-4
View File
@@ -1,17 +1,13 @@
package org.parabot;
import org.parabot.core.Configuration;
import org.parabot.core.Context;
import org.parabot.core.Core;
import org.parabot.core.Directories;
import org.parabot.core.desc.ServerDescription;
import org.parabot.core.network.NetworkInterface;
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 org.parabot.environment.Environment;
import java.io.File;
@@ -1,14 +0,0 @@
package org.parabot.api;
/**
* @author JKetelaar
*/
public class Configuration {
public static final String BOT_TITLE = "Parabot";
public static final String BOT_SLOGAN = "The best RuneScape private server bot";
public static final String V3_API_ENDPOINT = "http://v3.bdn.parabot.org/api/";
public static final String LIBRARIES_DOWNLOAD = V3_API_ENDPOINT + "bot/libraries/download";
}
@@ -1,67 +0,0 @@
package org.parabot.api.io.libraries.jpushbullet;
import org.parabot.api.Configuration;
import org.parabot.api.io.Directories;
import org.parabot.api.io.build.BuildPath;
import org.parabot.api.io.libraries.Library;
import java.io.File;
import java.net.URL;
/**
* @author EmmaStone
*/
public class JPushBullet extends Library {
private static boolean valid;
@Override
public void init() {
if (!hasJar()) {
System.err.println("Failed to load jpushbullet... [jar missing]");
return;
}
BuildPath.add(getJarFileURL());
try {
Class.forName("com.github.sheigutn.pushbullet.Pushbullet");
valid = true;
} catch (ClassNotFoundException e) {
System.err
.println("Failed to add jpushbullet to build path, or incorrupt download");
}
}
@Override
public boolean isAdded() {
return valid;
}
@Override
public File getJarFile() {
return new File(Directories.getCachePath(), "jpushbullet.jar");
}
@Override
public URL getDownloadLink() {
try {
return new URL(Configuration.LIBRARIES_DOWNLOAD + "/JPushBullet");
} catch (Throwable t) {
t.printStackTrace();
}
return null;
}
@Override
public boolean requiresJar() {
return true;
}
@Override
public String getLibraryName() {
return "JPushBullet";
}
public static boolean isValid() {
return valid;
}
}
@@ -2,7 +2,6 @@ package org.parabot.api.notifications;
import org.parabot.api.notifications.types.MacNotificationType;
import org.parabot.api.notifications.types.NotificationType;
import org.parabot.api.notifications.types.PushBulletNotificationType;
import java.util.ArrayList;
import java.util.Iterator;
@@ -34,7 +33,6 @@ public class NotificationManager {
private void fillNotificationTypes() {
this.notificationTypes.add(new MacNotificationType());
this.notificationTypes.add(new PushBulletNotificationType());
}
public void enableNotificationType(NotificationType type) {
@@ -1,6 +1,6 @@
package org.parabot.api.notifications.types;
import org.parabot.api.Configuration;
import org.parabot.Configuration;
/**
* @author JKetelaar
@@ -1,55 +0,0 @@
package org.parabot.api.notifications.types;
import org.parabot.api.io.libraries.Environment;
import org.parabot.api.io.libraries.jpushbullet.JPushBullet;
import org.parabot.api.notifications.types.pushbullet.PushBulletController;
import javax.swing.*;
/**
* @author JKetelaar
*/
public class PushBulletNotificationType extends NotificationType {
private boolean enabled = false;
public PushBulletNotificationType() {
super("PushBullet");
}
@Override
public boolean isAvailable() {
double version = 1.0;
try {
version = Double.parseDouble(System.getProperty("java.specification.version"));
} catch (NumberFormatException ignored) {
}
return version >= 1.8;
}
@Override
public void enable() {
final String message = "Please insert your PushBullet API key, so we could send notifications.";
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String s = JOptionPane.showInputDialog(null, message, "PushBullet API key", JOptionPane.QUESTION_MESSAGE);
if (s != null) {
Environment.loadLibrary(new JPushBullet());
enabled = PushBulletController.pushNote("Parabot", "PushBullets notifications have been enabled for Parabot", s);
}
}
});
}
@Override
public void notify(String title, String header, String message) {
if (this.enabled) {
PushBulletController.pushNote(title, message);
}
}
}
@@ -1,52 +0,0 @@
package org.parabot.api.notifications.types.pushbullet;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* @author JKetelaar
*/
public class PushBulletController {
private static Object pushBulletInstance;
public static void setPushBulletInstance(String key){
ClassLoader classLoader = PushBulletController.class.getClassLoader();
try {
PushBulletController.pushBulletInstance = classLoader.loadClass("com.github.sheigutn.pushbullet.Pushbullet").getConstructors()[0].newInstance(key);
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
e.printStackTrace();
}
}
public static Object getPushBulletInstance(String key){
PushBulletController.setPushBulletInstance(key);
return PushBulletController.pushBulletInstance;
}
public static boolean pushNote(String title, String message, String key){
PushBulletController.setPushBulletInstance(key);
return PushBulletController.pushNote(title, message);
}
public static boolean pushNote(String title, String message){
Class[] cArg = new Class[2];
cArg[0] = String.class;
cArg[1] = String.class;
if (PushBulletController.pushBulletInstance != null){
try {
Method method = PushBulletController.pushBulletInstance.getClass().getMethod("pushNote", cArg);
method.setAccessible(true);
method.invoke(PushBulletController.pushBulletInstance, title, message);
return true;
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
return false;
}
}
return false;
}
}
@@ -29,7 +29,7 @@ public class ProjectProperties {
private void setProperties() {
InputStream input;
try {
String propertiesFileName = "storage/parabot.properties";
String propertiesFileName = "storage/internal.properties";
input = getClass().getClassLoader()
.getResourceAsStream(propertiesFileName);
@@ -1,6 +1,6 @@
package org.parabot.core.desc;
import org.parabot.core.Configuration;
import org.parabot.Configuration;
/**
* Holds information about a server
@@ -1,6 +1,6 @@
package org.parabot.core.desc;
import org.parabot.core.Configuration;
import org.parabot.Configuration;
import org.parabot.environment.api.utils.WebUtil;
import java.net.MalformedURLException;
@@ -77,21 +77,6 @@ public class ServerProviderInfo {
return null;
}
/**
* Gets the current provider version
*
* @return provider version
*/
public String getProviderVersion() {
String providerType = WebUtil.getJsonValue(String.format(Configuration.GET_SERVER_PROVIDER_TYPE, Configuration.serverName), "type");
if (providerType != null) {
String providerInfo = String.format(Configuration.SERVER_PROVIDER_INFO, providerType);
return WebUtil.getJsonValue(providerInfo, "version");
}
return null;
}
private long getCRC32(String name, String type) {
CRC32 crc = new CRC32();
name += "-" + type;
@@ -1,7 +1,7 @@
package org.parabot.core.parsers.randoms;
import org.parabot.api.io.WebUtil;
import org.parabot.core.Configuration;
import org.parabot.Configuration;
import org.parabot.core.Context;
import org.parabot.core.Core;
import org.parabot.core.Directories;
+1 -1
View File
@@ -1,6 +1,6 @@
package org.parabot.core.ui;
import org.parabot.core.Configuration;
import org.parabot.Configuration;
import org.parabot.core.Context;
import org.parabot.core.Directories;
import org.parabot.core.ui.components.GamePanel;
@@ -1,6 +1,6 @@
package org.parabot.core.ui;
import org.parabot.core.Configuration;
import org.parabot.Configuration;
import org.parabot.core.Context;
import org.parabot.core.Directories;
import org.parabot.core.desc.ScriptDescription;
@@ -1,6 +1,6 @@
package org.parabot.core.ui;
import org.parabot.core.Configuration;
import org.parabot.Configuration;
import org.parabot.core.Core;
import org.parabot.core.desc.ServerDescription;
import org.parabot.core.parsers.ServerParser;
@@ -1,6 +1,6 @@
package org.parabot.core.ui.components;
import org.parabot.core.Configuration;
import org.parabot.Configuration;
import org.parabot.core.io.ProgressListener;
import org.parabot.core.ui.ServerSelector;
import org.parabot.core.ui.fonts.Fonts;
@@ -1,6 +1,6 @@
package org.parabot.core.ui.components.notifications;
import org.parabot.api.Configuration;
import org.parabot.Configuration;
import org.parabot.api.output.Verboser;
import org.parabot.api.ui.JavaFxUtil;
@@ -1,7 +1,7 @@
package org.parabot.environment.servers;
import org.objectweb.asm.Opcodes;
import org.parabot.core.Configuration;
import org.parabot.Configuration;
import org.parabot.core.Context;
import org.parabot.core.asm.hooks.HookFile;
import org.parabot.core.asm.interfaces.Injectable;
@@ -1,6 +1,6 @@
package org.parabot.environment.servers.executers;
import org.parabot.core.Configuration;
import org.parabot.Configuration;
import org.parabot.core.Context;
import org.parabot.core.Core;
import org.parabot.core.Directories;
@@ -1 +0,0 @@
application.version=${project.version}${build.version}