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();
}
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();
}
}
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);
}
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);
}
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;
}
Aggregations