Class MurmelAPI

java.lang.Object
de.murmelmeister.murmelapi.MurmelAPI

public final class MurmelAPI extends Object
The MurmelAPI main class.
  • Constructor Details

    • MurmelAPI

      public MurmelAPI()
  • Method Details

    • connect

      public static void connect(String url, String user, String password)
      Establishes a connection to the database using the provided credentials and URL, and initializes necessary configurations.
      Parameters:
      url - the database URL to connect to
      user - the username for authentication
      password - the password for authentication
    • disconnect

      public static void disconnect()
      Disconnects the application from the currently connected database. This method should be invoked when the database connection is no longer needed. It ensures proper disconnection and resource cleanup related to the database connection.
    • setup

      public static void setup()
      Sets up the necessary database tables, procedures, and initializes providers for the application.

      This method performs the initial configuration required for the application to function correctly. It includes the creation of database tables and stored procedures for various data entities, as well as initializing provider instances for managing these entities.

      The setup process involves: - Creating the necessary tables and procedures for handling users, groups, permissions, bans, mutes, login histories, play times, edit logs, and related data. - Initializing instances of providers and services such as editLogger, loginHistory, user, group, permission, ban, and mute for subsequent use in the application.

      This method is expected to be called once during the application's initialization phase.

    • deleteUser

      public static void deleteUser(int userId)
    • deleteFullUser

      public static void deleteFullUser(int userId)
    • getDatabaseName

      public static String getDatabaseName()
      Retrieves the name of the currently configured database.
      Returns:
      The name of the database as a String
    • setDatabaseName

      public static void setDatabaseName(String databaseName)
      Updates the name of the database used by the application.
      Parameters:
      databaseName - The name of the database to be set
    • getDateFormat

      public static SimpleDateFormat getDateFormat()
      Retrieves the current date format used by the application.
      Returns:
      The SimpleDateFormat instance representing the currently configured date format.
    • setDateFormat

      public static void setDateFormat(SimpleDateFormat dateFormat)
      Sets the date format for use within the application.
      Parameters:
      dateFormat - The date format to be used, represented as a SimpleDateFormat instance
    • getDatabase

      public static Database getDatabase()
      Returns the current instance of the database used by the application.
      Returns:
      The current instance of the database
    • getLoginHistory

      public static LoginHistory getLoginHistory()
      Retrieves the instance of the LoginHistory provider. If the provider is not already initialized, a new LoginHistoryProvider instance is created using the pre-configured database.
      Returns:
      The LoginHistory instance, representing the login history data provider.
    • getActiveSession

      public static ActiveSession getActiveSession()
      Retrieves the active session instance associated with the application. If no active session exists, a new one is initialized using ActiveSessionProvider.
      Returns:
      The ActiveSession instance representing the application's active session.
    • getUser

      public static User getUser()
      Retrieves the singleton instance of the User object. If the instance does not already exist, it is initialized using the UserProvider with the DATABASE.
      Returns:
      The singleton instance of the User object
    • getGroup

      public static Group getGroup()
      Retrieves the instance of the Group object. If the Group instance has not been initialized, this method initializes it using the GroupProvider with the configured DATABASE.
      Returns:
      The Group instance for managing group-related operations.
    • getPlayTime

      public static PlayTime getPlayTime()
      Retrieves the singleton instance of the PlayTime interface, initializing it if necessary.
      Returns:
      The singleton instance of the PlayTime interface for managing and manipulating user play times.
    • getPermission

      public static Permission getPermission(Group group, User user)
      Retrieves the Permission instance for the specified group and user. If the Permission instance has not been initialized, it creates a new PermissionProvider instance using the given group and user, and returns it.
      Parameters:
      group - The group for which the permissions are being retrieved.
      user - The user for whom the permissions are being retrieved.
      Returns:
      The Permission instance corresponding to the specified group and user.
    • getPermission

      public static Permission getPermission()
      Retrieves the current permission instance for the application. This method initializes the permission instance if it has not been previously created, using the group and user instances.
      Returns:
      The initialized or existing Permission instance based on the current group and user.
    • getPunishmentReason

      public static PunishmentReason getPunishmentReason()
      Retrieves the PunishmentReason instance, initializing it if necessary. This method ensures a singleton-like behavior for the PunishmentReason instance by lazily initializing it through the PunishmentReasonProvider using the DATABASE field, if it has not already been instantiated.
      Returns:
      The current instance of PunishmentReason
    • getPunishmentLog

      public static PunishmentLog getPunishmentLog(PunishmentReason reason)
      Retrieves the punishment log associated with the specified punishment reason. If the punishment log has not been initialized, it will create a new instance using the provided reason and the database configuration.
      Parameters:
      reason - The reason for the punishment to retrieve or generate the punishment log
      Returns:
      The instance of the punishment log corresponding to the given punishment reason
    • getPunishmentLog

      public static PunishmentLog getPunishmentLog()
      Retrieves the default punishment log associated with the system. This method internally uses the default punishment reason to obtain the punishment log.
      Returns:
      The punishment log associated with the default punishment reason
    • getPunishmentIP

      public static PunishmentIP getPunishmentIP(PunishmentReason reason, PunishmentLog log)
      Retrieves the PunishmentIP instance associated with the provided punishment reason and log. If the instance is not initialized, it creates a new PunishmentIPProvider using the database, reason, and log.
      Parameters:
      reason - The PunishmentReason object used to associate specific punishment logic
      log - The PunishmentLog object that tracks punishment-related actions and history
      Returns:
      The PunishmentIP instance for managing punishment-related IP operations
    • getPunishmentIP

      public static PunishmentIP getPunishmentIP()
      Retrieves the default instance of PunishmentIP using the default punishment reason and punishment log.
      Returns:
      The default PunishmentIP instance, constructed using the default punishment reason and punishment log.
    • getPunishmentUser

      public static PunishmentUser getPunishmentUser(PunishmentReason reason, PunishmentLog log)
      Retrieves the instance of PunishmentUser, initializing it if necessary, based on the provided PunishmentReason and PunishmentLog.
      Parameters:
      reason - The reason associated with the punishment
      log - The log containing details of the punishment
      Returns:
      The instance of PunishmentUser associated with the given reason and log
    • getPunishmentUser

      public static PunishmentUser getPunishmentUser()
      Retrieves a `PunishmentUser` object by internally obtaining the required `PunishmentReason` and `PunishmentLog` instances through corresponding methods.
      Returns:
      A `PunishmentUser` object constructed using the retrieved `PunishmentReason` and `PunishmentLog`