Search in sources :

Example 6 with YAMLException

use of org.yaml.snakeyaml.error.YAMLException in project cassandra by apache.

the class StressProfile method load.

public static StressProfile load(URI file) throws IOError {
    try {
        Constructor constructor = new Constructor(StressYaml.class);
        Yaml yaml = new Yaml(constructor);
        InputStream yamlStream = file.toURL().openStream();
        if (yamlStream.available() == 0)
            throw new IOException("Unable to load yaml file from: " + file);
        StressYaml profileYaml = yaml.loadAs(yamlStream, StressYaml.class);
        StressProfile profile = new StressProfile();
        profile.init(profileYaml);
        return profile;
    } catch (YAMLException | IOException | RequestValidationException e) {
        throw new IOError(e);
    }
}
Also used : IOError(java.io.IOError) Constructor(org.yaml.snakeyaml.constructor.Constructor) InputStream(java.io.InputStream) YAMLException(org.yaml.snakeyaml.error.YAMLException) IOException(java.io.IOException) RequestValidationException(org.apache.cassandra.exceptions.RequestValidationException) Yaml(org.yaml.snakeyaml.Yaml)

Example 7 with YAMLException

use of org.yaml.snakeyaml.error.YAMLException in project pinpoint by naver.

the class TraceMetadataProviderYamlParser method parse0.

private ParsedTraceMetadata parse0(URL metaUrl) throws IOException {
    InputStream inputStream = null;
    try {
        inputStream = metaUrl.openStream();
        Yaml yaml = new Yaml();
        ParsedTraceMetadata parsedTraceMetadata = yaml.loadAs(inputStream, ParsedTraceMetadata.class);
        if (parsedTraceMetadata == null) {
            logger.warn("Empty type provider definition. Skipping : {}", metaUrl.toExternalForm());
        }
        return parsedTraceMetadata;
    } catch (IOException e) {
        throw new IllegalStateException("Error opening stream : " + metaUrl.toString(), e);
    } catch (YAMLException e) {
        throw new IllegalStateException("Error parsing yml : " + metaUrl.toString(), e);
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
    }
}
Also used : InputStream(java.io.InputStream) YAMLException(org.yaml.snakeyaml.error.YAMLException) IOException(java.io.IOException) Yaml(org.yaml.snakeyaml.Yaml)

Example 8 with YAMLException

use of org.yaml.snakeyaml.error.YAMLException in project Bukkit by Bukkit.

the class JavaPluginLoader method getPluginDescription.

public PluginDescriptionFile getPluginDescription(File file) throws InvalidDescriptionException {
    Validate.notNull(file, "File cannot be null");
    JarFile jar = null;
    InputStream stream = null;
    try {
        jar = new JarFile(file);
        JarEntry entry = jar.getJarEntry("plugin.yml");
        if (entry == null) {
            throw new InvalidDescriptionException(new FileNotFoundException("Jar does not contain plugin.yml"));
        }
        stream = jar.getInputStream(entry);
        return new PluginDescriptionFile(stream);
    } catch (IOException ex) {
        throw new InvalidDescriptionException(ex);
    } catch (YAMLException ex) {
        throw new InvalidDescriptionException(ex);
    } finally {
        if (jar != null) {
            try {
                jar.close();
            } catch (IOException e) {
            }
        }
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
            }
        }
    }
}
Also used : InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) YAMLException(org.yaml.snakeyaml.error.YAMLException) InvalidDescriptionException(org.bukkit.plugin.InvalidDescriptionException) IOException(java.io.IOException) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry)

Example 9 with YAMLException

use of org.yaml.snakeyaml.error.YAMLException in project Angelia-core by Maxopoly.

the class YamlParser method loadFromString.

public static YamlMap loadFromString(String rawYaml) throws InvalidYamlFormatException {
    Map input;
    try {
        input = (Map) yaml.load(rawYaml);
    } catch (YAMLException e) {
        throw new InvalidYamlFormatException(e.getMessage());
    } catch (ClassCastException e) {
        throw new InvalidYamlFormatException("Tried to parse yaml, but top level was not a map");
    }
    if (input != null) {
        YamlMap superYaml = new YamlMap();
        convertMapsToSections(input, superYaml);
        return superYaml;
    }
    return null;
}
Also used : YAMLException(org.yaml.snakeyaml.error.YAMLException) Map(java.util.Map)

Example 10 with YAMLException

use of org.yaml.snakeyaml.error.YAMLException in project Essentials by EssentialsX.

the class Essentials method onEnable.

@Override
public void onEnable() {
    try {
        if (LOGGER != this.getLogger()) {
            LOGGER.setParent(this.getLogger());
        }
        execTimer = new ExecuteTimer();
        execTimer.start();
        i18n = new I18n(this);
        i18n.onEnable();
        execTimer.mark("I18n1");
        Console.setInstance(this);
        final PluginManager pm = getServer().getPluginManager();
        for (Plugin plugin : pm.getPlugins()) {
            if (plugin.getDescription().getName().startsWith("Essentials") && !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()) && !plugin.getDescription().getName().equals("EssentialsAntiCheat")) {
                getLogger().warning(tl("versionMismatch", plugin.getDescription().getName()));
            }
        }
        for (Method method : Server.class.getDeclaredMethods()) {
            if (method.getName().endsWith("getOnlinePlayers") && method.getReturnType() == Player[].class) {
                oldGetOnlinePlayers = method;
                break;
            }
        }
        forceLoadClasses();
        try {
            final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
            upgrade.beforeSettings();
            execTimer.mark("Upgrade");
            confList = new ArrayList<>();
            settings = new Settings(this);
            confList.add(settings);
            execTimer.mark("Settings");
            userMap = new UserMap(this);
            confList.add(userMap);
            execTimer.mark("Init(Usermap)");
            kits = new Kits(this);
            confList.add(kits);
            upgrade.convertKits();
            execTimer.mark("Kits");
            upgrade.afterSettings();
            execTimer.mark("Upgrade2");
            warps = new Warps(getServer(), this.getDataFolder());
            confList.add(warps);
            execTimer.mark("Init(Spawn/Warp)");
            worth = new Worth(this.getDataFolder());
            confList.add(worth);
            itemDb = new ItemDb(this);
            confList.add(itemDb);
            execTimer.mark("Init(Worth/ItemDB)");
            jails = new Jails(this);
            confList.add(jails);
            spawnerProvider = new ProviderFactory<>(getLogger(), Arrays.asList(BlockMetaSpawnerProvider.class, v1_8_R2SpawnerProvider.class, v1_8_R1SpawnerProvider.class, LegacySpawnerProvider.class), "mob spawner").getProvider();
            spawnEggProvider = new ProviderFactory<>(getLogger(), Arrays.asList(ReflSpawnEggProvider.class, LegacySpawnEggProvider.class), "spawn egg").getProvider();
            potionMetaProvider = new ProviderFactory<>(getLogger(), Arrays.asList(BasePotionDataProvider.class, LegacyPotionMetaProvider.class), "potion meta").getProvider();
            reload();
        } catch (YAMLException exception) {
            if (pm.getPlugin("EssentialsUpdate") != null) {
                LOGGER.log(Level.SEVERE, tl("essentialsHelp2"));
            } else {
                LOGGER.log(Level.SEVERE, tl("essentialsHelp1"));
            }
            handleCrash(exception);
            return;
        }
        backup = new Backup(this);
        permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
        alternativeCommandsHandler = new AlternativeCommandsHandler(this);
        timer = new EssentialsTimer(this);
        scheduleSyncRepeatingTask(timer, 1000, 50);
        Economy.setEss(this);
        execTimer.mark("RegHandler");
        metrics = new Metrics(this);
        if (!metrics.isOptOut()) {
            getLogger().info("Starting Metrics. Opt-out using the global bStats config.");
        } else {
            getLogger().info("Metrics disabled per bStats config.");
        }
        final String timeroutput = execTimer.end();
        if (getSettings().isDebug()) {
            LOGGER.log(Level.INFO, "Essentials load {0}", timeroutput);
        }
    } catch (NumberFormatException ex) {
        handleCrash(ex);
    } catch (Error ex) {
        handleCrash(ex);
        throw ex;
    }
}
Also used : LegacyPotionMetaProvider(net.ess3.nms.legacy.LegacyPotionMetaProvider) LegacySpawnerProvider(net.ess3.nms.legacy.LegacySpawnerProvider) BlockMetaSpawnerProvider(net.ess3.nms.updatedmeta.BlockMetaSpawnerProvider) net.ess3.nms.v1_8_R2.v1_8_R2SpawnerProvider(net.ess3.nms.v1_8_R2.v1_8_R2SpawnerProvider) BasePotionDataProvider(net.ess3.nms.updatedmeta.BasePotionDataProvider) PluginManager(org.bukkit.plugin.PluginManager) LegacySpawnEggProvider(net.ess3.nms.legacy.LegacySpawnEggProvider) Metrics(com.earth2me.essentials.metrics.Metrics) PermissionsHandler(com.earth2me.essentials.perm.PermissionsHandler) ProviderFactory(net.ess3.providers.ProviderFactory) ISettings(net.ess3.api.ISettings) net.ess3.nms.v1_8_R1.v1_8_R1SpawnerProvider(net.ess3.nms.v1_8_R1.v1_8_R1SpawnerProvider) YAMLException(org.yaml.snakeyaml.error.YAMLException) Method(java.lang.reflect.Method) ReflSpawnEggProvider(net.ess3.nms.refl.ReflSpawnEggProvider) Plugin(org.bukkit.plugin.Plugin) JavaPlugin(org.bukkit.plugin.java.JavaPlugin)

Aggregations

YAMLException (org.yaml.snakeyaml.error.YAMLException)15 Yaml (org.yaml.snakeyaml.Yaml)8 IOException (java.io.IOException)7 InputStream (java.io.InputStream)5 Map (java.util.Map)4 Constructor (org.yaml.snakeyaml.constructor.Constructor)4 Metrics (com.earth2me.essentials.metrics.Metrics)2 PermissionsHandler (com.earth2me.essentials.perm.PermissionsHandler)2 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 ISettings (net.ess3.api.ISettings)2 LegacyPotionMetaProvider (net.ess3.nms.legacy.LegacyPotionMetaProvider)2 LegacySpawnEggProvider (net.ess3.nms.legacy.LegacySpawnEggProvider)2 LegacySpawnerProvider (net.ess3.nms.legacy.LegacySpawnerProvider)2 ReflSpawnEggProvider (net.ess3.nms.refl.ReflSpawnEggProvider)2 BasePotionDataProvider (net.ess3.nms.updatedmeta.BasePotionDataProvider)2 BlockMetaSpawnerProvider (net.ess3.nms.updatedmeta.BlockMetaSpawnerProvider)2 net.ess3.nms.v1_8_R1.v1_8_R1SpawnerProvider (net.ess3.nms.v1_8_R1.v1_8_R1SpawnerProvider)2 net.ess3.nms.v1_8_R2.v1_8_R2SpawnerProvider (net.ess3.nms.v1_8_R2.v1_8_R2SpawnerProvider)2 ProviderFactory (net.ess3.providers.ProviderFactory)2