Solved Connecting to a server for data

Discussion in 'Plugin Development' started by davidclue, Sep 17, 2021.

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


    I want to connect to a server of some sort in my plugin and check the value of something on the server for instance the version so whenever I update my plugin, people who are using it will receive a message every time they start the server letting them know an update is available, or better yet it could auto-update but that's for another topic. So how would I go about doing this? Do I need to buy a website or something? I don't want them to have to port forward or anything and I've seen plugins do this before.

    EDIT: Okay I figured out how to get it to check for updates from spigot, but still how would I go about connecting to a server or discord server or something to send statistics about errors. I would like to implement an option to let users send a crash report with the log if my plugin crashes the server.
    Last edited: Sep 17, 2021
  2. Offline


    You could just make a simple HTTP(s) request to your server with the crash data in the body.
  3. Offline


    i can't say about servers like discord and others but, i was also trying to do the same..
    you will just have to host a server (using your own jar) at any other computer... after my research, i found using Java's sockets easy, i mean, don't know any other way is possible. here's how:
    Caution: never try to add the server.jar part in your plugin or i can ensure that 90% chance that your MC server will crash the next moment or may get stuck
  4. Offline


    @rudraksha007 That won't work every user would have to portforward to do this. Someone said to use MySQL and I am looking into that.

    EDIT: Setting up a MySQL Database works I can communicate between the two computers from anywhere its actually insane.
    Last edited: Sep 18, 2021
  5. Offline

    timtower Administrator Administrator Moderator

    @davidclue Do keep in mind that your plugin isn't running anymore the moment it will crash the server. So you can't send logs that way.
    Using mysql for the logs is not advised as I can just pull the information from the plugin to drop your database.
    Neither do you know which server is crashing btw.

    Best is to have the user upload the log somewhere instead.
  6. Offline


    @timtower My plugin doesn't usually crash the server just generates exceptions, I just scan the latest log file and submit only the error from it to not flood my database. Also, you can set user permissions for MySQL so I can just set the user permission to only insert into the database so they cannot drop anything, the only thing they could do if they really wanted to for some reason is flood the database with random data but even then I can limit connections per hour in my database to prevent that.
Thread Status:
Not open for further replies.

Share This Page