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

Commit 746c96a

Browse files
committed
Add forge
1 parent df94450 commit 746c96a

File tree

1 file changed

+77
-61
lines changed

1 file changed

+77
-61
lines changed

MineColab.ipynb

Lines changed: 77 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
{
2-
"nbformat": 4,
3-
"nbformat_minor": 0,
4-
"metadata": {
5-
"colab": {
6-
"name": "MineColab",
7-
"provenance": [],
8-
"collapsed_sections": []
9-
},
10-
"kernelspec": {
11-
"name": "python3",
12-
"display_name": "Python 3"
13-
}
14-
},
152
"cells": [
163
{
4+
"attachments": {},
175
"cell_type": "markdown",
186
"metadata": {
197
"id": "ZktjRJuZp1h6"
@@ -37,9 +25,11 @@
3725
},
3826
{
3927
"cell_type": "code",
28+
"execution_count": null,
4029
"metadata": {
4130
"id": "lqtMoYg0dUmu"
4231
},
32+
"outputs": [],
4333
"source": [
4434
"import os\n",
4535
"import re\n",
@@ -73,7 +63,7 @@
7363
" json.dump(colabconfig, open(\"colabconfig.json\",'w'))\n",
7464
"\n",
7565
"# Server jar names.\n",
76-
"jar_list = {'paper': 'server.jar', 'fabric': 'fabric-server-launch.jar', 'generic': 'server.jar'}\n",
66+
"jar_list = {'paper': 'server.jar', 'fabric': 'fabric-server-launch.jar', 'generic': 'server.jar', 'forge': 'server.jar'}\n",
7767
"jar_name = jar_list[colabconfig[\"server_type\"]]\n",
7868
"\n",
7969
"# Java arguments.\n",
@@ -87,6 +77,7 @@
8777
"# Available options: ngrok, argo, playit\n",
8878
"tunnel_service = \"argo\"\n",
8979
"print(\"Procedding to use\", tunnel_service)\n",
80+
" \n",
9081
"\n",
9182
"if tunnel_service == \"ngrok\":\n",
9283
" !pip -q install pyngrok\n",
@@ -121,11 +112,10 @@
121112
" !chmod +x cloudflared-linux-amd64\n",
122113
" print('Starting server...')\n",
123114
" !./cloudflared-linux-amd64 tunnel --url tcp://127.0.0.1:25565 & java $memory_allocation $server_flags -jar $jar_name nogui\n"
124-
],
125-
"execution_count": null,
126-
"outputs": []
115+
]
127116
},
128117
{
118+
"attachments": {},
129119
"cell_type": "markdown",
130120
"metadata": {
131121
"id": "_4IowSDVUZp8"
@@ -137,6 +127,7 @@
137127
]
138128
},
139129
{
130+
"attachments": {},
140131
"cell_type": "markdown",
141132
"metadata": {
142133
"id": "7wrNfinQOlWV"
@@ -150,9 +141,11 @@
150141
},
151142
{
152143
"cell_type": "code",
144+
"execution_count": null,
153145
"metadata": {
154146
"id": "Fy5-YjJMPV3S"
155147
},
148+
"outputs": [],
156149
"source": [
157150
"# Replace \"1.19.2\" with your desired server version.\n",
158151
"# Available versions:\n",
@@ -176,66 +169,60 @@
176169
"# - 1.8.8\n",
177170
"# Newer versions might work too, however this isn't guaranteed.\n",
178171
"version = '1.19.2'\n",
172+
"forge_version = \"43.2.8\" # If you are going to use forge \n",
179173
"\n",
180-
"#Chose server type. Currently available versions: fabric, paper\n",
174+
"#Chose server type. Currently available versions: fabric, paper, forge\n",
181175
"server_type = 'paper'\n",
182176
"\n",
183-
"# Print experimental build warning -- no longer needed\n",
184-
"# if version == '1.18' and server_type == 'paper':\n",
185-
"# print(\"<!> Paper 1.18 builds are still experimental. Make regular Backups!\")\n",
186-
"\n",
187177
"from google.colab import drive\n",
188178
"import requests\n",
189179
"import json\n",
190180
"\n",
191181
"\n",
192182
"drive.mount('/content/drive')\n",
193183
"\n",
194-
"# Create the directory which will be used for the server\n",
195184
"! mkdir \"/content/drive/My Drive/Minecraft-server\"\n",
196185
"%cd \"/content/drive/My Drive/Minecraft-server\"\n",
197186
"\n",
198-
"# Internal init...\n",
199-
"\n",
200-
"\n",
201-
"a = requests.get(\"https://papermc.io/api/v2/projects/paper/versions/\" + version)\n",
202-
"#print(a.json()[\"builds\"][-1])\n",
203-
"b = requests.get(\"https://papermc.io/api/v2/projects/paper/versions/\" + version + \"/builds/\" + str(a.json()[\"builds\"][-1]))\n",
204-
"#print(b.json()[\"downloads\"][\"application\"][\"name\"])\n",
205-
"print(\"https://papermc.io/api/v2/projects/paper/versions/\" + version + \"/builds/\" + str(a.json()[\"builds\"][-1]) + \"/downloads/\" + b.json()[\"downloads\"][\"application\"][\"name\"])\n",
206-
"\n",
207-
"paperURL = \"https://papermc.io/api/v2/projects/paper/versions/\" + version + \"/builds/\" + str(a.json()[\"builds\"][-1]) + \"/downloads/\" + b.json()[\"downloads\"][\"application\"][\"name\"]\n",
187+
"if server_type == \"paper\":\n",
188+
" a = requests.get(\"https://papermc.io/api/v2/projects/paper/versions/\" + version)\n",
189+
" b = requests.get(\"https://papermc.io/api/v2/projects/paper/versions/\" + version + \"/builds/\" + str(a.json()[\"builds\"][-1]))\n",
190+
" print(\"https://papermc.io/api/v2/projects/paper/versions/\" + version + \"/builds/\" + str(a.json()[\"builds\"][-1]) + \"/downloads/\" + b.json()[\"downloads\"][\"application\"][\"name\"])\n",
208191
"\n",
209-
"jar_name = {'paper': 'server.jar', 'fabric': 'fabric-installer.jar'}\n",
210-
"url = {\n",
211-
" 'paper': (paperURL),\n",
212-
" 'fabric': 'https://maven.fabricmc.net/net/fabricmc/fabric-installer/0.7.4/fabric-installer-0.7.4.jar'\n",
213-
" }\n",
192+
" url = \"https://papermc.io/api/v2/projects/paper/versions/\" + version + \"/builds/\" + str(a.json()[\"builds\"][-1]) + \"/downloads/\" + b.json()[\"downloads\"][\"application\"][\"name\"]\n",
214193
"\n",
194+
" jar_name = \"server.jar\"\n",
215195
"print('Downloading to Google Drive...')\n",
196+
"elif server_type == \"fabric\":\n",
197+
" url = \"https://maven.fabricmc.net/net/fabricmc/fabric-installer/0.7.4/fabric-installer-0.7.4.jar\"\n",
198+
" jar_name = \"fabric-installer.jar\"\n",
199+
"elif server_type == \"forge\":\n",
200+
" url = f\"https://maven.minecraftforge.net/net/minecraftforge/forge/{version}-{forge_version}/forge-{version}-{forge_version}-installer.jar\"\n",
201+
" jar_name = \"server.jar\"\n",
216202
"\n",
217-
"r = requests.get(url[server_type])\n",
203+
"\n",
204+
"r = requests.get(url)\n",
218205
"\n",
219206
"if r.status_code is 200:\n",
220-
" with open('/content/drive/My Drive/Minecraft-server/' + jar_name[server_type], 'wb') as f:\n",
207+
" with open('/content/drive/My Drive/Minecraft-server/' + jar_name, 'wb') as f:\n",
221208
" f.write(r.content)\n",
222209
"else:\n",
223210
" print('Error '+ str(r.status_code) + '! Most likely you entered a unsupported version. Try running the code again if you think that shouldn\\'t have happened.')\n",
224211
"\n",
225212
"# Running specific install path.\n",
226-
"if server_type == 'fabric':\n",
213+
"if server_type == \"fabric\":\n",
227214
" !java -jar fabric-installer.jar server -mcversion $version -downloadMinecraft\n",
215+
"elif server_type == \"forge\":\n",
216+
" !java -jar server.jar --installServer\n",
228217
"\n",
229-
"# Saving config\n",
230218
"colabconfig = {\"server_type\": server_type}\n",
231219
"json.dump(colabconfig, open(\"colabconfig.json\",'w'))\n",
232220
"\n",
233-
"print('Done!') # todo: Would show even after erroring.\n"
234-
],
235-
"execution_count": null,
236-
"outputs": []
221+
"print('Done!')\n"
222+
]
237223
},
238224
{
225+
"attachments": {},
239226
"cell_type": "markdown",
240227
"metadata": {
241228
"id": "vhHYrg6FlbcQ"
@@ -246,9 +233,11 @@
246233
},
247234
{
248235
"cell_type": "code",
236+
"execution_count": null,
249237
"metadata": {
250238
"id": "aefCB6cFlle8"
251239
},
240+
"outputs": [],
252241
"source": [
253242
"# Please read the file stored in your server folder before running this command. \n",
254243
"# Also, go to https://www.minecraft.net/en-us/eula to read Minecraft's EULA.\n",
@@ -259,25 +248,28 @@
259248
"\n",
260249
"%cd \"/content/drive/My Drive/Minecraft-server\"\n",
261250
"!echo \"eula=true\" >> eula.txt"
262-
],
263-
"execution_count": null,
264-
"outputs": []
251+
]
265252
},
266253
{
254+
"attachments": {},
267255
"cell_type": "markdown",
268256
"metadata": {
269257
"id": "FO5S4OHVdV5O"
270258
},
271259
"source": [
272260
"# Debug\n",
273-
"SSH access to host OS - Thanks to [colab-ssh](https://github.com/WassimBenzarti/colab-ssh)."
261+
"SSH access to host OS - Thanks to [colab-ssh](https://github.com/WassimBenzarti/colab-ssh).\n",
262+
"\n",
263+
"<p style=\"color:red;\">YOU MIGHT GET BANNED</p>"
274264
]
275265
},
276266
{
277267
"cell_type": "code",
268+
"execution_count": null,
278269
"metadata": {
279270
"id": "cM7gKp6Yi8Q2"
280271
},
272+
"outputs": [],
281273
"source": [
282274
"#@title Colab-ssh tunnel\n",
283275
"#@markdown Execute this cell to open the ssh tunnel. Check [colab-ssh documentation](https://github.com/WassimBenzarti/colab-ssh) for more details.\n",
@@ -288,35 +280,59 @@
288280
"from colab_ssh import launch_ssh_cloudflared, init_git_cloudflared\n",
289281
"ssh_tunnel_password = \"<PUT_YOUR_PASSWORD_HERE>\" #@param {type: \"string\"}\n",
290282
"launch_ssh_cloudflared(password=ssh_tunnel_password)"
291-
],
292-
"execution_count": null,
293-
"outputs": []
283+
]
294284
},
295285
{
296286
"cell_type": "code",
287+
"execution_count": null,
297288
"metadata": {
298289
"id": "7kR6rsn7jyxt"
299290
},
291+
"outputs": [],
300292
"source": [
301293
"#Get public address (ngrok)\n",
302294
"! curl -s http://localhost:4040/api/tunnels | python3 -c \\\n",
303295
" \"import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])\""
304-
],
305-
"execution_count": null,
306-
"outputs": []
296+
]
307297
},
308298
{
309299
"cell_type": "code",
300+
"execution_count": null,
310301
"metadata": {
311302
"id": "Z2rztsCQk0kh"
312303
},
304+
"outputs": [],
313305
"source": [
314306
"## For inspecting the minecraft server directory ##\n",
315307
"%cd \"/content/drive/My Drive/Minecraft-server\"\n",
316308
"!ls\n"
317-
],
318-
"execution_count": null,
319-
"outputs": []
309+
]
320310
}
321-
]
322-
}
311+
],
312+
"metadata": {
313+
"colab": {
314+
"collapsed_sections": [],
315+
"name": "MineColab",
316+
"provenance": []
317+
},
318+
"kernelspec": {
319+
"display_name": "Python 3 (ipykernel)",
320+
"language": "python",
321+
"name": "python3"
322+
},
323+
"language_info": {
324+
"codemirror_mode": {
325+
"name": "ipython",
326+
"version": 3
327+
},
328+
"file_extension": ".py",
329+
"mimetype": "text/x-python",
330+
"name": "python",
331+
"nbconvert_exporter": "python",
332+
"pygments_lexer": "ipython3",
333+
"version": "3.10.4"
334+
}
335+
},
336+
"nbformat": 4,
337+
"nbformat_minor": 0
338+
}

0 commit comments

Comments
 (0)