mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 08:39:09 +00:00
Final core package proper code style fixes
This commit is contained in:
@@ -14,6 +14,6 @@ public class Configuration {
|
||||
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
|
||||
public static final double BOT_VERSION = 2.05; // BETA
|
||||
|
||||
}
|
||||
|
||||
@@ -24,10 +24,11 @@ import org.parabot.core.classpath.ClassPath;
|
||||
*/
|
||||
public class ASMClassLoader extends ClassLoader {
|
||||
|
||||
private Map<String, Class<?>> classCache = new HashMap<String, Class<?>>();
|
||||
public ClassPath classPath = null;
|
||||
private Map<String, Class<?>> classCache;
|
||||
public ClassPath classPath;
|
||||
|
||||
public ASMClassLoader(final ClassPath classPath) {
|
||||
this.classCache = new HashMap<String, Class<?>>();
|
||||
this.classPath = classPath;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ import org.parabot.core.asm.interfaces.Injectable;
|
||||
*
|
||||
*/
|
||||
public class AddGetterAdapter implements Opcodes, Injectable {
|
||||
private ClassNode into = null;
|
||||
private ClassNode fieldLocation = null;
|
||||
private FieldNode fieldNode = null;
|
||||
private String methodName = null;
|
||||
private String returnDesc = null;
|
||||
private boolean staticField = false;
|
||||
private boolean staticMethod = false;
|
||||
private ClassNode into;
|
||||
private ClassNode fieldLocation;
|
||||
private FieldNode fieldNode;
|
||||
private String methodName;
|
||||
private String returnDesc;
|
||||
private boolean staticField;
|
||||
private boolean staticMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -13,10 +13,10 @@ import org.parabot.core.asm.interfaces.Injectable;
|
||||
*
|
||||
*/
|
||||
public class AddInterfaceAdapter implements Injectable {
|
||||
|
||||
private static String accessorPackage = null;
|
||||
private ClassNode node = null;
|
||||
private String interfaceClass = null;
|
||||
private static String accessorPackage;
|
||||
|
||||
private ClassNode node;
|
||||
private String interfaceClass;
|
||||
|
||||
public AddInterfaceAdapter(ClassNode node, String interfaceClass) {
|
||||
this.node = node;
|
||||
|
||||
@@ -14,12 +14,12 @@ import org.parabot.core.asm.interfaces.Injectable;
|
||||
*
|
||||
*/
|
||||
public class AddInvokerAdapter implements Opcodes, Injectable {
|
||||
private ClassNode into = null;
|
||||
private ClassNode methodLocation = null;
|
||||
private MethodNode mn = null;
|
||||
private String argsDesc = null;
|
||||
private String returnDesc = null;
|
||||
private String methodName = null;
|
||||
private ClassNode into;
|
||||
private ClassNode methodLocation;
|
||||
private MethodNode mn;
|
||||
private String argsDesc;
|
||||
private String returnDesc;
|
||||
private String methodName;
|
||||
|
||||
public AddInvokerAdapter(final ClassNode methodLocation,
|
||||
final ClassNode into, final MethodNode mn, final String argsDesc,
|
||||
|
||||
@@ -14,12 +14,12 @@ import org.parabot.core.asm.interfaces.Injectable;
|
||||
*
|
||||
*/
|
||||
public class AddSetterAdapter implements Opcodes, Injectable {
|
||||
private ClassNode fieldLocation = null;
|
||||
private ClassNode into = null;
|
||||
private FieldNode field = null;
|
||||
private String name = null;
|
||||
private String desc = null;
|
||||
private boolean methodStatic = false;
|
||||
private ClassNode fieldLocation;
|
||||
private ClassNode into;
|
||||
private FieldNode field;
|
||||
private String name;
|
||||
private String desc;
|
||||
private boolean methodStatic;
|
||||
|
||||
public AddSetterAdapter(ClassNode fieldLocation, ClassNode into,
|
||||
FieldNode field, String name, String desc, boolean methodStatic) {
|
||||
|
||||
@@ -19,8 +19,8 @@ import org.parabot.core.asm.interfaces.Injectable;
|
||||
*
|
||||
*/
|
||||
public class AddSuperAdapter implements Injectable {
|
||||
private ClassNode node = null;
|
||||
private String superClass = null;
|
||||
private ClassNode node;
|
||||
private String superClass;
|
||||
|
||||
public AddSuperAdapter(final ClassNode node, final String superClass) {
|
||||
this.node = node;
|
||||
|
||||
@@ -14,13 +14,12 @@ import org.parabot.core.asm.interfaces.Injectable;
|
||||
*
|
||||
*/
|
||||
public class Getter implements Injectable {
|
||||
|
||||
private ClassNode into = null;
|
||||
private ClassNode fieldLocation = null;
|
||||
private FieldNode fieldNode = null;
|
||||
private String methodName = null;
|
||||
private String returnDesc = null;
|
||||
private boolean staticMethod = false;
|
||||
private ClassNode into;
|
||||
private ClassNode fieldLocation;
|
||||
private FieldNode fieldNode;
|
||||
private String methodName;
|
||||
private String returnDesc;
|
||||
private boolean staticMethod;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -14,12 +14,12 @@ import org.parabot.core.asm.interfaces.Injectable;
|
||||
*
|
||||
*/
|
||||
public class Invoker implements Injectable {
|
||||
private ClassNode into = null;
|
||||
private ClassNode methodLocation = null;
|
||||
private MethodNode mn = null;
|
||||
private String argsDesc = null;
|
||||
private String returnDesc = null;
|
||||
private String methodName = null;
|
||||
private ClassNode into;
|
||||
private ClassNode methodLocation;
|
||||
private MethodNode mn;
|
||||
private String argsDesc;
|
||||
private String returnDesc;
|
||||
private String methodName;
|
||||
|
||||
public Invoker(String methodLoc, String invMethName, String argsDesc,
|
||||
String returnDesc, String methodName) {
|
||||
|
||||
@@ -14,12 +14,12 @@ import org.parabot.core.asm.interfaces.Injectable;
|
||||
*
|
||||
*/
|
||||
public class Setter implements Injectable {
|
||||
private ClassNode fieldLocation = null;
|
||||
private ClassNode into = null;
|
||||
private FieldNode field = null;
|
||||
private String name = null;
|
||||
private String desc = null;
|
||||
private boolean methodStatic = false;
|
||||
private ClassNode fieldLocation;
|
||||
private ClassNode into;
|
||||
private FieldNode field;
|
||||
private String name;
|
||||
private String desc;
|
||||
private boolean methodStatic;
|
||||
|
||||
public Setter(final String fieldLocation, String into, final String fieldName, final String methodName, final String desc, final boolean methodStatic) {
|
||||
this.fieldLocation = ASMUtils.getClass(fieldLocation);
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.parabot.core.asm.interfaces.Injectable;
|
||||
*
|
||||
*/
|
||||
public class Super implements Injectable {
|
||||
private String className = null;
|
||||
private String superClassName = null;
|
||||
private String className;
|
||||
private String superClassName;
|
||||
|
||||
public Super(String className, String superClassName) {
|
||||
this.className = className;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ScriptDescription {
|
||||
public String[] servers;
|
||||
public String isVip;
|
||||
public String isPremium;
|
||||
public int sdnId = -1;
|
||||
public int sdnId;
|
||||
public String jarName;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ public final class AccountManager {
|
||||
private static boolean validated;
|
||||
private static AccountManager instance;
|
||||
|
||||
private Account account = null;
|
||||
private Account account;
|
||||
|
||||
private AccountManager() {
|
||||
|
||||
|
||||
@@ -30,23 +30,14 @@ import javax.swing.border.EmptyBorder;
|
||||
* Non swing methods are thread safe.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class LogTextArea extends JList
|
||||
{
|
||||
public class LogTextArea extends JList {
|
||||
private static final int MAX_ENTRIES = 100;
|
||||
private static final Rectangle BOTTOM_OF_WINDOW = new Rectangle(0, Integer.MAX_VALUE, 0, 0);
|
||||
private static final Rectangle BOTTOM_OF_WINDOW = new Rectangle(0,
|
||||
Integer.MAX_VALUE, 0, 0);
|
||||
private static final long serialVersionUID = 0;
|
||||
private final LogQueue logQueue = new LogQueue();
|
||||
private final LogAreaListModel model = new LogAreaListModel();
|
||||
private final Runnable scrollToBottom = new Runnable()
|
||||
{
|
||||
public void run() {
|
||||
scrollRectToVisible(LogTextArea.BOTTOM_OF_WINDOW);
|
||||
}
|
||||
};
|
||||
|
||||
private static final Formatter formatter = new Formatter()
|
||||
{
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:ss");
|
||||
private static final Formatter formatter = new Formatter() {
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat(
|
||||
"hh:mm:ss");
|
||||
|
||||
@Override
|
||||
public String format(final LogRecord record) {
|
||||
@@ -55,30 +46,37 @@ public class LogTextArea extends JList
|
||||
final int maxLen = 16;
|
||||
final String append = "...";
|
||||
|
||||
return String.format("[%s] %-" + maxLen + "s %s %s", dateFormat.format(record.getMillis()), name.length() > maxLen ? name.substring(0, maxLen - append.length()) + append : name, record.getMessage(), throwableToString(record.getThrown()));
|
||||
return String.format(
|
||||
"[%s] %-" + maxLen + "s %s %s",
|
||||
dateFormat.format(record.getMillis()),
|
||||
name.length() > maxLen ? name.substring(0,
|
||||
maxLen - append.length())
|
||||
+ append : name, record.getMessage(),
|
||||
throwableToString(record.getThrown()));
|
||||
}
|
||||
};
|
||||
|
||||
private static String throwableToString(final Throwable t) {
|
||||
if (t != null) {
|
||||
final Writer exception = new StringWriter();
|
||||
final PrintWriter printWriter = new PrintWriter(exception);
|
||||
t.printStackTrace(printWriter);
|
||||
return exception.toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static final Formatter copyPasteFormatter = new LogFormatter(false);
|
||||
|
||||
private final LogQueue logQueue;
|
||||
private final LogAreaListModel model;
|
||||
private final Runnable scrollToBottom;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public LogTextArea()
|
||||
{
|
||||
public LogTextArea() {
|
||||
logQueue = new LogQueue();
|
||||
model = new LogAreaListModel();
|
||||
scrollToBottom = new Runnable() {
|
||||
public void run() {
|
||||
scrollRectToVisible(LogTextArea.BOTTOM_OF_WINDOW);
|
||||
}
|
||||
};
|
||||
|
||||
setModel(model);
|
||||
setCellRenderer(new Renderer());
|
||||
setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
String fontName = Font.MONOSPACED;
|
||||
for (final Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) {
|
||||
for (final Font font : GraphicsEnvironment
|
||||
.getLocalGraphicsEnvironment().getAllFonts()) {
|
||||
final String name = font.getName();
|
||||
if (name.matches("Monaco|Consolas")) {
|
||||
fontName = name;
|
||||
@@ -100,16 +98,17 @@ public class LogTextArea extends JList
|
||||
logQueue.queue(new WrappedLogRecord(logRecord));
|
||||
}
|
||||
|
||||
private class LogAreaListModel extends AbstractListModel
|
||||
{
|
||||
private class LogAreaListModel extends AbstractListModel {
|
||||
private static final long serialVersionUID = 0;
|
||||
|
||||
private List<WrappedLogRecord> records = new ArrayList<WrappedLogRecord>(LogTextArea.MAX_ENTRIES);
|
||||
private List<WrappedLogRecord> records = new ArrayList<WrappedLogRecord>(
|
||||
LogTextArea.MAX_ENTRIES);
|
||||
|
||||
public void addAllElements(final List<WrappedLogRecord> obj) {
|
||||
records.addAll(obj);
|
||||
if (getSize() > LogTextArea.MAX_ENTRIES) {
|
||||
records.subList(0, (getSize() - LogTextArea.MAX_ENTRIES)).clear();
|
||||
records.subList(0, (getSize() - LogTextArea.MAX_ENTRIES))
|
||||
.clear();
|
||||
|
||||
fireContentsChanged(this, 0, (getSize() - 1));
|
||||
} else {
|
||||
@@ -129,11 +128,11 @@ public class LogTextArea extends JList
|
||||
/**
|
||||
* Flushes every #FLUSH_RATE (milliseconds)
|
||||
*/
|
||||
private class LogQueue implements Runnable
|
||||
{
|
||||
private class LogQueue implements Runnable {
|
||||
public static final int FLUSH_RATE = 1000;
|
||||
private final Object lock = new Object();
|
||||
private List<WrappedLogRecord> queue = new ArrayList<WrappedLogRecord>(100);
|
||||
private List<WrappedLogRecord> queue = new ArrayList<WrappedLogRecord>(
|
||||
100);
|
||||
|
||||
public void queue(final WrappedLogRecord record) {
|
||||
synchronized (lock) {
|
||||
@@ -166,13 +165,17 @@ public class LogTextArea extends JList
|
||||
|
||||
}
|
||||
|
||||
private static class Renderer implements ListCellRenderer
|
||||
{
|
||||
private static class Renderer implements ListCellRenderer {
|
||||
private final Border EMPTY_BORDER = new EmptyBorder(1, 1, 1, 1);
|
||||
private final Border SELECTED_BORDER = UIManager.getBorder("List.focusCellHighlightBorder");
|
||||
private final Color DARK_GREEN = new Color(0, 0xcc, 0), DARK_RED = new Color(0xcc, 0, 0), DARK_PINK = new Color(0xff, 0, 0x66);
|
||||
private final Border SELECTED_BORDER = UIManager
|
||||
.getBorder("List.focusCellHighlightBorder");
|
||||
private final Color DARK_GREEN = new Color(0, 0xcc, 0),
|
||||
DARK_RED = new Color(0xcc, 0, 0), DARK_PINK = new Color(0xff,
|
||||
0, 0x66);
|
||||
|
||||
public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
|
||||
public Component getListCellRendererComponent(final JList list,
|
||||
final Object value, final int index, final boolean isSelected,
|
||||
final boolean cellHasFocus) {
|
||||
if (!(value instanceof WrappedLogRecord)) {
|
||||
return new JLabel();
|
||||
}
|
||||
@@ -183,7 +186,8 @@ public class LogTextArea extends JList
|
||||
result.setText(wlr.formatted);
|
||||
result.setComponentOrientation(list.getComponentOrientation());
|
||||
result.setFont(list.getFont());
|
||||
result.setBorder(cellHasFocus || isSelected ? SELECTED_BORDER : EMPTY_BORDER);
|
||||
result.setBorder(cellHasFocus || isSelected ? SELECTED_BORDER
|
||||
: EMPTY_BORDER);
|
||||
|
||||
result.setForeground(Color.BLACK);
|
||||
|
||||
@@ -196,7 +200,9 @@ public class LogTextArea extends JList
|
||||
result.setForeground(DARK_PINK);
|
||||
}
|
||||
|
||||
if (wlr.record.getLevel() == Level.FINE || wlr.record.getLevel() == Level.FINER || wlr.record.getLevel() == Level.FINEST) {
|
||||
if (wlr.record.getLevel() == Level.FINE
|
||||
|| wlr.record.getLevel() == Level.FINER
|
||||
|| wlr.record.getLevel() == Level.FINEST) {
|
||||
result.setForeground(DARK_GREEN);
|
||||
}
|
||||
|
||||
@@ -221,15 +227,14 @@ public class LogTextArea extends JList
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the log records so we can control the copy paste text (via #toString)
|
||||
* Wrap the log records so we can control the copy paste text (via
|
||||
* #toString)
|
||||
*/
|
||||
private class WrappedLogRecord
|
||||
{
|
||||
private class WrappedLogRecord {
|
||||
public final LogRecord record;
|
||||
public final String formatted;
|
||||
|
||||
public WrappedLogRecord(final LogRecord record)
|
||||
{
|
||||
public WrappedLogRecord(final LogRecord record) {
|
||||
this.record = record;
|
||||
formatted = LogTextArea.formatter.format(record);
|
||||
}
|
||||
@@ -239,4 +244,14 @@ public class LogTextArea extends JList
|
||||
return LogTextArea.copyPasteFormatter.format(record);
|
||||
}
|
||||
}
|
||||
|
||||
private static String throwableToString(final Throwable t) {
|
||||
if (t != null) {
|
||||
final Writer exception = new StringWriter();
|
||||
final PrintWriter printWriter = new PrintWriter(exception);
|
||||
t.printStackTrace(printWriter);
|
||||
return exception.toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class XMLHookParser extends HookParser {
|
||||
private boolean parsedInterfaces;
|
||||
private Document doc;
|
||||
private HashMap<String, String> interfaceMap;
|
||||
private HashMap<String, String> constants;
|
||||
private boolean parsedInterfaces;
|
||||
|
||||
public XMLHookParser(HookFile hookFile) {
|
||||
super(hookFile);
|
||||
|
||||
@@ -32,14 +32,14 @@ import org.parabot.core.ui.utils.SwingUtil;
|
||||
*
|
||||
*/
|
||||
public class LoginUI extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 2032832552863466297L;
|
||||
private static LoginUI instance;
|
||||
private static AccountManager manager;
|
||||
|
||||
private JTextField txtUsername;
|
||||
private JPasswordField txtPassword;
|
||||
private JButton cmdLogin;
|
||||
private JButton cmdRegister;
|
||||
private static AccountManager manager;
|
||||
|
||||
public static final AccountManagerAccess MANAGER_FETCHER = new AccountManagerAccess() {
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.awt.event.ActionListener;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class NetworkUI {
|
||||
|
||||
public JFrame frame;
|
||||
private JTextField proxyHostField;
|
||||
private JTextField proxyPortField;
|
||||
|
||||
@@ -27,14 +27,18 @@ import java.util.HashMap;
|
||||
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 HashMap<String, DefaultMutableTreeNode> categories;
|
||||
private HashMap<String, ScriptDescription> format;
|
||||
private DefaultMutableTreeNode root;
|
||||
private DefaultTreeModel model;
|
||||
private final int WIDTH;
|
||||
private final int HEIGHT;
|
||||
|
||||
public ScriptSelector() {
|
||||
this.categories = new HashMap<String, DefaultMutableTreeNode>();
|
||||
this.format = new HashMap<String, ScriptDescription>();
|
||||
this.root = new DefaultMutableTreeNode("Scripts");
|
||||
this.WIDTH = 640;
|
||||
this.HEIGHT = 256 + 128;
|
||||
this.model = new DefaultTreeModel(root);
|
||||
|
||||
@@ -28,6 +28,7 @@ public class ServerSelector extends JFrame {
|
||||
public static String initServer;
|
||||
private static final long serialVersionUID = 5238720307271493899L;
|
||||
private static ServerSelector instance;
|
||||
|
||||
private JPanel panel;
|
||||
|
||||
public static ServerSelector getInstance() {
|
||||
|
||||
@@ -32,12 +32,12 @@ public class BotToolbar extends JToolBar {
|
||||
private static final long serialVersionUID = 5373484845104212180L;
|
||||
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;
|
||||
private boolean runScript;
|
||||
private boolean pauseScript;
|
||||
|
||||
public BotToolbar() {
|
||||
this.run = new JButton();
|
||||
|
||||
@@ -20,6 +20,7 @@ public class GamePanel extends JPanel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static GamePanel instance;
|
||||
private static VerboseLoader loader = VerboseLoader.get();
|
||||
|
||||
public Context context;
|
||||
|
||||
private GamePanel() {
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.parabot.core.logging.TextAreaLogHandler;
|
||||
*
|
||||
*/
|
||||
public class LogArea extends JScrollPane {
|
||||
|
||||
private static final long serialVersionUID = 6571141103751675714L;
|
||||
private static LogTextArea logArea = new LogTextArea();
|
||||
private static LogArea instance;
|
||||
|
||||
@@ -19,8 +19,9 @@ import org.parabot.core.ui.images.Images;
|
||||
*/
|
||||
public class VerboseLoader extends JPanel implements ProgressListener {
|
||||
private static final long serialVersionUID = 7412412644921803896L;
|
||||
private static VerboseLoader current = null;
|
||||
private static VerboseLoader current;
|
||||
private static String state = "Initializing loader...";
|
||||
|
||||
private FontMetrics fontMetrics;
|
||||
private BufferedImage bot_image;
|
||||
private ProgressBar p;
|
||||
|
||||
@@ -13,15 +13,15 @@ import javax.imageio.ImageIO;
|
||||
*
|
||||
*/
|
||||
public final class Images {
|
||||
private static final HashMap<String, BufferedImage> imageCache = new HashMap<String, BufferedImage>();
|
||||
private static final HashMap<String, BufferedImage> IMAGE_CACHE = new HashMap<String, BufferedImage>();
|
||||
|
||||
public static BufferedImage getResource(final String resource) {
|
||||
if(imageCache.containsKey(resource)) {
|
||||
return imageCache.get(resource);
|
||||
if(IMAGE_CACHE.containsKey(resource)) {
|
||||
return IMAGE_CACHE.get(resource);
|
||||
}
|
||||
try {
|
||||
final BufferedImage img = ImageIO.read(Images.class.getResourceAsStream(resource));
|
||||
imageCache.put(resource, img);
|
||||
IMAGE_CACHE.put(resource, img);
|
||||
return img;
|
||||
} catch (Throwable t) {
|
||||
throw new RuntimeException("Failed to load image from resource. " + t.getMessage());
|
||||
|
||||
@@ -19,8 +19,9 @@ import java.awt.event.MouseMotionListener;
|
||||
*/
|
||||
public class ServerWidget extends JPanel implements MouseListener,
|
||||
MouseMotionListener {
|
||||
public ServerDescription desc;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ServerDescription desc;
|
||||
private String name;
|
||||
private boolean hovered;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user