Skip to content
Aksif edited this page Apr 18, 2024 · 5 revisions

Logo

Mine Colab [Improved]

Run Minecraft Server on Google Colab

Star Open In Colab Download

Hello, nice to meet you here. So, today I will tell you how Install_sever (function) works. Let's jump right in!

Some basic information:

Developers don't have to see this. But, it's necessary to be included in today's page

Python Libraries

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

Base function & Used variables:

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: 

image

Main function (Install_server):

  • Purpose: Install server for each software
  • Mechanism:

image

That's all. Want more? Check out others in Wiki

Want to ask anything? Join the discord: Minecolab Helper

Introduction:

  • This page is all about how the main functions in the scripts work.
  • It is important for developers/ contributors to read this.
Clone this wiki locally