February 21, 20169 yr Author Maybe use ID's instead of item names? Id's can change depending on updates while names don't.
February 21, 20169 yr 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 Edited February 21, 20169 yr by Extreme Scripts
February 21, 20169 yr Author 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 Literally a life saver Writing everything out was so annoying. Thanks :3
February 21, 20169 yr 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 Arrays.stream(getBank().getItems()).filter(item -> item.getName().contains("Amulet of glory")).collect(Collectors.toList()); FTFY. getBank().getItems() returns an Item[] Edited February 21, 20169 yr by Explv
February 21, 20169 yr 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.
February 21, 20169 yr Optional<Item> glory = Arrays.stream(getBank().getItems()).filter(i -> i.getName().startsWith("Amulet of glory")).findFirst(); FTFY. Item glory = getBank().getItem(item -> item.getName().startsWith("Amulet of glory")); FTFY. Edited February 21, 20169 yr by Explv
February 21, 20169 yr Item glory = getBank().getItem(item -> item.getName().startsWith("Amulet of glory")); FTFY. Nope. Mine is still faster, less expensive and safer. Thank you for playing, please try again! Edited February 21, 20169 yr by Botre
February 22, 20169 yr Nope. Mine is still faster, less expensive and safer. Thank you for playing, please try again! Your opinion. You should learn what premature optimisation is. My solution is better. Thank you for playing, please try again! Edited February 22, 20169 yr by Explv
February 22, 20169 yr 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 February 22, 20169 yr by Botre
February 22, 20169 yr for (Item item : script.getInventory().getItems()) { if (item != null && item.getName().startsWith("Amulet of glory")) { return item; } } I win for readable oldschool code Edited February 22, 20169 yr by lisabe96
February 22, 20169 yr 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 Edited February 22, 20169 yr by Flamezzz
February 22, 20169 yr 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 But didn't you know you should maximise performance, and minimise readability Edited February 22, 20169 yr by Explv
March 3, 20169 yr 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.
Create an account or sign in to comment