Website to Minecraft

Discussion in 'Plugin Development' started by 567legodude, Aug 10, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    567legodude

    Most people have heard of Buycraft. It lets you pay for something online, and then you get something on your server.
    I would like to know how I can write a plugin, and a website, so that when I click a button on the website, the plugin responds and can do something on the server. I know HTML and how to make Bukkit Plugins, (so I just need to know how to connect the plugin to the site.) but I need someone to tell me how I can make them work together. So I can make a button on my site, and when you press it, it will send something to the server that my plugin will pick up, and I can make it do an action.
    Does anyone know how to achieve something like this? I found something similar to this before, but it was in beta, and didn't work too well, and now I can't even find it anymore. I hope someone will understand this and can help.
     
  2. Offline

    Skionz

    Probably with SQL
     
  3. Offline

    ResultStatic

    567legodude look at buycraft's source code. they might use a custom packet system or something i have no idea
     
  4. Offline

    567legodude

    ResultStatic I did find what looks to be the source code, and I will have a look.
     
  5. Offline

    Skionz

    Yea pretty sure you would have to use a database. I'm not really sure how but first on the website you would have the user enter their name, then when they press the button it add the name they entered into a table. Then in your plugin you would probably have a scheduler constantly looping through all the online players and checking if their name is in the table. If it is you would remove them from the table and add a diamond to their inventory or something like that. I personally have never used SQL in a plugin before, only in websites but this is probably what you would do.
     
  6. Offline

    MegaNarwhal

    Check out Websend, it should allow you to do what you're describing.
     
  7. Offline

    ResultStatic

    Skionz i think packets would be more efficient.
     
  8. Offline

    endoml

  9. Offline

    567legodude

    MegaNarwhal I can't seem to get Websend to work, do you have any knowledge using it? Could you assist me in setting it up?
     
  10. Does buycraft operate within the minecraft EULA?
     
  11. Offline

    567legodude

    xYourFreindx Buycraft announced that it is not its job to enforce the EULA. Buycraft is still legal, for people who want to accept donation or sell non-gameplay-affecting items. The only illegal things on Buycraft is anyone who sells rewards that affect the gameplay.
     
    xYourFreindx likes this.
  12. Offline

    Chiller

    567legodude Learn about socket communication, open a http server within your bukkit plugin then you can actually talk to the server when you send the web response. You could also use a higher level web server Jetty, which you can embed in your plugin! I just recently did this for my Minecraft Admin Panel (McAdminPanel), just letting you know Jetty is pretty trivial to embed in your project so I would start with some lower level sockets... Also Jetty embedded is what dynmap uses to display their dynamic maps online!
     
  13. Offline

    567legodude

    Chiller I learned that Websend uses PHP Post method to send the data to the site. If someone could tell me how to send the post data like that, and then tell me the PHP code to receive it, then I could write the plugin myself to do that, but noone anywhere explains how to send something to my website that I can retrieve in any way.
     
  14. Offline

    Chiller

    567legodude You cannot send something from the server to a web page, you can only send from php to the server and get a response.
     
  15. Offline

    567legodude

    Chiller But with the Websend plugin, it actually does let you send things from your server to the PHP page and have it give a response back based on what you typed.
     
  16. Offline

    fireblast709

    567legodude wouldn't you want the reverse effect (according to your initial post)? If you do something on the PHP server, the Bukkit server reacts.

    Java side:
    • Create a new Thread (a Java Thread)
    • Create a serverside socket
    • indefinitely listen to newly connecting clients. If one connects
      • Then start a new Thread, where you handle the request and optionally write a response.
      • If you need the Bukkit API, don't forget that you most likely cannot call the method from your client Thread. You would need to use a sync task to fetch the required values.
    • Don't forget to close the server in onDisable
    PHP side:
    • (do whatever you need to do before the connection)
    • Create a PHP socket (*hint hint* fsockopen)
    • Write your request (data)
    • Optionally read the response
    • (do whatever you need to do after the connection)
    Chiller you can, as mentioned above with the 'optional responses'. If you want, you could have your webserver and your Bukkit server have a whole conversation about the nice weather :p
     
  17. Offline

    567legodude

    fireblast709 The only thing is, I don't know about sockets, and I don't have too much time to look into it, I really just need someone to help me troubleshoot why the Websend plugin doesn't work. I have been reading around, and there may be a possible solution, so I will try that and then I will see if it works.
     
Thread Status:
Not open for further replies.

Share This Page