Class LogManager
java.lang.Object
tfagaming.projects.minecraft.homestead.managers.LogManager
A utility class that manages
RegionLog.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdd a new log to a region.static voidaddLog(long regionId, @Nullable org.bukkit.OfflinePlayer player, LogManager.PredefinedLog log, Object... data) static voidAdd a new log to a region.static voidaddLog(Region region, @Nullable org.bukkit.OfflinePlayer player, LogManager.PredefinedLog log, Object... data) static intRemoves all logs with invalid references:
- Regions that no longer existstatic intDeletes every log in the cache.static voiddeleteLog(long logId) Delete a log.static voidDelete a log.static voiddeleteLogsOfRegion(long regionId) Delete all logs from a region.static voiddeleteLogsOfRegion(Region region) Delete all logs from a region.static intdeleteLogsOlderThan(long timestamp) Deletes all logs older than the specified timestamp.static intdeleteReadLogs(long regionId) Deletes all read logs from a region.static intdeleteReadLogs(Region region) Deletes all read logs from a region.static RegionLoggetLatestLog(long regionId) Returns the most recent log in a region.static RegionLoggetLatestLog(Region region) Returns the most recent log in a region.static RegionLoggetLog(long logId) Retrieves a specific log by its unique ID.static intReturns the total number of logs in the server.static intgetLogCount(long regionId) Returns the total number of logs in a region.static intgetLogCount(Region region) Returns the total number of logs in a region.getLogs(long regionId) Returns a list of logs from a region, sorted newest first.Returns a list of logs from a region, sorted newest first.getLogsAfter(long regionId, long timestamp) Returns logs sent after a specific timestamp.getLogsAfter(Region region, long timestamp) Returns logs sent after a specific timestamp.getLogsBefore(long regionId, long timestamp) Returns logs sent before a specific timestamp.getLogsBefore(Region region, long timestamp) Returns logs sent before a specific timestamp.getLogsByAuthor(long regionId, String author) Returns logs from a specific author in a region.getLogsByAuthor(Region region, String author) Returns logs from a specific author in a region.static RegionLoggetOldestLog(long regionId) Returns the oldest log in a region.static RegionLoggetOldestLog(Region region) Returns the oldest log in a region.static intgetUnreadCount(long regionId) Returns the number of unread logs in a region.static intgetUnreadCount(Region region) Returns the number of unread logs in a region.getUnreadLogs(long regionId) Returns only unread logs from a region.getUnreadLogs(Region region) Returns only unread logs from a region.static booleanhasUnreadLogs(long regionId) Checks if a region has any unread logs.static booleanhasUnreadLogs(Region region) Checks if a region has any unread logs.static voidmarkAllAsRead(long regionId) Mark all logs as read.static voidmarkAllAsRead(Region region) Mark all logs as read.static voidmarkAllAsUnread(long regionId) Mark all logs as unread.static voidmarkAllAsUnread(Region region) Mark all logs as unread.static booleanmarkAsRead(long logId) Marks a specific log as read.static booleanmarkAsUnread(long logId) Marks a specific log as unread.
-
Method Details
-
addLog
Add a new log to a region.- Parameters:
region- The regionauthor- The author of the messagemessage- The message
-
addLog
Add a new log to a region.- Parameters:
regionId- The region IDauthor- The author of the messagemessage- 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
Retrieves a specific log by its unique ID.- Parameters:
logId- The log ID- Returns:
- The
RegionLog, ornullif not found.
-
getLogs
Returns a list of logs from a region, sorted newest first.- Parameters:
region- The region- Returns:
- List of logs from a region
-
getLogs
Returns a list of logs from a region, sorted newest first.- Parameters:
regionId- The region ID- Returns:
- List of logs from a region
-
getUnreadLogs
Returns only unread logs from a region.- Parameters:
region- The region- Returns:
- List of unread logs.
-
getUnreadLogs
Returns only unread logs from a region.- Parameters:
regionId- The region ID- Returns:
- List of unread logs.
-
getUnreadCount
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
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
Checks if a region has any unread logs.- Parameters:
region- The region- Returns:
trueif unread logs exist.
-
hasUnreadLogs
public static boolean hasUnreadLogs(long regionId) Checks if a region has any unread logs.- Parameters:
regionId- The region ID- Returns:
trueif unread logs exist.
-
getLogsByAuthor
Returns logs from a specific author in a region.- Parameters:
region- The regionauthor- The author name- Returns:
- List of logs by the author.
-
getLogsByAuthor
Returns logs from a specific author in a region.- Parameters:
regionId- The region IDauthor- The author name- Returns:
- List of logs by the author.
-
getLogsBefore
Returns logs sent before a specific timestamp.- Parameters:
region- The regiontimestamp- The cutoff timestamp (exclusive)- Returns:
- List of older logs.
-
getLogsBefore
Returns logs sent before a specific timestamp.- Parameters:
regionId- The region IDtimestamp- The cutoff timestamp (exclusive)- Returns:
- List of older logs.
-
getLogsAfter
Returns logs sent after a specific timestamp.- Parameters:
region- The regiontimestamp- The cutoff timestamp (exclusive)- Returns:
- List of newer logs.
-
getLogsAfter
Returns logs sent after a specific timestamp.- Parameters:
regionId- The region IDtimestamp- The cutoff timestamp (exclusive)- Returns:
- List of newer logs.
-
getOldestLog
Returns the oldest log in a region.- Parameters:
region- The region- Returns:
- The oldest log, or
nullif none exist.
-
getOldestLog
Returns the oldest log in a region.- Parameters:
regionId- The region ID- Returns:
- The oldest log, or
nullif none exist.
-
getLatestLog
Returns the most recent log in a region.- Parameters:
region- The region- Returns:
- The latest log, or
nullif none exist.
-
getLatestLog
Returns the most recent log in a region.- Parameters:
regionId- The region ID- Returns:
- The latest log, or
nullif none exist.
-
markAsRead
public static boolean markAsRead(long logId) Marks a specific log as read.- Parameters:
logId- The log ID- Returns:
trueif 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:
trueif the log was found and updated.
-
markAllAsRead
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
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
Delete a log.- Parameters:
log- The log
-
deleteLog
public static void deleteLog(long logId) Delete a log.- Parameters:
logId- The log ID
-
deleteLogsOfRegion
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
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.
-