generated from EndstoneMC/python-example-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21b1582
commit ec26121
Showing
6 changed files
with
51 additions
and
4 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
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
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
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,8 +1,30 @@ | ||
from endstone.plugin import Plugin | ||
|
||
from endstone_test import EndstoneTest | ||
from endstone.command import CommandSenderWrapper | ||
|
||
|
||
def test_instance(plugin: Plugin): | ||
assert plugin is not None | ||
assert isinstance(plugin, EndstoneTest) | ||
|
||
|
||
def test_schedule_task(plugin: Plugin) -> None: | ||
# case study: https://github.com/EndstoneMC/endstone/issues/31 | ||
server = plugin.server | ||
assert server.dispatch_command(server.command_sender, "save hold") | ||
|
||
# since /save hold takes time to save, we run /save query in a delayed task to avoid blocking the thread | ||
def save_query(): | ||
messages = [] | ||
sender = CommandSenderWrapper(server.command_sender, | ||
on_message=lambda msg: messages.extend([msg.translate, *msg.with_])) | ||
ready = server.dispatch_command(sender, "save query") | ||
if not ready: | ||
server.scheduler.run_task(plugin, save_query, delay=5) | ||
return | ||
|
||
assert 'commands.save-all.success' in messages | ||
assert server.dispatch_command(server.command_sender, "save resume") | ||
|
||
server.scheduler.run_task(plugin, save_query, delay=5) |
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
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