Skip to content

Commit ff89c6c

Browse files
authored
Merge pull request pterodactyl#543 from udeva/develop
Add Forge Service Option
2 parents 19c7c7b + 63deed9 commit ff89c6c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

database/seeds/MinecraftServiceTableSeeder.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,43 @@ private function addCoreOptions()
243243
'startup' => null,
244244
'script_install' => $script,
245245
]);
246+
247+
$script = <<<'EOF'
248+
#!/bin/ash
249+
# Forge Installation Script
250+
#
251+
# Server Files: /mnt/server
252+
apk update
253+
apk add curl
254+
255+
GET_VERSIONS=$(curl -sl http://files.minecraftforge.net/maven/net/minecraftforge/forge/ | grep -A1 Latest | grep -o -e '[1]\.[0-9][0-9] - [0-9][0-9]\.[0-9][0-9]\.[0-9]\.[0-9][0-9][0-9][0-9]')
256+
LATEST_VERSION=$(echo $GET_VERSIONS | sed 's/ //g')
257+
258+
cd /mnt/server
259+
260+
curl -sS http://files.minecraftforge.net/maven/net/minecraftforge/forge/$LATEST_VERSION/forge-$LATEST_VERSION-installer.jar -o installer.jar
261+
curl -sS http://files.minecraftforge.net/maven/net/minecraftforge/forge/$LATEST_VERSION/forge-$LATEST_VERSION-universal.jar -o server.jar
262+
263+
java -jar installer.jar --installServer
264+
rm -rf installer.jar
265+
EOF;
266+
267+
$this->option['forge'] = ServiceOption::updateOrCreate([
268+
'service_id' => $this->service->id,
269+
'tag' => 'forge',
270+
], [
271+
'name' => 'Forge Minecraft',
272+
'description' => 'Minecraft Forge Server. Minecraft Forge is a modding API (Application Programming Interface), which makes it easier to create mods, and also make sure mods are compatible with each other.',
273+
'docker_image' => 'quay.io/pterodactyl/core:java',
274+
'config_startup' => '{"done": ")! For help, type ", "userInteraction": [ "Go to eula.txt for more info."]}',
275+
'config_logs' => '{"custom": false, "location": "logs/latest.log"}',
276+
'config_files' => '{"server.properties":{"parser": "properties", "find":{"server-ip": "0.0.0.0", "enable-query": "true", "server-port": "{{server.build.default.port}}", "query.port": "{{server.build.default.port}}"}}}',
277+
'config_stop' => 'stop',
278+
'config_from' => null,
279+
'startup' => 'java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}',
280+
'script_install' => $script,
281+
'script_container' => 'frolvlad/alpine-oraclejdk8:cleaned',
282+
]);
246283
}
247284

248285
private function addVariables()
@@ -251,6 +288,7 @@ private function addVariables()
251288
$this->addSpigotVariables();
252289
$this->addSpongeVariables();
253290
$this->addBungeecordVariables();
291+
$this->addForgeVariables();
254292
}
255293

256294
private function addVanillaVariables()
@@ -372,4 +410,19 @@ private function addBungeecordVariables()
372410
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
373411
]);
374412
}
413+
414+
private function addForgeVariables()
415+
{
416+
ServiceVariable::updateOrCreate([
417+
'option_id' => $this->option['forge']->id,
418+
'env_variable' => 'SERVER_JARFILE',
419+
], [
420+
'name' => 'Server Jar File',
421+
'description' => 'The name of the Jarfile to use when running Forge Mod.',
422+
'default_value' => 'server.jar',
423+
'user_viewable' => 1,
424+
'user_editable' => 1,
425+
'rules' => 'required|regex:/^([\w\d._-]+)(\.jar)$/',
426+
]);
427+
}
375428
}

0 commit comments

Comments
 (0)