Skip to content
Syrent edited this page Oct 9, 2022 · 2 revisions

Event API

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

Create a new report

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? = null

Note: VelocityReport was created with Kotlin language. You can access everything via Java as well.

Update report

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

Create and update report example

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))
}

Get reports from the Database

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)

Clone this wiki locally