Skip to content

Allow more versatile implementations of Polychat clients #50

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ThePixelbrain
Copy link

I was working on a Polychat client implementation for a custom Minecraft proxy.

While doing this I noticed some limitations in the Polychat client base I couldn't properly work around, so instead of hacking my way around them, I decided to make a PR!

These two limitations are addressed in this PR:

Config handling

Polychat requires a dedicated config file for each client and is incapable of getting config values passed during instantiation.

While this works fine in the scenario of a standalone Minecraft client, my client spawns multiple Polychat clients with similar configs. It is more reasonable for my usecase to maintain the configs on the implementation side and have them passed to the Polychat instance.

Which is what I did. I added an optional parameter YamlConfig config to the constructor of the PolychatClient class.

Logging

Polychat has System.out / System.err hard-coded for logging. While this is easy and doesn't introduce a dependency on a logging library such as Log4J, I want to have the possibility of configuring my own logger.

Therefore I added an Interface Logger that handles all logging methods. It's implemented by a DefaultLogger that uses System.out / System.err like before, but gives me the possibility of adding my own logger on my implementation.

private final PolychatProtobufMessageDispatcher polychatProtobufMessageDispatcher;
private final YamlConfig config;
private final String serverId;
private final ClientCallbacks clientCallbacks;
Copy link
Contributor

Choose a reason for hiding this comment

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

What made you strip the final from each of these?

Copy link
Author

Choose a reason for hiding this comment

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

I removed them because I moved common initialization code to it's own method. I was kinda lost how to properly do this, the new approach is better.

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.

2 participants