Makes sure arena data is deleted with the arena

This commit is contained in:
Kristian Knarvik 2023-04-09 18:22:45 +02:00
parent 6a41664fef
commit 3bbf41206c
2 changed files with 17 additions and 2 deletions

View File

@ -158,10 +158,15 @@ public class DropperArenaHandler {
* @param arena <p>The arena to remove</p>
*/
public void removeArena(@NotNull DropperArena arena) {
UUID arenaId = arena.getArenaId();
Dropper.getInstance().getPlayerRegistry().removeForArena(arena);
this.arenas.remove(arena.getArenaId());
this.arenas.remove(arenaId);
this.arenaNameLookup.remove(arena.getArenaNameSanitized());
this.arenaGroups.remove(arena.getArenaId());
this.arenaGroups.remove(arenaId);
if (!ArenaStorageHelper.removeArenaData(arenaId)) {
Dropper.getInstance().getLogger().log(Level.WARNING, "Unable to remove dropper arena data file " +
arenaId + ".yml. You must remove it manually!");
}
this.saveArenas();
}

View File

@ -203,6 +203,16 @@ public final class ArenaStorageHelper {
return (DropperArenaData) configuration.get(ArenaStorageKey.DATA.getKey());
}
/**
* Removes data for the arena with the given id
*
* @param arenaId <p>The id of the arena to remove data for</p>
* @return <p>True if the data was successfully removed</p>
*/
public static boolean removeArenaData(@NotNull UUID arenaId) {
return getArenaDataFile(arenaId).delete();
}
/**
* Gets the file used to store the given arena id's data
*