Search in sources :

Example 66 with ConfigurationSection

use of org.bukkit.configuration.ConfigurationSection in project MagicPlugin by elBukkit.

the class CasterProperties method setAttribute.

@Override
public void setAttribute(String attributeKey, Double attributeValue) {
    ConfigurationSection attributes = getConfigurationSection("attributes");
    if (attributes == null) {
        if (attributeValue == null)
            return;
        attributes = new MemoryConfiguration();
    }
    attributes.set(attributeKey, attributeValue);
    setProperty("attributes", attributes);
    updated();
}
Also used : MemoryConfiguration(org.bukkit.configuration.MemoryConfiguration) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 67 with ConfigurationSection

use of org.bukkit.configuration.ConfigurationSection in project MagicPlugin by elBukkit.

the class PotionEffectAction method getMappedPotionEffects.

private Collection<PotionEffect> getMappedPotionEffects(ConfigurationSection parameters) {
    ConfigurationSection section = parameters.getConfigurationSection("add_effects");
    if (section != null) {
        Collection<String> keys = section.getKeys(false);
        Collection<PotionEffect> effects = new ArrayList<>(keys.size());
        int ticks = parameters.getInt("duration", 500) / 50;
        for (String key : keys) {
            int strength = section.getInt(key, 0);
            PotionEffectType type = PotionEffectType.getByName(key);
            if (type != null) {
                effects.add(new PotionEffect(type, type.isInstant() ? 1 : ticks, strength, ambient, particles));
            }
        }
        return effects;
    } else {
        return Collections.emptyList();
    }
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) PotionEffectType(org.bukkit.potion.PotionEffectType) ArrayList(java.util.ArrayList) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 68 with ConfigurationSection

use of org.bukkit.configuration.ConfigurationSection in project MagicPlugin by elBukkit.

the class RecallAction method getWarp.

@Nullable
protected Waypoint getWarp(String warpKey) {
    if (warps == null)
        return getUnknownWarp(warpKey);
    ConfigurationSection config = warps.get(warpKey);
    if (config == null)
        return getUnknownWarp(warpKey);
    MageController controller = context.getController();
    String warpName = config.getString("name", warpKey);
    String castMessage = context.getMessage("cast_warp").replace("$name", warpName);
    String failMessage = context.getMessage("no_target_warp").replace("$name", warpName);
    String title = context.getMessage("title_warp").replace("$name", warpName);
    String description = config.getString("description");
    String iconURL = config.getString("icon_url");
    MaterialAndData icon = getIcon(context, config, "icon");
    Location warpLocation = controller.getWarp(warpKey);
    if (warpLocation == null || warpLocation.getWorld() == null) {
        String serverName = config.getString("server", null);
        if (serverName != null) {
            return new Waypoint(RecallType.WARP, warpKey, serverName, title, castMessage, failMessage, description, icon, iconURL);
        }
        return null;
    }
    return new Waypoint(RecallType.WARP, warpLocation, title, castMessage, failMessage, description, icon, iconURL);
}
Also used : MageController(com.elmakers.mine.bukkit.api.magic.MageController) MaterialAndData(com.elmakers.mine.bukkit.block.MaterialAndData) ConfigurationSection(org.bukkit.configuration.ConfigurationSection) Location(org.bukkit.Location) Nullable(javax.annotation.Nullable)

Example 69 with ConfigurationSection

use of org.bukkit.configuration.ConfigurationSection in project MagicPlugin by elBukkit.

the class RecallAction method getCommand.

@Nullable
protected Waypoint getCommand(CastContext context, String commandKey) {
    if (commands == null)
        return null;
    ConfigurationSection config = commands.get(commandKey);
    if (config == null)
        return null;
    String commandName = config.getString("name", commandKey);
    String castMessage = context.getMessage("cast_warp").replace("$name", commandName);
    String failMessage = context.getMessage("no_target_warp").replace("$name", commandName);
    String title = context.getMessage("title_warp").replace("$name", commandName);
    String description = config.getString("description");
    String iconURL = config.getString("icon_url");
    String command = context.parameterize(config.getString("command"));
    boolean op = config.getBoolean("op", false);
    boolean console = config.getBoolean("console", false);
    MaterialAndData icon = getIcon(context, config, "icon");
    return new Waypoint(RecallType.COMMAND, command, op, console, title, castMessage, failMessage, description, icon, iconURL);
}
Also used : MaterialAndData(com.elmakers.mine.bukkit.block.MaterialAndData) ConfigurationSection(org.bukkit.configuration.ConfigurationSection) Nullable(javax.annotation.Nullable)

Example 70 with ConfigurationSection

use of org.bukkit.configuration.ConfigurationSection in project MagicPlugin by elBukkit.

the class RecallAction method removeMarker.

protected boolean removeMarker() {
    Mage mage = context.getMage();
    ConfigurationSection mageData = mage.getData();
    Location location = ConfigurationUtils.getLocation(mageData, markerKey);
    if (location == null)
        return false;
    mageData.set(markerKey, null);
    return true;
}
Also used : Mage(com.elmakers.mine.bukkit.api.magic.Mage) ConfigurationSection(org.bukkit.configuration.ConfigurationSection) Location(org.bukkit.Location)

Aggregations

ConfigurationSection (org.bukkit.configuration.ConfigurationSection)263 ArrayList (java.util.ArrayList)37 HashMap (java.util.HashMap)29 MemoryConfiguration (org.bukkit.configuration.MemoryConfiguration)27 ItemStack (org.bukkit.inventory.ItemStack)26 File (java.io.File)22 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)22 IOException (java.io.IOException)21 Map (java.util.Map)18 Mage (com.elmakers.mine.bukkit.api.magic.Mage)17 Material (org.bukkit.Material)16 Nullable (javax.annotation.Nullable)14 Location (org.bukkit.Location)13 FileConfiguration (org.bukkit.configuration.file.FileConfiguration)11 MaterialAndData (com.elmakers.mine.bukkit.block.MaterialAndData)10 Player (org.bukkit.entity.Player)10 EntityType (org.bukkit.entity.EntityType)9 List (java.util.List)8 SpellTemplate (com.elmakers.mine.bukkit.api.spell.SpellTemplate)7 InvalidConfigurationException (org.bukkit.configuration.InvalidConfigurationException)7