java.lang.Object
com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL

public abstract class GlobalMySQL extends Object
Abstract class for managing global MySQL database operations across multiple servers.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GlobalMySQL(String tableName, com.bencodez.simpleapi.sql.mysql.config.MysqlConfig config)
    Constructs a GlobalMySQL instance with the specified table name and MySQL configuration.
    GlobalMySQL(String tableName, com.bencodez.simpleapi.sql.mysql.MySQL mysql)
    Constructs a GlobalMySQL instance with the specified table name and MySQL connection.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addColumn(String column, com.bencodez.simpleapi.sql.DataType dataType)
    Adds a new column to the database table.
    void
    alterColumnType(String column, String newType)
    Alters the type of an existing column in the database table.
    void
    checkColumn(String column, com.bencodez.simpleapi.sql.DataType dataType)
    Checks if a column exists in the table, and adds it if it does not.
    void
    Clears the basic cache and reloads columns and servers from the database.
    void
    Closes the database connection.
    boolean
    Checks if the database contains a record for the specified server.
    boolean
    Queries the database to check if it contains a record for the specified server.
    boolean
    Checks if the cached server list contains the specified server.
    abstract void
    Logs an exception for debugging purposes.
    abstract void
    Logs a debug message.
    void
    Deletes a server record from the database.
    void
    Executes a SQL query with placeholder replacement.
    Gets the list of column names in the table.
    Queries the database for the list of column names in the table.
    ArrayList<com.bencodez.simpleapi.sql.Column>
    getExact(String server)
    Gets the exact record for the specified server.
    ArrayList<com.bencodez.simpleapi.sql.Column>
    getExactQuery(com.bencodez.simpleapi.sql.Column column)
    Queries the database for records matching the specified column.
    Gets the table name.
    ArrayList<com.bencodez.simpleapi.sql.Column>
    Queries the database for all server records.
    Gets the set of server names from cache or database.
    Queries the database for all server names.
    abstract void
    info(String text)
    Logs an informational message.
    void
    insert(String index, String column, com.bencodez.simpleapi.sql.data.DataValue value)
    Inserts a single column value for the specified server.
    void
    insertQuery(String index, List<com.bencodez.simpleapi.sql.Column> cols)
    Inserts or updates multiple column values for the specified server.
    boolean
    Checks if the specified column is an integer column.
    boolean
    Checks if batch updates are supported.
    void
    Loads column and batch update support data from the database.
    abstract void
    Logs a severe error message.
    void
    update(String index, String column, com.bencodez.simpleapi.sql.data.DataValue value)
    Updates a single column value for the specified server.
    void
    update(String index, List<com.bencodez.simpleapi.sql.Column> cols, boolean runAsync)
    Updates multiple column values for the specified server.
    abstract void
    Logs a warning message.
    void
    wipeColumnData(String columnName)
    Wipes all data from the specified column by setting values to NULL.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GlobalMySQL

      public GlobalMySQL(String tableName, com.bencodez.simpleapi.sql.mysql.MySQL mysql)
      Constructs a GlobalMySQL instance with the specified table name and MySQL connection.
      Parameters:
      tableName - the name of the table
      mysql - the MySQL instance to use
    • GlobalMySQL

      public GlobalMySQL(String tableName, com.bencodez.simpleapi.sql.mysql.config.MysqlConfig config)
      Constructs a GlobalMySQL instance with the specified table name and MySQL configuration.
      Parameters:
      tableName - the name of the table
      config - the MySQL configuration
  • Method Details

    • addColumn

      public void addColumn(String column, com.bencodez.simpleapi.sql.DataType dataType)
      Adds a new column to the database table.
      Parameters:
      column - the name of the column to add
      dataType - the data type of the column
    • alterColumnType

      public void alterColumnType(String column, String newType)
      Alters the type of an existing column in the database table.
      Parameters:
      column - the name of the column to alter
      newType - the new data type for the column
    • checkColumn

      public void checkColumn(String column, com.bencodez.simpleapi.sql.DataType dataType)
      Checks if a column exists in the table, and adds it if it does not.
      Parameters:
      column - the name of the column to check
      dataType - the data type of the column
    • clearCacheBasic

      public void clearCacheBasic()
      Clears the basic cache and reloads columns and servers from the database.
    • close

      public void close()
      Closes the database connection.
    • containsKey

      public boolean containsKey(String server)
      Checks if the database contains a record for the specified server.
      Parameters:
      server - the server name to check
      Returns:
      true if the server exists, false otherwise
    • containsKeyQuery

      public boolean containsKeyQuery(String index)
      Queries the database to check if it contains a record for the specified server.
      Parameters:
      index - the server name to check
      Returns:
      true if the server exists in the database, false otherwise
    • containsServer

      public boolean containsServer(String server)
      Checks if the cached server list contains the specified server.
      Parameters:
      server - the server name to check
      Returns:
      true if the server is in the cache, false otherwise
    • debugEx

      public abstract void debugEx(Exception e)
      Logs an exception for debugging purposes.
      Parameters:
      e - the exception to log
    • debugLog

      public abstract void debugLog(String text)
      Logs a debug message.
      Parameters:
      text - the message to log
    • deleteServer

      public void deleteServer(String server)
      Deletes a server record from the database.
      Parameters:
      server - the server name to delete
    • executeQuery

      public void executeQuery(String str)
      Executes a SQL query with placeholder replacement.
      Parameters:
      str - the SQL query string
    • getColumns

      public List<String> getColumns()
      Gets the list of column names in the table.
      Returns:
      the list of column names
    • getColumnsQueury

      public ArrayList<String> getColumnsQueury()
      Queries the database for the list of column names in the table.
      Returns:
      the list of column names
    • getExact

      public ArrayList<com.bencodez.simpleapi.sql.Column> getExact(String server)
      Gets the exact record for the specified server.
      Parameters:
      server - the server name
      Returns:
      the list of columns for the server
    • getExactQuery

      public ArrayList<com.bencodez.simpleapi.sql.Column> getExactQuery(com.bencodez.simpleapi.sql.Column column)
      Queries the database for records matching the specified column.
      Parameters:
      column - the column to match
      Returns:
      the list of columns matching the query
    • getName

      public String getName()
      Gets the table name.
      Returns:
      the table name
    • getRowsQuery

      public ArrayList<com.bencodez.simpleapi.sql.Column> getRowsQuery()
      Queries the database for all server records.
      Returns:
      the list of server columns
    • getServers

      public Set<String> getServers()
      Gets the set of server names from cache or database.
      Returns:
      the set of server names
    • getServersQuery

      public ArrayList<String> getServersQuery()
      Queries the database for all server names.
      Returns:
      the list of server names
    • info

      public abstract void info(String text)
      Logs an informational message.
      Parameters:
      text - the message to log
    • insert

      public void insert(String index, String column, com.bencodez.simpleapi.sql.data.DataValue value)
      Inserts a single column value for the specified server.
      Parameters:
      index - the server name
      column - the column name
      value - the value to insert
    • insertQuery

      public void insertQuery(String index, List<com.bencodez.simpleapi.sql.Column> cols)
      Inserts or updates multiple column values for the specified server.
      Parameters:
      index - the server name
      cols - the list of columns to insert
    • isIntColumn

      public boolean isIntColumn(String key)
      Checks if the specified column is an integer column.
      Parameters:
      key - the column name
      Returns:
      true if the column is an integer column, false otherwise
    • isUseBatchUpdates

      public boolean isUseBatchUpdates()
      Checks if batch updates are supported.
      Returns:
      true if batch updates are supported, false otherwise
    • loadData

      public void loadData()
      Loads column and batch update support data from the database.
    • logSevere

      public abstract void logSevere(String text)
      Logs a severe error message.
      Parameters:
      text - the message to log
    • update

      public void update(String index, List<com.bencodez.simpleapi.sql.Column> cols, boolean runAsync)
      Updates multiple column values for the specified server.
      Parameters:
      index - the server name
      cols - the list of columns to update
      runAsync - whether to run the update asynchronously
    • update

      public void update(String index, String column, com.bencodez.simpleapi.sql.data.DataValue value)
      Updates a single column value for the specified server.
      Parameters:
      index - the server name
      column - the column name
      value - the value to update
    • warning

      public abstract void warning(String text)
      Logs a warning message.
      Parameters:
      text - the message to log
    • wipeColumnData

      public void wipeColumnData(String columnName)
      Wipes all data from the specified column by setting values to NULL.
      Parameters:
      columnName - the name of the column to wipe