-
Notifications
You must be signed in to change notification settings - Fork 56
Install server
Run Minecraft Server on Google Colab
Hello, nice to meet you here. So, today I will tell you how Install_sever (function) works. Let's jump right in!
Developers don't have to see this. But, it's necessary to be included in today's page
Libraries | Commands | Uses |
---|---|---|
google.colab | drive() | Mounting google drive |
os | environ() | Setting java environment |
os.path | exists() | Checking exsisting folder |
requests | get() | HTML Parse |
json | load() | Transform to dict type |
json | dump() | Dumping dict values to .txt files |
bs4 | BeautifulSoup4() | HTML Parse |
-
Some had been included in Basic Information (IMPORTANT)
-
Global variables:
- COLABCONFIG()
- SERVERCONFIG
-
Input variables:
- tunnel_service: tunnel service (ngrok, playit, cloudflare-argo)
- authtoken: Your ngrok auth token (if tunnel_service is 'ngrok')
- region: Your region (if tunnel_service is 'ngrok')
- server_name: The server folder name
- type_: The server software type
- version: The server version (set automatically to 'vanilla - latest_version')
-
Global function:
- DOWNLOAD_FILE()
-
Small function ( for only Install_server function):
-
JAR_LIST_RUN:
-
Purpose: Get jar file name according to the server type
-
This is just a dict value, not a function. But the jar file for forge type needed server version value => Using function type.
-
Return value:
{'generic': 'server.jar', 'vanilla':'server.jar','snapshot': 'server.jar', 'purpur' : 'server.jar', 'paper': 'server.jar', 'velocity' : 'server.jar', 'fabric' : 'server.jar', 'forge': 'minecraft_server.' + colabconfig['server_version'] + '.jar', # forge can't change the jar file 'arclight' : 'server.jar', 'mohist': 'server.jar', 'banner': 'server.jar'}
-
-
SERVERSJAR:
- Purpose: Get the download URL (jar) AND return the detailed versions for each software (all)
- API URLs(all):
- vanilla or snapshot: https://launchermeta.mojang.com/mc/game/version_manifest.json,
- paper: https://api.papermc.io/v2/projects/paper, velocity: https://api.papermc.io/v2/projects/velocity,
- purpur: https://api.purpurmc.org/v2/purpur,
- mohist: https://mohistmc.com/api/v2/projects/mohist, banner: https://mohistmc.com/api/v2/projects/banner,
- arclight : https://files.hypoglycemia.icu/v1/files/arclight/minecraft,
- fabric: https://meta.fabricmc.net/v2/versions/game, forge: https://files.minecraftforge.net/net/minecraftforge/forge/index.html
- Download URLs (jar): Because there are too many URLs to be added, I don't insert them here. Just look at the code.
- Code:
-
if all:
Server_Jars_All = {
'vanilla': 'https://launchermeta.mojang.com/mc/game/version_manifest.json',
'paper': 'https://api.papermc.io/v2/projects/paper', 'velocity': 'https://api.papermc.io/v2/projects/velocity',
'purpur': 'https://api.purpurmc.org/v2/purpur',
'mohist': 'https://mohistmc.com/api/v2/projects/mohist', 'banner': 'https://mohistmc.com/api/v2/projects/banner', 'arclight' :'https://files.hypoglycemia.icu/v1/files/arclight/minecraft',
'fabric': 'https://meta.fabricmc.net/v2/versions/game', 'forge':'https://files.minecraftforge.net/net/minecraftforge/forge/index.html'
}
if server_type == 'vanilla' or server_type=='snapshot':
rJSON = GET(Server_Jars_All['vanilla']).json
if server_type == 'vanilla': server_type = 'release'
if version != 'vanilla - latest_version': server_version = [hit["id"] for hit in rJSON["versions"] if hit["type"] == server_type]
else:
for hit in rJSON["versions"]:
if hit["type"] == server_type:
return hit['id']
elif server_type == 'paper' or server_type == 'velocity' or server_type == 'purpur' or server_type == 'mohist' or server_type == 'banner':
rJSON = GET(Server_Jars_All[server_type]).json()
server_version = [hit for hit in rJSON["versions"]]
elif server_type == 'fabric':
rJSON = GET(Server_Jars_All[server_type]).json()
server_version = [hit['version'] for hit in rJSON["games"] if hit['stable'] == 'true']
elif server_type == 'forge':
rJSON = GET(Server_Jars_All[server_type])
soup = BeautifulSoup(rJSON.content, "html.parser")
server_version = [tag.text for tag in soup.find_all('a') if '.' in tag.text and '\n' not in tag.text]
else:
LOG('Before going deeper, please check out https://github.com/IzzelAliz/Arclight')
rJSON = GET(Server_Jars_All[server_type]).json()
server_version = [hit['name'] for hit in rJSON["files"]]
return server_version
elif jar == True and version != None:
# RETURN DOWNLOAD URL
if server_type == 'vanilla' or server_type=='snapshot':
rJSON = GET('https://launchermeta.mojang.com/mc/game/version_manifest.json').json()
if server_type == 'vanilla': server_type = 'release'
for hit in rJSON["versions"]:
if hit["type"] == server_type and hit['id'] == version:
return GET(hit['url']).json()["downloads"]['server']['url']
elif server_type == 'paper' or server_type == 'velocity':
build = GET(f'https://api.papermc.io/v2/projects/{server_type}/versions/{version}').json()["builds"][-1]
jar_name = GET(f'https://api.papermc.io/v2/projects/{server_type}/versions/{version}/builds/{build}').json()["downloads"]["application"]["name"]
return f'https://api.papermc.io/v2/projects/{server_type}/versions/{version}/builds/{build}/downloads/{jar_name}'
elif server_type == 'purpur':
build = GET(f'https://api.purpurmc.org/v2/purpur/{version}').json()["builds"]["latest"]
return f'https://api.purpurmc.org/v2/purpur/{version}/{build}/download'
elif server_type == 'mohist' or server_type == 'banner':
return GET(f'https://mohistmc.com/api/v2/projects/{server_type}/{version}/builds').json()["builds"][-1]["url"]
elif server_type == 'fabric':
installerVersion = GET('https://meta.fabricmc.net/v2/versions/installer').json()[0]["version"]
fabricVersion = GET(f'https://meta.fabricmc.net/v2/versions/loader/{version}').json()[0]["loader"]["version"]
return "https://meta.fabricmc.net/v2/versions/loader/" + version + "/" + fabricVersion + "/" + installerVersion + "/server/jar"
elif server_type == 'forge':
rJSON = GET(f'https://files.minecraftforge.net/net/minecraftforge/forge/index_{version}.html')
soup = BeautifulSoup(rJSON.content, "html.parser")
tag = soup.find('a', title="Installer"); tag = str(tag); tag = tag[tag.find('"') + 1 :]
link = tag[:tag.find('"')]; link = link[link.find('=') + 1:]; link = link[link.find('=') + 1:]
return link
else:
rJSON = GET(f'https://files.hypoglycemia.icu/v1/files/arclight/minecraft/{version}/loaders').json()
LOG('Available type: ')
print([hit['name'] for hit in rJSON['files']])
build = input(' Type: ')
choice = input('Stable(st) or Snapshot(sn): ')
if choice == 'sn': choice = 'latest-snapshot';
else: choice = "latest-stable";
return f'https://files.hypoglycemia.icu/v1/files/arclight/minecraft/{version}/loaders/{build}/{choice}'
else: raise Exception('Wrong given arguments')
- Mechanism:
- Purpose: Install server for each software
- Mechanism:
That's all. Want more? Check out others in Wiki
Want to ask anything? Join the discord: Minecolab Helper