Completely remove old staff notifications system
This commit is contained in:
parent
dc566c8fb3
commit
58df3022a5
@ -23,10 +23,9 @@ public class PreferencesRepository extends MinecraftRepository
|
|||||||
// privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL
|
// privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL
|
||||||
// DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL
|
// DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL
|
||||||
// DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL
|
// DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL
|
||||||
// NOT NULL DEFAULT 0, showUserReports BOOL NOT NULL DEFAULT 0, PRIMARY
|
// NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||||
// KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
|
||||||
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
||||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ?, hubMusic = ?, disableAds = ?, showUserReports = ? WHERE uuid=?;";
|
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ?, hubMusic = ?, disableAds = ? WHERE uuid=?;";
|
||||||
|
|
||||||
public PreferencesRepository(JavaPlugin plugin)
|
public PreferencesRepository(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
@ -65,7 +64,6 @@ public class PreferencesRepository extends MinecraftRepository
|
|||||||
preparedStatement.setBoolean(13, entry.getValue().ClanTips);
|
preparedStatement.setBoolean(13, entry.getValue().ClanTips);
|
||||||
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
|
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
|
||||||
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
|
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
|
||||||
preparedStatement.setBoolean(16, entry.getValue().ShowUserReports);
|
|
||||||
System.out.println(">> " + entry.getValue().ClanTips);
|
System.out.println(">> " + entry.getValue().ClanTips);
|
||||||
preparedStatement.setString(17, entry.getKey());
|
preparedStatement.setString(17, entry.getKey());
|
||||||
|
|
||||||
@ -96,7 +94,6 @@ public class PreferencesRepository extends MinecraftRepository
|
|||||||
preparedStatement.setBoolean(13, entry.getValue().ClanTips);
|
preparedStatement.setBoolean(13, entry.getValue().ClanTips);
|
||||||
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
|
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
|
||||||
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
|
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
|
||||||
preparedStatement.setBoolean(16, entry.getValue().ShowUserReports);
|
|
||||||
System.out.println(">> " + entry.getValue().ClanTips);
|
System.out.println(">> " + entry.getValue().ClanTips);
|
||||||
preparedStatement.setString(17, entry.getKey());
|
preparedStatement.setString(17, entry.getKey());
|
||||||
preparedStatement.execute();
|
preparedStatement.execute();
|
||||||
@ -132,7 +129,6 @@ public class PreferencesRepository extends MinecraftRepository
|
|||||||
preferences.ClanTips = resultSet.getBoolean(13);
|
preferences.ClanTips = resultSet.getBoolean(13);
|
||||||
preferences.HubMusic = resultSet.getBoolean(14);
|
preferences.HubMusic = resultSet.getBoolean(14);
|
||||||
preferences.DisableAds = resultSet.getBoolean(15);
|
preferences.DisableAds = resultSet.getBoolean(15);
|
||||||
preferences.ShowUserReports = resultSet.getBoolean(16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return preferences;
|
return preferences;
|
||||||
|
@ -12,7 +12,6 @@ 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;
|
||||||
|
@ -24,13 +24,11 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
|||||||
private IButton _toggleHubForcefield;
|
private IButton _toggleHubForcefield;
|
||||||
private IButton _toggleHubIgnoreVelocity;
|
private IButton _toggleHubIgnoreVelocity;
|
||||||
private IButton _toggleMacReports;
|
private IButton _toggleMacReports;
|
||||||
private IButton _toggleUserReports;
|
|
||||||
|
|
||||||
private boolean _hubInvisibilityToggled;
|
private boolean _hubInvisibilityToggled;
|
||||||
private boolean _hubForcefieldToggled;
|
private boolean _hubForcefieldToggled;
|
||||||
private boolean _hubIgnoreVelocityToggled;
|
private boolean _hubIgnoreVelocityToggled;
|
||||||
private boolean _macReportsToggled;
|
private boolean _macReportsToggled;
|
||||||
private boolean _userReportsToggled;
|
|
||||||
|
|
||||||
private PreferencesShop _preferencesShop;
|
private PreferencesShop _preferencesShop;
|
||||||
|
|
||||||
@ -73,15 +71,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_toggleUserReports = new IButton()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(Player player, ClickType clickType)
|
|
||||||
{
|
|
||||||
toggleUserReports(player);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
_toggleHubIgnoreVelocity = new IButton()
|
_toggleHubIgnoreVelocity = new IButton()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -128,7 +117,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
|||||||
buildPreference(indices[1], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
|
buildPreference(indices[1], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
|
||||||
buildPreference(indices[2], Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
buildPreference(indices[2], Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||||
buildPreference(indices[3], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
buildPreference(indices[3], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||||
buildPreference(indices[4], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports);
|
|
||||||
}
|
}
|
||||||
else if (rank.has(Rank.MODERATOR))
|
else if (rank.has(Rank.MODERATOR))
|
||||||
{
|
{
|
||||||
@ -136,7 +124,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
|||||||
|
|
||||||
buildPreference(indices[0], Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
buildPreference(indices[0], Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||||
buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||||
buildPreference(indices[2], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports);
|
|
||||||
}
|
}
|
||||||
else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH)
|
else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH)
|
||||||
{
|
{
|
||||||
@ -193,13 +180,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
|||||||
buildPage();
|
buildPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleUserReports(org.bukkit.entity.Player player)
|
|
||||||
{
|
|
||||||
getPlugin().Get(player).ShowUserReports = !getPlugin().Get(player).ShowUserReports;
|
|
||||||
_userReportsToggled = !_userReportsToggled;
|
|
||||||
buildPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toggleHubIgnoreVelocity(org.bukkit.entity.Player player)
|
private void toggleHubIgnoreVelocity(org.bukkit.entity.Player player)
|
||||||
{
|
{
|
||||||
getPlugin().Get(player).IgnoreVelocity = !getPlugin().Get(player).IgnoreVelocity;
|
getPlugin().Get(player).IgnoreVelocity = !getPlugin().Get(player).IgnoreVelocity;
|
||||||
@ -222,6 +202,6 @@ public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, E
|
|||||||
|
|
||||||
public boolean preferencesChanged()
|
public boolean preferencesChanged()
|
||||||
{
|
{
|
||||||
return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled || _userReportsToggled;
|
return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,6 @@ public class ReportManager
|
|||||||
_reportProfileRepository.initialize();
|
_reportProfileRepository.initialize();
|
||||||
|
|
||||||
ReportNotificationCallback callback = new ReportNotificationCallback(this);
|
ReportNotificationCallback callback = new ReportNotificationCallback(this);
|
||||||
ServerCommandManager.getInstance().registerCommandType("ReportNotification", ReportNotification.class, callback);
|
|
||||||
ServerCommandManager.getInstance().registerCommandType("ReportHandlerNotification", ReportHandlerNotification.class, callback);
|
ServerCommandManager.getInstance().registerCommandType("ReportHandlerNotification", ReportHandlerNotification.class, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,18 +289,6 @@ public class ReportManager
|
|||||||
_reportRepository.clearCacheFor(_clientManager.getAccountId(player));
|
_reportRepository.clearCacheFor(_clientManager.getAccountId(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player - the player whose report notification settings are to be checked
|
|
||||||
* @return true, if the player should receive report notifications, false otherwise.
|
|
||||||
*/
|
|
||||||
public boolean hasReportNotifications(Player player)
|
|
||||||
{
|
|
||||||
// TODO remove report notifications preference
|
|
||||||
boolean isStaff = CommandCenter.Instance.GetClientManager().Get(player).GetRank().has(Rank.MODERATOR);
|
|
||||||
boolean hasReportNotifications = _preferencesManager.Get(player).ShowUserReports;
|
|
||||||
return isStaff && hasReportNotifications;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send to the handler of a {@link Report}, regardless of whether or not the handler is currently on this server instance.
|
* Send to the handler of a {@link Report}, regardless of whether or not the handler is currently on this server instance.
|
||||||
* If there is no handler for a report, it will be sent to all staff instead.
|
* If there is no handler for a report, it will be sent to all staff instead.
|
||||||
|
@ -28,41 +28,27 @@ public class ReportNotificationCallback implements CommandCallback
|
|||||||
{
|
{
|
||||||
ReportHandlerNotification reportNotification = (ReportHandlerNotification) command;
|
ReportHandlerNotification reportNotification = (ReportHandlerNotification) command;
|
||||||
|
|
||||||
_reportManager.getReportRepository().getReport(reportNotification.getReportId())
|
_reportManager.getReportRepository().getReport(reportNotification.getReportId()).thenAccept(report ->
|
||||||
.thenAccept(report ->
|
{
|
||||||
|
if (report != null)
|
||||||
|
{
|
||||||
|
int handlerId = reportNotification.getHandlerId();
|
||||||
|
|
||||||
|
_reportManager.getReportRepository().getAccountUUID(handlerId).thenAccept(handlerUUID ->
|
||||||
{
|
{
|
||||||
if (report != null)
|
if (handlerUUID != null)
|
||||||
{
|
{
|
||||||
int handlerId = reportNotification.getHandlerId();
|
Player handler = Bukkit.getPlayer(handlerUUID);
|
||||||
|
|
||||||
_reportManager.getReportRepository().getAccountUUID(handlerId).thenAccept(handlerUUID ->
|
if (handler != null)
|
||||||
{
|
{
|
||||||
if (handlerUUID != null)
|
sendRawMessage(handler, reportNotification.getNotification());
|
||||||
{
|
}
|
||||||
Player handler = Bukkit.getPlayer(handlerUUID);
|
|
||||||
|
|
||||||
if (handler != null)
|
|
||||||
{
|
|
||||||
sendRawMessage(handler, reportNotification.getNotification());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
else if (command instanceof ReportNotification)
|
);
|
||||||
{
|
|
||||||
ReportNotification reportNotification = (ReportNotification) command;
|
|
||||||
|
|
||||||
// Message all players that can receive report notifications.
|
|
||||||
for (Player player : UtilServer.getPlayers())
|
|
||||||
{
|
|
||||||
if (_reportManager.hasReportNotifications(player))
|
|
||||||
{
|
|
||||||
sendRawMessage(player, reportNotification.getNotification());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user