diff --git a/pom.xml b/pom.xml
index 4c9fcaf..3a412fd 100755
--- a/pom.xml
+++ b/pom.xml
@@ -73,7 +73,7 @@
org.parabot
internal-api
- 1.4.5.1
+ 1.51.1
diff --git a/src/main/java/org/parabot/core/build/BuildPath.java b/src/main/java/org/parabot/core/build/BuildPath.java
index b80e78e..5ca4971 100644
--- a/src/main/java/org/parabot/core/build/BuildPath.java
+++ b/src/main/java/org/parabot/core/build/BuildPath.java
@@ -1,9 +1,5 @@
package org.parabot.core.build;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLClassLoader;
-
/**
*
* Class used for adding urls to the buildpath
@@ -11,16 +7,6 @@ import java.net.URLClassLoader;
* @author Everel
*
*/
-public class BuildPath {
-
- public static void add(final URL url) {
- try {
- Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
- method.setAccessible(true);
- method.invoke((URLClassLoader) ClassLoader.getSystemClassLoader(), url);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+public class BuildPath extends org.parabot.api.io.build.BuildPath {
}
diff --git a/src/main/java/org/parabot/core/lib/Library.java b/src/main/java/org/parabot/core/lib/Library.java
index 9ac49e5..c8a7645 100644
--- a/src/main/java/org/parabot/core/lib/Library.java
+++ b/src/main/java/org/parabot/core/lib/Library.java
@@ -1,67 +1,10 @@
package org.parabot.core.lib;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
/**
*
* @author Everel
*
*/
-public abstract class Library {
-
- /**
- * Determines if this library jar has already been downloaded.
- * @return false if library jar has not been downloaded, otherwise true
- */
- public boolean hasJar() {
- return getJarFile().exists();
- }
-
- /**
- * Adds the library to the buildpath and validates if it has been added
- */
- public abstract void init();
-
- /**
- * Determines if library has been added to the buildpath
- * @return true if library has been added to the buildpath, otherwise false.
- */
- public abstract boolean isAdded();
-
- /**
- * Gets the local file target/location of the jar file
- * @return local file (target) to library
- */
- public abstract File getJarFile();
-
- /**
- * Gets download url to the library
- * @return url
- */
- public abstract URL getDownloadLink();
-
- /**
- * Defines if the system requires a jar
- * @return boolean
- */
- public abstract boolean requiresJar();
-
-
- /**
- * Fetches URL from {@link Library#getJarFile()}
- * @return URL to local library jar file
- */
- public URL getJarFileURL() {
- try {
- return getJarFile().toURI().toURL();
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public abstract String getLibraryName();
+public abstract class Library extends org.parabot.api.io.libraries.Library {
}
diff --git a/src/main/java/org/parabot/core/lib/jpushbullet/JPushBullet.java b/src/main/java/org/parabot/core/lib/jpushbullet/JPushBullet.java
deleted file mode 100644
index 0f7fdfc..0000000
--- a/src/main/java/org/parabot/core/lib/jpushbullet/JPushBullet.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.parabot.core.lib.jpushbullet;
-
-import org.parabot.core.Configuration;
-import org.parabot.core.Core;
-import org.parabot.core.Directories;
-import org.parabot.core.build.BuildPath;
-import org.parabot.core.lib.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;
- }
- Core.verbose("Adding jpushbullet jar file to build path: "
- + getJarFileURL().getPath());
- BuildPath.add(getJarFileURL());
-
- try {
- Class.forName("com.shakethat.jpushbullet.net.PushbulletClient");
- valid = true;
- } catch (ClassNotFoundException e) {
- System.err
- .println("Failed to add jpushbullet to build path, or incorrupt download");
- }
-
- Core.verbose("JPushBullet initialized.");
- }
-
- @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;
- }
-}
diff --git a/src/main/java/org/parabot/core/ui/BotUI.java b/src/main/java/org/parabot/core/ui/BotUI.java
index e2f8b1c..8ec5532 100644
--- a/src/main/java/org/parabot/core/ui/BotUI.java
+++ b/src/main/java/org/parabot/core/ui/BotUI.java
@@ -1,10 +1,12 @@
package org.parabot.core.ui;
+import javafx.application.Application;
import org.parabot.core.Configuration;
import org.parabot.core.Context;
import org.parabot.core.Directories;
import org.parabot.core.ui.components.GamePanel;
import org.parabot.core.ui.components.VerboseLoader;
+import org.parabot.core.ui.components.notifications.NotificationUI;
import org.parabot.core.ui.images.Images;
import org.parabot.core.ui.utils.SwingUtil;
import org.parabot.environment.OperatingSystem;
@@ -105,6 +107,9 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
JMenuItem cacheClear = new JMenuItem("Clear cache");
cacheClear.setIcon(new ImageIcon(Images.getResource("/storage/images/trash.png")));
+ JMenuItem notifications = new JMenuItem("Notifications");
+ notifications.setIcon(new ImageIcon(Images.getResource("/storage/images/bell.png")));
+
screenshot.addActionListener(this);
proxy.addActionListener(this);
randoms.addActionListener(this);
@@ -113,6 +118,7 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
explorer.addActionListener(this);
exit.addActionListener(this);
cacheClear.addActionListener(this);
+ notifications.addActionListener(this);
run.addActionListener(this);
pause.addActionListener(this);
@@ -131,6 +137,7 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
scripts.add(stop);
features.add(cacheClear);
+ features.add(notifications);
menuBar.add(file);
menuBar.add(scripts);
@@ -237,6 +244,9 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
case "Clear cache":
Directories.clearCache();
break;
+ case "Notifications":
+ Application.launch(NotificationUI.class);
+ break;
default:
System.out.println("Invalid command: " + command);
}
diff --git a/src/main/java/org/parabot/core/ui/components/notifications/NotificationUI.java b/src/main/java/org/parabot/core/ui/components/notifications/NotificationUI.java
new file mode 100644
index 0000000..bc55311
--- /dev/null
+++ b/src/main/java/org/parabot/core/ui/components/notifications/NotificationUI.java
@@ -0,0 +1,20 @@
+package org.parabot.core.ui.components.notifications;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.layout.BorderPane;
+import javafx.stage.Stage;
+import org.parabot.core.Configuration;
+
+public class NotificationUI extends Application {
+
+ @Override
+ public void start(Stage stage) throws Exception {
+ //noinspection RedundantCast
+ BorderPane root = (BorderPane) FXMLLoader.load(this.getClass().getResource("/storage/ui/notifications.fxml"));
+ stage.setTitle(Configuration.BOT_TITLE);
+ stage.setScene(new Scene(root));
+ stage.show();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/parabot/core/ui/components/notifications/NotificationUIController.java b/src/main/java/org/parabot/core/ui/components/notifications/NotificationUIController.java
new file mode 100644
index 0000000..bc7a42d
--- /dev/null
+++ b/src/main/java/org/parabot/core/ui/components/notifications/NotificationUIController.java
@@ -0,0 +1,72 @@
+package org.parabot.core.ui.components.notifications;
+
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+import javafx.scene.control.ListView;
+import javafx.stage.Stage;
+import org.parabot.api.notifications.NotificationManager;
+import org.parabot.api.notifications.types.NotificationType;
+
+import java.net.URL;
+import java.util.ResourceBundle;
+
+/**
+ * @author JKetelaar
+ */
+public class NotificationUIController implements Initializable {
+
+ @FXML // fx:id="availableTypes"
+ private ListView availableTypes;
+
+ @FXML // fx:id="enabledTypes"
+ private ListView enabledTypes;
+
+ @Override
+ public void initialize(URL location, ResourceBundle resources) {
+ this.refreshTypes();
+ }
+
+ private void refreshTypes() {
+ availableTypes.getItems().clear();
+ for (NotificationType notificationType : NotificationManager.getContext().getAvailableNotificationTypes()) {
+ availableTypes.getItems().add(notificationType.getName());
+ }
+
+ enabledTypes.getItems().clear();
+ for (NotificationType notificationType : NotificationManager.getContext().getEnabledTypes()) {
+ enabledTypes.getItems().add(notificationType.getName());
+ }
+ }
+
+ @FXML
+ private void enableType() {
+ Object object = availableTypes.getSelectionModel().getSelectedItem();
+ if (object != null) {
+ String name = (String) object;
+
+ NotificationType type = NotificationManager.getContext().getNotificationType(name);
+ NotificationManager.getContext().enableNotificationType(type);
+
+ this.refreshTypes();
+ }
+ }
+
+ @FXML
+ private void disableType() {
+ Object object = enabledTypes.getSelectionModel().getSelectedItem();
+ if (object != null) {
+ String name = (String) object;
+
+ NotificationType type = NotificationManager.getContext().getNotificationType(name);
+ NotificationManager.getContext().disableNotificationType(type);
+
+ this.refreshTypes();
+ }
+ }
+
+ @FXML
+ private void save() {
+ Stage stage = (Stage) this.enabledTypes.getScene().getWindow();
+ stage.close();
+ }
+}
diff --git a/src/main/java/org/parabot/environment/Environment.java b/src/main/java/org/parabot/environment/Environment.java
index b3ba652..75b7bf8 100644
--- a/src/main/java/org/parabot/environment/Environment.java
+++ b/src/main/java/org/parabot/environment/Environment.java
@@ -16,7 +16,13 @@ import java.util.LinkedList;
*
* @author Everel, JKetelaar
*/
-public class Environment {
+public class Environment extends org.parabot.api.io.libraries.Environment {
+
+ private static LinkedList libs = new LinkedList<>();
+
+ static {
+ libs.add(new JavaFX());
+ }
/**
* Loads a new environment
@@ -24,10 +30,6 @@ public class Environment {
* @param desc
*/
public static void load(final ServerDescription desc) {
-
- LinkedList libs = new LinkedList<>();
- libs.add(new JavaFX());
-
for (Library lib : libs) {
loadLibrary(lib, true);
}
diff --git a/src/main/resources/storage/images/bell.png b/src/main/resources/storage/images/bell.png
new file mode 100644
index 0000000..5aab10f
Binary files /dev/null and b/src/main/resources/storage/images/bell.png differ
diff --git a/src/main/resources/storage/ui/notifications.fxml b/src/main/resources/storage/ui/notifications.fxml
new file mode 100644
index 0000000..1e6ac7b
--- /dev/null
+++ b/src/main/resources/storage/ui/notifications.fxml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+