Jump to content

RSlayer [AIO]


Recommended Posts

Posted (edited)

Really good attempt for a first script! My suggestions would be to clean up your code a lil cos you could simplify a lot of things e.g. When checking for a Glory in your bank you can just use: 

getBank().getItems().stream().filter(item -> item != null && item.getName().contains("Amulet of glory")).collect(Collectors.toList());

That will return all the glories in your bank. Great start though happy.png

Edited by Extreme Scripts
  • Like 2
Posted

Really good attempt for a first script! My suggestions would be to clean up your code a lil cos you could simplify a lot of things e.g. When checking for a Glory in your bank you can just use: 

getBank().getItems().stream().filter(item -> item != null && item.getName().contains("Amulet of glory")).collect(Collectors.toList());

That will return all the glories in your bank. Great start though happy.png

Literally a life saver :doge:

Writing everything out was so annoying.

 

Thanks :3

Posted (edited)

Really good attempt for a first script! My suggestions would be to clean up your code a lil cos you could simplify a lot of things e.g. When checking for a Glory in your bank you can just use: 

getBank().getItems().stream().filter(item -> item != null && item.getName().contains("Amulet of glory")).collect(Collectors.toList());

That will return all the glories in your bank. Great start though happy.png

Arrays.stream(getBank().getItems()).filter(item -> item.getName().contains("Amulet of glory")).collect(Collectors.toList());

FTFY.

 

getBank().getItems() returns an Item[]

Edited by Explv
Posted
Arrays.stream(getBank().getItems()).filter(item -> item.getName().contains("Amulet of glory")).collect(Collectors.toList());

FTFY.

 

getBank().getItems() returns an Item[]

 

Optional<Item> glory = Arrays.stream(getBank().getItems()).filter(i -> i.getName().startsWith("Amulet of glory")).findFirst();

FTFY.

  • Like 1
Posted (edited)

Your opinion.

 

You should learn what premature optimisation is.

 

My solution is better.

 

Thank you for playing, please try again!

 

Premature optimization is only an anti-pattern if the cost of the optimization outweighs the benefit.

Me picking the best solution over the worse solution in this case and at this point doesn't cost me anything extra because....

 

... I already know the best solution and can implement it as fast if not faster than the lesser solution.

 

Since the optimization didn't cost me anything, the cost can't outweigh the benefit and this is there not a case of antipattern premature optimization but efficient optimization tout-court.

 

*tokens only, push to reject*

 

I'm just playing lel, let's stop this cockfight.

Edited by Botre
Posted (edited)

I would still prefer the most readable solution of all:

 

bank.getItem(new ContainsNameFilter<>("Amulet of glory"));

It reads nicely like a sentence and is equal in performance when rounded to nanoseconds.

@OP  Nice script smile.png

 

But didn't you know you should maximise performance, and minimise readability

 

 

 

 

 

doge.png

Edited by Explv
  • 2 weeks later...
Posted

Using the string ("Amulet of glory") will also give you uncharged glory's so wouldn't it be safer to just use ("Amulet of glory (") to at least make sure that there's at least a single charge left in the glory? Not sure if the script doesn't need uncharged glorys but my assumption was that they're used for teleporting.

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...