3030import java .util .Set ;
3131import java .util .concurrent .CompletableFuture ;
3232import java .util .concurrent .ThreadLocalRandom ;
33+ import java .util .function .Predicate ;
3334
3435import static java .util .Objects .requireNonNull ;
3536
@@ -274,11 +275,11 @@ public CompletableFuture<PlayerData> login() {
274275 if (data != null ) {
275276 temporary = false ;
276277 }
278+ loadData (data );
279+ if (data == null ) {
280+ position = spawnPosition ;
281+ }
277282 if (world .getPlayers ().add (this )) {
278- loadData (data );
279- if (data == null ) {
280- setPosition (spawnPosition );
281- }
282283 world .getBots ().add (this );
283284 setState (EntityState .ACTIVE );
284285 log ("I'm alive!" );
@@ -342,15 +343,25 @@ public void randomizeSkills() {
342343 ? ThreadLocalRandom .current ().nextInt (1 , 100 )
343344 : ThreadLocalRandom .current ().nextInt (50 , 100 );
344345 skill .setStaticLevel (level );
346+ skill .setLevel (level );
345347 }
346348 }
347349
348350 /**
349351 * Randomizes the bot’s currently equipped items.
350352 */
351353 public void randomizeEquipment () {
354+ randomizeEquipment (def -> true );
355+ }
356+
357+ /**
358+ * Randomizes the bot’s currently equipped items, only factoring in filtered items.
359+ *
360+ * @param filter The filter to apply.
361+ */
362+ public void randomizeEquipment (Predicate <EquipmentDefinition > filter ) {
352363 ArrayListMultimap <Integer , EquipmentDefinition > eligible = ArrayListMultimap .create ();
353- EquipmentDefinition .ALL .lookupAll (def -> def .meetsAllRequirements (this ))
364+ EquipmentDefinition .ALL .lookupAll (def -> def .meetsAllRequirements (this ) && filter . test ( def ) )
354365 .forEach (def -> eligible .put (def .getIndex (), def ));
355366
356367 for (int index = 0 ; index < getEquipment ().capacity (); index ++) {
@@ -361,6 +372,16 @@ public void randomizeEquipment() {
361372 }
362373 }
363374
375+ /**
376+ * Maxes the bot’s skill levels.
377+ */
378+ public void maxSkills () {
379+ for (Skill skill : skills ) {
380+ skill .setStaticLevel (99 );
381+ skill .setLevel (99 );
382+ }
383+ }
384+
364385 /**
365386 * @return {@code true} if this bot is temporary (non-persistent).
366387 */
0 commit comments