Skip to content

Commit 569ce92

Browse files
committed
[+] Add update_build script
1 parent 1a20af7 commit 569ce92

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ Setup and start a testing minecraft server:
1515
1. `pip install -r requirements.txt`
1616
2. `python3 -m tools.start_server`
1717

18+
Rebuild & update our MCPM plugin while the server is running:
19+
20+
1. `python3 -m tools.update_build`
21+
2. `plugman reload mcpm` (Inside the server's command prompt)
22+
1823
## Brainstorm
1924

2025
Server file/endpoint structure:

tools/start_server.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ def start(java: Path, mc_path: Path):
4646
exit(0)
4747

4848

49+
def update_build(mc_path: Path):
50+
# Build project
51+
print('Building project...')
52+
build_jar = Path('build/libs')
53+
shutil.rmtree(build_jar, ignore_errors=True)
54+
check_call('./gradlew build', shell=True)
55+
56+
# Install plugin
57+
print('Installing our MCPM plugin...')
58+
plugin_path = mc_path / 'plugins/mcpm.jar'
59+
shutil.rmtree(plugin_path, ignore_errors=True)
60+
ensure_dir(plugin_path.parent)
61+
shutil.copy2(build_jar / str(os.listdir(build_jar)[0]), plugin_path)
62+
63+
4964
if __name__ == '__main__':
5065
# Download JDK
5166
java = ensure_java("19", 'build/jdk19')
@@ -72,18 +87,8 @@ def start(java: Path, mc_path: Path):
7287

7388
print(f'Server installed to {mc_path}')
7489

75-
# Build project
76-
print('Building project...')
77-
build_jar = Path('build/libs')
78-
shutil.rmtree(build_jar, ignore_errors=True)
79-
check_call('./gradlew build', shell=True)
80-
81-
# Install plugin
82-
print('Installing our MCPM plugin...')
83-
plugin_path = mc_path / 'plugins/mcpm.jar'
84-
shutil.rmtree(plugin_path, ignore_errors=True)
85-
ensure_dir(plugin_path.parent)
86-
shutil.copy2(build_jar / str(os.listdir(build_jar)[0]), plugin_path)
90+
# Update built jar file
91+
update_build(mc_path)
8792

8893
# Start server
8994
print('Starting server...')

tools/update_build.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from pathlib import Path
2+
3+
from tools.start_server import update_build
4+
5+
if __name__ == '__main__':
6+
mc_path = Path('build/mc-server')
7+
update_build(mc_path)

0 commit comments

Comments
 (0)