1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tutorial Notice to all authors regarding spectre

Discussion in 'Tutorials & Resources' started by Aidden, Mar 10, 2016.

  1. Aidden

    Aidden Author of MaxiBots

    Joined:
    Dec 3, 2013
    Messages:
    6,600
    Likes Received:
    990
    Hey guys,

    Some of you may or may not have already heard that spectre comes with some api changes that will break your bots. While most of them can't really be handled by you guys pre-emptively, there is one that you can be ready for now, and that is the removal of the Filter(s) class. It was initially introduced because we weren't forcing the use of Java 8 which comes with the Predicate class, which has the same functionality as Filters (Probably more).

    The documentation for predicates can be found here: Predicate (Java Platform SE 8 )

    Here's an example:
    Code (Text):
    1.  
    2. final Filter<ItemDefinition> itemFilter = new Filter<ItemDefinition>() {
    3.  
    4.         @Override
    5.         public boolean accepts(ItemDefinition def) {
    6.             if (def != null) {
    7.                 final String name = def.getName();
    8.                 return name != null && !name.isEmpty() && name.contains("Add to bonfire");
    9.             }
    10.             return false;
    11.         }
    12.  
    13.     };
    14.  
    is equivalent to:
    Code (Text):
    1.  
    2. final Predicate<ItemDefinition> itemFilter = def -> {
    3.         if (def != null) {
    4.             final String name = def.getName();
    5.             return name != null && !name.isEmpty() && name.contains("Add to bonfire");
    6.         }
    7.         return false;
    8.     };
    9.  
    Finally, any of the methods from the Filters class can be found in the Predicate class. With the example above i could do itemFilter.negate() instead of Filters.invert(itemFilter)

    Hope this was helpful!

    Note: I'll post the other changes that can't be compiled with the current version of runemate soon.

    FileWeb -> SerializableWeb
    ActionSlot -> ActionBar.Slot
     
    #1 Aidden, Mar 10, 2016
    Last edited: Mar 12, 2016
    smitty260 likes this.
  2. proxi

    proxi s̶c̶r̶i̶p̶t̶ bot*

    Joined:
    Aug 23, 2015
    Messages:
    2,223
    Likes Received:
    501
    Aidden laying it Down!
     
  3. Aidden

    Aidden Author of MaxiBots

    Joined:
    Dec 3, 2013
    Messages:
    6,600
    Likes Received:
    990
    I'll post a full list of changes after i finish this assignment, however if you choose to implement them now you won't be able to compile your bots without spectre.
     
    LucasSousa likes this.
  4. kristiaan

    Joined:
    Feb 24, 2015
    Messages:
    1,206
    Likes Received:
    203
    Thanks for this :)
     

Share This Page

Loading...