Add "ShowUserReports" preference (however currently not visible to players nor does it get saved to the DB currently).
Fix variable names in ReportManager.
This commit is contained in:
parent
0c0b3708c6
commit
fd2a543418
|
@ -12,6 +12,7 @@ public class UserPreferences
|
||||||
public boolean Invisibility = false;
|
public boolean Invisibility = false;
|
||||||
public boolean HubForcefield = false;
|
public boolean HubForcefield = false;
|
||||||
public boolean ShowMacReports = false;
|
public boolean ShowMacReports = false;
|
||||||
|
public boolean ShowUserReports = false;
|
||||||
public boolean IgnoreVelocity = false;
|
public boolean IgnoreVelocity = false;
|
||||||
public boolean PendingFriendRequests = true;
|
public boolean PendingFriendRequests = true;
|
||||||
public boolean friendDisplayInventoryUI = true;
|
public boolean friendDisplayInventoryUI = true;
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||||
private IButton _toggleHubForcefield;
|
private IButton _toggleHubForcefield;
|
||||||
private IButton _toggleHubIgnoreVelocity;
|
private IButton _toggleHubIgnoreVelocity;
|
||||||
private IButton _toggleMacReports;
|
private IButton _toggleMacReports;
|
||||||
|
private IButton _toggleUserReports;
|
||||||
|
|
||||||
private boolean _hubGamesToggled;
|
private boolean _hubGamesToggled;
|
||||||
private boolean _hubPlayersToggled;
|
private boolean _hubPlayersToggled;
|
||||||
|
@ -36,6 +37,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||||
private boolean _hubInvisibilityToggled;
|
private boolean _hubInvisibilityToggled;
|
||||||
private boolean _hubForcefieldToggled;
|
private boolean _hubForcefieldToggled;
|
||||||
private boolean _macReportsToggled;
|
private boolean _macReportsToggled;
|
||||||
|
private boolean _userReportsToggled;
|
||||||
private boolean _hubIgnoreVelocityToggled;
|
private boolean _hubIgnoreVelocityToggled;
|
||||||
|
|
||||||
public PreferencesPage(PreferencesManager plugin, PreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
|
public PreferencesPage(PreferencesManager plugin, PreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
|
||||||
|
@ -129,6 +131,15 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_toggleUserReports = new IButton()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(Player player, ClickType clickType)
|
||||||
|
{
|
||||||
|
toggleUserReports(player);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
_toggleHubIgnoreVelocity = new IButton()
|
_toggleHubIgnoreVelocity = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -233,6 +244,13 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||||
buildPage();
|
buildPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void toggleUserReports(org.bukkit.entity.Player player)
|
||||||
|
{
|
||||||
|
getPlugin().Get(player).ShowUserReports = !getPlugin().Get(player).ShowUserReports;
|
||||||
|
_userReportsToggled = !_userReportsToggled;
|
||||||
|
buildPage();
|
||||||
|
}
|
||||||
|
|
||||||
protected void toggleHubIgnoreVelocity(org.bukkit.entity.Player player)
|
protected void toggleHubIgnoreVelocity(org.bukkit.entity.Player player)
|
||||||
{
|
{
|
||||||
getPlugin().Get(player).IgnoreVelocity = !getPlugin().Get(player).IgnoreVelocity;
|
getPlugin().Get(player).IgnoreVelocity = !getPlugin().Get(player).IgnoreVelocity;
|
||||||
|
@ -282,6 +300,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||||
buildPreference(38, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
|
buildPreference(38, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
|
||||||
buildPreference(42, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
buildPreference(42, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||||
buildPreference(44, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
buildPreference(44, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||||
|
// TODO: add user reports button
|
||||||
}
|
}
|
||||||
else if (getClientManager().Get(getPlayer()).GetRank() == Rank.YOUTUBE || getClientManager().Get(getPlayer()).GetRank() == Rank.TWITCH)
|
else if (getClientManager().Get(getPlayer()).GetRank() == Rank.YOUTUBE || getClientManager().Get(getPlayer()).GetRank() == Rank.TWITCH)
|
||||||
{
|
{
|
||||||
|
@ -293,6 +312,6 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||||
|
|
||||||
public boolean preferencesChanged()
|
public boolean preferencesChanged()
|
||||||
{
|
{
|
||||||
return _hubGamesToggled || _hubPlayersToggled || _hubChatToggled || _hubPrivateChatToggled || _hubPartyRequestsToggled || _hubInvisibilityToggled || _hubForcefieldToggled || _pendingFriendRequestsToggled;
|
return _hubGamesToggled || _hubPlayersToggled || _hubChatToggled || _hubPrivateChatToggled || _hubPartyRequestsToggled || _hubInvisibilityToggled || _hubForcefieldToggled || _pendingFriendRequestsToggled && _userReportsToggled;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,9 +6,11 @@ import java.util.Map.Entry;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.command.CommandCenter;
|
import mineplex.core.command.CommandCenter;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.jsonchat.ClickEvent;
|
import mineplex.core.common.jsonchat.ClickEvent;
|
||||||
import mineplex.core.common.jsonchat.JsonMessage;
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
import mineplex.core.portal.Portal;
|
import mineplex.core.portal.Portal;
|
||||||
|
import mineplex.core.preferences.PreferencesManager;
|
||||||
import mineplex.core.report.command.ReportNotification;
|
import mineplex.core.report.command.ReportNotification;
|
||||||
import mineplex.serverdata.Region;
|
import mineplex.serverdata.Region;
|
||||||
import mineplex.serverdata.Utility;
|
import mineplex.serverdata.Utility;
|
||||||
|
@ -30,27 +32,29 @@ import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||||
*/
|
*/
|
||||||
public class ReportManager {
|
public class ReportManager {
|
||||||
|
|
||||||
private String serverName;
|
private PreferencesManager _preferencesManager;
|
||||||
|
private String _serverName;
|
||||||
|
|
||||||
// Holds active/open reports in a synchronized database.
|
// Holds active/open reports in a synchronized database.
|
||||||
private DataRepository<Report> reportRepository;
|
private DataRepository<Report> _reportRepository;
|
||||||
|
|
||||||
private DataRepository<ReportProfile> reportProfiles;
|
private DataRepository<ReportProfile> _reportProfiles;
|
||||||
|
|
||||||
// Stores/logs closed tickets, and various reporter/staff actions.
|
// Stores/logs closed tickets, and various reporter/staff actions.
|
||||||
private ReportRepository reportSqlRepository;
|
private ReportRepository _reportSqlRepository;
|
||||||
|
|
||||||
// A mapping of PlayerName(String) to the ReportId(Integer) for all active reports on this server.
|
// A mapping of PlayerName(String) to the ReportId(Integer) for all active reports on this server.
|
||||||
private Map<String, Integer> activeReports;
|
private Map<String, Integer> _activeReports;
|
||||||
|
|
||||||
public ReportManager(JavaPlugin plugin, String serverName)
|
public ReportManager(JavaPlugin plugin, PreferencesManager preferencesManager, String serverName)
|
||||||
{
|
{
|
||||||
this.serverName = serverName;
|
_preferencesManager = preferencesManager;
|
||||||
this.reportRepository = new RedisDataRepository<Report>(Region.ALL, Report.class, "reports");
|
_serverName = serverName;
|
||||||
this.reportProfiles = new RedisDataRepository<ReportProfile>(Region.ALL, ReportProfile.class, "reportprofiles");
|
_reportRepository = new RedisDataRepository<Report>(Region.ALL, Report.class, "reports");
|
||||||
this.activeReports = new HashMap<String, Integer>();
|
_reportProfiles = new RedisDataRepository<ReportProfile>(Region.ALL, ReportProfile.class, "reportprofiles");
|
||||||
this.reportSqlRepository = new ReportRepository(plugin);
|
_activeReports = new HashMap<String, Integer>();
|
||||||
reportSqlRepository.initialize();
|
_reportSqlRepository = new ReportRepository(plugin);
|
||||||
|
_reportSqlRepository.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retrieveReportResult(int reportId, Player reportCloser, String reason)
|
public void retrieveReportResult(int reportId, Player reportCloser, String reason)
|
||||||
|
@ -71,13 +75,13 @@ public class ReportManager {
|
||||||
if (isActiveReport(reportId))
|
if (isActiveReport(reportId))
|
||||||
{
|
{
|
||||||
Report report = getReport(reportId);
|
Report report = getReport(reportId);
|
||||||
reportRepository.removeElement(String.valueOf(reportId)); // Remove report from redis database
|
_reportRepository.removeElement(String.valueOf(reportId)); // Remove report from redis database
|
||||||
removeActiveReport(reportId);
|
removeActiveReport(reportId);
|
||||||
|
|
||||||
int closerId = reportCloser != null ? getPlayerAccount(reportCloser).getAccountId() : -1;
|
int closerId = reportCloser != null ? getPlayerAccount(reportCloser).getAccountId() : -1;
|
||||||
String playerName = getReport(reportId).getPlayerName();
|
String playerName = getReport(reportId).getPlayerName();
|
||||||
int playerId = getPlayerAccount(playerName).getAccountId();
|
int playerId = getPlayerAccount(playerName).getAccountId();
|
||||||
reportSqlRepository.logReport(reportId, playerId, serverName, closerId, result, reason);
|
_reportSqlRepository.logReport(reportId, playerId, _serverName, closerId, result, reason);
|
||||||
|
|
||||||
// Update the reputation/profiles of all reporters on this closing report.
|
// Update the reputation/profiles of all reporters on this closing report.
|
||||||
for (String reporterName : report.getReporters())
|
for (String reporterName : report.getReporters())
|
||||||
|
@ -85,7 +89,7 @@ public class ReportManager {
|
||||||
CoreClient reporterAccount = getPlayerAccount(reporterName);
|
CoreClient reporterAccount = getPlayerAccount(reporterName);
|
||||||
ReportProfile reportProfile = getReportProfile(String.valueOf(reporterAccount.getAccountId()));
|
ReportProfile reportProfile = getReportProfile(String.valueOf(reporterAccount.getAccountId()));
|
||||||
reportProfile.onReportClose(result);
|
reportProfile.onReportClose(result);
|
||||||
reportProfiles.addElement(reportProfile);
|
_reportProfiles.addElement(reportProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reportCloser != null)
|
if (reportCloser != null)
|
||||||
|
@ -95,12 +99,11 @@ public class ReportManager {
|
||||||
reportCloser.getName(), result.toDisplayMessage()));
|
reportCloser.getName(), result.toDisplayMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleReport(int reportId, Player reportHandler)
|
public void handleReport(int reportId, Player reportHandler)
|
||||||
{
|
{
|
||||||
if (reportRepository.elementExists(String.valueOf(reportId)))
|
if (_reportRepository.elementExists(String.valueOf(reportId)))
|
||||||
{
|
{
|
||||||
Report report = getReport(reportId);
|
Report report = getReport(reportId);
|
||||||
Portal.transferPlayer(reportHandler.getName(), report.getServerName());
|
Portal.transferPlayer(reportHandler.getName(), report.getServerName());
|
||||||
|
@ -111,7 +114,7 @@ public class ReportManager {
|
||||||
// with info about the case/report.
|
// with info about the case/report.
|
||||||
|
|
||||||
int handlerId = getPlayerAccount(reportHandler).getAccountId();
|
int handlerId = getPlayerAccount(reportHandler).getAccountId();
|
||||||
reportSqlRepository.logReportHandling(reportId, handlerId); // Log handling into sql database
|
_reportSqlRepository.logReportHandling(reportId, handlerId); // Log handling into sql database
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,10 +135,10 @@ public class ReportManager {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reportId = generateReportId();
|
reportId = generateReportId();
|
||||||
report = new Report(reportId, reportedPlayer.getName(), serverName, category);
|
report = new Report(reportId, reportedPlayer.getName(), _serverName, category);
|
||||||
report.addReporter(reporter.getName());
|
report.addReporter(reporter.getName());
|
||||||
activeReports.put(reportedPlayer.getName().toLowerCase(), report.getReportId());
|
_activeReports.put(reportedPlayer.getName().toLowerCase(), report.getReportId());
|
||||||
reportRepository.addElement(report);
|
_reportRepository.addElement(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
// only start notifying staff when
|
// only start notifying staff when
|
||||||
|
@ -156,7 +159,7 @@ public class ReportManager {
|
||||||
sendReportNotification(clickableMessage);
|
sendReportNotification(clickableMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
reportSqlRepository.logReportSending(report.getReportId(), reporterId, category, reason);
|
_reportSqlRepository.logReportSending(report.getReportId(), reporterId, category, reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +175,7 @@ public class ReportManager {
|
||||||
|
|
||||||
public ReportProfile getReportProfile(String playerName)
|
public ReportProfile getReportProfile(String playerName)
|
||||||
{
|
{
|
||||||
ReportProfile profile = reportProfiles.getElement(playerName);
|
ReportProfile profile = _reportProfiles.getElement(playerName);
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
|
@ -185,7 +188,7 @@ public class ReportManager {
|
||||||
|
|
||||||
private void saveReportProfile(ReportProfile profile)
|
private void saveReportProfile(ReportProfile profile)
|
||||||
{
|
{
|
||||||
reportProfiles.addElement(profile);
|
_reportProfiles.addElement(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,7 +223,7 @@ public class ReportManager {
|
||||||
|
|
||||||
public Report getReport(int reportId)
|
public Report getReport(int reportId)
|
||||||
{
|
{
|
||||||
return reportRepository.getElement(String.valueOf(reportId));
|
return _reportRepository.getElement(String.valueOf(reportId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private CoreClient getPlayerAccount(Player player)
|
private CoreClient getPlayerAccount(Player player)
|
||||||
|
@ -244,10 +247,9 @@ public class ReportManager {
|
||||||
*/
|
*/
|
||||||
public boolean hasReportNotifications(Player player)
|
public boolean hasReportNotifications(Player player)
|
||||||
{
|
{
|
||||||
// If player is not staff, return false.
|
boolean isStaff = CommandCenter.Instance.GetClientManager().Get(player).GetRank().has(Rank.HELPER);
|
||||||
// If player is staff but has report notifications pref disabled, return false;
|
boolean hasReportNotifications = _preferencesManager.Get(player).ShowUserReports;
|
||||||
// Else return true.
|
return isStaff && hasReportNotifications;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -277,9 +279,9 @@ public class ReportManager {
|
||||||
*/
|
*/
|
||||||
public int getActiveReport(String playerName)
|
public int getActiveReport(String playerName)
|
||||||
{
|
{
|
||||||
if (activeReports.containsKey(playerName.toLowerCase()))
|
if (_activeReports.containsKey(playerName.toLowerCase()))
|
||||||
{
|
{
|
||||||
return activeReports.get(playerName.toLowerCase());
|
return _activeReports.get(playerName.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -292,7 +294,7 @@ public class ReportManager {
|
||||||
|
|
||||||
public boolean isActiveReport(int reportId)
|
public boolean isActiveReport(int reportId)
|
||||||
{
|
{
|
||||||
for (Entry<String, Integer> activeReport : activeReports.entrySet())
|
for (Entry<String, Integer> activeReport : _activeReports.entrySet())
|
||||||
{
|
{
|
||||||
if (activeReport.getValue() == reportId)
|
if (activeReport.getValue() == reportId)
|
||||||
{
|
{
|
||||||
|
@ -305,11 +307,11 @@ public class ReportManager {
|
||||||
|
|
||||||
public boolean removeActiveReport(int reportId)
|
public boolean removeActiveReport(int reportId)
|
||||||
{
|
{
|
||||||
for (Entry<String, Integer> activeReport : activeReports.entrySet())
|
for (Entry<String, Integer> activeReport : _activeReports.entrySet())
|
||||||
{
|
{
|
||||||
if (activeReport.getValue() == reportId)
|
if (activeReport.getValue() == reportId)
|
||||||
{
|
{
|
||||||
activeReports.remove(activeReport.getKey());
|
_activeReports.remove(activeReport.getKey());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class Hub extends JavaPlugin implements IRelation
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
new GlobalPacketManager(this, clientManager, serverStatusManager);
|
new GlobalPacketManager(this, clientManager, serverStatusManager);
|
||||||
new ReportPlugin(this, new ReportManager(this, serverStatusManager.getCurrentServerName()));
|
new ReportPlugin(this, new ReportManager(this, preferenceManager, serverStatusManager.getCurrentServerName()));
|
||||||
//new Replay(this, packetHandler);
|
//new Replay(this, packetHandler);
|
||||||
|
|
||||||
AprilFoolsManager.Initialize(this, clientManager, disguiseManager);
|
AprilFoolsManager.Initialize(this, clientManager, disguiseManager);
|
||||||
|
|
Loading…
Reference in New Issue