Skip to content

Conversation

@paul07iq
Copy link

Added show_title function

paul07iq added 24 commits May 18, 2024 20:39
added "show_title" function for player
Added reset_title/clear_title
Added show_title, clear_title, reset_title
fixed show_title
fixed show_title
fixed color at show_title
fixed color at show_title
fixed show_title
fixed show_title
fixed import
fixed time
fixed time
fixed show_title
fixed show_title
fixed show_title
fixed show_title
fixed color at show_title
fixed color at show_title
fixed color at show_title
fixed port
Improved Color at show_title
Improved Color at show_title
Added slots to _types.py
Removed slots
Copy link
Owner

@icezyclon icezyclon left a comment

Choose a reason for hiding this comment

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

Code funktioniert insofern ich das testen konnte, es gibt einige Typ-Unstimmigkeiten und Details, die mit Projektstruktur zu tun haben, ansonsten ein sehr guter erster Commit.
Ich würde den Commit akzeptieren, wenn die angemerkten Änderungen durchgeführt werden. Gute Arbeit!

response = self._stub.postToChat(pb.ChatPostRequest(message=sep.join(map(str, args))))
raise_on_error(response)

def show_title(self, text: str, typ: Literal["actionbar", "subtitle", "title"] = "title", color: COLOR = "gray", bold: bool = "false", italic: bool = "false", strikethrough: bool = "false", underlined: bool = "false", obfuscated: bool = "false", duration: int = 1, fade_in: int = 5, fade_out: int = 1) -> None:
Copy link
Owner

Choose a reason for hiding this comment

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

Bitte gleiche Schreibweise von Funktionen weiterverwenden, wie im Projekt. Alle anderen Funktionen verwenden camelCase nicht snake_case.

Hier gibt es Typ-Unstimmigkeiten:
Du sagst zwar dass die Variablen bold, italic, usw. "bool" sind, sie sind aber "str" hier. Bitte auf echte "bool" ändern und falls Groß-Kleinschreibung im Befehl eine Rolle spielt, mit "str(True/False).lower()" umwandeln.

Zuletzt wäre ein Vorschlag die Duration auf 5 und den FadeIn auf 1 zu setzten.

HasStub.runCommand(self, f'title @a times {fade_in}s {duration}s {fade_out}s')
HasStub.runCommand(self, f'title @a {typ} ' + '{' + f'"text":"{text}","color":"{color}","bold":{bold},"italic":{italic},"strikethrough":{strikethrough},"underlined":{underlined},"obfuscated":{obfuscated}' + '}')

def reset_title(self):
Copy link
Owner

Choose a reason for hiding this comment

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

Wozu brauchen wir resetTitle? Wird nicht eh jedes Mal, wenn wir showTitle aufrufen, die Attribute neu gesetzt?

HasStub.runCommand(self, f'title @a reset')

def clear_title(self):
HasStub.runCommand(self, f'title @a clear')
Copy link
Owner

Choose a reason for hiding this comment

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

Braucht kein f-string sein.

def deop(self) -> None:
HasStub.runCommand(self, f"deop {self.name}")

def show_title(self, text: str, typ: Literal["actionbar", "subtitle", "title"] = "title", color: COLOR = "gray", bold: bool = "false", italic: bool = "false", strikethrough: bool = "false", underlined: bool = "false", obfuscated: bool = "false", duration: int = 1, fade_in: int = 5, fade_out: int = 1) -> None:
Copy link
Owner

Choose a reason for hiding this comment

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

Bitte gleiche Änderungen wie oben für die Typen und den Case.


def show_title(self, text: str, typ: Literal["actionbar", "subtitle", "title"] = "title", color: COLOR = "gray", bold: bool = "false", italic: bool = "false", strikethrough: bool = "false", underlined: bool = "false", obfuscated: bool = "false", duration: int = 1, fade_in: int = 5, fade_out: int = 1) -> None:
HasStub.runCommand(self, f'title {self.name} times {fade_in}s {duration}s {fade_out}s')
HasStub.runCommand(self, f'title {self.name} {typ} ' + '{' + f'"text":"{text}","color":"{color}","bold":{bold},"italic":{italic},"strikethrough":{strikethrough},"underlined":{underlined},"obfuscated":{obfuscated}' + '}')
Copy link
Owner

Choose a reason for hiding this comment

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

Da wir in der Klasse Player > Entity hier sind, können wir ruhig die überschriebene "runCommand" Funktion dieser Klasse verwenden. Hier direkt HasStub.runCommand zu verwenden umgeht die Klassenhierachie.
Wenn man das macht, könnte man auch bei allen Befehlen einfach 'title @s ...' schreiben, da der Player identifier schon in Entity.runCommand gesetzt wird 👍

Copy link
Owner

Choose a reason for hiding this comment

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

Bitte diesen Punkt noch ausbessern, alle Instanzen von HasStub.runCommand durch self.runCommand ersetzten, und im Falle von der Player-Klasse, mit title @s ... anstelle von title {self.name} ...

paul07iq added 2 commits May 21, 2024 12:40
- Used camelCase
- Removed reset_title
- Change default values
- Imported Literal
- Used camelCase
- Removed reset_title
- Change default values
Copy link
Owner

@icezyclon icezyclon left a comment

Choose a reason for hiding this comment

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

Danke fürs ausbessern soweit. Bitte noch die zwei letzten Kommentare zu 1) Datentypen und 2) HasStub -> self ersetzten, dann sind alle Punkte erledigt 👍


def show_title(self, text: str, typ: Literal["actionbar", "subtitle", "title"] = "title", color: COLOR = "gray", bold: bool = "false", italic: bool = "false", strikethrough: bool = "false", underlined: bool = "false", obfuscated: bool = "false", duration: int = 1, fade_in: int = 5, fade_out: int = 1) -> None:
HasStub.runCommand(self, f'title {self.name} times {fade_in}s {duration}s {fade_out}s')
HasStub.runCommand(self, f'title {self.name} {typ} ' + '{' + f'"text":"{text}","color":"{color}","bold":{bold},"italic":{italic},"strikethrough":{strikethrough},"underlined":{underlined},"obfuscated":{obfuscated}' + '}')
Copy link
Owner

Choose a reason for hiding this comment

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

Bitte diesen Punkt noch ausbessern, alle Instanzen von HasStub.runCommand durch self.runCommand ersetzten, und im Falle von der Player-Klasse, mit title @s ... anstelle von title {self.name} ...

response = self._stub.postToChat(pb.ChatPostRequest(message=sep.join(map(str, args))))
raise_on_error(response)

def showTitle(self, text: str, typ: Literal["actionbar", "subtitle", "title"] = "title", color: COLOR = "gray", bold: bool = "false", italic: bool = "false", strikethrough: bool = "false", underlined: bool = "false", obfuscated: bool = "false", duration: int = 3, fade_in: int = 1, fade_out: int = 1) -> None:
Copy link
Owner

Choose a reason for hiding this comment

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

Und zuletzt bitte noch die Datentypen anpassen: Datentyp boolsollte als default Argument True oder False haben, nicht "true" oder "false". 👍

@icezyclon
Copy link
Owner

icezyclon commented May 26, 2024

Übrigens, es gibt noch einen Punkt der wichtig für mich ist: und zwar, gibt es ein default formatting in diesem Projekt, das mit pre-commit gemacht wird. Die passende Konfiguration dafür liegt im Repository.
Bevor du einen PR einreichst, würde ich dich bitte sowohl requirements.txt als auch requirements-dev.txt zu installieren, und im Anschluss pre-commit install auszuführen, damit pre-commit installiert wird. (Es scheint auch ein Plugin für PyCharm zu geben: https://plugins.jetbrains.com/plugin/9278-pre-commit-hook-plugin)
Dieses wird dann jedes Mal wenn du einen Commit machst, alle Dateien formatieren, sodass alle Dateien im Repository gleich aussehen 👍

Auf diese Art und Weise ist alles einheitlich und sortiert.

@icezyclon icezyclon mentioned this pull request May 26, 2024
- Duration Standartwert auf 5s erhöht
- HasStub.runCommand durch self.runCommand ersetzt
- Duration Standartwert auf 5s erhöht
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