mcserver-cli 3.0.0__py3-none-any.whl → 4.0.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcserver/__init__.py +1 -1
- mcserver/app.py +13 -9
- mcserver/caching.py +16 -0
- mcserver/cli.py +117 -71
- mcserver/commands/__init__.py +1 -1
- mcserver/commands/add_projects.py +144 -3
- mcserver/commands/import_setup.py +7 -4
- mcserver/commands/initialize_server.py +17 -4
- mcserver/commands/list_projects.py +6 -4
- mcserver/commands/op_grant.py +6 -4
- mcserver/commands/op_list.py +4 -4
- mcserver/commands/op_revoke.py +6 -4
- mcserver/commands/remove_projects.py +6 -4
- mcserver/commands/search_projects.py +106 -4
- mcserver/commands/server_status.py +6 -4
- mcserver/commands/show_projects.py +20 -17
- mcserver/commands/start_server.py +22 -9
- mcserver/commands/stop_server.py +8 -24
- mcserver/commands/update_projects.py +6 -4
- mcserver/commands/whitelist_add.py +6 -4
- mcserver/commands/whitelist_list.py +4 -3
- mcserver/commands/whitelist_remove.py +30 -28
- mcserver/config.py +45 -16
- mcserver/constants.py +0 -2
- mcserver/mcserver_v2.0.0.py +1119 -0
- mcserver/metadata.py +2 -2
- mcserver/modrinth/api.py +158 -47
- mcserver/modrinth/apis/__init__.py +9 -0
- mcserver/modrinth/apis/get_project_informations.py +216 -0
- mcserver/modrinth/apis/get_project_versions.py +131 -0
- mcserver/modrinth/apis/search_projects.py +122 -0
- mcserver/modrinth/constants.py +1 -0
- mcserver/modrinth/paths.py +3 -0
- mcserver/modrinth/project_records/relationships.py +5 -3
- mcserver/modrinth/project_records/shared.py +1 -2
- mcserver/modrinth/project_records.py +104 -0
- mcserver/modrinth/shared.py +86 -6
- mcserver/modrinth/slug_index.py +105 -9
- mcserver/modrinth/typings/__init__.py +38 -0
- mcserver/modrinth/typings/project_informations.py +137 -0
- mcserver/modrinth/typings/search_projects.py +94 -0
- mcserver/modrinth/typings/shared.py +17 -0
- mcserver/mysterious.py +22 -2
- mcserver/networking.py +14 -7
- mcserver/paths.py +18 -0
- mcserver/resolver.py +63 -14
- mcserver/server_files/properties.py +8 -7
- mcserver/server_files/whitelist.py +60 -39
- mcserver/shared.py +59 -17
- mcserver/state.py +22 -14
- {mcserver_cli-3.0.0.dist-info → mcserver_cli-4.0.0.dev0.dist-info}/METADATA +22 -15
- mcserver_cli-4.0.0.dev0.dist-info/RECORD +73 -0
- {mcserver_cli-3.0.0.dist-info → mcserver_cli-4.0.0.dev0.dist-info}/WHEEL +1 -1
- mcserver_cli-4.0.0.dev0.dist-info/entry_points.txt +2 -0
- mcserver_cli-4.0.0.dev0.dist-info/licenses/LICENSE +9 -0
- mcserver/commandsa.py +0 -1297
- mcserver_cli-3.0.0.dist-info/RECORD +0 -61
- mcserver_cli-3.0.0.dist-info/entry_points.txt +0 -2
- mcserver_cli-3.0.0.dist-info/licenses/LICENSE +0 -9
mcserver/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "
|
|
1
|
+
__version__ = "4.0.0.dev0"
|
mcserver/app.py
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
def main()
|
|
1
|
+
def main():
|
|
2
2
|
import sys
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
from .mysterious import nothing_to_see_here_move_along
|
|
6
|
-
|
|
7
|
-
nothing_to_see_here_move_along()
|
|
8
|
-
|
|
9
|
-
MIN_PYTHON_VERSION: tuple[int, int] = (3, 14)
|
|
4
|
+
MIN_PYTHON_VERSION: tuple[int, int] = (3, 12)
|
|
10
5
|
if sys.version_info < MIN_PYTHON_VERSION:
|
|
11
6
|
sys.exit(
|
|
12
7
|
f"MCServer requires Python {'.'.join(map(str, MIN_PYTHON_VERSION))} or newer."
|
|
13
8
|
)
|
|
14
9
|
|
|
10
|
+
if (sys.argv[1] if len(sys.argv) > 1 else "") == "uh...":
|
|
11
|
+
from .mysterious import nothing_to_see_here_move_along
|
|
12
|
+
|
|
13
|
+
nothing_to_see_here_move_along()
|
|
14
|
+
|
|
15
15
|
import logging as log
|
|
16
16
|
import os
|
|
17
17
|
|
|
18
18
|
from . import cli
|
|
19
19
|
|
|
20
20
|
debug_mode = os.getenv("MCSERVER_DEBUG") == "1"
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
if debug_mode:
|
|
22
|
+
log.basicConfig(
|
|
23
|
+
level=log.DEBUG, format="[%(levelname)s] [%(module)s]: %(message)s"
|
|
24
|
+
)
|
|
25
|
+
else:
|
|
26
|
+
log.basicConfig(level=log.INFO, format="[%(levelname)s]: %(message)s")
|
|
23
27
|
|
|
24
28
|
sys.exit(cli.main())
|
mcserver/caching.py
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
cache_dir = Path.home() / ".cache"
|
|
5
|
+
|
|
6
|
+
xdg_cache_dir = os.getenv("XDG_CACHE_DIR")
|
|
7
|
+
if xdg_cache_dir:
|
|
8
|
+
cache_dir = Path(xdg_cache_dir)
|
|
9
|
+
|
|
10
|
+
mcserver_cache_dir = cache_dir / "mcserver"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def create_file(file_name: str, file_data: bytes):
|
|
14
|
+
mcserver_cache_dir.mkdir(parents=True, exist_ok=True)
|
|
15
|
+
cache_file = mcserver_cache_dir / file_name
|
|
16
|
+
cache_file.write_bytes(file_data)
|
mcserver/cli.py
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
def main() -> int:
|
|
2
2
|
import argparse
|
|
3
|
+
import sys
|
|
3
4
|
|
|
4
5
|
from . import __version__
|
|
6
|
+
from .modrinth.shared import search_sort_index
|
|
5
7
|
from .shared import loader_list
|
|
6
8
|
|
|
9
|
+
def bound_int(min_integer: int, max_integer: int | None = None):
|
|
10
|
+
def parse(cli_string: str):
|
|
11
|
+
try:
|
|
12
|
+
integer = int(cli_string)
|
|
13
|
+
except TypeError:
|
|
14
|
+
raise argparse.ArgumentTypeError(f"{cli_string} is not an integer")
|
|
15
|
+
|
|
16
|
+
if integer <= min_integer:
|
|
17
|
+
raise argparse.ArgumentTypeError(
|
|
18
|
+
f"{integer} must be higher than or equal to {min_integer}"
|
|
19
|
+
)
|
|
20
|
+
if max_integer is not None and integer >= max_integer:
|
|
21
|
+
raise argparse.ArgumentTypeError(
|
|
22
|
+
f"{integer} must be between {min_integer} and {max_integer} (inclusive)"
|
|
23
|
+
)
|
|
24
|
+
return integer
|
|
25
|
+
|
|
26
|
+
return parse
|
|
27
|
+
|
|
7
28
|
def command_function(args: argparse.Namespace) -> int:
|
|
8
29
|
command_name: str = args.command_name
|
|
9
30
|
|
|
@@ -86,6 +107,8 @@ def main() -> int:
|
|
|
86
107
|
log.error(f"Unknown command: {command_name}")
|
|
87
108
|
return 1
|
|
88
109
|
|
|
110
|
+
# Parser Setup
|
|
111
|
+
|
|
89
112
|
parser = argparse.ArgumentParser(
|
|
90
113
|
prog="mcserver",
|
|
91
114
|
description="A CLI tool for managing Minecraft: Java Edition servers.",
|
|
@@ -95,10 +118,12 @@ def main() -> int:
|
|
|
95
118
|
add_help=True,
|
|
96
119
|
allow_abbrev=False,
|
|
97
120
|
exit_on_error=True,
|
|
98
|
-
suggest_on_error=True,
|
|
99
|
-
color=True,
|
|
100
121
|
)
|
|
101
122
|
|
|
123
|
+
if sys.version_info >= (3, 14):
|
|
124
|
+
parser.suggest_on_error = True
|
|
125
|
+
parser.color = True
|
|
126
|
+
|
|
102
127
|
parser.set_defaults(func=command_function, command_name="help", parser=parser)
|
|
103
128
|
parser.add_argument(
|
|
104
129
|
"-v",
|
|
@@ -112,13 +137,13 @@ def main() -> int:
|
|
|
112
137
|
# 'add' command
|
|
113
138
|
add_command = commands.add_parser(
|
|
114
139
|
"add",
|
|
115
|
-
help="Add
|
|
116
|
-
description="Add mods/plugins
|
|
140
|
+
help="Add Modrinth projects to the server",
|
|
141
|
+
description="Add Modrinth mods/plugins to the server",
|
|
117
142
|
)
|
|
118
143
|
|
|
119
144
|
add_command.set_defaults(command_name="add")
|
|
120
145
|
add_command.add_argument(
|
|
121
|
-
"projects", nargs="+", type=str, help="
|
|
146
|
+
"projects", nargs="+", type=str, help="Modrinth project slugs or IDs"
|
|
122
147
|
)
|
|
123
148
|
|
|
124
149
|
# 'import' command
|
|
@@ -129,7 +154,7 @@ def main() -> int:
|
|
|
129
154
|
)
|
|
130
155
|
|
|
131
156
|
import_command.set_defaults(command_name="import")
|
|
132
|
-
import_command.add_argument("
|
|
157
|
+
import_command.add_argument("file", type=str, help="The Modrinth modpack file")
|
|
133
158
|
|
|
134
159
|
# 'init' command
|
|
135
160
|
init_command = commands.add_parser(
|
|
@@ -140,12 +165,11 @@ def main() -> int:
|
|
|
140
165
|
|
|
141
166
|
init_command.set_defaults(command_name="init")
|
|
142
167
|
init_command.add_argument(
|
|
143
|
-
"--
|
|
168
|
+
"--game-version",
|
|
144
169
|
default="latest-release",
|
|
145
170
|
type=str,
|
|
146
171
|
help="Minecraft version of the server",
|
|
147
172
|
metavar="Version",
|
|
148
|
-
dest="game_version",
|
|
149
173
|
)
|
|
150
174
|
|
|
151
175
|
init_command.add_argument(
|
|
@@ -169,19 +193,38 @@ def main() -> int:
|
|
|
169
193
|
init_command.add_argument(
|
|
170
194
|
"--min-ram",
|
|
171
195
|
default=512,
|
|
172
|
-
type=
|
|
173
|
-
help="Minimum RAM for the server (in MebiBytes)",
|
|
196
|
+
type=bound_int(1024),
|
|
197
|
+
help="Minimum RAM for the server (in MebiBytes) (minimum value: 1024)",
|
|
174
198
|
metavar="Size",
|
|
175
199
|
)
|
|
176
200
|
|
|
177
201
|
init_command.add_argument(
|
|
178
202
|
"--max-ram",
|
|
179
|
-
default=
|
|
203
|
+
default=bound_int(1024),
|
|
180
204
|
type=int,
|
|
181
|
-
help="Maximum RAM for the server (in MebiBytes)",
|
|
205
|
+
help="Maximum RAM for the server (in MebiBytes) (minimum value: 1024)",
|
|
182
206
|
metavar="Size",
|
|
183
207
|
)
|
|
184
208
|
|
|
209
|
+
init_command.add_argument(
|
|
210
|
+
"--search-limit",
|
|
211
|
+
default=20,
|
|
212
|
+
type=bound_int(1, 100),
|
|
213
|
+
help="Default search limit value (value between (inclusive): 1-100)",
|
|
214
|
+
metavar="Number",
|
|
215
|
+
dest="search_limit",
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
init_command.add_argument(
|
|
219
|
+
"--search-sort",
|
|
220
|
+
default="relevance",
|
|
221
|
+
type=str,
|
|
222
|
+
choices=search_sort_index,
|
|
223
|
+
help="Default search sort index",
|
|
224
|
+
metavar="Index",
|
|
225
|
+
dest="search_limit",
|
|
226
|
+
)
|
|
227
|
+
|
|
185
228
|
# 'list' command
|
|
186
229
|
list_command = commands.add_parser(
|
|
187
230
|
"list", help="List all added projects", description="List all added projects."
|
|
@@ -197,18 +240,7 @@ def main() -> int:
|
|
|
197
240
|
op_command.set_defaults(parser=op_command)
|
|
198
241
|
op_subcommands = op_command.add_subparsers(title="Subcommands")
|
|
199
242
|
|
|
200
|
-
#
|
|
201
|
-
op_grant_command = op_subcommands.add_parser(
|
|
202
|
-
"grant",
|
|
203
|
-
help="Grant operator to players",
|
|
204
|
-
description="Grant operator status to players.",
|
|
205
|
-
)
|
|
206
|
-
|
|
207
|
-
op_grant_command.set_defaults(command_name="op_grant")
|
|
208
|
-
op_grant_command.add_argument(
|
|
209
|
-
"players", nargs="+", type=str, help="Player names or UUIDs"
|
|
210
|
-
)
|
|
211
|
-
|
|
243
|
+
# op_grant and op_revoke is not going to be implemented in this version
|
|
212
244
|
# 'op list'
|
|
213
245
|
op_list_command = op_subcommands.add_parser(
|
|
214
246
|
"list", help="List operator players", description="List all operator players."
|
|
@@ -216,23 +248,16 @@ def main() -> int:
|
|
|
216
248
|
|
|
217
249
|
op_list_command.set_defaults(command_name="op_list")
|
|
218
250
|
|
|
219
|
-
# 'op revoke'
|
|
220
|
-
op_revoke_command = op_subcommands.add_parser(
|
|
221
|
-
"revoke",
|
|
222
|
-
help="Revoke operator from players",
|
|
223
|
-
description="Revoke operator status from players.",
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
op_revoke_command.set_defaults(command_name="op_revoke")
|
|
227
|
-
op_revoke_command.add_argument(
|
|
228
|
-
"players", nargs="+", type=str, help="Player names or UUIDs"
|
|
229
|
-
)
|
|
230
|
-
|
|
231
251
|
# 'remove' command
|
|
232
252
|
remove_command = commands.add_parser(
|
|
233
253
|
"remove", help="Remove projects", description="Remove projects"
|
|
234
254
|
)
|
|
235
255
|
|
|
256
|
+
remove_command.set_defaults(command_name="remove")
|
|
257
|
+
remove_command.add_argument(
|
|
258
|
+
"projects", nargs="+", type=str, help="Modrinth project slugs or IDs"
|
|
259
|
+
)
|
|
260
|
+
|
|
236
261
|
# 'search' command
|
|
237
262
|
search_command = commands.add_parser(
|
|
238
263
|
"search",
|
|
@@ -241,7 +266,60 @@ def main() -> int:
|
|
|
241
266
|
)
|
|
242
267
|
|
|
243
268
|
search_command.set_defaults(command_name="search")
|
|
244
|
-
search_command.add_argument(
|
|
269
|
+
search_command.add_argument(
|
|
270
|
+
"search_query", nargs="*", type=str, help="Query to search"
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
search_command.add_argument(
|
|
274
|
+
"--limit",
|
|
275
|
+
default=20,
|
|
276
|
+
type=bound_int(1, 100),
|
|
277
|
+
help="Search projects per page (value between (inclusive): 1-100)",
|
|
278
|
+
metavar="Number",
|
|
279
|
+
dest="search_limit",
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
search_command.add_argument(
|
|
283
|
+
"--page",
|
|
284
|
+
default=1,
|
|
285
|
+
type=bound_int(1),
|
|
286
|
+
help="Show mods in page number (minimum value: 1)",
|
|
287
|
+
metavar="Number",
|
|
288
|
+
dest="page_number",
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
search_command.add_argument(
|
|
292
|
+
"--sort",
|
|
293
|
+
default="relevance",
|
|
294
|
+
type=str,
|
|
295
|
+
choices=search_sort_index,
|
|
296
|
+
help="Sort by index",
|
|
297
|
+
metavar="Index",
|
|
298
|
+
dest="sort_index",
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
search_command.add_argument(
|
|
302
|
+
"--game-version",
|
|
303
|
+
type=str,
|
|
304
|
+
help="Override the Minecraft version filter",
|
|
305
|
+
metavar="Version",
|
|
306
|
+
dest="game_version",
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
search_command.add_argument(
|
|
310
|
+
"--no-version",
|
|
311
|
+
action="store_true",
|
|
312
|
+
help="Ignore game version at all",
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
search_command.add_argument(
|
|
316
|
+
"--loader",
|
|
317
|
+
type=str,
|
|
318
|
+
choices=loader_list,
|
|
319
|
+
help="Override the loader filter",
|
|
320
|
+
metavar="Loader",
|
|
321
|
+
dest="loader_name",
|
|
322
|
+
)
|
|
245
323
|
|
|
246
324
|
# 'show' command
|
|
247
325
|
show_command = commands.add_parser(
|
|
@@ -262,22 +340,13 @@ def main() -> int:
|
|
|
262
340
|
|
|
263
341
|
start_command.set_defaults(command_name="start")
|
|
264
342
|
|
|
343
|
+
# status_command is not going to be implemented in this version
|
|
265
344
|
# "stop" command
|
|
266
345
|
stop_command = commands.add_parser(
|
|
267
346
|
"stop", help="Stop the server", description="Stop the running server"
|
|
268
347
|
)
|
|
269
348
|
|
|
270
349
|
stop_command.set_defaults(command_name="stop")
|
|
271
|
-
stop_command.add_argument(
|
|
272
|
-
"--force-stop", action="store_true", help="Force stop the server"
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
# "update" command
|
|
276
|
-
update_command = commands.add_parser(
|
|
277
|
-
"update",
|
|
278
|
-
help="Update projects from Modrinth",
|
|
279
|
-
description="Update projects from Modrinth",
|
|
280
|
-
)
|
|
281
350
|
|
|
282
351
|
# 'whitelist' command
|
|
283
352
|
whitelist_command = commands.add_parser(
|
|
@@ -289,18 +358,7 @@ def main() -> int:
|
|
|
289
358
|
whitelist_command.set_defaults(parser=whitelist_command)
|
|
290
359
|
whitelist_subcommands = whitelist_command.add_subparsers(title="Subcommands")
|
|
291
360
|
|
|
292
|
-
#
|
|
293
|
-
whitelist_add_command = whitelist_subcommands.add_parser(
|
|
294
|
-
"add",
|
|
295
|
-
help="Add players to whitelist",
|
|
296
|
-
description="Add players to the whitelist.",
|
|
297
|
-
)
|
|
298
|
-
|
|
299
|
-
whitelist_add_command.set_defaults(command_name="whitelist_add")
|
|
300
|
-
whitelist_add_command.add_argument(
|
|
301
|
-
"players", nargs="+", type=str, help="Player names or UUIDs"
|
|
302
|
-
)
|
|
303
|
-
|
|
361
|
+
# whitelist_add and whitelist_remove is not going to be implemented in this version
|
|
304
362
|
# 'whitelist list'
|
|
305
363
|
whitelist_list_command = whitelist_subcommands.add_parser(
|
|
306
364
|
"list",
|
|
@@ -310,17 +368,5 @@ def main() -> int:
|
|
|
310
368
|
|
|
311
369
|
whitelist_list_command.set_defaults(command_name="whitelist_list")
|
|
312
370
|
|
|
313
|
-
# 'whitelist remove'
|
|
314
|
-
whitelist_remove_command = whitelist_subcommands.add_parser(
|
|
315
|
-
"remove",
|
|
316
|
-
help="Remove players from whitelist",
|
|
317
|
-
description="Remove players from the whitelist.",
|
|
318
|
-
)
|
|
319
|
-
|
|
320
|
-
whitelist_remove_command.set_defaults(command_name="whitelist_remove")
|
|
321
|
-
whitelist_remove_command.add_argument(
|
|
322
|
-
"players", nargs="+", type=str, help="Player names or UUIDs"
|
|
323
|
-
)
|
|
324
|
-
|
|
325
371
|
args = parser.parse_args()
|
|
326
372
|
return args.func(args)
|
mcserver/commands/__init__.py
CHANGED
|
@@ -8,8 +8,8 @@ from .op_revoke import main as op_revoke
|
|
|
8
8
|
from .print_help import main as print_help
|
|
9
9
|
from .remove_projects import main as remove_projects
|
|
10
10
|
from .search_projects import main as search_projects
|
|
11
|
-
from .show_projects import main as show_projects
|
|
12
11
|
from .server_status import main as server_status
|
|
12
|
+
from .show_projects import main as show_projects
|
|
13
13
|
from .start_server import main as start_server
|
|
14
14
|
from .stop_server import main as stop_server
|
|
15
15
|
from .update_projects import main as update_projects
|
|
@@ -1,7 +1,148 @@
|
|
|
1
|
-
import
|
|
1
|
+
from argparse import Namespace
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def main(args:
|
|
4
|
+
def main(args: Namespace) -> int:
|
|
5
5
|
projects: list[str] = args.projects
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
# from ..modrinth.apis import get_project_versions
|
|
8
|
+
from ..config import load_config
|
|
9
|
+
from ..resolver import (
|
|
10
|
+
Dependency,
|
|
11
|
+
human_to_resolver,
|
|
12
|
+
resolve_dependencies,
|
|
13
|
+
resolver_to_human,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
def get_project_versions(
|
|
17
|
+
project_id, loader_names, game_versions, featured=None, include_changelog=True
|
|
18
|
+
):
|
|
19
|
+
project_version = {
|
|
20
|
+
"embeddium": {
|
|
21
|
+
"dependencies": [
|
|
22
|
+
{"project_id": "AANobbMI", "dependency_type": "incompatible"}
|
|
23
|
+
],
|
|
24
|
+
"project_id": "sk9rgfiA",
|
|
25
|
+
},
|
|
26
|
+
"fabric-api": {"dependencies": [], "project_id": "P7dR8mSH"},
|
|
27
|
+
"jade": {
|
|
28
|
+
"dependencies": [
|
|
29
|
+
{"project_id": "AANobbMI", "dependency_type": "required"},
|
|
30
|
+
{"project_id": "u6dRKJwZ", "dependency_type": "optional"},
|
|
31
|
+
],
|
|
32
|
+
"project_id": "nvQzSEkH",
|
|
33
|
+
},
|
|
34
|
+
"jei": {"dependencies": [], "project_id": "u6dRKJwZ"},
|
|
35
|
+
"just-enough-resources-jer": {
|
|
36
|
+
"dependencies": [
|
|
37
|
+
{"project_id": "u6dRKJwZ", "dependency_type": "required"}
|
|
38
|
+
],
|
|
39
|
+
"project_id": "uEfK2CXF",
|
|
40
|
+
},
|
|
41
|
+
"origins": {
|
|
42
|
+
"dependencies": [
|
|
43
|
+
{"project_id": "P7dR8mSH", "dependency_type": "required"}
|
|
44
|
+
],
|
|
45
|
+
"project_id": "3BeIrqZR",
|
|
46
|
+
},
|
|
47
|
+
"pehkui": {
|
|
48
|
+
"dependencies": [
|
|
49
|
+
{"project_id": "P7dR8mSH", "dependency_type": "required"}
|
|
50
|
+
],
|
|
51
|
+
"project_id": "t5W7Jfwy",
|
|
52
|
+
},
|
|
53
|
+
"podium": {
|
|
54
|
+
"dependencies": [
|
|
55
|
+
{"project_id": "AANobbMI", "dependency_type": "required"}
|
|
56
|
+
],
|
|
57
|
+
"project_id": "fW8woQj4",
|
|
58
|
+
},
|
|
59
|
+
"sodium": {"dependencies": [], "project_id": "AANobbMI"},
|
|
60
|
+
"thdilos-fox-origin-expanded": {
|
|
61
|
+
"dependencies": [
|
|
62
|
+
{"project_id": "9qGn08Dr", "dependency_type": "required"},
|
|
63
|
+
{"project_id": "3BeIrqZR", "dependency_type": "required"},
|
|
64
|
+
{"project_id": "t5W7Jfwy", "dependency_type": "required"},
|
|
65
|
+
],
|
|
66
|
+
"project_id": "CbsRGXBx",
|
|
67
|
+
},
|
|
68
|
+
"thdilos-fox-origin": {
|
|
69
|
+
"dependencies": [
|
|
70
|
+
{"project_id": "3BeIrqZR", "dependency_type": "required"},
|
|
71
|
+
{"project_id": "t5W7Jfwy", "dependency_type": "required"},
|
|
72
|
+
],
|
|
73
|
+
"project_id": "9qGn08Dr",
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
id_slug = {
|
|
78
|
+
"3BeIrqZR": "origins",
|
|
79
|
+
"9qGn08Dr": "thdilos-fox-origin",
|
|
80
|
+
"AANobbMI": "sodium",
|
|
81
|
+
"CbsRGXBx": "thdilos-fox-origin-expanded",
|
|
82
|
+
"P7dR8mSH": "fabric-api",
|
|
83
|
+
"fW8woQj4": "podium",
|
|
84
|
+
"nvQzSEkH": "jade",
|
|
85
|
+
"sk9rgfiA": "embeddium",
|
|
86
|
+
"t5W7Jfwy": "pehkui",
|
|
87
|
+
"u6dRKJwZ": "jei",
|
|
88
|
+
"uEfK2CXF": "just-enough-resources-jer",
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
a = [
|
|
92
|
+
(
|
|
93
|
+
project_version[project_id]
|
|
94
|
+
if project_id in project_version
|
|
95
|
+
else project_version[id_slug[project_id]]
|
|
96
|
+
)
|
|
97
|
+
]
|
|
98
|
+
return a
|
|
99
|
+
|
|
100
|
+
server_config = load_config("server")
|
|
101
|
+
loader_name = server_config["loader"]["name"]
|
|
102
|
+
game_version = server_config["game_version"]
|
|
103
|
+
|
|
104
|
+
cached_project_versions = {}
|
|
105
|
+
project_ids = []
|
|
106
|
+
|
|
107
|
+
for project in projects:
|
|
108
|
+
project_version = get_project_versions(
|
|
109
|
+
project, loader_name, game_version, include_changelog=False
|
|
110
|
+
)[0]
|
|
111
|
+
|
|
112
|
+
cached_project_versions[project_version["project_id"]] = project_version
|
|
113
|
+
project_ids.append(project_version["project_id"])
|
|
114
|
+
|
|
115
|
+
def get_dependencies(project_id: str) -> dict[str, int]:
|
|
116
|
+
dependencies: list[Dependency] = []
|
|
117
|
+
|
|
118
|
+
# Get the latest version
|
|
119
|
+
project_version = get_project_versions(
|
|
120
|
+
project_id, loader_name, game_version, include_changelog=False
|
|
121
|
+
)[0]
|
|
122
|
+
if "dependencies" in project_version:
|
|
123
|
+
project_dependencies = project_version["dependencies"]
|
|
124
|
+
for dependency in project_dependencies:
|
|
125
|
+
if not "project_id" in dependency:
|
|
126
|
+
continue
|
|
127
|
+
|
|
128
|
+
if dependency["project_id"] is None:
|
|
129
|
+
continue
|
|
130
|
+
|
|
131
|
+
dependencies.append(
|
|
132
|
+
{
|
|
133
|
+
"project_id": dependency["project_id"],
|
|
134
|
+
"dependency_type": dependency["dependency_type"],
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
return human_to_resolver(dependencies)
|
|
139
|
+
|
|
140
|
+
def required_only(dependency_type: int) -> bool:
|
|
141
|
+
return dependency_type == 2
|
|
142
|
+
|
|
143
|
+
print(
|
|
144
|
+
resolver_to_human(
|
|
145
|
+
resolve_dependencies(project_ids, get_dependencies, required_only, 2)
|
|
146
|
+
)
|
|
147
|
+
)
|
|
7
148
|
return 0
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
from argparse import Namespace
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def main(args:
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
def main(args: Namespace) -> int:
|
|
5
|
+
file: str = args.file
|
|
6
|
+
import logging as log
|
|
7
|
+
|
|
8
|
+
log.error("Command is not implemented yet.")
|
|
9
|
+
return 1
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
from argparse import Namespace
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def main(args:
|
|
4
|
+
def main(args: Namespace) -> int:
|
|
5
|
+
from ..modrinth.shared import SearchSortIndex
|
|
6
|
+
|
|
5
7
|
# CLI Arguments
|
|
6
8
|
game_version: str = args.game_version
|
|
7
9
|
|
|
@@ -11,6 +13,9 @@ def main(args: argparse.Namespace) -> int:
|
|
|
11
13
|
min_ram: int = args.min_ram
|
|
12
14
|
max_ram: int = args.max_ram
|
|
13
15
|
|
|
16
|
+
search_limit: int = args.search_limit
|
|
17
|
+
sort_index: SearchSortIndex = args.sort_index
|
|
18
|
+
|
|
14
19
|
# Imports
|
|
15
20
|
import copy
|
|
16
21
|
import logging as log
|
|
@@ -47,14 +52,16 @@ def main(args: argparse.Namespace) -> int:
|
|
|
47
52
|
loader_version = version["loader_version"]
|
|
48
53
|
break
|
|
49
54
|
|
|
50
|
-
log.info(f"Latest Fabric loader version is {loader_version}")
|
|
55
|
+
log.info(f"Latest Fabric loader version is: {loader_version}")
|
|
56
|
+
case "legacyfabric":
|
|
57
|
+
pass
|
|
51
58
|
case "quilt":
|
|
52
59
|
from ..quiltmc import meta as quiltmc_meta
|
|
53
60
|
|
|
54
61
|
loader_versions = quiltmc_meta.get_loader_versions()
|
|
55
62
|
latest_quilt_version = loader_versions[0]
|
|
56
63
|
loader_version = str(latest_quilt_version["loader_version"])
|
|
57
|
-
log.info(f"Latest Quilt loader version is {loader_version}")
|
|
64
|
+
log.info(f"Latest Quilt loader version is: {loader_version}")
|
|
58
65
|
# Plugin Loader
|
|
59
66
|
case "paper":
|
|
60
67
|
from ..papermc import api as papermc_api
|
|
@@ -98,6 +105,12 @@ def main(args: argparse.Namespace) -> int:
|
|
|
98
105
|
case "launcher":
|
|
99
106
|
config_override = {"ram": {"min": min_ram, "max": max_ram}}
|
|
100
107
|
|
|
108
|
+
case "modrinth":
|
|
109
|
+
config_override = {
|
|
110
|
+
"search_limit": search_limit,
|
|
111
|
+
"sort_index": sort_index,
|
|
112
|
+
}
|
|
113
|
+
|
|
101
114
|
case "server":
|
|
102
115
|
config_override = {
|
|
103
116
|
"game_version": game_version,
|
mcserver/commands/op_grant.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
from argparse import Namespace
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def main(args:
|
|
4
|
+
def main(args: Namespace) -> int:
|
|
5
5
|
players: list[str] = args.players
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import logging as log
|
|
7
|
+
|
|
8
|
+
log.error("Command is not implemented yet.")
|
|
9
|
+
return 1
|
mcserver/commands/op_list.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
from argparse import Namespace
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def main(args:
|
|
4
|
+
def main(args: Namespace) -> int:
|
|
5
5
|
import logging as log
|
|
6
6
|
|
|
7
7
|
from ..server_files import ops
|
|
@@ -16,7 +16,7 @@ def main(args: argparse.Namespace) -> int:
|
|
|
16
16
|
players: list[str] = []
|
|
17
17
|
for player in operator_players:
|
|
18
18
|
players.append(
|
|
19
|
-
f"{player['player_name']} ({player['player_uuid']}) Level: {player[
|
|
19
|
+
f"{player['player_name']} ({player['player_uuid']}) Level: {player['permission_level']}"
|
|
20
20
|
)
|
|
21
21
|
|
|
22
22
|
players.sort()
|
|
@@ -27,6 +27,6 @@ def main(args: argparse.Namespace) -> int:
|
|
|
27
27
|
log.info("There's no operator player.")
|
|
28
28
|
return 0
|
|
29
29
|
|
|
30
|
-
log.info(f"All {player_count} operator {pluralize(
|
|
30
|
+
log.info(f"All {player_count} operator {pluralize('player', player_count)}:")
|
|
31
31
|
print(sorted_players)
|
|
32
32
|
return 0
|
mcserver/commands/op_revoke.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
from argparse import Namespace
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def main(args:
|
|
4
|
+
def main(args: Namespace) -> int:
|
|
5
5
|
players: list[str] = args.players
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import logging as log
|
|
7
|
+
|
|
8
|
+
log.error("Command is not implemented yet.")
|
|
9
|
+
return 1
|