mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancydialogs: Add command to clear joined players cache
This commit is contained in:
@@ -224,4 +224,29 @@ public final class FancyDialogsCMD {
|
||||
.replace("id", dialog.getId())
|
||||
.send(actor.sender());
|
||||
}
|
||||
|
||||
@Command("fancydialogs joined_players_cache clear")
|
||||
@Description("Clears the joined players cache")
|
||||
@CommandPermission("fancydialogs.commands.fancydialogs.joined_players_cache.clear")
|
||||
public void joinedPlayersCacheClear(
|
||||
final BukkitCommandActor actor
|
||||
) {
|
||||
if (actor.isPlayer()) {
|
||||
new ConfirmationDialog("Are you sure you want to clear the joined players cache?")
|
||||
.withTitle("Confirm clear")
|
||||
.withOnConfirm(() -> clearJoinedPlayersCache(actor))
|
||||
.withOnCancel(() -> translator.translate("commands.fancydialogs.joined_players_cache.clear.cancelled").send(actor.sender()))
|
||||
.ask(actor.asPlayer());
|
||||
} else {
|
||||
clearJoinedPlayersCache(actor);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearJoinedPlayersCache(
|
||||
final BukkitCommandActor actor
|
||||
) {
|
||||
plugin.getJoinedPlayersCache().clear();
|
||||
translator.translate("commands.fancydialogs.joined_players_cache.clear.success")
|
||||
.send(actor.sender());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,11 @@ public class JoinedPlayersCache {
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
playersJoined.clear();
|
||||
save();
|
||||
}
|
||||
|
||||
public boolean checkIfPlayerJoined(UUID playerUUID) {
|
||||
return playersJoined.contains(playerUUID.toString());
|
||||
}
|
||||
|
||||
@@ -32,4 +32,8 @@ messages:
|
||||
cancelled: "<dark_gray>› <gray>Clearing registered dialogs was cancelled."
|
||||
unregister:
|
||||
success: "<dark_gray>› <gray>Successfully unregistered dialog {warningColor}{id}<gray>."
|
||||
cancelled: "<dark_gray>› <gray>Unregistering dialog {warningColor}{id}<gray> was cancelled."
|
||||
cancelled: "<dark_gray>› <gray>Unregistering dialog {warningColor}{id}<gray> was cancelled."
|
||||
joined_players_cache:
|
||||
clear:
|
||||
success: "<dark_gray>› <gray>Successfully cleared the joined players cache."
|
||||
cancelled: "<dark_gray>› <gray>Clearing the joined players cache was cancelled."
|
||||
Reference in New Issue
Block a user