Merge pull request #9627 from abextm/runscript-args-external

Ensure runScript is invoked with the correct number of arguments
This commit is contained in:
Adam
2019-08-10 17:32:05 -04:00
committed by GitHub
9 changed files with 93 additions and 56 deletions

View File

@@ -1252,11 +1252,10 @@ public interface Client extends GameEngine
*
* This method must be ran on the client thread and is not reentrant
*
* @param id the script ID
* @param args additional arguments to execute the script with
* @param args the script id, then any additional arguments to execute the script with
* @see ScriptID
*/
void runScript(int id, Object... args);
void runScript(Object... args);
/**
* Checks whether or not there is any active hint arrow.

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2019 Abex
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
@Documented
@Target(ElementType.FIELD)
@interface ScriptArguments
{
/**
* The number of int arguments the script takes
*/
int integer() default 0;
/**
* The number of string arguments the script takes
*/
int string() default 0;
}

View File

@@ -34,6 +34,7 @@ public final class ScriptID
* <li> int how far down to scroll </li>
* </ul>
*/
@ScriptArguments(integer = 3)
public static final int UPDATE_SCROLLBAR = 72;
/**
@@ -43,11 +44,13 @@ public final class ScriptID
* <li> String Message to send </li>
* </ul>
*/
@ScriptArguments(integer = 1, string = 1)
public static final int CHATBOX_INPUT = 96;
/**
* Rebuilds the chatbox
*/
@ScriptArguments()
public static final int BUILD_CHATBOX = 216;
/**
@@ -58,6 +61,7 @@ public final class ScriptID
* <li> String Player to send private message to</li>
* </ul>
*/
@ScriptArguments(string = 1)
public static final int OPEN_PRIVATE_MESSAGE_INTERFACE = 107;
/**
@@ -66,15 +70,9 @@ public final class ScriptID
* <li> String Message Prefix. Only used inside the GE search interfaces
* </ul>
*/
@ScriptArguments(string = 1)
public static final int CHAT_TEXT_INPUT_REBUILD = 222;
/**
* Layouts the bank widgets
*
* Takes 13 widget ids of various parts of the bank interface
*/
public static final int BANK_LAYOUT = 277;
/**
* Closes the chatbox input
* <ul>
@@ -82,17 +80,23 @@ public final class ScriptID
* <li> int (boolean) Restore to chat view </li>
* </ul>
*/
public static final int RESET_CHATBOX_INPUT = 299;
@ScriptArguments(integer = 2)
public static final int MESSAGE_LAYER_CLOSE = 299;
/**
* Readies the chatbox panel for things like the chatbox input
* Inverse of RESET_CHATBOX_INPUT
* Inverse of MESSAGE_LAYER_CLOSE
* <ul>
* <li> int (InputType) message layer type we are changing to </li>
* </ul>
*/
public static final int CLEAR_CHATBOX_PANEL = 677;
@ScriptArguments(integer = 1)
public static final int MESSAGE_LAYER_OPEN = 677;
/**
* Builds the chatbox input widget
*/
@ScriptArguments()
public static final int CHAT_PROMPT_INIT = 223;
/**
@@ -103,19 +107,21 @@ public final class ScriptID
* <li> String Item Name </li>
* </ul>
*/
@ScriptArguments(integer = 2, string = 1)
public static final int DEATH_KEEP_ITEM_EXAMINE = 1603;
/**
* Checks the state of the given stash unit.
* <ul>
* <li>int (loc) The stash unit object id</li>
* <li>int Bitpacked stash unit states</li>
* <li>int Bitpacked stash unit states 2</li>
* <li>int Bitpacked stash unit states 3</li>
* <li>int Bitpacked stash unit states</li>
* <li>int Bitpacked stash unit states 2</li>
* <li>int Bitpacked stash unit states 3</li>
* </ul>
*
* Returns a pair of booleans indicating if the stash unit is built and if it is filled
*/
@ScriptArguments(integer = 4)
public static final int WATSON_STASH_UNIT_CHECK = 1479;
/**
@@ -128,6 +134,7 @@ public final class ScriptID
* <li> int (QuestState) the normalized state of the quest
* </ul>
*/
@ScriptArguments(integer = 1)
public static final int QUESTLIST_PROGRESS = 2267;
/**
@@ -137,6 +144,7 @@ public final class ScriptID
* <li> int Number of lines </li>
* </ul>
*/
@ScriptArguments(integer = 2)
public static final int DIARY_QUEST_UPDATE_LINECOUNT = 2523;
/**
@@ -148,6 +156,7 @@ public final class ScriptID
* <li> int Reset zoom position </li>
* </ul>
*/
@ScriptArguments(integer = 2)
public static final int CAMERA_DO_ZOOM = 42;
/**
@@ -156,11 +165,13 @@ public final class ScriptID
* This is used to eat events when you want a menu action attached to it
* because you need an op listener attached to it for it to work
*/
@ScriptArguments()
public static final int NULL = 10003;
/**
* Send a private message.
*/
@ScriptArguments(string = 2)
public static final int PRIVMSG = 10004;
/**
@@ -171,5 +182,6 @@ public final class ScriptID
* <li>int Amount of exp to drop</li>
* </ul>
*/
@ScriptArguments(integer = 2)
public static final int XPDROP_DISABLED = 2091;
}

View File

@@ -42,6 +42,10 @@ public enum VarClientInt
*/
TOOLTIP_VISIBLE(2),
/**
* Current message layer mode
* @see net.runelite.api.vars.InputType
*/
INPUT_TYPE(5),
MEMBERSHIP_STATUS(103),

View File

@@ -622,6 +622,8 @@ public interface Widget
*/
Object[] getOnLoadListener();
Object[] getOnInvTransmitListener();
/**
* Returns the archive id of the font used
*