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

Remove the duplicate logic in connection classes #355

Open
ItsDrike opened this issue Jul 16, 2022 · 1 comment
Open

Remove the duplicate logic in connection classes #355

ItsDrike opened this issue Jul 16, 2022 · 1 comment
Labels
area: protocol Related to underlying networking protocol type: enhancement Improvement to an existing feature

Comments

@ItsDrike
Copy link
Member

ItsDrike commented Jul 16, 2022

There is a couple of methods with duplicated logic. Maybe we should do it in one method with dict or possibly with an enum class?

from enum import Enum

class ValueType(Enum):
    FULL_NAME = "Q"
    ...

def write_value_with_type(self, value: int, type: ValueType) -> None:
    self.write(self._pack(type.value, value))

write_value_with_type(123, ValueType.FULL_NAME)

https://docs.python.org/3/library/enum.html

Originally posted by @PerchunPak in #273 (comment)

@ItsDrike ItsDrike changed the title There is a couple of methods with duplicated logic in connection classes. Maybe you should do it in one method with dict or possibly enum? Remove the duplicate logic in connection classes Jul 16, 2022
@ItsDrike ItsDrike added type: enhancement Improvement to an existing feature area: API Related to core API of the project labels Jul 20, 2022
@ItsDrike ItsDrike added area: protocol Related to underlying networking protocol and removed area: API Related to core API of the project labels Oct 13, 2022
@ItsDrike
Copy link
Member Author

Potentially no longer relevant if mcstatus will move to using mcproto as dependency (however that could still take a while, as mcproto doesn't yet have complete support for java, and currently completely lacks bedrock support)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: protocol Related to underlying networking protocol type: enhancement Improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant