java.lang.Object
tfagaming.projects.minecraft.homestead.managers.LogManager

public final class LogManager extends Object
A utility class that manages RegionLog.
  • Method Details

    • addLog

      public static void addLog(Region region, String author, String message)
      Add a new log to a region.
      Parameters:
      region - The region
      author - The author of the message
      message - The message
    • addLog

      public static void addLog(long regionId, String author, String message)
      Add a new log to a region.
      Parameters:
      regionId - The region ID
      author - The author of the message
      message - The message
    • addLog

      public static void addLog(Region region, @Nullable @Nullable org.bukkit.OfflinePlayer player, LogManager.PredefinedLog log, Object... data)
    • addLog

      public static void addLog(long regionId, @Nullable @Nullable org.bukkit.OfflinePlayer player, LogManager.PredefinedLog log, Object... data)
    • getLog

      public static RegionLog getLog(long logId)
      Retrieves a specific log by its unique ID.
      Parameters:
      logId - The log ID
      Returns:
      The RegionLog, or null if not found.
    • getLogs

      public static List<RegionLog> getLogs(Region region)
      Returns a list of logs from a region, sorted newest first.
      Parameters:
      region - The region
      Returns:
      List of logs from a region
    • getLogs

      public static List<RegionLog> getLogs(long regionId)
      Returns a list of logs from a region, sorted newest first.
      Parameters:
      regionId - The region ID
      Returns:
      List of logs from a region
    • getUnreadLogs

      public static List<RegionLog> getUnreadLogs(Region region)
      Returns only unread logs from a region.
      Parameters:
      region - The region
      Returns:
      List of unread logs.
    • getUnreadLogs

      public static List<RegionLog> getUnreadLogs(long regionId)
      Returns only unread logs from a region.
      Parameters:
      regionId - The region ID
      Returns:
      List of unread logs.
    • getUnreadCount

      public static int getUnreadCount(Region region)
      Returns the number of unread logs in a region.
      Parameters:
      region - The region
      Returns:
      Unread log count.
    • getUnreadCount

      public static int getUnreadCount(long regionId)
      Returns the number of unread logs in a region.
      Parameters:
      regionId - The region ID
      Returns:
      Unread log count.
    • getLogCount

      public static int getLogCount()
      Returns the total number of logs in the server.
      Returns:
      Total log count.
    • getLogCount

      public static int getLogCount(Region region)
      Returns the total number of logs in a region.
      Parameters:
      region - The region
      Returns:
      Total log count.
    • getLogCount

      public static int getLogCount(long regionId)
      Returns the total number of logs in a region.
      Parameters:
      regionId - The region ID
      Returns:
      Total log count.
    • hasUnreadLogs

      public static boolean hasUnreadLogs(Region region)
      Checks if a region has any unread logs.
      Parameters:
      region - The region
      Returns:
      true if unread logs exist.
    • hasUnreadLogs

      public static boolean hasUnreadLogs(long regionId)
      Checks if a region has any unread logs.
      Parameters:
      regionId - The region ID
      Returns:
      true if unread logs exist.
    • getLogsByAuthor

      public static List<RegionLog> getLogsByAuthor(Region region, String author)
      Returns logs from a specific author in a region.
      Parameters:
      region - The region
      author - The author name
      Returns:
      List of logs by the author.
    • getLogsByAuthor

      public static List<RegionLog> getLogsByAuthor(long regionId, String author)
      Returns logs from a specific author in a region.
      Parameters:
      regionId - The region ID
      author - The author name
      Returns:
      List of logs by the author.
    • getLogsBefore

      public static List<RegionLog> getLogsBefore(Region region, long timestamp)
      Returns logs sent before a specific timestamp.
      Parameters:
      region - The region
      timestamp - The cutoff timestamp (exclusive)
      Returns:
      List of older logs.
    • getLogsBefore

      public static List<RegionLog> getLogsBefore(long regionId, long timestamp)
      Returns logs sent before a specific timestamp.
      Parameters:
      regionId - The region ID
      timestamp - The cutoff timestamp (exclusive)
      Returns:
      List of older logs.
    • getLogsAfter

      public static List<RegionLog> getLogsAfter(Region region, long timestamp)
      Returns logs sent after a specific timestamp.
      Parameters:
      region - The region
      timestamp - The cutoff timestamp (exclusive)
      Returns:
      List of newer logs.
    • getLogsAfter

      public static List<RegionLog> getLogsAfter(long regionId, long timestamp)
      Returns logs sent after a specific timestamp.
      Parameters:
      regionId - The region ID
      timestamp - The cutoff timestamp (exclusive)
      Returns:
      List of newer logs.
    • getOldestLog

      public static RegionLog getOldestLog(Region region)
      Returns the oldest log in a region.
      Parameters:
      region - The region
      Returns:
      The oldest log, or null if none exist.
    • getOldestLog

      public static RegionLog getOldestLog(long regionId)
      Returns the oldest log in a region.
      Parameters:
      regionId - The region ID
      Returns:
      The oldest log, or null if none exist.
    • getLatestLog

      public static RegionLog getLatestLog(Region region)
      Returns the most recent log in a region.
      Parameters:
      region - The region
      Returns:
      The latest log, or null if none exist.
    • getLatestLog

      public static RegionLog getLatestLog(long regionId)
      Returns the most recent log in a region.
      Parameters:
      regionId - The region ID
      Returns:
      The latest log, or null if none exist.
    • markAsRead

      public static boolean markAsRead(long logId)
      Marks a specific log as read.
      Parameters:
      logId - The log ID
      Returns:
      true if the log was found and updated.
    • markAsUnread

      public static boolean markAsUnread(long logId)
      Marks a specific log as unread.
      Parameters:
      logId - The log ID
      Returns:
      true if the log was found and updated.
    • markAllAsRead

      public static void markAllAsRead(Region region)
      Mark all logs as read.
      Parameters:
      region - The region
    • markAllAsRead

      public static void markAllAsRead(long regionId)
      Mark all logs as read.
      Parameters:
      regionId - The region ID
    • markAllAsUnread

      public static void markAllAsUnread(Region region)
      Mark all logs as unread.
      Parameters:
      region - The region
    • markAllAsUnread

      public static void markAllAsUnread(long regionId)
      Mark all logs as unread.
      Parameters:
      regionId - The region ID
    • deleteLog

      public static void deleteLog(RegionLog log)
      Delete a log.
      Parameters:
      log - The log
    • deleteLog

      public static void deleteLog(long logId)
      Delete a log.
      Parameters:
      logId - The log ID
    • deleteLogsOfRegion

      public static void deleteLogsOfRegion(Region region)
      Delete all logs from a region.
      Parameters:
      region - The region
    • deleteLogsOfRegion

      public static void deleteLogsOfRegion(long regionId)
      Delete all logs from a region.
      Parameters:
      regionId - The region ID
    • deleteReadLogs

      public static int deleteReadLogs(Region region)
      Deletes all read logs from a region.
      Parameters:
      region - The region
      Returns:
      The number of logs deleted.
    • deleteReadLogs

      public static int deleteReadLogs(long regionId)
      Deletes all read logs from a region.
      Parameters:
      regionId - The region ID
      Returns:
      The number of logs deleted.
    • deleteLogsOlderThan

      public static int deleteLogsOlderThan(long timestamp)
      Deletes all logs older than the specified timestamp.
      Parameters:
      timestamp - The cutoff timestamp (exclusive)
      Returns:
      The number of logs deleted.
    • deleteAllLogs

      public static int deleteAllLogs()
      Deletes every log in the cache. Use with caution.
      Returns:
      The number of logs deleted.
    • cleanupInvalidLogs

      public static int cleanupInvalidLogs()
      Removes all logs with invalid references:
      - Regions that no longer exist
      Returns:
      Number of corrupted logs removed.