Skip to content

Commit 467647b

Browse files
committed
Use AI to generate javadoc notation
This should help a bit when writing scripts and not knowing what method does what.
1 parent 87411e9 commit 467647b

7 files changed

Lines changed: 535 additions & 196 deletions

File tree

client/src/main/java/LoginListener.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ private LoginListener() {
2626
client = Extension.getInstance();
2727
}
2828

29+
/**
30+
* Hooks the instance.onLoginScreen() method
31+
*/
2932
static void loginScreenHook() {
3033
instance.onLoginScreen();
3134
}
32-
35+
/**
36+
* Executes the logic when the user is on the login screen.
37+
*/
3338
public void onLoginScreen() {
3439
if (!initialized) {
3540
final String font = ClientInit.getBotLoader().getFont();
@@ -55,7 +60,9 @@ public void onLoginScreen() {
5560
static void loginResponseHook(final String arg0, final String arg1) {
5661
instance.onLoginResponse(arg0, arg1);
5762
}
58-
63+
/**
64+
* Handles the bots response when a login attempt is made.
65+
*/
5966
public void onLoginResponse(final String arg0, final String arg1) {
6067
long loginDelay;
6168
long quickLoginDelay;
@@ -85,14 +92,23 @@ public static LoginListener getInstance() {
8592
public boolean isEnabled() {
8693
return autoLogin;
8794
}
88-
95+
/**
96+
* Sets autologin enabled
97+
*
98+
* @param enabled true to enable autologin
99+
*/
89100
@Override
90101
public void setEnabled(final boolean enabled) {
91102
autoLogin = enabled;
92103
botFrame.updateAutoLoginCheckBox(enabled);
93104
if (enabled) nextAttempt = 0;
94105
}
95-
106+
/**
107+
* Sets the account username and password.
108+
*
109+
* @param username the username to set
110+
* @param password the password to set
111+
*/
96112
@Override
97113
public void setAccount(final String username, final String password) {
98114
this.username = username;

client/src/main/java/PaintListener.java

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ private PaintListener() {
3939
static void paintHook() {
4040
instance.onPaint();
4141
}
42-
42+
/**
43+
* This function is called when the paint is updated.
44+
* It draws the gradient, resizes the game window if necessary,
45+
* and displays information about the player's hits, prayer level,
46+
* current tile, fatigue, and PID.
47+
*/
4348
@Override
4449
public void onPaint() {
4550
drawGradient();
@@ -109,7 +114,16 @@ private void drawGradient() {
109114
y += 1;
110115
RasterOps.fillRect(pixels, rw, rh, x, y, rw, 3, BOTTOM_LIGHT);
111116
}
112-
117+
/**
118+
* Draws a stat bar at the specified coordinates with the given current and base values.
119+
*
120+
* @param x the x-coordinate of the stat bar
121+
* @param y the y-coordinate of the stat bar
122+
* @param current the current value of the stat bar
123+
* @param base the base value of the stat bar
124+
* @param front the color of the front part of the bar
125+
* @param back the color of the back part of the bar
126+
*/
113127
private void drawStatBar(final int x, int y,
114128
final double current, final double base, final int front, final int back) {
115129
final int rw = client.getGameWidth();
@@ -125,17 +139,30 @@ private void drawStatBar(final int x, int y,
125139
x + width, y, BAR_WIDTH - width, BAR_HEIGHT,
126140
65, back);
127141
}
128-
142+
/**
143+
* Returns whether painting is enabled.
144+
*
145+
* @return true if painting is enabled, false otherwise
146+
*/
129147
@Override
130148
public boolean isPaintingEnabled() {
131149
return enabled;
132150
}
133-
151+
/**
152+
* Sets painting enabled/disabled
153+
*
154+
* @param enabled boolean value for the painting enabled flag
155+
*/
134156
@Override
135157
public void setPaintingEnabled(final boolean enabled) {
136158
this.enabled = enabled;
137159
}
138-
160+
/**
161+
* Resizes the object with the given width and height.
162+
*
163+
* @param width the new width for the object
164+
* @param height the new height for the object
165+
*/
139166
@Override
140167
public void doResize(final int width, final int height) {
141168
synchronized (dimension) {

client/src/main/java/Script.java

Lines changed: 112 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,13 @@ public boolean canCastSpell(final int spell) {
744744
}
745745
return true;
746746
}
747-
747+
/**
748+
* Checks for amount of provided runeId, also checks elemental staffs and returns the corresponding runes
749+
*
750+
* @param id the ID of the rune to check
751+
* @param amount the desired number of runes (does not matter if you have a staff)
752+
* @return true if the specified number of runes is available (or staff exists), false otherwise
753+
*/
748754
private boolean ensureRunes(final int id, final int amount) {
749755
switch (id) {
750756
case 31:
@@ -770,7 +776,12 @@ private boolean ensureRunes(final int id, final int amount) {
770776
}
771777
return getInventoryCount(id) >= amount;
772778
}
773-
779+
/**
780+
* Determines if the given ID is present in the inventory and if the corresponding item is equipped.
781+
*
782+
* @param id the ID to check
783+
* @return true if the item is equipped, false otherwise
784+
*/
774785
private boolean isEquippedId(final int id) {
775786
for (int i = 0; i < getInventoryCount(); i++) {
776787
if (client.getInventoryId(i) == id) {
@@ -1174,7 +1185,13 @@ public int[] getObjectById(final int... ids) {
11741185
public void useItemOnObject(final int item_id, final int object_x, final int object_y) {
11751186
useSlotOnObject(getInventoryIndex(item_id), object_x, object_y);
11761187
}
1177-
1188+
/**
1189+
* Uses the given item slot index on the object at the specified coordinates.
1190+
*
1191+
* @param slot the item slot index to use
1192+
* @param object_x the x-coordinate of the object
1193+
* @param object_y the y-coordinate of the object
1194+
*/
11781195
public void useSlotOnObject(final int slot, final int object_x, final int object_y) {
11791196
if (slot == -1)
11801197
return;
@@ -1190,7 +1207,13 @@ public void useSlotOnObject(final int slot, final int object_x, final int object
11901207
client.finishPacket();
11911208
}
11921209
}
1193-
1210+
/**
1211+
* Finds the index of the object at the specified coordinates relative to the client's area.
1212+
*
1213+
* @param x the x-coordinate of the object
1214+
* @param y the y-coordinate of the object
1215+
* @return the index of the object, or -1 if no object is found at the specified coordinates
1216+
*/
11941217
private int getObjectIndex(final int x, final int y) {
11951218
final int lx = x - client.getAreaX();
11961219
final int ly = y - client.getAreaY();
@@ -1900,7 +1923,13 @@ public void atWallObject(final int x, final int y) {
19001923
client.finishPacket();
19011924
}
19021925
}
1903-
1926+
/**
1927+
* Returns the index of the bound at the specified coordinates.
1928+
*
1929+
* @param x the x-coordinate of the bound
1930+
* @param y the y-coordinate of the bound
1931+
* @return the index of the bound, or -1 if not found
1932+
*/
19041933
private int getBoundIndex(final int x, final int y) {
19051934
final int lx = x - client.getAreaX();
19061935
final int ly = y - client.getAreaY();
@@ -2372,14 +2401,25 @@ public int getLocalTradeItemCount() {
23722401
public int getOurTradedItemCount() {
23732402
return client.getLocalTradeItemCount();
23742403
}
2375-
2404+
/**
2405+
* Retrieves the local(your) trade itemID at the specified trade window index
2406+
*
2407+
* @param i the index of the local trade item
2408+
* @return the local trade item ID at the specified index, or -1 if the index is out of bounds
2409+
*/
23762410
public int getLocalTradeItemId(final int i) {
23772411
if (i >= client.getLocalTradeItemCount()) {
23782412
return -1;
23792413
}
23802414
return client.getLocalTradeItemId(i);
23812415
}
2382-
2416+
/**
2417+
* Retrieves the local(your) trade item stack at the specified trade window index
2418+
*
2419+
* @param i the index of the item stack to retrieve
2420+
* @return the item stack at the specified index, or -1 if the index is
2421+
* out of range
2422+
*/
23832423
public int getLocalTradeItemStack(final int i) {
23842424
if (i >= client.getLocalTradeItemCount()) {
23852425
return -1;
@@ -2401,21 +2441,36 @@ public int getRemoteTradeItemCount() {
24012441
public int getTheirTradedItemCount() {
24022442
return client.getRemoteTradeItemCount();
24032443
}
2404-
2444+
/**
2445+
* Retrieves the remote (the other person) trade itemID at the specified trade window index
2446+
*
2447+
* @param i the index of the remote trade item
2448+
* @return the remote trade item ID at the specified index, or -1 if the index is out of bounds
2449+
*/
24052450
public int getRemoteTradeItemId(final int i) {
24062451
if (i >= client.getRemoteTradeItemCount()) {
24072452
return -1;
24082453
}
24092454
return client.getRemoteTradeItemId(i);
24102455
}
2411-
2456+
/**
2457+
* Retrieves the remote (the other person) trade item stack at the specified trade window index
2458+
*
2459+
* @param i the index of the remote item stack to retrieve
2460+
* @return the item stack at the specified index, or -1 if the index is
2461+
* out of range
2462+
*/
24122463
public int getRemoteTradeItemStack(final int i) {
24132464
if (i >= client.getRemoteTradeItemCount()) {
24142465
return -1;
24152466
}
24162467
return client.getRemoteTradeItemStack(i);
24172468
}
2418-
2469+
/**
2470+
* Determines if the local(self) client has accepted the trade
2471+
*
2472+
* @return true if the client has a local accepted trade, false otherwise
2473+
*/
24192474
public boolean hasLocalAcceptedTrade() {
24202475
if (isInTradeConfirm()) {
24212476
return client.hasLocalConfirmedTrade();
@@ -2432,7 +2487,11 @@ public boolean hasLocalAcceptedTrade() {
24322487
public boolean isInTradeConfirm() {
24332488
return client.isInTradeConfirm();
24342489
}
2435-
2490+
/**
2491+
* Determines if the remote (the other person) trade has been accepted.
2492+
*
2493+
* @return true if the remote trade has been accepted, false otherwise.
2494+
*/
24362495
public boolean hasRemoteAcceptedTrade() {
24372496
return client.hasRemoteAcceptedTrade();
24382497
}
@@ -2649,7 +2708,16 @@ public void drawImage(final Image image, final int start_x, final int start_y) {
26492708
drawBuf(buf, start_x, start_y, client.getPixels(),
26502709
client.getGameWidth(), client.getGameHeight());
26512710
}
2652-
2711+
/**
2712+
* Draws a portion of an image onto an array of pixels.
2713+
*
2714+
* @param image the source image to draw from
2715+
* @param start_x the starting x-coordinate of the portion to draw
2716+
* @param start_y the starting y-coordinate of the portion to draw
2717+
* @param pixels the array of pixels to draw onto
2718+
* @param rw the maximum width of the portion to draw
2719+
* @param rh the maximum height of the portion to draw
2720+
*/
26532721
private static void drawBuf(final BufferedImage image,
26542722
final int start_x, final int start_y,
26552723
final int[] pixels, final int rw, final int rh) {
@@ -2913,7 +2981,12 @@ public void sendPrivateMessage(final String msg, final String name) {
29132981
client.sendPrivateMessage(msg, name);
29142982
}
29152983
}
2916-
2984+
/**
2985+
* Determines whether a given name is a friend.
2986+
*
2987+
* @param name the name to check
2988+
* @return true if the name is a friend, false otherwise
2989+
*/
29172990
public boolean isFriend(final String name) {
29182991
final int count = StaticAccess.getInstance().getFriendCount();
29192992
for (int i = 0; i < count; ++i) {
@@ -2923,33 +2996,54 @@ public boolean isFriend(final String name) {
29232996
}
29242997
return false;
29252998
}
2926-
2999+
/**
3000+
* Adds a friend with the given name.
3001+
*
3002+
* @param name the name of the friend to be added
3003+
*/
29273004
public void addFriend(final String name) {
29283005
final String lname = client.getPlayerName(client.getPlayer());
29293006
if (name.length() > 0 && !name.equalsIgnoreCase(lname)) {
29303007
client.addFriend(name);
29313008
}
29323009
}
2933-
3010+
/**
3011+
* Removes a friend with the given name.
3012+
*
3013+
* @param name the name of the friend to be removed
3014+
*/
29343015
public void removeFriend(final String name) {
29353016
if (isFriend(name)) {
29363017
client.removeFriend(name);
29373018
}
29383019
}
2939-
3020+
/**
3021+
* Adds a player to the ignore list.
3022+
*
3023+
* @param name the name of the player to ignore
3024+
*/
29403025
public void addIgnore(final String name) {
29413026
final String lname = client.getPlayerName(client.getPlayer());
29423027
if (name.length() > 0 && !name.equalsIgnoreCase(lname)) {
29433028
client.addIgnore(name);
29443029
}
29453030
}
2946-
3031+
/**
3032+
* Removes the specified name from the ignore list.
3033+
*
3034+
* @param name the name to be removed from the ignore list
3035+
*/
29473036
public void removeIgnore(final String name) {
29483037
if (isIgnored(name)) {
29493038
client.removeIgnore(name);
29503039
}
29513040
}
2952-
3041+
/**
3042+
* Determines if the given name is ignored.
3043+
*
3044+
* @param name the name to check
3045+
* @return true if the name is ignored, false otherwise
3046+
*/
29533047
public boolean isIgnored(final String name) {
29543048
final int count = StaticAccess.getInstance().getIgnoredCount();
29553049
for (int i = 0; i < count; ++i) {

client/src/main/java/ScriptListener.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ private void onGameMessage(final boolean flag, String s1, final int i1, final St
9797
static void playerDamagedHook(final ta player) {
9898
instance.onPlayerDamaged(player);
9999
}
100-
100+
/**
101+
* Executes when a player is damaged.
102+
*
103+
* @param player the player object that was damaged
104+
*/
101105
private void onPlayerDamaged(final Object player) {
102106
if (!running) {
103107
return;

0 commit comments

Comments
 (0)