-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add examples of PlayerJoinEvent and PlayerQuitEvent
- Loading branch information
1 parent
01237b7
commit 59e069b
Showing
2 changed files
with
18 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
from endstone import ColorFormat | ||
from endstone.event import ServerListPingEvent, event_handler, EventPriority | ||
from endstone.event import event_handler, EventPriority, PlayerJoinEvent, PlayerQuitEvent, ServerListPingEvent | ||
from endstone.plugin import Plugin | ||
|
||
|
||
class ExampleListener: | ||
|
||
def __init__(self, plugin: Plugin): | ||
self._plugin = plugin | ||
|
||
@event_handler(priority=EventPriority.HIGHEST) | ||
def on_server_list_ping(self, event: ServerListPingEvent): | ||
event.motd = ColorFormat.BOLD + ColorFormat.AQUA + "Example MOTD" | ||
event.level_name = f"Your IP is {ColorFormat.YELLOW}{event.remote_host}:{event.remote_port}{ColorFormat.RESET}" | ||
|
||
@event_handler | ||
def on_player_join(self, event: PlayerJoinEvent): | ||
player = event.player | ||
self._plugin.logger.info(ColorFormat.YELLOW + f"{player.name} ({player.unique_id}) joins the game.") | ||
|
||
@event_handler | ||
def on_player_quit(self, event: PlayerQuitEvent): | ||
player = event.player | ||
self._plugin.logger.info(ColorFormat.YELLOW + f"{player.name} ({player.unique_id}) leaves the game.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters