Skip to content

Commit

Permalink
Add method that wipes island data.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Oct 3, 2020
1 parent 53e177f commit bd0c790
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,34 @@ public void wipeGameModeGenerators(Optional<GameModeAddon> optional)
}


/**
* This method removes from cache and database every island data that is related to given gamemode.
*
* @param optional GameMode addon which generators must be removed.
*/
public void wipeIslandData(Optional<GameModeAddon> optional)
{
if (!optional.isPresent())
{
// Done.
return;
}

final String objectKey = optional.get().getDescription().getName();

List<String> keySet = new ArrayList<>(this.generatorDataCache.keySet());

// Remove everything that starts with gamemode name.
keySet.forEach(uniqueId -> {
if (uniqueId.startsWith(objectKey))
{
this.generatorDataCache.remove(uniqueId);
this.generatorDataDatabase.deleteID(uniqueId);
}
});
}


// ---------------------------------------------------------------------
// Section: Generator related methods
// ---------------------------------------------------------------------
Expand Down

0 comments on commit bd0c790

Please sign in to comment.