-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API error if you use Quantity as configurable option #34
Comments
Nevermind, i edit the function "pteroSyncGetOption" as follows: function pteroSyncGetOption(array $params, $id, $default = NULL)
{
$options = pterosync_ConfigKeys();
$friendlyName = $options[$id];
if (isset($params['A'][$friendlyName]) && $params['configoptions'][$friendlyName] !== '') {
$value = $params['configoptions'][$friendlyName];
} else if (isset($params['configoptions'][$id]) && $params['configoptions'][$id] !== '') {
$value = $params['configoptions'][$id];
} else if (isset($params['customfields'][$friendlyName]) && $params['customfields'][$friendlyName] !== '') {
$value = $params['customfields'][$friendlyName];
} else if (isset($params['customfields'][$id]) && $params['customfields'][$id] !== '') {
$value = $params['customfields'][$id];
} else {
$found = false;
$i = 0;
foreach ($options as $key => $value) {
$i++;
if ($key === $id) {
$found = true;
break;
}
}
if ($found && isset($params['configoption' . $i]) && $params['configoption' . $i] !== '') {
$value = $params['configoption' . $i];
} else {
$value = $default;
}
}
// Check if value is an integer
if (is_int($value)) {
return (string)$value; // convert integer to string
}
return $value;
} |
Nope, not working for me. I also tested it with various config options in And if I am correctly informed, all values, regardless of whether they are integers or bools, must be transferred to the Pterodactyl API as strings. |
Then is not max_players, it will be something else. What game is that? |
Now I have tested it with all variables only have "required". And I am so sorry I forgot to say that this problem only appears if I up- or downgrade a server in whmcs. I use my own egg for minecraft vanilla. |
Yes please. I don't think the issue is due the max_players
does not say the variable name. Which is wired. |
Here is my egg. Minecraft Vanilla Egg
{
"_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO",
"meta": {
"version": "PTDL_v2",
"update_url": null
},
"exported_at": "2024-08-29T21:21:18+02:00",
"name": "Vanilla Minecraft",
"author": "info@hosthonest.de",
"description": "Minecraft ist ein Spiel, in dem es darum geht, Bl\u00f6cke zu platzieren und Abenteuer zu erleben. Erforsche zuf\u00e4llig generierte Welten und baue erstaunliche Dinge, vom einfachsten Haus bis hin zu den gr\u00f6\u00dften Schl\u00f6ssern. Spiele im Kreativmodus mit unbegrenzten Ressourcen oder baue im \u00dcberlebensmodus tief in der Erde und stelle Waffen und R\u00fcstungen her, um gef\u00e4hrliche Mobs abzuwehren. Das alles kannst du allein oder mit Freunden machen.",
"features": [
"eula",
"java_version",
"pid_limit"
],
"docker_images": {
"Java 21": "ghcr.io\/pterodactyl\/yolks:java_21",
"Java 17": "ghcr.io\/pterodactyl\/yolks:java_17",
"Java 16": "ghcr.io\/pterodactyl\/yolks:java_16",
"Java 11": "ghcr.io\/pterodactyl\/yolks:java_11",
"Java 8": "ghcr.io\/pterodactyl\/yolks:java_8"
},
"file_denylist": [],
"startup": "\/tmp\/.run",
"config": {
"files": "{\r\n \"server.properties\": {\r\n \"parser\": \"properties\",\r\n \"find\": {\r\n \"server-ip\": \"{{server.build.default.ip}}\",\r\n \"server-port\": \"{{server.build.default.port}}\",\r\n \"query.port\": \"{{server.build.default.port}}\",\r\n \"max-players\": \"{{server.build.env.MAX_PLAYERS}}\",\r\n \"motd\": \"{{server.build.env.MOTD}}\",\r\n \"allow-nether\": \"{{server.build.env.NETHER}}\",\r\n \"gamemode\": \"{{server.build.env.GAMEMODE}}\",\r\n \"difficulty\": \"{{server.build.env.DIFFICULTY}}\",\r\n \"spawn-monsters\": \"{{server.build.env.SPAWNMOBS}}\",\r\n \"pvp\": \"{{server.build.env.PVP}}\",\r\n \"spawn-npcs\": \"{{server.build.env.SPAWNNPC}}\",\r\n \"allow-flight\": \"{{server.build.env.FLIGHT}}\",\r\n \"spawn-animals\": \"{{server.build.env.SPAWNANIMALS}}\",\r\n \"generate-structures\": \"{{server.build.env.SPAWNSTRUCTURES}}\"\r\n }\r\n }\r\n}",
"startup": "{\r\n \"done\": \")! For help, type \"\r\n}",
"logs": "{}",
"stop": "stop"
},
"scripts": {
"installation": {
"script": "#!\/bin\/ash\r\n# Vanilla MC Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\nmkdir -p \/mnt\/server\r\ncd \/mnt\/server\r\n\r\nLATEST_VERSION=`curl https:\/\/launchermeta.mojang.com\/mc\/game\/version_manifest.json | jq -r '.latest.release'`\r\nLATEST_SNAPSHOT_VERSION=`curl https:\/\/launchermeta.mojang.com\/mc\/game\/version_manifest.json | jq -r '.latest.snapshot'`\r\n\r\necho -e \"latest version is $LATEST_VERSION\"\r\necho -e \"latest snapshot is $LATEST_SNAPSHOT_VERSION\"\r\n\r\nif [ -z \"$VANILLA_VERSION\" ] || [ \"$VANILLA_VERSION\" == \"latest\" ]; then\r\n MANIFEST_URL=$(curl -sSL https:\/\/launchermeta.mojang.com\/mc\/game\/version_manifest.json | jq --arg VERSION $LATEST_VERSION -r '.versions | .[] | select(.id== $VERSION )|.url')\r\nelif [ \"$VANILLA_VERSION\" == \"snapshot\" ]; then\r\n MANIFEST_URL=$(curl -sSL https:\/\/launchermeta.mojang.com\/mc\/game\/version_manifest.json | jq --arg VERSION $LATEST_SNAPSHOT_VERSION -r '.versions | .[] | select(.id== $VERSION )|.url')\r\nelse\r\n MANIFEST_URL=$(curl -sSL https:\/\/launchermeta.mojang.com\/mc\/game\/version_manifest.json | jq --arg VERSION $VANILLA_VERSION -r '.versions | .[] | select(.id== $VERSION )|.url')\r\nfi\r\n\r\nDOWNLOAD_URL=$(curl ${MANIFEST_URL} | jq .downloads.server | jq -r '. | .url')\r\n\r\necho -e \"running: curl -o ${SERVER_JARFILE} $DOWNLOAD_URL\"\r\ncurl -o ${SERVER_JARFILE} $DOWNLOAD_URL\r\n\r\necho -e \"Install Complete\"",
"container": "ghcr.io\/pterodactyl\/installers:alpine",
"entrypoint": "ash"
}
},
"variables": [
{
"name": "Gameserver",
"description": "Diese Variable gibt an, um welchen Gameserver es sich handelt.",
"env_variable": "HHGS",
"default_value": "mcv",
"user_viewable": false,
"user_editable": false,
"rules": "required",
"field_type": "text"
},
{
"name": "Setup: Server Version",
"description": "Die zu installierende Version von Minecraft Vanilla. Verwende \u201elatest\u201c, um die neueste Version zu installieren, oder verwende \u201esnapshot\u201c, um den neuesten Snapshot zu installieren. Gehe zu \u201eSettings > Reinstall Server\u201c, um die \u00c4nderung anzuwenden.\r\nAlle Daten des Servers bleiben bestehen, sofern nicht andere Optionen gesetzt wurden.",
"env_variable": "BUILD_VANILLA_VERSION",
"default_value": "latest",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Setup: Server Bereinigung",
"description": "L\u00f6schung aller Daten des Servers bei einem Reinstall des Servers. Gehe zu \u201eSettings > Reinstall Server\u201c, um die \u00c4nderung anzuwenden.\r\nAlle Daten des Servers werden gel\u00f6scht, inkl. Backups.",
"env_variable": "BUILD_PURGE",
"default_value": "false",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Setup: Backup bei Reinstall",
"description": "Es wird ein Backup des aktuellen Servers durchgef\u00fchrt, wenn eine Neuinstallation des Servers angesto\u00dfen wird. Gehe zu \u201eSettings > Reinstall Server\u201c, um die \u00c4nderung anzuwenden.\r\nAlle Daten des Servers bleiben bestehen.\r\nDiese Option wird \u00fcbersprungen, wenn \"Setup: Server Bereinigung\" aktiviert ist.\r\nBackups werden deinem Speicherplatzverbrauch gutgeschrieben.",
"env_variable": "BUILD_CREATE_BACKUP_ON_SAME_SERVER",
"default_value": "false",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Setup: Datenbereinigung nach Backup",
"description": "Wenn bei einem Reinstall ein Backup erstellt wird, wird im Anschluss der Server bereinigt.\r\nGehe zu \u201eSettings > Reinstall Server\u201c, um die \u00c4nderung anzuwenden.\r\nServerdaten werden bereinigt. Backups bleiben bestehen.\r\nDiese Option wird \u00fcbersprungen, wenn \"Setup: Server Bereinigung\" aktiviert ist.\r\nDiese Option wird \u00fcbersprungen, wenn \"Setup: Backup bei Reinstall\" deaktivert ist.\r\nBackups werden deinem Speicherplatzverbrauch gutgeschrieben.",
"env_variable": "BUILD_PURGE_AFTER_BACKUP_ON_SAME_SERVER",
"default_value": "false",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Slots",
"description": "Maximale Anzahl an Spielern, die den Server gleichzeitig betreten d\u00fcrfen.",
"env_variable": "MAX_PLAYERS",
"default_value": "1",
"user_viewable": true,
"user_editable": false,
"rules": "required",
"field_type": "text"
},
{
"name": "Message of the Day",
"description": "Nachricht, die im Serverbrowser angezeigt werden soll.",
"env_variable": "MOTD",
"default_value": "Minecraft Vanilla Server by hosthonest.de",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Gamemode",
"description": "Stelle ein, welcher Gamemode genutzt werden soll\r\n0:Survival\r\n1:Creative\r\n2:Adventure",
"env_variable": "GAMEMODE",
"default_value": "0",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Difficulty",
"description": "Stelle ein, welche Schwierigkeitsstufe eingestellt werden soll.\r\n0:peaceful\r\n1:easy\r\n2:normal\r\n3:hard",
"env_variable": "DIFFICULTY",
"default_value": "2",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "PVP",
"description": "Erlaube PVP auf deinem Server, oder auch nicht.",
"env_variable": "PVP",
"default_value": "true",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Fliegen erlauben",
"description": "Erlaube es dir und deinen Spielern zu fliegen.",
"env_variable": "FLIGHT",
"default_value": "false",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Nether erlauben",
"description": "Erlaube den Zugang zum Nether.",
"env_variable": "NETHER",
"default_value": "true",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Monster spawnen",
"description": "Monster werden gespawnt",
"env_variable": "SPAWNMOBS",
"default_value": "true",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "NPC's spawnen",
"description": "NPC's werden gespawnt",
"env_variable": "SPAWNNPC",
"default_value": "true",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Tiere spawnen",
"description": "Tiere werden gespawnt",
"env_variable": "SPAWNANIMALS",
"default_value": "true",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
},
{
"name": "Strukturen generierend",
"description": "Strukturen werden gebaut",
"env_variable": "SPAWNSTRUCTURES",
"default_value": "true",
"user_viewable": true,
"user_editable": true,
"rules": "required",
"field_type": "text"
}
]
} |
Ok. Will try it today. Also please share with me your module "log" for request and response , from the last changes not old one. |
I have just tested your egg and is working fine. If you upgrade the product from the "admin panel in whmcs" make sure when you change Max Players to press save, and after that Change Package. |
Just don't work for me, sadly. Client side up- and downgrade also. Date: 02/09/2024 20:58 - Module: pterosync-whmcs - Action: patch - https://[mydomain]/api/application/servers/106/startup Request
{"environment":{"HHGS":"mcv","BUILD_VANILLA_VERSION":"latest","BUILD_PURGE":"false","BUILD_CREATE_BACKUP_ON_SAME_SERVER":"false","BUILD_PURGE_AFTER_BACKUP_ON_SAME_SERVER":"false","MAX_PLAYERS":179,"MOTD":"MOTD","GAMEMODE":"0","DIFFICULTY":"2","PVP":"true","FLIGHT":"false","NETHER":"true","SPAWNMOBS":"true","SPAWNNPC":"true","SPAWNANIMALS":"true","SPAWNSTRUCTURES":"true"},"startup":"\/tmp\/.run","egg":25,"image":"image","skip_scripts":false} Response
|
Hi, sorry for late response just little be busy. Then the issue is not from the MAX_PLAYERS must be something else. Try with the default egg from pterodactyl ? |
Hi, I tested it now with the original Minecraft Vanilla Egg. I Just add the MAX_PLAYERS variable. Request
{"environment":{"SERVER_JARFILE":"server.jar","VANILLA_VERSION":"latest","MAX_PLAYERS":5},"startup":"java -Xms128M -XX:MaxRAMPercentage=95.0 -jar {{SERVER_JARFILE}}","egg":43,"image":"ghcr.io\/pterodactyl\/yolks:java_21","skip_scripts":false} Response
Only when I force the MAX_PLAYERS variable to be a string, this error is gone and everything is working fine. |
That's soo wired you are the only one with such as issue. Can you show me in a video what exactly what u r doing. |
Cool, nice to hear that. I will try to make a video for u this weekend. |
Done: https://youtu.be/JpXJtu60P0w Sorry for the bad quality at the end. |
In your egg settings how does the VARIABLE MAX_PLAYERS look like. |
In my egg settings the Variable looks Like that: Same results i get if i test it with other input rules i descriped here |
Ok, I was playing with this and i don't understand what's wrong for you. Do you mind if join the Discord Server so we can talk and u share me a screen ? |
Sorry for the late response. For now, I use the dropdown menu. But if I have more time again, I will test if the problem maybe on my whmcs version. |
Hi, Last night someone else also had same issue. I have added fix for it on the main branch. Look like, that all request that being send to pterodactyl in environment must be type of "string". So yea, your pull request was right, but did not know that all inputs must be send as "string" |
If you use as configurable option type "Quantity", the Variable will be interpreted as integer while the environment array always need strings.
In my example, the wrong Value is at MAX_PLAYERS
This problem only appears if you up- or downgrade a server in whmcs.
Module Log:
Request:
Response:
If I use the Dropdown type for configurable options, it will work.
The MAX_PLAYER value is a string here.
Request:
Response:
I remember this worked in the past with the Quantity type also.
So I would fix it by my self, but my PHP knowledge is too small :)
The text was updated successfully, but these errors were encountered: