tempban with mysql

Discussion in 'Plugin Development' started by tg95, Apr 17, 2015.

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


    Hello, i create plugin "ban" and i need code with temban, but my plugin connect with mysql, and how tempban with mysql?

    Thanks for help and sorry for my bad english
  2. Offline



    Why do you need MySQL?
  3. Offline


    Why not?
    TilzyCodes likes this.
  4. Offline


  5. Offline


    @Evaluations There are always reasons to use an external database.

    "Why not?" is not one of them.
    nverdier likes this.
  6. Offline


    1. Slow
    2. Difficult to program around
    3. Requires extra skills (database design and SQL)
    4. Relies on outside software to ensure your server stays up
    5. Artificially limits your plugin to servers that have access to MySQL
    Should I keep going?
    nverdier likes this.
  7. Offline


    Just use the same exact method you would use in storing that sort of information in a config, except do it in the MySQL tables. For example, if you wanted to test if the player is banned, just add an isBanned boolean in the table. You could store the time in which the player gets unbanned / allowed to join using varchars, and then just convert them back to dates in Bukkit. Then you can test if the unban date is before the current date whenever a player joins. That's how I did it, sorry if that isn't exactly what you were asking in your question.
  8. Offline


    @Vextricity What, why would you store time as a character array?
  9. Offline


    What method would you recommend for him to use then? In this instance and this situation, (at least in my judgement) a database seems the most reasonable way to store data...
  10. Offline


    Am I the one wanting to use it?

  11. Offline


    Once you have a table in your database with the appropriate columns, e.g (VARCHAR(255) and INTEGER(255)).

    //Creating statement to grab current time
    PreparedStatement state = connection.prepareStatement("SELECT time FROM `" + table + "` WHERE uuid=?;");
    state.setString(1, uuid.toString());
    ResultSet set = state.executeQuery();
    int oldTime = set.getInt("time");
    //Create statement to update the time, ^ subtract from the current time.
    PreparedStatement state1 = connection.prepareStatement("UPDATE `" + table + "` SET time=? WHERE uuid=?;");
    state1.setLong(1, oldTime - [AMOUNT TO TAKE AWAY]);
    state1.setString(2, uuid.toString());

    //Close statements

    A bit messy.. or you could use something like
    DELETE FROM table WHERE date <'year:month:date time';
  12. Offline


  13. Offline


    hello, i need mysql, for, i have 5 servers "bungeecord" and if i ban on server 3, player cant join on server 1,2,3,4,5 xD
    And mysql is to much easy because have all in database, xD not in config "server file"

    thanks for help.
    and sorry for my bad english :b

    now i use MaxBans, but this plugin have much bugs, i unban player and if reload plugin player returns to be ban, and this is to much bad
    now i have on my plugin ban,unban,mute,unmute, need tempban, but, need to mysql , for connect all svs xD

    thanks for help :b
  14. Locked, Bungeecord requires servers to be in offline mode which is not supported here.
Thread Status:
Not open for further replies.

Share This Page