-
Notifications
You must be signed in to change notification settings - Fork 8
API
Syrent edited this page Oct 9, 2022
·
2 revisions
There are 4 available Bukkit events for you to modify or listen to report creation and updates. Available events:
- PreReportEvent
- Event is cancellable
- Report is mutable
- PostReportEvent
- Report is immutable
- PreReportUpdateEvent
- Update is cancellable
- Previous report and new report are accessible
- New report is mutable
- PostReportUpdateEvent
- New report is immutable
You can create a new report with six parameters
data class Report(
val server: String,
val reporterID: UUID,
val reporterName: String,
val reportedName: String,
val date: Long,
val reason: String,
)All report fields are mutable and you can change them
var reportID: UUID = UUID.randomUUID()
var stage = ReportStage.ACTIVE
var moderatorUUID: UUID? = null
var moderatorName: String? = nullNote: VelocityReport was created with Kotlin language. You can access everything via Java as well.
You can easily update reports via Report#update(callEvent) method.
If you want to call report events you can set callEvent to true otherwise, let it be false
Report(
plugin.networkPlayersServer[sender.uniqueId] ?: "Unknown",
sender.uniqueId,
sender.name,
target,
System.currentTimeMillis(),
MiniMessage.miniMessage().stripTags(formattedReason)
).update(true).whenComplete {_, _ ->
val newCooldownCounter = MilliCounter()
newCooldownCounter.start()
plugin.cooldowns[sender.uniqueId] = newCooldownCounter
sender.sendMessage(Message.REPORT_USE, TextReplacement("player", target), TextReplacement("reason", formattedReason))
}You can get all report data from the Database using external database queries.
But there are some static functions provided in Database.kt class that you can use to easily access reports data.
Database#saveReport(Report)
Database#getReports(ReportStage)
Database#getReportsByModeratorID(UUID, ReportStage)
Database#getReportByID(String, ReportStage)
Database#getReportsCount(ReportStage)