Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

getPlayerObjectFromName

Featured Replies

I am trying to get a Player's object from the specified name. What I have currently only works when the name doesn't contain a space. What am I doing wrong?

    private Player getPlayerObjectFromName(String name) {
        List<Player> players = getPlayers().filter(player -> player != null && player.getName().equalsIgnoreCase(name));

        if (players != null) {
            for (Player p : players) {
                if (p.getName().equalsIgnoreCase(name)) {
                    return p;
                }
            }
        }
        return null;
    }

Edit: So I figured out the issue. Player objects use (char) 160 as a space which is why I was never getting a match when testing a name with (char) 32 as its space.

Edited by torquish

23 minutes ago, torquish said:

I am trying to get a Player's object from the specified name. What I have currently only works when the name doesn't contain a space. What am I doing wrong?


    private Player getPlayerObjectFromName(String name) {
      	return getPlayers().closest(player -> player.getName().replaceAll(“\\h”,  “).equalsIgnoreCase(name));
    }

Edit: So I figured out the issue. Player objects use (char) 160 as a space which is why I was never getting a match when testing a name with (char) 32 as its space.

Can’t check if that works as I’m on phone atm, but the idea is those weird characters should be in java’s horizontal whitespace character class, but not in the general whitespace class \s.

P.S. Replace the double quote characters, I don’t have that on iphone keyboard

  • Author
4 minutes ago, Token said:

Can’t check if that works as I’m on phone atm, but the idea is those weird characters should be in java’s horizontal whitespace character class, but not in the general whitespace class \s.

P.S. Replace the double quote characters, I don’t have that on iphone keyboard

Yes it works. Thanks.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.