Search in sources :

Example 1 with AdapterLoadException

use of com.sk89q.worldedit.sponge.adapter.AdapterLoadException in project FastAsyncWorldEdit by IntellectualSites.

the class SpongeWorldEdit method loadAdapter.

private void loadAdapter() {
    WorldEdit worldEdit = WorldEdit.getInstance();
    // Attempt to load a Sponge adapter
    SpongeImplLoader adapterLoader = new SpongeImplLoader();
    try {
        adapterLoader.addFromPath(getClass().getClassLoader());
    } catch (IOException e) {
        logger.warn("Failed to search path for Sponge adapters");
    }
    try {
        adapterLoader.addFromJar(container.getSource().get().toFile());
    } catch (IOException e) {
        logger.warn("Failed to search " + container.getSource().get().toFile() + " for Sponge adapters", e);
    }
    try {
        spongeAdapter = adapterLoader.loadAdapter();
        logger.info("Using " + spongeAdapter.getClass().getCanonicalName() + " as the Sponge adapter");
    } catch (AdapterLoadException e) {
        Platform platform = worldEdit.getPlatformManager().queryCapability(Capability.WORLD_EDITING);
        if (platform instanceof SpongePlatform) {
            logger.warn(e.getMessage());
        } else {
            logger.info("WorldEdit could not find a Sponge adapter for this MC version, " + "but it seems that you have another implementation of WorldEdit installed (" + platform.getPlatformName() + ") " + "that handles the world editing.");
        }
    }
}
Also used : WorldEdit(com.sk89q.worldedit.WorldEdit) Platform(com.sk89q.worldedit.extension.platform.Platform) SpongeImplLoader(com.sk89q.worldedit.sponge.adapter.SpongeImplLoader) IOException(java.io.IOException) AdapterLoadException(com.sk89q.worldedit.sponge.adapter.AdapterLoadException)

Aggregations

WorldEdit (com.sk89q.worldedit.WorldEdit)1 Platform (com.sk89q.worldedit.extension.platform.Platform)1 AdapterLoadException (com.sk89q.worldedit.sponge.adapter.AdapterLoadException)1 SpongeImplLoader (com.sk89q.worldedit.sponge.adapter.SpongeImplLoader)1 IOException (java.io.IOException)1