mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 08:39:09 +00:00
Proper code style for core package
TODO: environment package
This commit is contained in:
@@ -11,10 +11,9 @@ import java.io.IOException;
|
||||
* @author Everel
|
||||
*/
|
||||
public class Core {
|
||||
|
||||
private static boolean debug = false;
|
||||
private static boolean verbose = false;
|
||||
private static boolean loadLocal = false; //Loads both local and public scripts/servers
|
||||
private static boolean debug;
|
||||
private static boolean verbose;
|
||||
private static boolean loadLocal; //Loads both local and public scripts/servers
|
||||
|
||||
/**
|
||||
* Enabled loadLocal mode
|
||||
|
||||
@@ -13,11 +13,10 @@ import java.util.*;
|
||||
* @author Matt
|
||||
*/
|
||||
public class Directories {
|
||||
|
||||
private static Map<String, File> cached = new HashMap<String, File>();
|
||||
private static Map<String, File> cached;
|
||||
|
||||
static {
|
||||
|
||||
cached = new HashMap<String, File>();
|
||||
switch (OperatingSystem.getOS()) {
|
||||
case WINDOWS:
|
||||
cached.put("Root", new JFileChooser().getFileSystemView().getDefaultDirectory());
|
||||
|
||||
@@ -34,21 +34,23 @@ import org.parabot.core.ui.components.VerboseLoader;
|
||||
* @author Matt
|
||||
*/
|
||||
public class ClassPath {
|
||||
public final HashMap<String, ClassNode> classes = new HashMap<String, ClassNode>();
|
||||
public final Map<String, URL> resources = new HashMap<String, URL>();
|
||||
|
||||
private boolean isJar = false;
|
||||
private boolean parseJar = true;
|
||||
private ArrayList<URL> jarFiles = new ArrayList<URL>();
|
||||
public final HashMap<String, ClassNode> classes;
|
||||
public final Map<String, URL> resources;
|
||||
private boolean isJar;
|
||||
private boolean parseJar;
|
||||
private ArrayList<URL> jarFiles;
|
||||
|
||||
public URL lastParsed = null;
|
||||
|
||||
public ClassPath() {
|
||||
|
||||
this(false);
|
||||
}
|
||||
|
||||
public ClassPath(final boolean isJar) {
|
||||
this.isJar = isJar;
|
||||
this.classes = new HashMap<String, ClassNode>();
|
||||
this.resources = new HashMap<String, URL>();
|
||||
this.jarFiles = new ArrayList<URL>();
|
||||
}
|
||||
|
||||
public void addJar(final File file) {
|
||||
|
||||
@@ -7,16 +7,16 @@ package org.parabot.core.desc;
|
||||
*
|
||||
*/
|
||||
public class ScriptDescription {
|
||||
public String scriptName = null;
|
||||
public String author = null;
|
||||
public String category = null;
|
||||
public double version = 0;
|
||||
public String description = null;
|
||||
public String[] servers = null;
|
||||
public String isVip = null;
|
||||
public String isPremium = null;
|
||||
public String scriptName;
|
||||
public String author;
|
||||
public String category;
|
||||
public double version;
|
||||
public String description;
|
||||
public String[] servers;
|
||||
public String isVip;
|
||||
public String isPremium;
|
||||
public int sdnId = -1;
|
||||
public String jarName = null;
|
||||
public String jarName;
|
||||
|
||||
/**
|
||||
* The ScriptManifest
|
||||
|
||||
@@ -8,9 +8,9 @@ package org.parabot.core.desc;
|
||||
*
|
||||
*/
|
||||
public class ServerDescription {
|
||||
private String serverName = null;
|
||||
private String author = null;
|
||||
private double revision = 0;
|
||||
private String serverName;
|
||||
private String author;
|
||||
private double revision;
|
||||
|
||||
public ServerDescription(final String serverName, final String author,
|
||||
final double revision) {
|
||||
|
||||
@@ -10,8 +10,8 @@ package org.parabot.core.forum;
|
||||
*
|
||||
*/
|
||||
public class Account {
|
||||
private String username = null;
|
||||
private String password = null;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -17,8 +17,8 @@ import java.util.ArrayList;
|
||||
*
|
||||
*/
|
||||
public final class AccountManager {
|
||||
private static boolean validated = false;
|
||||
private static AccountManager instance = null;
|
||||
private static boolean validated;
|
||||
private static AccountManager instance;
|
||||
|
||||
private Account account = null;
|
||||
|
||||
|
||||
@@ -3,16 +3,17 @@ package org.parabot.core.io;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class SizeInputStream extends InputStream {
|
||||
private InputStream in = null;
|
||||
|
||||
private double size = 0;
|
||||
|
||||
public int bytesRead = 0;
|
||||
|
||||
public int bytesRead;
|
||||
private ProgressListener l;
|
||||
|
||||
private long startTime = 0L;
|
||||
private InputStream in;
|
||||
private long startTime;
|
||||
private double size;
|
||||
|
||||
public SizeInputStream(InputStream in, int size, ProgressListener l) {
|
||||
this.in = in;
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.parabot.core.build.BuildPath;
|
||||
*
|
||||
*/
|
||||
public class Jython {
|
||||
private static boolean valid = false;
|
||||
private static boolean valid;
|
||||
|
||||
/**
|
||||
* Determines if jython jar has been downloaded.
|
||||
|
||||
@@ -8,12 +8,12 @@ import java.util.logging.LogRecord;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public class LabelLogHandler extends Handler {
|
||||
public final JLabel label = new JLabel();
|
||||
public final JLabel label;
|
||||
private final Color defaultColor;
|
||||
|
||||
public LabelLogHandler() {
|
||||
super();
|
||||
defaultColor = label.getForeground();
|
||||
this.label = new JLabel();
|
||||
this.defaultColor = label.getForeground();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,25 +7,27 @@ import java.util.Date;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
public class LogFormatter extends Formatter
|
||||
{
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
public class LogFormatter extends Formatter {
|
||||
private static final String LINE_SEPARATOR = System
|
||||
.getProperty("line.separator");
|
||||
private final boolean appendNewLine;
|
||||
|
||||
public LogFormatter()
|
||||
{
|
||||
public LogFormatter() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
public LogFormatter(final boolean appendNewLine)
|
||||
{
|
||||
public LogFormatter(final boolean appendNewLine) {
|
||||
this.appendNewLine = appendNewLine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(final LogRecord record) {
|
||||
final StringBuilder result = new StringBuilder().append("[").append(record.getLevel().getName()).append("] ").append(new Date(record.getMillis())).append(": ").append(record.getLoggerName()).append(": ").append(record.getMessage()).append(throwableToString(record.getThrown()));
|
||||
final StringBuilder result = new StringBuilder().append("[")
|
||||
.append(record.getLevel().getName()).append("] ")
|
||||
.append(new Date(record.getMillis())).append(": ")
|
||||
.append(record.getLoggerName()).append(": ")
|
||||
.append(record.getMessage())
|
||||
.append(throwableToString(record.getThrown()));
|
||||
if (appendNewLine) {
|
||||
result.append(LogFormatter.LINE_SEPARATOR);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.logging.Logger;
|
||||
* @author Paris
|
||||
*/
|
||||
public class LogOutputStream extends OutputStream {
|
||||
protected boolean hasBeenClosed = false;
|
||||
protected boolean hasBeenClosed;
|
||||
protected Logger category;
|
||||
protected Level priority;
|
||||
protected StringBuilder buffer;
|
||||
|
||||
@@ -16,8 +16,13 @@ import org.parabot.core.Context;
|
||||
*
|
||||
*/
|
||||
public class PaintDebugger {
|
||||
private final HashMap<String, AbstractDebugger> debuggers = new HashMap<String, AbstractDebugger>();
|
||||
private final Queue<String> stringDebug = new LinkedList<String>();
|
||||
private final HashMap<String, AbstractDebugger> debuggers;
|
||||
private final Queue<String> stringDebug;
|
||||
|
||||
public PaintDebugger() {
|
||||
this.debuggers = new HashMap<String, AbstractDebugger>();
|
||||
this.stringDebug = new LinkedList<String>();
|
||||
}
|
||||
|
||||
public final void addDebugger(final String name, final AbstractDebugger debugger) {
|
||||
debuggers.put(name, debugger);
|
||||
|
||||
@@ -20,11 +20,8 @@ import org.parabot.core.asm.wrappers.Super;
|
||||
*
|
||||
* @author Dane
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class JSONHookParser extends HookParser {
|
||||
|
||||
private JSONObject root;
|
||||
private Map<String, String> interfaces;
|
||||
private HashMap<String, String> constants;
|
||||
|
||||
@@ -18,9 +18,7 @@ import java.io.FilenameFilter;
|
||||
* @author Everel
|
||||
*/
|
||||
public class LocalPythonScripts extends ScriptParser {
|
||||
private PythonInterpreter interpreter = new PythonInterpreter();
|
||||
|
||||
private static final FilenameFilter PYTHON_SCRIPT_FILTER = new FilenameFilter() {
|
||||
private static final FilenameFilter PYTHON_SCRIPT_FILTER = new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
@@ -28,6 +26,12 @@ public class LocalPythonScripts extends ScriptParser {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private PythonInterpreter interpreter;
|
||||
|
||||
public LocalPythonScripts() {
|
||||
this.interpreter = new PythonInterpreter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name - local var name
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.net.URL;
|
||||
* @author Everel
|
||||
*/
|
||||
public class SDNScripts extends ScriptParser {
|
||||
private static AccountManager manager = null;
|
||||
private static AccountManager manager;
|
||||
|
||||
public static final AccountManagerAccess MANAGER_FETCHER = new AccountManagerAccess() {
|
||||
|
||||
|
||||
@@ -5,11 +5,8 @@ import java.net.SocketException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class MacAddress {
|
||||
|
||||
public static byte[] mac = new byte[] { 11, 11, 11, 11, 11, 11 };
|
||||
|
||||
private static byte[] realMac;
|
||||
|
||||
private static MacAddress cached;
|
||||
|
||||
static {
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.awt.event.ActionListener;
|
||||
public class BotUI extends JFrame implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = -2126184292879805519L;
|
||||
private static BotUI instance = null;
|
||||
private static BotUI instance;
|
||||
|
||||
public static BotUI getInstance() {
|
||||
return instance == null ? instance = new BotUI() : instance;
|
||||
|
||||
@@ -34,12 +34,12 @@ import org.parabot.core.ui.utils.SwingUtil;
|
||||
public class LoginUI extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 2032832552863466297L;
|
||||
private static LoginUI instance = null;
|
||||
private static LoginUI instance;
|
||||
private JTextField txtUsername;
|
||||
private JPasswordField txtPassword;
|
||||
private JButton cmdLogin;
|
||||
private JButton cmdRegister;
|
||||
private static AccountManager manager = null;
|
||||
private static AccountManager manager;
|
||||
|
||||
public static final AccountManagerAccess MANAGER_FETCHER = new AccountManagerAccess() {
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
public class NetworkUI {
|
||||
|
||||
public JFrame frame;
|
||||
private JTextField proxyHostField;
|
||||
private JTextField proxyPortField;
|
||||
private HashMap<String, Integer> socksVersions = new HashMap<>();
|
||||
private HashMap<String, Integer> socksVersions;
|
||||
|
||||
public NetworkUI() {
|
||||
this.socksVersions = new HashMap<String, Integer>();
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,19 @@ import java.util.HashMap;
|
||||
* @author Everel
|
||||
*/
|
||||
public final class ScriptSelector extends JFrame {
|
||||
public static ScriptParser parser;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private HashMap<String, DefaultMutableTreeNode> categories = new HashMap<String, DefaultMutableTreeNode>();
|
||||
private HashMap<String, ScriptDescription> format = new HashMap<String, ScriptDescription>();
|
||||
private DefaultMutableTreeNode root = new DefaultMutableTreeNode("Scripts");
|
||||
private DefaultTreeModel model = null;
|
||||
private final int WIDTH = 640;
|
||||
private final int HEIGHT = 256 + 128;
|
||||
|
||||
public static ScriptParser parser = null;
|
||||
private DefaultTreeModel model;
|
||||
private final int WIDTH;
|
||||
private final int HEIGHT;
|
||||
|
||||
public ScriptSelector() {
|
||||
model = new DefaultTreeModel(root);
|
||||
this.WIDTH = 640;
|
||||
this.HEIGHT = 256 + 128;
|
||||
this.model = new DefaultTreeModel(root);
|
||||
putScripts();
|
||||
createUI();
|
||||
}
|
||||
|
||||
@@ -25,13 +25,11 @@ import org.parabot.environment.Environment;
|
||||
*/
|
||||
|
||||
public class ServerSelector extends JFrame {
|
||||
|
||||
public static String initServer;
|
||||
private static final long serialVersionUID = 5238720307271493899L;
|
||||
private static ServerSelector instance = null;
|
||||
private static ServerSelector instance;
|
||||
private JPanel panel;
|
||||
|
||||
public static String initServer = null;
|
||||
|
||||
public static ServerSelector getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ServerSelector();
|
||||
|
||||
@@ -30,16 +30,18 @@ import org.parabot.environment.scripts.Script;
|
||||
*/
|
||||
public class BotToolbar extends JToolBar {
|
||||
private static final long serialVersionUID = 5373484845104212180L;
|
||||
private static BotToolbar instance = null;
|
||||
private JButton tab = null;
|
||||
private final JButton run = new JButton();
|
||||
private final JButton stop = new JButton();
|
||||
private static BotToolbar instance;
|
||||
private static Map<TabButton, Context> environments = new HashMap<TabButton, Context>();
|
||||
private JButton tab;
|
||||
private final JButton run;
|
||||
private final JButton stop;
|
||||
|
||||
private boolean runScript = false;
|
||||
private boolean pauseScript = false;
|
||||
|
||||
public BotToolbar() {
|
||||
this.run = new JButton();
|
||||
this.stop = new JButton();
|
||||
setFloatable(false);
|
||||
tab = new JButton();
|
||||
tab.addActionListener(new ActionListener() {
|
||||
|
||||
@@ -18,9 +18,9 @@ import org.parabot.core.Context;
|
||||
*/
|
||||
public class GamePanel extends JPanel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static GamePanel instance = null;
|
||||
private static GamePanel instance;
|
||||
private static VerboseLoader loader = VerboseLoader.get();
|
||||
public Context context = null;
|
||||
public Context context;
|
||||
|
||||
private GamePanel() {
|
||||
setFocusable(true);
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.parabot.core.logging.TextAreaLogHandler;
|
||||
public class LogArea extends JScrollPane {
|
||||
|
||||
private static final long serialVersionUID = 6571141103751675714L;
|
||||
private static LogArea instance = null;
|
||||
private static LogTextArea logArea = new LogTextArea();
|
||||
private static LogArea instance;
|
||||
|
||||
private LogArea() {
|
||||
super(TextAreaLogHandler.TEXT_AREA,
|
||||
|
||||
@@ -14,18 +14,21 @@ import java.awt.geom.Rectangle2D;
|
||||
*
|
||||
*/
|
||||
public class ProgressBar {
|
||||
private double value = 0;
|
||||
private int width = 0;
|
||||
private int height = 0;
|
||||
private double locX = 0;
|
||||
private Color progColor = new Color(255, 0, 0);
|
||||
private Color backColor = new Color(74, 74, 72, 100);
|
||||
private FontMetrics fontMetrics = null;
|
||||
private String text = "";
|
||||
private double value;
|
||||
private int width;
|
||||
private int height;
|
||||
private double locX;
|
||||
private Color progColor;
|
||||
private Color backColor;
|
||||
private FontMetrics fontMetrics;
|
||||
private String text;
|
||||
|
||||
public ProgressBar(int width, int height) {
|
||||
this.progColor = new Color(255, 0, 0);
|
||||
this.backColor = new Color(74, 74, 72, 100);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.text = "";
|
||||
}
|
||||
|
||||
public void setText(final String text) {
|
||||
|
||||
@@ -21,12 +21,13 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
||||
private static final long serialVersionUID = 7412412644921803896L;
|
||||
private static VerboseLoader current = null;
|
||||
private static String state = "Initializing loader...";
|
||||
private FontMetrics fontMetrics = null;
|
||||
private BufferedImage bot_image = null;
|
||||
private ProgressBar p = new ProgressBar(400, 20);
|
||||
private FontMetrics fontMetrics;
|
||||
private BufferedImage bot_image;
|
||||
private ProgressBar p;
|
||||
|
||||
public VerboseLoader() {
|
||||
bot_image = Images.getResource("/org/parabot/core/ui/images/para.png");
|
||||
this.bot_image = Images.getResource("/org/parabot/core/ui/images/para.png");
|
||||
this.p = new ProgressBar(400, 20);
|
||||
setSize(775, 510);
|
||||
setBackground(Color.black);
|
||||
setDoubleBuffered(true);
|
||||
|
||||
@@ -8,10 +8,9 @@ import java.awt.Toolkit;
|
||||
* Holds various awt util based methods
|
||||
*
|
||||
* @author Dane
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class AwtUtil {
|
||||
|
||||
private static Toolkit toolkit;
|
||||
|
||||
public static Toolkit getToolkit() {
|
||||
|
||||
@@ -19,11 +19,10 @@ import java.awt.event.MouseMotionListener;
|
||||
*/
|
||||
public class ServerWidget extends JPanel implements MouseListener,
|
||||
MouseMotionListener {
|
||||
|
||||
public ServerDescription desc;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String name = null;
|
||||
public ServerDescription desc = null;
|
||||
private boolean hovered = false;
|
||||
private String name;
|
||||
private boolean hovered;
|
||||
|
||||
public ServerWidget(final ServerDescription desc) {
|
||||
this.desc = desc;
|
||||
|
||||
Reference in New Issue
Block a user