fancydialogs: Add command to clear joined players cache

This commit is contained in:
Oliver
2025-06-27 19:09:22 +02:00
parent f16759a3ea
commit ee918f73ab
4 changed files with 48 additions and 5 deletions

View File

@@ -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());
}
}

View File

@@ -42,6 +42,11 @@ public class JoinedPlayersCache {
}
}
public void clear() {
playersJoined.clear();
save();
}
public boolean checkIfPlayerJoined(UUID playerUUID) {
return playersJoined.contains(playerUUID.toString());
}

View File

@@ -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."