Skip to content
This repository has been archived by the owner on Oct 13, 2020. It is now read-only.

Bukkit to PHP

Waterflames edited this page Feb 9, 2017 · 1 revision

Bukkit to PHP setup

Websend does Bukkit -> PHP communication by sending a HTTP POST request to a URL and parsing the response. Here is how to test this function using an example script:

  1. Open the “minecraft.php” file included in the Websend download.
  2. Set the password variable to the password specified in the Websend configuration file.
  3. Upload this file to your website.
  4. Open the Websend plugin configuration file.
  5. Set the "URL=" option to the url of your php file.
  6. Start your Bukkit server.
  7. Try command “/ws example”.

Data sent by Websend

When Websend sends its request it includes information in the POST data. Since Websend 2.5 most of the data is contained in a JSON string under $_POST['jsonData'], unless GZIP_REQUESTS is enabled, in which case it is available in gzip form under $_FILES['jsonData']. Whether the JSON data is compressed or not is specified under the $_POST['isCompressed'] variable. The $_POST['authKey'] variable contains the hashed password and the $_POST['args'][] has the arguments.

The contents of the JSON data string is variable but here is an example of what a request might include: ``` { "Plugins": [ { "Name": "WSEvents v0.5" }, { "Name": "Websend v2.5" } ], "Invoker": { "XP": 0, "IP": "/127.0.0.1:4246", "FoodLevel": 12, "CurrentItemIndex": 4, "Location": { "World": "world", "Yaw": -58.201622009277344, "Y": 165.4582213886673, "X": 99.2219457004584, "Pitch": 86.10000610351562, "Z": 358.63092181396456 }, "XPLevel": 0, "Health": 13, "Inventory": [ { "Durability": 0, "Amount": 1, "Type": 6, "Slot": 0 }, { "Durability": 0, "Amount": 1, "Type": 295, "Slot": 1 } ], "Exhaustion": 3.3545002937316895, "Name": "TestPlayer", "CurrentItemID": 0, "GameMode": "CREATIVE", "IsOP": true }, "ServerStatus": { "MaxMemory": 2863333376, "AvailableMemory": 1844794288, "OnlinePlayers": [ { "Name": "TestPlayer", "IP": "/127.0.0.1:4246" } ] }, "ServerSettings": { "NetherEnabled": true, "Name": "Unknown Server", "Port": 25565, "Build": "git-Bukkit-1.6.2-R0.1-b2838jnks (MC: 1.6.2)", "MaxPlayers": 20, "FlyingEnabled": false, "OnlineMode": false, "DefaultGameMode": "SURVIVAL" } }```

Sending a reply

You can repond to the request by simply printing commands with print() or echo. Websend will then parse and execute these commands in the order that they were printed. Each command is seperated by a semi-colon (;).

Output

  • PrintToConsole :Text;
    Print text to console.
    Ex: PrintToConsole_: Message from Websend;
  • PrintToPlayer [-playername]:Text;
    Prints to text to a player currently playing on your server.
    By using "-playername", you can specify the player to send the message to, otherwise the message will be sent to the player that started the websend request.
    Ex: PrintToPlayer: Message from Websend;
    Ex: PrintToPlayer-notch: Message from Websend;
  • Broadcast :Text;
    Broadcast a message to all players currently playing on the server.
    Ex: Broadcast: Message from Websend;

Commands

  • ExecutePlayerCommand [-playername]:command arguments;
    Executes a command as a player currently playing on your server.
    By using "-playername", you can specify the player to set as command source, otherwise the command will be ran as the player that started the websend request.
    Ex: ExecutePlayerCommand: time set 0;
    Ex: ExecutePlayerCommand-notch: time set 0;
  • ExecuteConsoleCommand :command arguments;
    Prints to text to a player currently playing on your server.
    By using "-playername", you can specify the player to send the message to, otherwise the message will be sent to the player that started the websend request.
    Ex: ExecuteConsoleCommand: time set 0;
  • ExecuteScript :scriptname;
    Runs a script. The script has to be in the Websend scripts directory and has to be compiled and loaded before this is runned.
    Ex: ExecuteScript: time set 0;
Clone this wiki locally