All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.level.format.LevelProviderManager Maven / Gradle / Ivy

Go to download

A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.

There is a newer version: 1.6.0.1-PN
Show newest version
package cn.nukkit.level.format;

import cn.nukkit.Server;

import java.util.HashMap;
import java.util.Map;

/**
 * @author MagicDroidX (Nukkit Project)
 */
public abstract class LevelProviderManager {
    protected static final Map> providers = new HashMap<>();

    public static void addProvider(Server server, Class clazz) {
        try {
            providers.put((String) clazz.getMethod("getProviderName").invoke(null), clazz);
        } catch (Exception e) {
            Server.getInstance().getLogger().logException(e);
        }
    }

    public static Class getProvider(String path) {
        for (Class provider : providers.values()) {
            try {
                if ((boolean) provider.getMethod("isValid", String.class).invoke(null, path)) {
                    return provider;
                }
            } catch (Exception e) {
                Server.getInstance().getLogger().logException(e);
            }
        }
        return null;
    }

    public static Class getProviderByName(String name) {
        name = name.trim().toLowerCase();
        return providers.getOrDefault(name, null);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy