/* * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Baritone is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ package baritone.utils.schematic; import baritone.api.command.registry.Registry; import baritone.api.schematic.ISchematicSystem; import baritone.api.schematic.format.ISchematicFormat; import baritone.utils.schematic.format.DefaultSchematicFormats; import java.io.File; import java.util.Arrays; import java.util.Optional; /** * @author Brady * @since 12/24/2019 */ public enum SchematicSystem implements ISchematicSystem { INSTANCE; private final Registry registry = new Registry<>(); SchematicSystem() { Arrays.stream(DefaultSchematicFormats.values()).forEach(this.registry::register); } @Override public Registry getRegistry() { return this.registry; } @Override public Optional getByFile(File file) { return this.registry.stream().filter(format -> format.isFileType(file)).findFirst(); } }