-
Notifications
You must be signed in to change notification settings - Fork 1
show_title #5
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
base: main
Are you sure you want to change the base?
show_title #5
Changes from 26 commits
848394d
9df09bc
af28fa7
83e5a0f
9f1e716
3f0abfe
0320042
c006106
7d65a18
5047735
c84c2b8
2d8664b
7151c1b
e9c5eb6
1762f3a
d9e683d
6df6394
c2f9175
3654006
d0a37a2
692413c
69d92ae
bf61f67
5a11490
058a791
944ecfb
d895a0a
4f80ab4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
|
|
||
| import grpc | ||
|
|
||
| from ._types import COLOR | ||
| from ._base import HasStub | ||
| from .entity import _EntityCache | ||
| from .events import _EventHandler | ||
|
|
@@ -13,6 +14,7 @@ | |
| from .mcpb import minecraft_pb2 as pb | ||
| from .player import _PlayerCache | ||
| from .world import _DefaultWorld, _WorldHub | ||
| from typing import Literal | ||
|
|
||
| __all__ = ["Minecraft"] | ||
|
|
||
|
|
@@ -54,3 +56,10 @@ def port(self) -> int: | |
| def postToChat(self, *args, sep: str = " ") -> None: | ||
| 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: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Und zuletzt bitte noch die Datentypen anpassen: Datentyp |
||
| 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 clearTitle(self): | ||
| HasStub.runCommand(self, 'title @a clear') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| from functools import partial | ||
| from typing import Literal | ||
|
|
||
| from ._types import COLOR | ||
| from ._base import HasStub, _PlayerProvider | ||
| from ._util import ThreadSafeCachedKeyBasedFactory | ||
| from .entity import Entity | ||
|
|
@@ -118,6 +119,13 @@ def op(self) -> None: | |
| def deop(self) -> None: | ||
| HasStub.runCommand(self, f"deop {self.name}") | ||
|
|
||
| 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: | ||
| 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}' + '}') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bitte diesen Punkt noch ausbessern, alle Instanzen von |
||
|
|
||
| def clearTitle(self): | ||
| self.runCommand("title @s clear") | ||
|
|
||
| # properties that have different stub entpoints than entity | ||
| @property | ||
| def pos(self) -> Vec3: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.