mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-05 23:33:36 +00:00
fancydialogs: Add command to clear joined players cache
This commit is contained in:
@@ -48,23 +48,32 @@ Clears the dialog registry and loads all dialog data from the storage.
|
||||
|
||||
## Registry
|
||||
|
||||
## List all dialogs
|
||||
### List all dialogs
|
||||
|
||||
Lists all registered dialogs.
|
||||
|
||||
- **Syntax**: `/fancydialogs registry list`
|
||||
- **Permissions**: `fancydialogs.commands.fancydialogs.registry.list`
|
||||
|
||||
## Clear registry
|
||||
### Clear registry
|
||||
|
||||
Clears the dialog registry
|
||||
|
||||
- **Syntax**: `/fancydialogs registry clear`
|
||||
- **Permissions**: `fancydialogs.commands.fancydialogs.registry.clear`
|
||||
|
||||
## Unregister dialog
|
||||
### Unregister dialog
|
||||
|
||||
Unregisters a dialog by its ID.
|
||||
|
||||
- **Syntax**: `/fancydialogs registry unregister <id>`
|
||||
- **Permissions**: `fancydialogs.commands.fancydialogs.registry.unregister`
|
||||
- **Permissions**: `fancydialogs.commands.fancydialogs.registry.unregister`
|
||||
|
||||
## Joined Players Cache
|
||||
|
||||
## Clear joined players cache
|
||||
|
||||
Clears the cache of players who have joined a dialog.
|
||||
|
||||
- **Syntax**: `/fancydialogs joined_players_cache clear`
|
||||
- **Permissions**: `fancydialogs.commands.fancydialogs.joined_players_cache.clear`
|
||||
@@ -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