Small refactoring

This commit is contained in:
Keir Nellyer 2016-10-26 10:50:49 +01:00
parent a97ad8dd76
commit 79b5439aa4
9 changed files with 20 additions and 20 deletions

View File

@ -18,17 +18,17 @@ import mineplex.core.report.command.ReportMetricsCommand;
*/
public class ReportPlugin extends MiniPlugin
{
private final ReportManager _reportManager;
private final ReportManager _manager;
public ReportPlugin(JavaPlugin plugin, ReportManager reportManager)
public ReportPlugin(JavaPlugin plugin, ReportManager manager)
{
super("Report", plugin);
_reportManager = reportManager;
_manager = manager;
}
public ReportManager getReportManager()
public ReportManager getManager()
{
return _reportManager;
return _manager;
}
@Override
@ -45,12 +45,12 @@ public class ReportPlugin extends MiniPlugin
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e)
{
_reportManager.onPlayerJoin(e.getPlayer());
_manager.onPlayerJoin(e.getPlayer());
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e)
{
_reportManager.onPlayerQuit(e.getPlayer());
_manager.onPlayerQuit(e.getPlayer());
}
}

View File

@ -35,7 +35,7 @@ public class ReportCloseCommand extends CommandBase<ReportPlugin>
else
{
String reason = F.combine(args, 0, null, false);
ReportManager reportManager = Plugin.getReportManager();
ReportManager reportManager = Plugin.getManager();
reportManager.getReportHandling(player).whenComplete((reportOptional, throwable) ->
{

View File

@ -35,7 +35,7 @@ public class ReportCommand extends CommandBase<ReportPlugin>
}
else
{
ReportManager reportManager = Plugin.getReportManager();
ReportManager reportManager = Plugin.getManager();
boolean canReport = reportManager.canReport(reporter);
if (canReport)

View File

@ -32,13 +32,13 @@ public class ReportHistoryCommand extends CommandBase<ReportPlugin>
{
String playerName = args[0];
Plugin.getReportManager().getRepository().getAccountId(playerName).thenAccept(accountIdOptional ->
Plugin.getManager().getRepository().getAccountId(playerName).thenAccept(accountIdOptional ->
{
if (accountIdOptional.isPresent())
{
int accountId = accountIdOptional.get();
Plugin.getReportManager().getRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats ->
Plugin.getManager().getRepository().getAccountStatistics(accountId).thenCompose(BukkitFuture.accept(stats ->
{
UtilPlayer.message(player, F.main(Plugin.getName(), "Report History for " + F.elem(playerName)));

View File

@ -42,7 +42,7 @@ public class ReportInfoCommand extends CommandBase<ReportPlugin>
{
long reportId = Long.parseLong(args[0]);
ReportManager reportManager = Plugin.getReportManager();
ReportManager reportManager = Plugin.getManager();
ReportRepository repository = reportManager.getRepository();
repository.getReport(reportId).thenAccept(reportOptional ->

View File

@ -50,7 +50,7 @@ public class ReportMetricsCommand extends CommandBase<ReportPlugin>
}
int finalDays = days;
Plugin.getReportManager().getRepository().getAccountId(targetName).thenAccept(targetIdOptional ->
Plugin.getManager().getRepository().getAccountId(targetName).thenAccept(targetIdOptional ->
{
if (targetIdOptional.isPresent())
{
@ -105,7 +105,7 @@ public class ReportMetricsCommand extends CommandBase<ReportPlugin>
public void displayGlobalMetrics(Player player, int days)
{
Plugin.getReportManager().getMetricsRepository().getGlobalMetrics(days).thenCompose(
Plugin.getManager().getMetricsRepository().getGlobalMetrics(days).thenCompose(
BukkitFuture.accept(globalMetrics ->
{
UtilPlayer.message(player, F.main("Report Metrics", "Submitted: " + F.elem(globalMetrics.getSubmitted())));
@ -116,7 +116,7 @@ public class ReportMetricsCommand extends CommandBase<ReportPlugin>
public void displayUserMetrics(Player player, String targetName, int targetId, int days)
{
Plugin.getReportManager().getMetricsRepository().getUserMetrics(targetId, days).thenCompose(
Plugin.getManager().getMetricsRepository().getUserMetrics(targetId, days).thenCompose(
BukkitFuture.accept(userMetrics ->
{
UtilPlayer.message(player,

View File

@ -69,7 +69,7 @@ public class ReportCreatePage extends SimpleGui implements ReportCategoryCallba
private boolean hasSentMessage(int accountId)
{
SnapshotManager snapshotManager = _plugin.getReportManager().getSnapshotManager();
SnapshotManager snapshotManager = _plugin.getManager().getSnapshotManager();
int suspectId = _suspect.getAccountId();
List<SnapshotMessage> suspectMessages = snapshotManager.getMessagesFrom(accountId).stream()
.filter(message -> message.getSenderId() == suspectId || message.getRecipientIds().contains(suspectId))
@ -80,7 +80,7 @@ public class ReportCreatePage extends SimpleGui implements ReportCategoryCallba
private void createReport(ReportCategory category)
{
_plugin.getReportManager().createReport(_reporterId, _suspect.getAccountId(), category, _reason)
_plugin.getManager().createReport(_reporterId, _suspect.getAccountId(), category, _reason)
.thenAccept(report -> {
boolean error = true;

View File

@ -38,7 +38,7 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac
_plugin = plugin;
_handler = handler;
_handlerId = handlerId;
_region = plugin.getReportManager().getRegion();
_region = plugin.getManager().getRegion();
buildPage();
}
@ -59,7 +59,7 @@ public class ReportHandlePage extends SimpleGui implements ReportCategoryCallbac
public void handleReport(ReportCategory category)
{
ReportManager reportManager = _plugin.getReportManager();
ReportManager reportManager = _plugin.getManager();
ReportRepository reportRepository = reportManager.getRepository();
reportManager.isHandlingReport(_handler).whenComplete((handlingReport, throwable) ->

View File

@ -31,7 +31,7 @@ public class ReportResultPage extends SimpleGui
{
super(plugin.getPlugin(), reportCloser, "Close Report", 9 * 4);
_plugin = plugin;
_reportManager = plugin.getReportManager();
_reportManager = plugin.getManager();
_report = report;
_suspectName = suspectName;
_reason = reason;