Class LogManager
java.lang.Object
me.tayebyassine.homestead.managers.LogManager
-
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) Add a new log to a region using a predefined log template.static voidAdd a new log to a region.static voidaddLog(Region region, @Nullable org.bukkit.OfflinePlayer player, LogManager.PredefinedLog log, Object... data) Add a new log to a region using a predefined log template.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
-
addLog
-
addLog
public static void addLog(Region region, @Nullable @Nullable org.bukkit.OfflinePlayer player, LogManager.PredefinedLog log, Object... data) Add a new log to a region using a predefined log template.- Parameters:
region- the regionplayer- the player associated with the log, ornullfor system logslog- the predefined log typedata- the placeholder data to fill in the log message
-
addLog
public static void addLog(long regionId, @Nullable @Nullable org.bukkit.OfflinePlayer player, LogManager.PredefinedLog log, Object... data) Add a new log to a region using a predefined log template.- Parameters:
regionId- the region IDplayer- the player associated with the log, ornullfor system logslog- the predefined log typedata- the placeholder data to fill in the log message
-
getLog
-
getLogs
-
getLogs
-
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
-
getOldestLog
-
getOldestLog
Returns the oldest log in a region.- Parameters:
regionId- the region ID- Returns:
- the oldest log, or
nullif none exist
-
getLatestLog
-
getLatestLog
Returns the most recent log in a region.- Parameters:
regionId- the region ID- Returns:
- the latest log, or
nullif none exist
-
getLogsByAuthor
-
getLogsByAuthor
-
getLogsBefore
-
getLogsBefore
-
getLogsAfter
-
getLogsAfter
-
getUnreadLogs
-
getUnreadLogs
-
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
-
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
-
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
-
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
-