The only times I've ever used "injection" (if you even want to call it that) has been setting instance variables to my own modified classes. I'm still pretty new to programming in general, thanks for clearing that up for me
I have no life, nor friends, nor loved ones.
You misspelled sA (what you meant to type) in the Node constructor argument. Right now you're just assigning the instance variable sA a reference to itself which is, of course, null.
return sA.client.getLocalNPCs().contains("Banker");
Not sure if you meant this or not, but you're checking if a list of NPC objects contains a String.
As for the NPE, show us your abstract Node class.
Well they're not really comparable as they do completely separate things. I'm just saying it's more efficient to use a StringBuilder object when doing multiple operations on a String rather than modify it and litter the stack with unneeded variables.
Also, why didn't you just make a String variable to store the name of the enum instead of calling the #name() method twice?
The code I posted returns the same exact String and is more efficient. You're calling the #name() method twice as well as creating additional String objects while mine only uses only a single StringBuilder.
Strings are immutable, which means any operation on them creates an entirely new String instance (leaving the other to be garbage collected).
It was easy to create a flawless script back in the days because the bot itself took care of most of the work for the scripter. Now it's entirely possible to design a fully functioning script however there is a lot more work required to make it perfect.
Why loop through every interface when there's a more efficient way? Besides, you don't have a "Click here to continue" option when selecting a response.
There's no reason to have an empty default constructor, and your toString could be a lot cleaner and efficient:
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(super.toString());
return sb.charAt(0) + sb.substring(1).toLowerCase().replace("_", " ");
}
final Inventory inven = client.getInventory();
for (final Item item : inven.getItems()) {
if (item != null && Arrays.asList(item.getDefinition().getActions()).contains("Drop")) {
inven.interactWithId(item.getId(), "Drop");
}
}
Wrote in 5 seconds without IDE.
It's probably throwing an exception since you're invoking #isVisible() on a null instance. Create an RS2Interface object like so:
final RS2Interface parent = client.getInterface(469);
and do a null check on it before doing any type of interaction/method.
150+ iterations per script loop. Oh my fucking lel.
OT goodluck but I'm 99% sure there's going to be an official OSBot rule added limiting the amount of SSF advertisements
Could you maybe have an option to just reload local scripts? It's annoying having to wait 10 seconds while it connects to the server while I only want to test something out.