1
1
{
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
- },
15
2
"cells" : [
16
3
{
4
+ "attachments" : {},
17
5
"cell_type" : " markdown" ,
18
6
"metadata" : {
19
7
"id" : " ZktjRJuZp1h6"
37
25
},
38
26
{
39
27
"cell_type" : " code" ,
28
+ "execution_count" : null ,
40
29
"metadata" : {
41
30
"id" : " lqtMoYg0dUmu"
42
31
},
32
+ "outputs" : [],
43
33
"source" : [
44
34
" import os\n " ,
45
35
" import re\n " ,
73
63
" json.dump(colabconfig, open(\" colabconfig.json\" ,'w'))\n " ,
74
64
" \n " ,
75
65
" # 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 " ,
77
67
" jar_name = jar_list[colabconfig[\" server_type\" ]]\n " ,
78
68
" \n " ,
79
69
" # Java arguments.\n " ,
87
77
" # Available options: ngrok, argo, playit\n " ,
88
78
" tunnel_service = \" argo\"\n " ,
89
79
" print(\" Procedding to use\" , tunnel_service)\n " ,
80
+ " \n " ,
90
81
" \n " ,
91
82
" if tunnel_service == \" ngrok\" :\n " ,
92
83
" !pip -q install pyngrok\n " ,
121
112
" !chmod +x cloudflared-linux-amd64\n " ,
122
113
" print('Starting server...')\n " ,
123
114
" !./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
+ ]
127
116
},
128
117
{
118
+ "attachments" : {},
129
119
"cell_type" : " markdown" ,
130
120
"metadata" : {
131
121
"id" : " _4IowSDVUZp8"
137
127
]
138
128
},
139
129
{
130
+ "attachments" : {},
140
131
"cell_type" : " markdown" ,
141
132
"metadata" : {
142
133
"id" : " 7wrNfinQOlWV"
150
141
},
151
142
{
152
143
"cell_type" : " code" ,
144
+ "execution_count" : null ,
153
145
"metadata" : {
154
146
"id" : " Fy5-YjJMPV3S"
155
147
},
148
+ "outputs" : [],
156
149
"source" : [
157
150
" # Replace \" 1.19.2\" with your desired server version.\n " ,
158
151
" # Available versions:\n " ,
176
169
" # - 1.8.8\n " ,
177
170
" # Newer versions might work too, however this isn't guaranteed.\n " ,
178
171
" version = '1.19.2'\n " ,
172
+ " forge_version = \" 43.2.8\" # If you are going to use forge \n " ,
179
173
" \n " ,
180
- " #Chose server type. Currently available versions: fabric, paper\n " ,
174
+ " #Chose server type. Currently available versions: fabric, paper, forge \n " ,
181
175
" server_type = 'paper'\n " ,
182
176
" \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 " ,
187
177
" from google.colab import drive\n " ,
188
178
" import requests\n " ,
189
179
" import json\n " ,
190
180
" \n " ,
191
181
" \n " ,
192
182
" drive.mount('/content/drive')\n " ,
193
183
" \n " ,
194
- " # Create the directory which will be used for the server\n " ,
195
184
" ! mkdir \" /content/drive/My Drive/Minecraft-server\"\n " ,
196
185
" %cd \" /content/drive/My Drive/Minecraft-server\"\n " ,
197
186
" \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 " ,
208
191
" \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 " ,
214
193
" \n " ,
194
+ " jar_name = \" server.jar\"\n " ,
215
195
" 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 " ,
216
202
" \n " ,
217
- " r = requests.get(url[server_type])\n " ,
203
+ " \n " ,
204
+ " r = requests.get(url)\n " ,
218
205
" \n " ,
219
206
" 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 " ,
221
208
" f.write(r.content)\n " ,
222
209
" else:\n " ,
223
210
" 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 " ,
224
211
" \n " ,
225
212
" # Running specific install path.\n " ,
226
- " if server_type == ' fabric' :\n " ,
213
+ " if server_type == \" fabric\" :\n " ,
227
214
" !java -jar fabric-installer.jar server -mcversion $version -downloadMinecraft\n " ,
215
+ " elif server_type == \" forge\" :\n " ,
216
+ " !java -jar server.jar --installServer\n " ,
228
217
" \n " ,
229
- " # Saving config\n " ,
230
218
" colabconfig = {\" server_type\" : server_type}\n " ,
231
219
" json.dump(colabconfig, open(\" colabconfig.json\" ,'w'))\n " ,
232
220
" \n " ,
233
- " print('Done!') # todo: Would show even after erroring.\n "
234
- ],
235
- "execution_count" : null ,
236
- "outputs" : []
221
+ " print('Done!')\n "
222
+ ]
237
223
},
238
224
{
225
+ "attachments" : {},
239
226
"cell_type" : " markdown" ,
240
227
"metadata" : {
241
228
"id" : " vhHYrg6FlbcQ"
246
233
},
247
234
{
248
235
"cell_type" : " code" ,
236
+ "execution_count" : null ,
249
237
"metadata" : {
250
238
"id" : " aefCB6cFlle8"
251
239
},
240
+ "outputs" : [],
252
241
"source" : [
253
242
" # Please read the file stored in your server folder before running this command. \n " ,
254
243
" # Also, go to https://www.minecraft.net/en-us/eula to read Minecraft's EULA.\n " ,
259
248
" \n " ,
260
249
" %cd \" /content/drive/My Drive/Minecraft-server\"\n " ,
261
250
" !echo \" eula=true\" >> eula.txt"
262
- ],
263
- "execution_count" : null ,
264
- "outputs" : []
251
+ ]
265
252
},
266
253
{
254
+ "attachments" : {},
267
255
"cell_type" : " markdown" ,
268
256
"metadata" : {
269
257
"id" : " FO5S4OHVdV5O"
270
258
},
271
259
"source" : [
272
260
" # 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>"
274
264
]
275
265
},
276
266
{
277
267
"cell_type" : " code" ,
268
+ "execution_count" : null ,
278
269
"metadata" : {
279
270
"id" : " cM7gKp6Yi8Q2"
280
271
},
272
+ "outputs" : [],
281
273
"source" : [
282
274
" #@title Colab-ssh tunnel\n " ,
283
275
" #@markdown Execute this cell to open the ssh tunnel. Check [colab-ssh documentation](https://github.com/WassimBenzarti/colab-ssh) for more details.\n " ,
288
280
" from colab_ssh import launch_ssh_cloudflared, init_git_cloudflared\n " ,
289
281
" ssh_tunnel_password = \" <PUT_YOUR_PASSWORD_HERE>\" #@param {type: \" string\" }\n " ,
290
282
" launch_ssh_cloudflared(password=ssh_tunnel_password)"
291
- ],
292
- "execution_count" : null ,
293
- "outputs" : []
283
+ ]
294
284
},
295
285
{
296
286
"cell_type" : " code" ,
287
+ "execution_count" : null ,
297
288
"metadata" : {
298
289
"id" : " 7kR6rsn7jyxt"
299
290
},
291
+ "outputs" : [],
300
292
"source" : [
301
293
" #Get public address (ngrok)\n " ,
302
294
" ! curl -s http://localhost:4040/api/tunnels | python3 -c \\\n " ,
303
295
" \" import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])\" "
304
- ],
305
- "execution_count" : null ,
306
- "outputs" : []
296
+ ]
307
297
},
308
298
{
309
299
"cell_type" : " code" ,
300
+ "execution_count" : null ,
310
301
"metadata" : {
311
302
"id" : " Z2rztsCQk0kh"
312
303
},
304
+ "outputs" : [],
313
305
"source" : [
314
306
" ## For inspecting the minecraft server directory ##\n " ,
315
307
" %cd \" /content/drive/My Drive/Minecraft-server\"\n " ,
316
308
" !ls\n "
317
- ],
318
- "execution_count" : null ,
319
- "outputs" : []
309
+ ]
320
310
}
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