Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 66372ac

Browse files
committed
Added basic config system
1 parent d6caa66 commit 66372ac

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

MineColab.ipynb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@
7575
"%cd \"/content/drive/My Drive/Minecraft-server\"\n",
7676
"!ls #list the directory contents (to verify that working directory was changed)\n",
7777
"\n",
78+
"# Import config file.\n",
79+
"if os.path.isfile(\"colabconfig.json\"):\n",
80+
" colabconfig = json.load(open(\"colabconfig.json\"))\n",
81+
"else:\n",
82+
" colabconfig = {\"server_type\": generic} # using default, if config doesn't exists.\n",
83+
" json.dump(colabconfig, open(\"colabconfig.json\",'w'))\n",
84+
"\n",
85+
"# Server jar names.\n",
86+
"jar_list = {'paper': 'server.jar', 'fabric': 'fabric-server-launch.jar', 'generic': 'server.jar'}\n",
87+
"jar_name = jar_list[colabconfig[\"server_type\"]]\n",
7888
"\n",
7989
"# Chose the tunnle service you want to use\n",
8090
"# Available options: ngrok, argo\n",
@@ -99,14 +109,14 @@
99109
" print('Your server address is ' + ((str(url).split('\"')[1::2])[0]).replace('tcp://', ''))\n",
100110
"\n",
101111
" print('Starting server...')\n",
102-
" !java -Xmx6144M -Xms6144M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui\n",
112+
" !java -Xmx6144M -Xms6144M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar $jar_name nogui\n",
103113
"\n",
104114
"else:\n",
105115
" # Download & make argo executable\n",
106116
" !wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64\n",
107117
" !chmod +x cloudflared-linux-amd64\n",
108118
" print('Starting server...')\n",
109-
" !./cloudflared-linux-amd64 tunnel --url tcp://127.0.0.1:25565 | java -Xmx6144M -Xms6144M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar server.jar nogui\n"
119+
" !./cloudflared-linux-amd64 tunnel --url tcp://127.0.0.1:25565 | java -Xmx6144M -Xms6144M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar $jar_name nogui\n"
110120
],
111121
"execution_count": null,
112122
"outputs": []
@@ -162,6 +172,8 @@
162172
"\n",
163173
"from google.colab import drive\n",
164174
"import requests\n",
175+
"import json\n",
176+
"\n",
165177
"\n",
166178
"drive.mount('/content/drive')\n",
167179
"\n",
@@ -189,6 +201,11 @@
189201
"# Running specific install path.\n",
190202
"if server_type == 'fabric':\n",
191203
" !java -jar fabric-installer.jar server -mcversion $version -downloadMinecraft\n",
204+
"\n",
205+
"# Saving config\n",
206+
"colabconfig = {\"server_type\": server_type}\n",
207+
"json.dump(colabconfig, open(\"colabconfig.json\",'w'))\n",
208+
"\n",
192209
"print('Done!') # todo: Would show even after erroring.\n"
193210
],
194211
"execution_count": null,

0 commit comments

Comments
 (0)