-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
orig source.. nothing changed here..
- Loading branch information
0 parents
commit d105e4d
Showing
319 changed files
with
49,476 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dundundun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
@ECHO OFF | ||
|
||
SETLOCAL | ||
CALL :setvars | ||
SET cmd=%1 | ||
IF "%cmd%"=="" SET cmd=all | ||
CALL :%cmd% | ||
GOTO :eof | ||
|
||
:setvars | ||
SET name=RSBot | ||
SET cc=javac | ||
SET cflags=-g:none -Xlint:deprecation | ||
SET src=src | ||
SET lib=lib | ||
SET res=resources | ||
SET out=bin | ||
SET dist=%name%.jar | ||
SET lstf=temp.txt | ||
SET imgdir=%res%\images | ||
SET manifest=%res%\Manifest.txt | ||
SET versionfile=%res%\version.txt | ||
FOR /F %%G IN (%versionfile%) DO SET version=%%G | ||
SET scripts=scripts | ||
CALL "%res%\FindJDK.bat" | ||
GOTO :eof | ||
|
||
:all | ||
CALL :clean 2>NUL | ||
ECHO Compiling bot | ||
CALL :Bot | ||
ECHO Compiling scripts | ||
CALL :Scripts 2>NUL | ||
ECHO Packing JAR | ||
CALL :pack | ||
CALL :end | ||
GOTO :eof | ||
|
||
:Bot | ||
IF EXIST "%lstf%" DEL /F /Q "%lstf%" | ||
FOR /F "usebackq tokens=*" %%G IN (`DIR /B /S "%src%\*.java"`) DO CALL :append "%%G" | ||
IF EXIST "%out%" RMDIR /S /Q "%out%" > NUL | ||
MKDIR "%out%" | ||
"%cc%" %cflags% -d "%out%" "@%lstf%" 2>NUL | ||
DEL /F /Q "%lstf%" | ||
GOTO :eof | ||
|
||
:Scripts | ||
CALL :mostlyclean | ||
IF EXIST "%scripts%" "%cc%" %cflags% -cp "%out%" %scripts%\*.java | ||
GOTO :eof | ||
|
||
:pack | ||
IF EXIST "%dist%" DEL /F /Q "%dist%" | ||
IF EXIST "%lstf%" DEL /F /Q "%lstf%" | ||
COPY "%manifest%" "%lstf%" > NUL | ||
ECHO Specification-Version: "%version%" >> "%lstf%" | ||
ECHO Implementation-Version: "%version%" >> "%lstf%" | ||
jar cfm "%dist%" "%lstf%" -C "%out%" . %versionfile% %imgdir%\* %res%\*.bat %res%\*.sh | ||
DEL /F /Q "%lstf%" | ||
GOTO :eof | ||
|
||
:end | ||
CALL :clean 2>NUL | ||
ECHO Compilation successful. | ||
GOTO :eof | ||
|
||
:append | ||
SET gx=%1 | ||
SET gx=%gx:\=\\% | ||
ECHO %gx% >> %lstf% | ||
GOTO :eof | ||
|
||
:mostlyclean | ||
IF EXIST "%scripts%" ECHO. > "%scripts%\.class" | ||
IF EXIST "%scripts%" DEL /F /Q %scripts%\*.class | ||
GOTO :eof | ||
|
||
:clean | ||
CALL :mostlyclean | ||
RMDIR /S /Q "%out%" 2>NUL | ||
GOTO :eof | ||
|
||
:remove | ||
IF EXIST "%APPDATA%\%name%_Accounts.ini" DEL "%APPDATA%\%name%_Accounts.ini" | ||
IF EXIST "%APPDATA%\%name% Accounts.ini" DEL "%APPDATA%\%name% Accounts.ini" | ||
IF EXIST "%RSBOT_HOME%" RMDIR /S /Q "%RSBOT_HOME%" | ||
FOR /F "tokens=3" %%G IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal"') DO (SET docs=%%G) | ||
IF EXIST "%docs%\%name%" RMDIR /S /Q "%docs%\%name%" | ||
GOTO :eof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Adding stuffs here soon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@ECHO OFF | ||
|
||
TITLE RSBot Scripts | ||
|
||
SET cc=javac | ||
SET cflags= | ||
SET scripts=Scripts\Sources | ||
SET scriptspre=Scripts\Precompiled | ||
SET jarpathfile=Settings\path.txt | ||
|
||
IF NOT EXIST "%jarpathfile%" ( | ||
ECHO Path file does not exist. Please run RSBot and try again. | ||
GOTO end | ||
) | ||
|
||
FOR /F "delims=" %%G IN (%jarpathfile%) DO SET jarpath=%%G | ||
|
||
CALL FindJDK.bat | ||
|
||
IF NOT EXIST %scripts%\*.java ( | ||
ECHO No .java script source files found. | ||
GOTO end | ||
) | ||
|
||
ECHO Compiling scripts | ||
ECHO. > "%scripts%\.class" | ||
DEL /F /Q "%scripts%\*.class" > NUL | ||
"%cc%" %cflags% -cp "%jarpath%" %scripts%\*.java | ||
|
||
:end | ||
PAUSE | ||
EXIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@ECHO OFF | ||
|
||
ECHO Looking for JDK | ||
|
||
SET KEY_NAME=HKLM\SOFTWARE\JavaSoft\Java Development Kit | ||
FOR /F "tokens=3" %%A IN ('REG QUERY "%KEY_NAME%" /v CurrentVersion 2^>NUL') DO SET jdkv=%%A | ||
SET jdk= | ||
|
||
IF DEFINED jdkv ( | ||
FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "%KEY_NAME%\%jdkv%" /v JavaHome 2^>NUL') DO SET jdk=%%B | ||
) ELSE ( | ||
FOR /F "tokens=*" %%G IN ('DIR /B "%ProgramFiles%\Java\jdk*"') DO SET jdk=%%G | ||
) | ||
|
||
SET jdk=%jdk%\bin | ||
SET javac="%jdk%\javac.exe" | ||
|
||
IF NOT EXIST %javac% ( | ||
javac -version 2>NUL | ||
IF "%ERRORLEVEL%" NEQ "0" GOTO :notfound | ||
) ELSE ( | ||
GOTO :setpath | ||
) | ||
GOTO :eof | ||
|
||
:notfound | ||
ECHO JDK is not installed, please download and install it from: | ||
ECHO http://java.sun.com/javase/downloads | ||
ECHO. | ||
PAUSE | ||
EXIT | ||
|
||
:setpath | ||
SET PATH=%jdk%;%PATH% | ||
GOTO :eof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Main-Class: org.rsbot.Boot | ||
Class-Path: lib/xel.jar | ||
|
||
Name: org/rsbot | ||
Sealed: true | ||
Specification-Title: "RSBot" | ||
Specification-Vendor: "org.rsbot" | ||
Implementation-Title: "RSBot" | ||
Implementation-Vendor: "org.rsbot" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/sh | ||
|
||
cc=javac | ||
cflags= | ||
scripts=Scripts/Sources | ||
scriptspre=Scripts/Precompiled | ||
jarpathfile=Settings/path.txt | ||
|
||
cd ~/RSBot | ||
|
||
if [ ! -e "$jarpathfile" ]; then | ||
echo "Path file does not exist. Please run RSBot and try again." | ||
exit | ||
fi | ||
|
||
for file in $scripts/*.java | ||
do | ||
if [ ! -e "${file}" ]; then | ||
echo "No .java script source files found." | ||
exit | ||
fi | ||
done | ||
|
||
echo "Compiling scripts" | ||
for file in $scripts/*.class | ||
do | ||
if [ -e "${file}" ]; then | ||
rm -R $scripts/*.class | ||
break | ||
fi | ||
done | ||
|
||
"$cc" $cflags -cp "/$(cat $jarpathfile)" $scripts/*.java |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
245 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package org.rsbot; | ||
|
||
import org.rsbot.bot.Bot; | ||
import org.rsbot.gui.BotGUI; | ||
import org.rsbot.log.LogOutputStream; | ||
import org.rsbot.log.SystemConsoleHandler; | ||
import org.rsbot.security.RestrictedSecurityManager; | ||
import org.rsbot.util.ApplicationException; | ||
import org.rsbot.util.io.IOHelper; | ||
|
||
import javax.swing.*; | ||
|
||
import java.awt.*; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.PrintStream; | ||
import java.util.ArrayList; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class Application { | ||
private static BotGUI gui; | ||
|
||
public static void main(final String[] args) { | ||
try { | ||
bootstrap(); | ||
RestrictedSecurityManager.fixHosts(); | ||
extractResources(); | ||
commands(args); | ||
System.setSecurityManager(new RestrictedSecurityManager()); | ||
System.setProperty("java.io.tmpdir", Configuration.Paths.getGarbageDirectory()); | ||
gui = new BotGUI(); | ||
gui.setVisible(true); | ||
} catch (final Exception e) { | ||
e.printStackTrace(); | ||
System.out.print(e.getMessage()); | ||
try { | ||
if (gui != null) { | ||
gui.setVisible(false); | ||
} | ||
} catch (final Exception ignored) { | ||
} | ||
final String msg = (e.getClass().isAssignableFrom(ApplicationException.class)) ? e.getMessage() : "Error: " + e.toString() + "\nUnable to start."; | ||
try { | ||
final JFrame frame = new JFrame(); | ||
frame.setIconImage(Configuration.getImage(Configuration.Paths.Resources.ICON)); | ||
frame.setLocationRelativeTo(frame.getOwner()); | ||
frame.setVisible(true); | ||
new Thread() { | ||
@Override | ||
public void run() { | ||
final Dimension s = Toolkit.getDefaultToolkit().getScreenSize(); | ||
try { | ||
Thread.sleep(64); // race condition :) | ||
} catch (final InterruptedException ignored) { | ||
} | ||
frame.setLocation(s.width + 0xff, s.height + 0xff); | ||
} | ||
}.start(); | ||
JOptionPane.showMessageDialog(frame, msg, Configuration.NAME, JOptionPane.ERROR_MESSAGE); | ||
} catch (final HeadlessException ignored) { | ||
} | ||
try { | ||
if (gui != null) { | ||
gui.cleanExit(false); | ||
} | ||
} catch (final Exception ignored) { | ||
} | ||
System.exit(1); | ||
} | ||
} | ||
|
||
private static void commands(final String[] args) { | ||
if (args.length > 1) { | ||
if (args[0].toLowerCase().endsWith("delete")) { | ||
final File jarOld = new File(args[1]); | ||
if (jarOld.exists()) { | ||
if (!jarOld.delete()) { | ||
jarOld.deleteOnExit(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static void extractResources() { | ||
final ArrayList<String> extract = new ArrayList<String>(2); | ||
if (Configuration.getCurrentOperatingSystem() == Configuration.OperatingSystem.WINDOWS) { | ||
extract.add(Configuration.Paths.COMPILE_SCRIPTS_BAT); | ||
extract.add(Configuration.Paths.COMPILE_FIND_JDK); | ||
} else { | ||
extract.add(Configuration.Paths.COMPILE_SCRIPTS_SH); | ||
} | ||
for (final String item : extract) { | ||
final String path = Configuration.Paths.Resources.ROOT + "/" + item; | ||
final InputStream in; | ||
try { | ||
in = Configuration.getResourceURL(path).openStream(); | ||
} catch (IOException ignored) { | ||
continue; | ||
} | ||
final File output = new File(Configuration.Paths.getHomeDirectory(), item); | ||
IOHelper.write(in, output); | ||
} | ||
} | ||
|
||
/** | ||
* Returns the Bot for any object loaded in its client. For internal use | ||
* only (not useful for script writers). | ||
* | ||
* @param o Any object from within the client. | ||
* @return The Bot for the client. | ||
*/ | ||
public static Bot getBot(final Object o) { | ||
return gui.getBot(o); | ||
} | ||
|
||
/** | ||
* Returns the size of the panel that clients should be drawn into. For | ||
* internal use. | ||
* | ||
* @return The client panel size. | ||
*/ | ||
public static Dimension getPanelSize() { | ||
return gui.getPanel().getSize(); | ||
} | ||
|
||
private static void bootstrap() { | ||
Logger.getLogger("").setLevel(Level.ALL); | ||
Logger.getLogger("").addHandler(new SystemConsoleHandler()); | ||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | ||
private final Logger log = Logger.getLogger("EXCEPTION"); | ||
|
||
public void uncaughtException(final Thread t, final Throwable e) { | ||
log.logp(Level.SEVERE, "EXCEPTION", "", "Unhandled exception in thread " + t.getName() + ": ", e); | ||
} | ||
}); | ||
System.setErr(new PrintStream(new LogOutputStream(Logger.getLogger("STDERR"), Level.SEVERE), true)); | ||
} | ||
} |
Oops, something went wrong.