Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin-api): userId & clientName getters #743

Merged
merged 3 commits into from
Oct 12, 2022
Merged

feat(plugin-api): userId & clientName getters #743

merged 3 commits into from
Oct 12, 2022

Conversation

viztea
Copy link
Contributor

@viztea viztea commented Sep 16, 2022

Adds two methods for getting the name & userId of a client

Copy link
Member

@freyacodes freyacodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not idiomatic Kotlin. In Kotlin, if you have a property like val userId: String, which is a public final value, a getter is automatically created. From the perspective of Java, it would look like public String getUserId()

Interfaces in Kotlin support properties, not just functions.

You should thus:

  1. Add the two properties to the interface
  2. Remove the explicit getters
  3. Remove the private access modifiers. Default is public.
  4. Add the override modifier to SocketContext, e.g. override val userId: String

@freyacodes
Copy link
Member

@devoxin @TopiSenpai just for future reference, the release of code changes to the API have to go through me, as I am the only one with credentials and who can sign releases.

@freyacodes
Copy link
Member

Should probably also consider parsing the userId to be a Long. It's a string because Discord snowflakes are sent from Discord as strings in JSON for the sake of compatibility

@viztea
Copy link
Contributor Author

viztea commented Sep 17, 2022

This is not idiomatic Kotlin. In Kotlin, if you have a property like val userId: String, which is a public final value, a getter is automatically created. From the perspective of Java, it would look like public String getUserId()

Yes I'm aware of what idiomatic kotlin is. I attempted to have kotlin automatically create getters for me but it complained...

Interfaces in Kotlin support properties, not just functions.

ISocketContext is a Java interface.

You should thus:

  1. Add the two properties to the interface
  2. Remove the explicit getters
  3. Remove the private access modifiers. Default is public.
  4. Add the override modifier to SocketContext, e.g. override val userId: String

Properties inside of a java interface? I'm pretty sure this isn't idiomatic java.

@viztea
Copy link
Contributor Author

viztea commented Sep 17, 2022

Should probably also consider parsing the userId to be a Long. It's a string because Discord snowflakes are sent from Discord as strings in JSON for the sake of compatibility

Wouldn't that kind of be out of scope for this PR? It should be separate.

@freyacodes
Copy link
Member

Fair, I didn't realise it was written in Java. That was a deliberate choice.

Wouldn't that kind of be out of scope for this PR? It should be separate.

Perhaps. But then you can do the conversion in the getter. I am not willing to release two separate API versions.

@viztea
Copy link
Contributor Author

viztea commented Oct 10, 2022

Perhaps. But then you can do the conversion in the getter. I am not willing to release two separate API versions.

Sounds good 👍🏼

Copy link
Member

@freyacodes freyacodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. I will be releasing a new API version to Maven Central

@freyacodes freyacodes merged commit 4524f67 into lavalink-devs:dev Oct 12, 2022
@freyacodes
Copy link
Member

Actually, we haven't really decided on how to manage plugin API versions that have not been merged into master. Are you fine with using JitPack for now?

@freyacodes
Copy link
Member

API version 3.6.0 released

@viztea viztea deleted the feat/socket-context-userId-getter branch October 12, 2022 19:34
topi314 pushed a commit to topi314/Lavalink that referenced this pull request Oct 24, 2022
* feat(plugin-api): userId & clientName getters

* fix: remove trailing space from javadoc

* chore: convert user id to long in getter
topi314 pushed a commit that referenced this pull request Oct 26, 2022
* feat(plugin-api): userId & clientName getters

* fix: remove trailing space from javadoc

* chore: convert user id to long in getter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants