Added support for resources

This commit is contained in:
JKetelaar
2015-09-13 23:44:04 +02:00
parent 5bdfbb22df
commit 1841485d32
415 changed files with 47 additions and 31 deletions
@@ -21,5 +21,5 @@ public class Configuration {
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 String BOT_VERSION = "2.2";
public static final String BOT_VERSION = "2.2.3";
}
@@ -23,7 +23,7 @@ public class ProjectProperties {
String propertiesFileName = "/app.properties";
Properties properties = new Properties();
InputStream inputStream = this.getClass().getClassLoader()
InputStream inputStream = ProjectProperties.class.getClassLoader()
.getResourceAsStream(propertiesFileName);
cached.load(inputStream);
@@ -3,45 +3,57 @@ package org.parabot.core.asm.redirect;
import org.parabot.core.asm.RedirectClassAdapter;
public class ThreadRedirect {
private static int count = 0;
public static void start(Thread t){
t.start();
}
public static void setPriority(Thread t,int i){
t.setPriority(i);
}
public static void setDaemon(Thread t,boolean b){
t.setDaemon(b);
}
public static void interrupt(Thread t){
t.interrupt();
}
public static Thread currentThread(){
return null;
}
public static void join(Thread t) throws InterruptedException{
t.join();
}
public static void join(Thread t,long l) throws InterruptedException{
t.join(l);
}
public static void join(Thread t, long l,int i) throws InterruptedException{
t.join(l, i);
}
public static ClassLoader getContextClassLoader(Thread t){
return null;
}
public static ThreadGroup getThreadGroup(Thread t){
throw RedirectClassAdapter.createSecurityException();
}
public static void setName(Thread t, String name){
t.setName(name);
}
public static String getName(Thread t){
return t.getName();
}
public static void sleep(long time) throws InterruptedException{
Thread.sleep(time);
}
+3 -3
View File
@@ -84,15 +84,15 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
JMenuItem exit = new JMenuItem("Exit");
run = new JMenuItem("Run");
run.setIcon(new ImageIcon(Images.getResource("/org/parabot/core/ui/images/run.png")));
run.setIcon(new ImageIcon(Images.getResource("/images/run.png")));
pause = new JMenuItem("Pause");
pause.setEnabled(false);
pause.setIcon(new ImageIcon(Images.getResource("/org/parabot/core/ui/images/pause.png")));
pause.setIcon(new ImageIcon(Images.getResource("/images/pause.png")));
stop = new JMenuItem("Stop");
stop.setEnabled(false);
stop.setIcon(new ImageIcon(Images.getResource("/org/parabot/core/ui/images/stop.png")));
stop.setIcon(new ImageIcon(Images.getResource("/images/stop.png")));
screenshot.addActionListener(this);
proxy.addActionListener(this);
@@ -95,7 +95,7 @@ public class LoginUI extends JFrame {
RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g.drawImage(Images
.getResource("/org/parabot/core/ui/images/para.png"),
.getResource("/images/para.png"),
0, 8, 250, 45, null);
}
};
@@ -51,7 +51,7 @@ public class VerboseLoader extends JPanel implements ProgressListener {
throw new IllegalStateException("MainScreenComponent already made.");
}
current = this;
this.background = Images.getResource("/org/parabot/core/ui/images/background.png");
this.background = Images.getResource("/images/background.png");
this.progressBar = new ProgressBar(400, 20);
setLayout(new GridBagLayout());
setSize(775, 510);
@@ -1,10 +1,9 @@
package org.parabot.core.ui.images;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import javax.imageio.ImageIO;
/**
*
* Caches and loads images from resource
@@ -1,14 +1,13 @@
package org.parabot.core.ui.utils;
import java.awt.Image;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.swing.JFrame;
import org.parabot.core.ui.images.Images;
import org.parabot.environment.OperatingSystem;
import javax.swing.*;
import java.awt.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
*
* Holds various swing util based methods
@@ -30,7 +29,7 @@ public class SwingUtil {
}
public static void setParabotIcons(JFrame f) {
f.setIconImage(Images.getResource("/org/parabot/core/ui/images/icon.png"));
f.setIconImage(Images.getResource("/images/icon.png"));
if(OperatingSystem.getOS() == OperatingSystem.MAC) {
/** Adds the dock icon to mac users */
@@ -38,7 +37,7 @@ public class SwingUtil {
Class<?> util = Class.forName("com.apple.eawt.Application");
Object application = util.getMethod("getApplication", new Class[] { }).invoke(null);
Method setDockIconImage = util.getMethod("setDockIconImage", new Class[] { Image.class });
setDockIconImage.invoke(application, Images.getResource("/org/parabot/core/ui/images/icon.png"));
setDockIconImage.invoke(application, Images.getResource("/images/icon.png"));
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException ignored) {
} catch (Throwable t) {
t.printStackTrace();
@@ -33,7 +33,7 @@ public enum Category
*/
public static BufferedImage getIcon(String s) {
if (images.get(s) == null) {
images.put(s, Images.getResource("/org/parabot/core/ui/images/category/" + s + ".png"));
images.put(s, Images.getResource("/images/category/" + s + ".png"));
}
return images.get(s);
}
@@ -52,7 +52,7 @@ public enum Category
private static HashMap<String, BufferedImage> images = new HashMap<>();
static {
images.put("script", Images.getResource("/org/parabot/core/ui/images/category/script.png"));
images.put("script", Images.getResource("/images/category/script.png"));
}
}