Types of communication.
Note: This information is outdated. Use the documentation found here for version 2.5 and higher.
Bukkit to PHP to bukkit
Note: to use a url different from the one specified in the config, use -wp:url in your command (ex: /ws -wp:http://example.com/websend.php timeset) This requires you to be op.
Using the communication in this kind of connection works using the print(); function. Basic on-request command scripts are fairly to create:
- Make a new PHP file
- Paste this in:
<?php //variables /*********************************** Variables ***********************************/ /**/ $checkpass = "PutYourPasswordHere"; /*********************************************************************************/ /**/ $receivedMD5 = $_POST['authKey']; /**/ $player = $_POST["player"]; /**/ $args = $_POST["args"]; //each argument is stored in an array called "args" /*********************************************************************************/ //Do not edit! if($receivedMD5 != "" && $args[0] != "") { if($receivedMD5 == md5($checkpass)) { //Begin your code here. if($args[0] == "checkcolors") //script 1 { print('/Output/PrintToPlayer:Example script from php.;'); print('/Output/PrintToPlayer:This command will show all possible colors;'); // use minecraft color codes to color the text print("&aThis is green;"); print("&bThis is light blue;"); print("&cThis is red;"); print("&dThis is pink;"); print("&eThis is yellow;"); print("&fThis is white;"); print("&1This is dark blue;"); print("&2This is dark green;"); print("&3This is aqua;"); print("&4This is dark red;"); print("&5This is purple;"); print("&6This is gold;"); print("&7This is grey;"); print("&8This is dark grey;"); print("&9This is blue;"); print("&0This is black;"); print("&7These are &1multiple colors &cin one &5sentence;"); } elseif($args[0] == "timeset") //script 2 { print('/Output/PrintToPlayer:Success;'); print('/Output/PrintToPlayer:Example script from php.;'); print('/Output/PrintToPlayer:This will set the time of players world to day.;'); // use /Command/ExecuteBukkitCommand: to indicate a command sent by $player. // Behind that line you can put any player chat command. print("/Command/ExecuteBukkitCommand:time day;"); print("/Output/PrintToPlayer:Player = ".$player.";"); print("/Output/PrintToPlayer:Argument 1 = ".$args[0].";"); } elseif($args[0] == "weatherset") //script 3 { print('/Output/PrintToPlayer:Success;'); print('/Output/PrintToPlayer:Example script from php.;'); print('/Output/PrintToPlayer:This will set the weather of players world to sun.;'); // use /Command/ExecuteBukkitCommand: to indicate a command sent by $player. // Behind that line you can put any player chat command. print("/Command/ExecuteBukkitCommand:weather sun;"); print("/Output/PrintToPlayer:Player = ".$player.";"); print("/Output/PrintToPlayer:Argument 1 = ".$args[0].";"); } elseif($args[0] == "consoleCommand") //script 4 { print('/Output/PrintToPlayer:Example script from php.;'); print('/Output/PrintToPlayer:This command will send a command to the console.;'); if($player == 'console') { print('/Output/PrintToConsole:Error: Only in-game players can use this command.;'); } else { print('/Output/PrintToPlayer:Proof it is send to console:;'); // use /Command/ExecuteConsoleCommand: to indicate a command from console. print("/Command/ExecuteConsoleCommand:say Hello World;"); } } else { print('/Output/PrintToPlayer:Websend: Unknown command.;'); } //Stop editing here. } else { print('/Output/PrintToConsole:Authorization Failed;'); } } else { print("/Output/PrintToConsole:No (enough) data provided.;"); } ?>
- Fill in the password.
- Upload this file to your website.
- Go to your plugin configuration file.
- Set the "URL=" tag to the url of your php file.
PHP to bukkit
Scripts like the supplied "ExternalTimeSet.php" can be used to send a command to the server, without needing an event from the server first. This is useful for applications like registration forms (whitelisting), online server setting adjustment (time set), ect... Communicating here is done via the API in the supplied Websend.php file. To use this, follow these steps:
- Forward port 4445 on the minecraft server side.
- Go to the plugin settings and uncomment (remove the #) the #WEBLISTENER_ACTIVE=true line. (If you can't find it, paste it in.)
- Make a new php file and paste this in:
<?php include_once 'Websend.php'; //Replace with bukkit server IP. To use a different port, change the constructor to new Websend(ip, port) $ws = new Websend("123.456.789.123"); //Replace with password specified in Websend config file $ws->connect("password"); $ws->doCommandAsConsole("time set 6000"); $ws->disconnect(); ?>
- Upload this and Websend.php (download in files section) to your website.
- Try it out. The time should be set to day.
More information on this can be found here.
I get error: could not connect to host.
My ip is localhost and I uncommented the line in the config. Please help.
what must I type at: "<Password>" ?
I got this error:
07:31:20 [INFO] no password was found on the first line, any command 07:31:20 [INFO] before the authentification will be ignored. 07:31:20 [SEVERE] Exception in thread "Thread-9" 07:31:20 [SEVERE] java.lang.NullPointerException 07:31:20 [SEVERE] at websend.PHPSktSrvrThread.run(Main.java:357)
@PaddyHerrmy i have that same error have you fixed yet?
"<Password>" should not be changed.
There's no "default url" in the config file, documentation is poorly written and I just can't get it to work. I put the script on my localhost, tried setting this url from Minecraft, and I get an error:
Please help.
@RefluxMC
New version checks for empty urls. I'm not sure what you used as a url, but try using 127.0.0.1 Also, please use the forums since I don't check the comments in the pages very often.
Is it also possible to use a domain that is forwarded to my dynamic ip or do I have to edit the .php file every day?
@UbuntuFreak Most ISPs (like mine) provide a special webadres for consumers with a dynamic IP. My IP changes about once every week, but they update <something>.dynamic.<my-ISP-website.com> to use for stuff like that.
You can find out if your ISP has a such page for you here: Reverse DNS lookup.
@frenchfries999
Thank you very much frenchfries.
How would i send colored text from php to bukkit?
How do I actually intergrate it so if someone signs up the command "rank <player> Member" works?
Works great thanks!
Hi
I have a script on the page and when I confirm writes: Fatal error: Class 'Websend' not found in / home / owcatv / public_html / diax.php on line 21
on line 21 write:
$ ws = new Websend ("188.165.217.54");
what is the problem?
Hey , can you help me out pleas with bukkit>php so i want to do that kind of thing when player joins the console executes /gm survival <player who joined>
EDIT: Nevermind, I thought I had to set it to port 25565, not 4445, my fault! :P
When using the PHP to Bukkit connection I get this error:
Really need some help! :S
@Locercus
I'm having the exact same issue. Don't know what's causing the issue. I've tried changing the port, password, IP, etc...
@SzymonOwca
You need to download WebSend.php in the files (Here: http://dev.bukkit.org/bukkit-mods/websend/files/)
Epic plugin :) Is there anyway that when you do something like
$ws->doCommandAsConsole("list");
We can then echo this to the front end ?
@stuiterveer
You get this error cause its cant talk to the bukkit plugin properly. Confirm you have the plugin installed correctly and you are pointing to the right file on the includes. I didnt make the plugin but im good with php so if your still having problems message me i can try and help you get it working. :)
@technodork
By using the colour codes as shown in the example
@Platinum_Apple
To do this on your website where you have your register after they have registered and all is verified use something like
Then it will update the user.
@nolarrr
If you want them to be set survival at join of the server set it to the default ? if its when joining your site similar to above
Your user will then be updated
Is possible PHP -> bukkit -> PHP?
ex. check is player banned (PHP -> Bukkit -> PHP) if yes, unban him (PHP -> Bukkit [(OK or error) -> PHP])