mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-13 10:51:20 +01:00
Fixes admin blueprint delete command
https://github.com/BentoBoxWorld/BentoBox/issues/1382
This commit is contained in:
parent
9df54ff07f
commit
a6d6895676
@ -49,7 +49,9 @@ public class Blueprint {
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
@NonNull
|
||||
public String getName() {
|
||||
if (name == null) name = "unnamed";
|
||||
// Force lower case
|
||||
return name.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -407,18 +408,22 @@ public class BlueprintsManager {
|
||||
*/
|
||||
public void deleteBlueprint(GameModeAddon addon, String name) {
|
||||
List<Blueprint> addonBlueprints = blueprints.get(addon);
|
||||
addonBlueprints.stream().filter(b -> b.getName().equals(name)).forEach(b -> {
|
||||
addonBlueprints.remove(b);
|
||||
blueprints.put(addon, addonBlueprints);
|
||||
Iterator<Blueprint> it = addonBlueprints.iterator();
|
||||
while (it.hasNext()) {
|
||||
Blueprint b = it.next();
|
||||
if (b.getName().equalsIgnoreCase(name)) {
|
||||
it.remove();
|
||||
blueprints.put(addon, addonBlueprints);
|
||||
|
||||
File file = new File(getBlueprintsFolder(addon), name + BLUEPRINT_SUFFIX);
|
||||
// Delete the file
|
||||
try {
|
||||
Files.deleteIfExists(file.toPath());
|
||||
} catch (IOException e) {
|
||||
plugin.logError("Could not delete Blueprint " + e.getLocalizedMessage());
|
||||
}
|
||||
});
|
||||
File file = new File(getBlueprintsFolder(addon), b.getName() + BLUEPRINT_SUFFIX);
|
||||
// Delete the file
|
||||
try {
|
||||
Files.deleteIfExists(file.toPath());
|
||||
} catch (IOException e) {
|
||||
plugin.logError("Could not delete Blueprint " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user