preference

static T preference<T>(String key, Function<PlayerPreferences.Generator, T> generatorFunction)

Gets a preference, or generates the preference if it doesn't exist. The preference is generated by calling the generatorFunction parameter with a Generator seeded with the current in-game account name and the preference key. Each preference is unique to the in-game account. When another account is used, these are cleared and the preferences will be regenerated again. Example usage: {@code PlayerPreferences.preference("org.tribot.Antiban.eatPercent", g -> g.uniform(30, 60))} This above line would generate a value evenly distributed from 30-60 for all accounts. Calling that method with the same parameters always gives the same value for the same account, even if you re-run the script on another machine. Note that some level of care must be taken to not duplicate the preference key - see the preference {@code key} docs for a convention to follow.

Return

a preference for the current account based on the generator function

Parameters

key

the preference key - a general naming convention to follow is package.Class.field (ex. org.tribot.Npcs.RandomPreference) to prevent collisions. This key must be unique. If two generator functions give different results for the same key, the behavior may be inconsistent.

generatorFunction

a function to generate the preference given a Generator seeded with the in-game account and preference key

<T>

the preference type