MySQL API 2.9

A simplified API that will help you work with your Minecraft related database.

  1. Vagdedes
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    • 1.13
    • 1.14
    • 1.15
    Contributors:
    Can be found in the Discord server (https://vagdedes.com/discord)
    Languages Supported:
    English
    MySQL API is a library-plugin that simplifies the process of running a database. SQL commands are replaced with methods that require a few arguments in order to execute a query.

    Permissions
    mysql.admin - Gives your permission to /mysql command.

    Commands

    /mysql reload/rl - Reloads the configuration.
    /mysql connect - Connects the plugin to the database.
    /mysql disconnect - Disconnects the plugin from the database.
    /mysql reconnect - Resets the plugin's connection to the database.

    Config API

    Class: me.vagdedes.basic.Config
    This class will control the plugin's configuration. It is recommended to reconnect the database after configuration changes.
    Code (Text):

    void create() // Creates the config or object if doesn't exist.
    void reload() // Reloads the plugin config.
    void clear() // Clears the mysql configuration file.

    String getHost() // Returns the host.
    String getUser() // Returns the user.
    String getPassword() // Returns the password.
    String getDatabase() // Returns the database.
    String getPort() // Returns the port.

    void setHost(String s) // Changes the host.
    void setUser(String s) // Changes the user
    void setPassword(String s) // Changes the password.
    void setDatabase(String s) // Changes the database.
    void setPort(String s) // Changes the port.
     
    Basic API

    Class: me.vagdedes.mysql.MySQL
    This class contains the base methods of the API. The update() and query() methods can be used to extend the API's capabilities.
    Code (Text):

    void connect() // Connects to the database.
    void disconnect() // Disconnects from the database.
    void reconnect() // Restarts the connection to the database.
    Boolean isConnected() // Checks if the connection exists.
    void update(String command) // Excecutes an update to the database.
    ResultSet query(String command) // Returns a query from the database.
    Connection getConnection() // Returns the mysql current connection.
     
    Advanced API

    Class: me.vagdedes.mysql.SQL
    If the advanced methods of the SQL class aren't enough for your systems, you can still make your own by using MySQL's class update() and query() methods.
    Code (Text):

    void deleteTable(String table) // Deletes a table from the database.
    void truncateTable(String table) // Clears a table in the database.
    Integer countRows(String table) // Coureturns retunrs the number of rows in a table.
    Boolean tableExists(String table) // Returns if a table exists in the database.

    void set(String selected, Object object, String column, String logic_gate, String data, String table) // Updates the data of a column with your inserted object.
    SQL.set("cooldown", 5, "name", "=", "Player", "basic_table"); // Example

    void set(String selected, Object object, String where_arguments, String table) // Updates the data of a column with your inserted object based on multiple arguments.
    SQL.set("cooldown", 5, new String[]{"name=Player", "cooldown=0"}, "basic_table"); // Example

    void deleteData(String column, String logic_gate, String data, String table) // Deletes data from a table.
    SQL.deleteData("nickname", "=", "George2009", "ranks"); // Example

    void insertData(String columns, String values, String table) // Inserts data into a table.
    SQL.insertData("name, kit, cooldown", " 'Sam', 'Fisherman', '29' ", "kitpvp"); // Example

    void upsert(String selected, Object object, String column, String logic_gate, String data, String table) // Updates the data of a column with your inserted object if it exists, or alternatively inserts a new row to the table.
    SQL.upsert("cooldown", 5, "name", "=", "Player", "basic_table"); // Example

    Boolean exists(String column, String data, String table) // Checks if a data exists in a certain column.
    Boolean b = SQL.exists("custom_nickname", "&1J&2o&3h&4n", "player_settings"); // Example

    void createTable(String table, String columns) // Creates a new table if it doesn't already exist.
    SQL.createTable("ranks", "rank INT (11), join_date TIMESTAMP"); // Example

    Object get(String selected, String column, String logic_gate, String data, String table) // Returns an object variable owned by the selected column.
    Object o = SQL.get("kills", "uuid", "!=", "deleted_player", "pvp_stats"); // Example

    Object get(String selected, String[] where_arguments, String table) // Returns an object variable owned by the selected columns.
    Object o = SQL.get("kills", new String[]{"uuid != deleted_player", "enabled = 1"}, "pvp_stats"); // Example

    ArrayList<Object> listGet(String selected, String column, String logic_gate, String data, String table) // Returns an object variable owned by the selected column.
    ArrayList<Object> arrayList = SQL.listGet("kills", "uuid", "!=", "deleted_player", "pvp_stats"); // Example

    for (Object individual : arrayList) {
        // Do Stuff
    }

    ArrayList<Object> listGet(String selected, String[] where_arguments, String table) // Returns an object variable owned by the selected columns.
    ArrayList<Object> arrayList = SQL.listGet("kills", new String[]{"uuid != deleted_player", "enabled = 1"}, "pvp_stats"); // Example

    for (Object individual : arrayList) {
        // Do Stuff
    }
     

Recent Updates

  1. Version 2.9
  2. Version 2.8
  3. Version 2.7

Recent Reviews

  1. NixiCZ
    NixiCZ
    4/5,
    Version: 2.9
    Hello there,
    your plugin is very useful and creative. But i have one problem.
    I'm using your plugin at server 1.12.2 version and that works. But when I use my own plugin with your API plugin on 1.8.8 version server it don't want to connect to the same database.. It wrote me: Unknown initial character set index '255' received from server. Can you help me?
    All console output: https://pastebin.com/2Bx3SXBd
    1. Vagdedes
      Author's Response
      Reviews should represent your opinion, so please delete it and provide me a paste of your configuration via a conversation or the resource's thread.
  2. hjk321
    hjk321
    4/5,
    Version: Version 2.7
    Works exactly as advertised, great for developers making custom plugins for servers but not too much else since there's only support for one server. Also, there is no localhost support (or it's numeric equivalent) so you'll have to put your public ip in the config even if the mysql server is on the same machine as your minecraft server.

    Otherwise very great plugin, would recommend as long as neither of the above concerns matter to you.
    1. Vagdedes
      Author's Response
      Thanks for the review, but you can always contact me to suggest new features.
  3. McMasterPlayz
    McMasterPlayz
    5/5,
    Version: 2.4
    Insanely useful API for people who don't know how to use MYSQL (Like me). Just started using it and it works perfectly, the api is insanely easy to use.
  4. RedLime
    RedLime
    5/5,
    Version: 2.4
    thank you!
    I can developing plugins as too fast!
    10/10
    =========================
  5. 14i56
    14i56
    5/5,
    Version: 2.4
    After hours of thinking about my errors, they were fixed. Now I can say this is great API. Keep up the good work and support.

    For another persons, if your plugin is started previously than API, it shows errors in console with NullPointer because SQL is not connected.
  6. DrOreo002
    DrOreo002
    5/5,
    Version: 2.4
    Really useful API!. Thanks so much for this!, this will help me a lot!

    10/10

    - DrOreo002
  7. FalconSeeker
    FalconSeeker
    5/5,
    Version: 2.4
    Excellent work!
    ------------------------------------------------------------------------------
    i needed something like this badly ffor a while
  8. Mr_Redstone_19
    Mr_Redstone_19
    4/5,
    Version: 2.4
    If I do /mysql disconnect, MySQL doesnt disconnect. What can I do? I need it :D.
    1. Vagdedes
      Author's Response
      Threads exist for discussions. Leaving a review, won't get you the answer...
  9. VoidCraftPlays
    VoidCraftPlays
    5/5,
    Version: 2.4
    I love this API seeing as I am ridiculously lazy and never implement MySQL into my plugins, but this makes it that much easier.
  10. IncognitoStaff
    IncognitoStaff
    5/5,
    Version: 2.3
    Pure amazing! Never have seen a better API. Docs are great. No real way to explain it more than examples!
    1. Vagdedes
      Author's Response
      Thank you!