Ran a code inspection and implemented some suggested changes
This commit is contained in:
parent
7e33558e2d
commit
d67082bca2
@ -8,7 +8,7 @@ public enum MessageType
|
||||
CHAT(0),
|
||||
PM(1);
|
||||
|
||||
private int _id;
|
||||
private final int _id;
|
||||
|
||||
MessageType(int id)
|
||||
{
|
||||
|
@ -18,11 +18,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class Snapshot implements Comparable<Snapshot>
|
||||
{
|
||||
protected Long _id = null;
|
||||
private MessageType _messageType;
|
||||
private int _senderId;
|
||||
private Collection<Integer> _recipientIds;
|
||||
private String _message;
|
||||
private LocalDateTime _time;
|
||||
private final MessageType _messageType;
|
||||
private final int _senderId;
|
||||
private final Collection<Integer> _recipientIds;
|
||||
private final String _message;
|
||||
private final LocalDateTime _time;
|
||||
|
||||
public Snapshot(int senderId, int recipientId, String message)
|
||||
{
|
||||
|
@ -2,7 +2,6 @@ package mineplex.core.chatsnap;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -11,7 +11,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.mysql.jdbc.Statement;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
|
||||
|
@ -1,24 +1,14 @@
|
||||
package mineplex.core.report;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.chatsnap.Snapshot;
|
||||
import mineplex.core.chatsnap.SnapshotManager;
|
||||
import mineplex.core.chatsnap.SnapshotRepository;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
|
@ -3,7 +3,6 @@ package mineplex.core.report;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
|
@ -7,7 +7,6 @@ import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -16,9 +15,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
|
||||
/**
|
||||
* Created by ikeirnez on 01/05/16.
|
||||
*/
|
||||
public class ReportProfileRepository extends MinecraftRepository
|
||||
{
|
||||
// todo test this query
|
||||
|
@ -8,7 +8,7 @@ import mineplex.serverdata.commands.ServerCommand;
|
||||
*/
|
||||
public class ReportNotification extends ServerCommand
|
||||
{
|
||||
private String _notification; // in json format
|
||||
private final String _notification; // in json format
|
||||
|
||||
public ReportNotification(String notification)
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ import mineplex.serverdata.commands.ServerCommand;
|
||||
*/
|
||||
public class ReportNotificationCallback implements CommandCallback
|
||||
{
|
||||
private ReportManager _reportManager;
|
||||
private final ReportManager _reportManager;
|
||||
|
||||
public ReportNotificationCallback(ReportManager reportManager)
|
||||
{
|
||||
|
@ -21,8 +21,8 @@ public class ReportHandlerMessageTask extends BukkitRunnable
|
||||
{
|
||||
private static final String DECORATION = C.cAqua + "------------------------------------";
|
||||
|
||||
private ReportManager _reportManager;
|
||||
private Report _report;
|
||||
private final ReportManager _reportManager;
|
||||
private final Report _report;
|
||||
|
||||
public ReportHandlerMessageTask(ReportManager reportManager, Report report)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ import mineplex.core.report.ReportCategory;
|
||||
public class ReportCategoryButton extends SimpleGuiItem
|
||||
{
|
||||
// initialize the display items we use
|
||||
private static Map<ReportCategory, ItemStack> ITEM_STACKS = new EnumMap<ReportCategory, ItemStack>(ReportCategory.class)
|
||||
private static final Map<ReportCategory, ItemStack> ITEM_STACKS = new EnumMap<ReportCategory, ItemStack>(ReportCategory.class)
|
||||
{{
|
||||
ItemStack itemHack = new ItemBuilder(Material.IRON_SWORD)
|
||||
.setTitle(C.cRedB + "Hacking")
|
||||
@ -33,8 +33,8 @@ public class ReportCategoryButton extends SimpleGuiItem
|
||||
put(ReportCategory.CHAT_ABUSE, itemChatAbuse);
|
||||
}};
|
||||
|
||||
private ReportCategoryPage _reportCategoryPage;
|
||||
private ReportCategory _category;
|
||||
private final ReportCategoryPage _reportCategoryPage;
|
||||
private final ReportCategory _category;
|
||||
|
||||
public ReportCategoryButton(ReportCategoryPage reportCategoryPage, ReportCategory reportCategory)
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ package mineplex.core.report.ui;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -24,10 +25,10 @@ public class ReportCategoryPage extends SimpleGui
|
||||
put(rowStartSlot + 5, ReportCategory.CHAT_ABUSE);
|
||||
}});
|
||||
|
||||
private ReportPlugin _reportPlugin;
|
||||
private Player _reporter;
|
||||
private Player _offender;
|
||||
private String _reason;
|
||||
private final ReportPlugin _reportPlugin;
|
||||
private final Player _reporter;
|
||||
private final Player _offender;
|
||||
private final String _reason;
|
||||
|
||||
public ReportCategoryPage(ReportPlugin reportPlugin, Player reporter, Player offender, String reason)
|
||||
{
|
||||
@ -57,11 +58,20 @@ public class ReportCategoryPage extends SimpleGui
|
||||
|
||||
_reportPlugin.getReportManager().reportPlayer(_reporter, _offender, category, _reason)
|
||||
.thenAccept(report -> {
|
||||
if (report != null && report.getReportId().isPresent())
|
||||
boolean error = true;
|
||||
|
||||
if (report != null)
|
||||
{
|
||||
_reporter.sendMessage(C.cGreen + "Report sent successfully (" + C.cGold + "#" + report.getReportId().get() + C.cGreen + ").");
|
||||
Optional<Long> reportIdOptional = report.getReportId();
|
||||
|
||||
if (reportIdOptional.isPresent())
|
||||
{
|
||||
_reporter.sendMessage(C.cGreen + "Report sent successfully (" + C.cGold + "#" + reportIdOptional.get() + C.cGreen + ").");
|
||||
error = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (error)
|
||||
{
|
||||
_reporter.sendMessage(C.cRed + "An error occurred whilst reporting that player, please try again.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user