Small refactorings (class relocations and renames)

This commit is contained in:
Keir Nellyer 2016-07-14 20:15:14 +01:00
parent 15b5198dbb
commit 65e8b92c1a
9 changed files with 34 additions and 20 deletions

View File

@ -1,4 +1,4 @@
package mineplex.core.report.task; package mineplex.core.report;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -13,21 +13,19 @@ import mineplex.core.common.jsonchat.HoverEvent;
import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.report.Report;
import mineplex.core.report.ReportCategory;
import mineplex.core.report.ReportManager;
import mineplex.core.report.ReportMessage;
import mineplex.core.report.command.ReportHandlerNotification; import mineplex.core.report.command.ReportHandlerNotification;
import mineplex.core.report.data.Report;
import mineplex.core.report.data.ReportMessage;
/** /**
* Displays a message containing up-to-date details of a report to it's handler. * Displays a message containing up-to-date details of a report to it's handler.
*/ */
public class ReportHandlerMessageTask extends BukkitRunnable public class ReportHandlerMessenger extends BukkitRunnable
{ {
private final ReportManager _reportManager; private final ReportManager _reportManager;
private final Report _report; private final Report _report;
public ReportHandlerMessageTask(ReportManager reportManager, Report report) public ReportHandlerMessenger(ReportManager reportManager, Report report)
{ {
_reportManager = reportManager; _reportManager = reportManager;
_report = report; _report = report;

View File

@ -17,7 +17,11 @@ import mineplex.core.common.util.F;
import mineplex.core.portal.Portal; import mineplex.core.portal.Portal;
import mineplex.core.report.command.ReportHandlerNotification; import mineplex.core.report.command.ReportHandlerNotification;
import mineplex.core.report.command.ReportNotificationCallback; import mineplex.core.report.command.ReportNotificationCallback;
import mineplex.core.report.task.ReportHandlerMessageTask; import mineplex.core.report.data.Report;
import mineplex.core.report.data.ReportMessage;
import mineplex.core.report.data.ReportProfile;
import mineplex.core.report.data.ReportProfileRepository;
import mineplex.core.report.data.ReportRepository;
import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.commands.ServerCommandManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -159,7 +163,7 @@ public class ReportManager
saveReport(report).thenAccept(reportId2 -> saveReport(report).thenAccept(reportId2 ->
{ {
// Show user details of the report every x seconds // Show user details of the report every x seconds
new ReportHandlerMessageTask(this, report).runTaskTimer(_plugin, 1L, 20L * 10); new ReportHandlerMessenger(this, report).runTaskTimer(_plugin, 1L, 20L * 10);
}); });
Portal.transferPlayer(reportHandler.getName(), report.getLatestMessage().getServer()); Portal.transferPlayer(reportHandler.getName(), report.getLatestMessage().getServer());

View File

@ -11,10 +11,10 @@ import mineplex.core.common.util.BukkitFuture;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.report.Report; import mineplex.core.report.data.Report;
import mineplex.core.report.ReportManager; import mineplex.core.report.ReportManager;
import mineplex.core.report.ReportPlugin; import mineplex.core.report.ReportPlugin;
import mineplex.core.report.ReportRepository; import mineplex.core.report.data.ReportRepository;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,8 +1,8 @@
package mineplex.core.report.command; package mineplex.core.report.command;
import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.report.Report; import mineplex.core.report.data.Report;
import mineplex.core.report.ReportMessage; import mineplex.core.report.data.ReportMessage;
/** /**
* A message regarding a report which is sent only to the player handling the report. * A message regarding a report which is sent only to the player handling the report.

View File

@ -1,10 +1,13 @@
package mineplex.core.report; package mineplex.core.report.data;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import mineplex.core.report.ReportCategory;
import mineplex.core.report.ReportResult;
/** /**
* Holds data for a Report. * Holds data for a Report.
*/ */

View File

@ -1,8 +1,9 @@
package mineplex.core.report; package mineplex.core.report.data;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import mineplex.core.report.data.Report;
import static com.google.common.base.Preconditions.*; import static com.google.common.base.Preconditions.*;
/** /**

View File

@ -1,10 +1,12 @@
package mineplex.core.report; package mineplex.core.report.data;
import java.util.Collections; import java.util.Collections;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.Map; import java.util.Map;
import com.google.common.collect.TreeBasedTable; import com.google.common.collect.TreeBasedTable;
import mineplex.core.report.ReportCategory;
import mineplex.core.report.ReportResultType;
/** /**
* Holds report specific data for a user. * Holds report specific data for a user.

View File

@ -1,4 +1,4 @@
package mineplex.core.report; package mineplex.core.report.data;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -13,6 +13,8 @@ import java.util.stream.Collectors;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import mineplex.core.report.ReportCategory;
import mineplex.core.report.ReportResultType;
import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.DBPool;
/** /**

View File

@ -1,4 +1,4 @@
package mineplex.core.report; package mineplex.core.report.data;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -27,6 +27,10 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.mysql.jdbc.Statement; import com.mysql.jdbc.Statement;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.report.ReportCategory;
import mineplex.core.report.ReportManager;
import mineplex.core.report.ReportResult;
import mineplex.core.report.ReportResultType;
import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.DBPool;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -509,7 +513,7 @@ public class ReportRepository
* *
* @param accountId the account id to clean the cached reports of * @param accountId the account id to clean the cached reports of
*/ */
protected void clearCacheFor(int accountId) public void clearCacheFor(int accountId)
{ {
Iterator<Report> iterator = _cachedReports.asMap().values().iterator(); Iterator<Report> iterator = _cachedReports.asMap().values().iterator();
@ -547,7 +551,7 @@ public class ReportRepository
} }
} }
protected void clearCache(long reportId) public void clearCache(long reportId)
{ {
_cachedReports.invalidate(reportId); _cachedReports.invalidate(reportId);
} }