Skip to content

Commit 2f99589

Browse files
committed
v1.2.0
1 parent f36ed62 commit 2f99589

File tree

6 files changed

+46
-26
lines changed

6 files changed

+46
-26
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea/
22
__pycache__/
3-
.vscode/
3+
.vscode/
4+
5+
debug.sh

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Seed
2-
3-
!!seed to get world seed.
2+
> Get world seed without op permission.
43
54
## Preview
65

lang/en_us.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
seed:
2-
help_msg: Get world seed
2+
help_msg: 'Get world seed without op permission.'
33
get_seed: 'Seed: '
4-
copy_to_clipboard: Click to copy to clipboard
5-
failed: Failed to get seed
4+
copy_to_clipboard: 'Click to copy to clipboard'
5+
failed: 'Failed to get seed!'
6+
not_started: 'Server is not running!'
67

lang/zh_cn.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
seed:
2-
help_msg: 获取世界种子
3-
get_seed: 种子:
4-
copy_to_clipboard: 点击复制到剪贴板
5-
failed: 无法获取种子
2+
help_msg: '在没有op权限的情况下获取种子'
3+
get_seed: '种子:'
4+
copy_to_clipboard: '点击复制到剪贴板'
5+
failed: '无法获取种子'
6+
not_started: '服务器未启动'
67

mcdreforged.plugin.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{
22
"id": "seed",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"name": "Seed",
5-
"description": "Get world seed without op permission.",
5+
"description": {
6+
"en_us": "Get world seed without op permission.",
7+
"zh_cn": "在没有op权限的情况下获取种子"
8+
},
69
"author": [
710
"OptiJava"
811
],
912
"link": "https://github.com/OptiJava/Seed",
1013
"dependencies": {
11-
"mcdreforged": ">=2.2.0"
14+
"mcdreforged": ">=2.5.0"
1215
},
1316

1417
"archive_name": "seed-v{version}",

seed/__init__.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,36 @@
66

77
getting_seed = False
88
seed: Optional[str] = None
9-
config: dict = None
9+
config: dict = {}
1010

1111

1212
def on_load(server: PluginServerInterface, old_module):
1313
global config
14+
1415
config = server.load_config_simple(default_config={
1516
'command': 'seed',
1617
'parser': 'Seed: [{}]'
1718
})
1819

1920
if server.is_server_running():
2021
get_seed(server)
21-
server.register_command(Literal('!!seed').runs(print_seed))
22-
server.register_help_message('!!seed', server.tr('seed.help_msg'))
22+
23+
server.register_command(
24+
Literal('!!seed')
25+
.runs(lambda src: print_seed(src, server))
26+
)
27+
server.register_help_message('!!seed', RTextMCDRTranslation('seed.help_msg'))
2328

2429

2530
def on_server_startup(server: PluginServerInterface):
2631
if seed is None:
2732
get_seed(server)
2833

2934

30-
@new_thread('seed')
35+
@new_thread('seed - get')
3136
def get_seed(server: PluginServerInterface):
32-
global seed, getting_seed
37+
global getting_seed
38+
3339
if getting_seed:
3440
return
3541
else:
@@ -42,26 +48,34 @@ def get_seed(server: PluginServerInterface):
4248
else:
4349
getting_seed = False
4450
return
45-
server.logger.error(server.tr('seed.failed'))
51+
52+
server.logger.error(RTextMCDRTranslation('seed.failed'))
4653
getting_seed = False
4754

4855

4956
def on_info(server: PluginServerInterface, info: Info):
50-
global getting_seed, seed
57+
global seed
58+
5159
if getting_seed:
5260
result = parse(config['parser'], info.content)
5361
if result:
5462
seed = result[0]
5563

5664

57-
def print_seed(source: CommandSource):
65+
def print_seed(source: CommandSource, server: PluginServerInterface):
66+
if not server.is_server_running():
67+
source.reply(RTextMCDRTranslation('seed.not_started').set_color(RColor.red))
68+
return
69+
5870
if seed is None:
59-
source.reply(RText(RTextMCDRTranslation('seed.failed'), RColor.red))
71+
source.reply(RTextMCDRTranslation('seed.failed').set_color(RColor.red))
72+
return
73+
6074
source.reply(RTextList(
61-
RTextMCDRTranslation('seed.get_seed', RColor.yellow),
62-
RText('[', RColor.white),
63-
RText(seed, RColor.green, RStyle.underlined).
75+
RTextMCDRTranslation('seed.get_seed').set_color(RColor.yellow),
76+
RText('['),
77+
RText(seed, color=RColor.green, styles=RStyle.underlined).
6478
h(RTextMCDRTranslation('seed.copy_to_clipboard')).
6579
c(RAction.copy_to_clipboard, seed),
66-
RText(']', RColor.white))
80+
RText(']'))
6781
)

0 commit comments

Comments
 (0)