|
75 | 75 | "%cd \"/content/drive/My Drive/Minecraft-server\"\n",
|
76 | 76 | "!ls #list the directory contents (to verify that working directory was changed)\n",
|
77 | 77 | "\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", |
78 | 88 | "\n",
|
79 | 89 | "# Chose the tunnle service you want to use\n",
|
80 | 90 | "# Available options: ngrok, argo\n",
|
|
99 | 109 | " print('Your server address is ' + ((str(url).split('\"')[1::2])[0]).replace('tcp://', ''))\n",
|
100 | 110 | "\n",
|
101 | 111 | " 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", |
103 | 113 | "\n",
|
104 | 114 | "else:\n",
|
105 | 115 | " # Download & make argo executable\n",
|
106 | 116 | " !wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64\n",
|
107 | 117 | " !chmod +x cloudflared-linux-amd64\n",
|
108 | 118 | " 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" |
110 | 120 | ],
|
111 | 121 | "execution_count": null,
|
112 | 122 | "outputs": []
|
|
162 | 172 | "\n",
|
163 | 173 | "from google.colab import drive\n",
|
164 | 174 | "import requests\n",
|
| 175 | + "import json\n", |
| 176 | + "\n", |
165 | 177 | "\n",
|
166 | 178 | "drive.mount('/content/drive')\n",
|
167 | 179 | "\n",
|
|
189 | 201 | "# Running specific install path.\n",
|
190 | 202 | "if server_type == 'fabric':\n",
|
191 | 203 | " !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", |
192 | 209 | "print('Done!') # todo: Would show even after erroring.\n"
|
193 | 210 | ],
|
194 | 211 | "execution_count": null,
|
|
0 commit comments