Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Get Username By ID #1

Open
viddie opened this issue Sep 28, 2016 · 1 comment
Open

Get Username By ID #1

viddie opened this issue Sep 28, 2016 · 1 comment

Comments

@viddie
Copy link

viddie commented Sep 28, 2016

I want to get a users name by their ID. As far as I understand all this it should be as follows:

  • Bot has an ID and sends packet "PacketRequestUserInfo" containing the user ID
  • Bot recieves a packet "PacketUserInfo" but it does not contain anything.

In this repository there is actually a different packet named "PacketUserPresence" with the methods I need but it does not seem to be implemented in the bancho-api.jar.

Any ideas on how to fix this or get the username differently?

Edit: Looking at the releases source code, I see the values from "PacketUserInfo" are stored in the object but aren't visible. Can I get them in any other way? (Sorry, I am not really experienced with streams and stuff)

@ekgame
Copy link
Owner

ekgame commented Sep 29, 2016

I really wouldn't recommend using the release jar as library anymore. What you should do is clone this repository and use it as an exernal library.

I've made effort to handle user presence packets within the new API. I don't have any documentations on how to use the new api, so here's a quick tutorial:

BanchoClient bancho = new BanchoClientBuilder(username, password).build();

bancho.addPacketHandler((packet) -> {
    if (packet instanceof PacketReceivingFinished) {
        bancho.getClientManager().changeStatus()
            .setStatus(UserState.TESTING)
            .setBeatmap(new Beatmap(" the bot!"))
            .send();
    }
});

bancho.addEventHandler((event) -> {
    if (event instanceof EventMessage) {
        EventMessage message = (EventMessage) event;
        System.out.println(message.toString());
    }
});

With this to get the user by ID you can do:

User user = bancho.getChannelManager().getUserById(userId);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants