Fixes blueprint saving with same name.

Blueprints saved with the same name were not overwriting the internal
blueprint list causing duplicates.
This commit is contained in:
tastybento 2019-05-27 09:16:22 -07:00
parent cca381e51a
commit 7843d2b23a

View File

@ -235,12 +235,14 @@ public class BlueprintsManager {
}
/**
* Adds a blueprint to addon's list of blueprints
* Adds a blueprint to addon's list of blueprints. If the list already contains a blueprint with the same name
* it is replaced.
* @param addon - the {@link GameModeAddon}
* @param bp - blueprint
*/
public void addBlueprint(@NonNull GameModeAddon addon, @NonNull Blueprint bp) {
blueprints.putIfAbsent(addon, new ArrayList<>());
blueprints.get(addon).removeIf(b -> b.getName().equals(bp.getName()));
blueprints.get(addon).add(bp);
plugin.log("Added blueprint '" + bp.getName() + "' for " + addon.getDescription().getName());
}