Log report category to database.
Allow report to easily be handled by clicking text to fire the reporthandle command.
This commit is contained in:
parent
d23230504f
commit
1857afa826
|
@ -6,6 +6,8 @@ import java.util.Map.Entry;
|
|||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.report.command.ReportNotification;
|
||||
import mineplex.serverdata.Region;
|
||||
|
@ -147,10 +149,18 @@ public class ReportManager {
|
|||
String message = String.format("[Report %d] [%s %d] [%s - %d - %s]", report.getReportId(),
|
||||
reporter.getName(), reportProfile.getReputation(),
|
||||
reportedPlayer.getName(), report.getReporters().size(), reason);
|
||||
|
||||
JsonMessage clickableMessage = new JsonMessage("Click ")
|
||||
.extra("here")
|
||||
.bold()
|
||||
.click(ClickEvent.RUN_COMMAND, "/reporthandle " + reportId)
|
||||
.add(" to respond to ticket.");
|
||||
|
||||
sendReportNotification(message);
|
||||
sendReportNotification(clickableMessage);
|
||||
}
|
||||
|
||||
reportSqlRepository.logReportSending(report.getReportId(), reporterId, reason);
|
||||
reportSqlRepository.logReportSending(report.getReportId(), reporterId, category, reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,6 +254,16 @@ public class ReportManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a network-wide {@link ReportNotification} to all online staff.
|
||||
* @param message - the report notification message to send.
|
||||
*/
|
||||
public void sendReportNotification(JsonMessage message)
|
||||
{
|
||||
ReportNotification reportNotification = new ReportNotification(message);
|
||||
reportNotification.publish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a network-wide {@link ReportNotification} to all online staff.
|
||||
* @param message - the report notification message to send.
|
||||
|
|
|
@ -14,14 +14,22 @@ public class ReportPlugin extends MiniPlugin
|
|||
|
||||
private static JavaPlugin instance;
|
||||
public static JavaPlugin getPluginInstance() { return instance; }
|
||||
|
||||
|
||||
private final String _serverName;
|
||||
|
||||
public ReportPlugin(JavaPlugin plugin, String serverName)
|
||||
{
|
||||
super("Report", plugin);
|
||||
|
||||
instance = plugin;
|
||||
_serverName = serverName;
|
||||
}
|
||||
|
||||
|
||||
public String getServerName()
|
||||
{
|
||||
return _serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@ import mineplex.core.common.util.NautHashMap;
|
|||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.Column;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.core.preferences.UserPreferences;
|
||||
|
@ -31,14 +32,13 @@ id, date, reportId, accountId of Staff
|
|||
This will be used to determine if staff are handling
|
||||
*/
|
||||
|
||||
// todo include category
|
||||
private static String CREATE_TICKET_TABLE = "CREATE TABLE IF NOT EXISTS reportTickets (reportId INT NOT NULL, date LONG, eventDate LONG, playerId INT NOT NULL, server VARCHAR(50), closerId INT NOT NULL, result VARCHAR(25), reason VARCHAR(100), PRIMARY KEY (reportId), INDEX playerIdIndex (playerId), INDEX closerIdIndex (closerId));";
|
||||
private static String CREATE_HANDLER_TABLE = "CREATE TABLE IF NOT EXISTS reportHandlers (id INT NOT NULL AUTO_INCREMENT, reportId INT NOT NULL, eventDate LONG, handlerId INT NOT NULL, PRIMARY KEY (id), INDEX handlerIdIndex (handlerId) );";
|
||||
private static String CREATE_REPORTERS_TABLE = "CREATE TABLE IF NOT EXISTS reportSenders (id INT NOT NULL AUTO_INCREMENT, reportId INT NOT NULL, eventDate LONG, reporterId INT NOT NULL, reason VARCHAR(100), PRIMARY KEY (id), INDEX reporterIdIndex (reporterId));";
|
||||
private static String CREATE_REPORTERS_TABLE = "CREATE TABLE IF NOT EXISTS reportSenders (id INT NOT NULL AUTO_INCREMENT, reportId INT NOT NULL, eventDate LONG, reporterId INT NOT NULL, category VARCHAR(20), reason VARCHAR(100), PRIMARY KEY (id), INDEX reporterIdIndex (reporterId));";
|
||||
|
||||
private static String INSERT_TICKET = "INSERT INTO reportTickets (reportId, eventDate, playerId, server, closerId, result, reason) VALUES (?, now(), ?, ?, ?, ?, ?);";
|
||||
private static String INSERT_HANDLER = "INSERT INTO reportHandlers (eventDate, reportId, handlerId) VALUES(now(), ?, ?);";
|
||||
private static String INSERT_SENDER = "INSERT INTO reportSenders (eventDate, reportId, reporterId, reason) VALUES(now(), ?, ?, ?);";
|
||||
private static String INSERT_SENDER = "INSERT INTO reportSenders (eventDate, reportId, reporterId, category, reason) VALUES(now(), ?, ?, ?, ?);";
|
||||
|
||||
public ReportRepository(JavaPlugin plugin, String connectionString)
|
||||
{
|
||||
|
@ -48,11 +48,9 @@ This will be used to determine if staff are handling
|
|||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
/*
|
||||
executeUpdate(CREATE_TICKET_TABLE);
|
||||
executeUpdate(CREATE_HANDLER_TABLE);
|
||||
executeUpdate(CREATE_REPORTERS_TABLE);
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,10 +64,10 @@ This will be used to determine if staff are handling
|
|||
executeUpdate(INSERT_HANDLER, new ColumnInt("reportId", reportId), new ColumnInt("handlerId", handlerId));
|
||||
}
|
||||
|
||||
public void logReportSending(int reportId, int reporterId, String reason)
|
||||
public void logReportSending(int reportId, int reporterId, Category category, String reason)
|
||||
{
|
||||
executeUpdate(INSERT_SENDER, new ColumnInt("reportId", reportId), new ColumnInt("reporterId", reporterId),
|
||||
new ColumnVarChar("reason", 100, reason));
|
||||
executeUpdate(INSERT_SENDER, new ColumnInt("reportId", reportId), new ColumnInt("reporterId", reporterId),
|
||||
new ColumnVarChar("type", 20, category.name()), new ColumnVarChar("reason", 100, reason));
|
||||
}
|
||||
|
||||
public void logReport(int reportId, int playerId, String server, int closerId, ReportResult result, String reason)
|
||||
|
|
Loading…
Reference in New Issue