use of org.bukkit.configuration.MemoryConfiguration in project MagicPlugin by elBukkit.
the class WandUpgradePath method upgradeTo.
protected void upgradeTo(com.elmakers.mine.bukkit.api.wand.Wand wand) {
wand.setPath(getKey());
boolean addedProperties = false;
ConfigurationSection wandProperties = new MemoryConfiguration();
int manaRegeneration = wand.getManaRegeneration();
if (this.manaRegeneration > 0 && maxManaRegeneration == 0 && this.manaRegeneration > manaRegeneration) {
addedProperties = true;
wandProperties.set("mana_regeneration", this.manaRegeneration);
}
int manaMax = wand.getManaMax();
if (this.maxMana > 0 && maxMaxMana == 0 && this.maxMana > manaMax) {
addedProperties = true;
wandProperties.set("mana_max", this.maxMana);
}
if (addedProperties) {
wand.upgrade(wandProperties);
}
}
use of org.bukkit.configuration.MemoryConfiguration in project NoCheatPlus by NoCheatPlus.
the class PathUtils method getWorldsDefaultConfig.
/**
* A config file only containing the entries that are not set as global only.
* @param defaultConfig
* @return
*/
public static MemoryConfiguration getWorldsDefaultConfig(final MemoryConfiguration defaultConfig) {
final char sep = defaultConfig.options().pathSeparator();
final MemoryConfiguration config = new ConfigFile();
config.options().pathSeparator(sep);
final Map<String, Object> defaults = defaultConfig.getValues(false);
for (final Entry<String, Object> entry : defaults.entrySet()) {
final String part = entry.getKey();
if (!part.isEmpty() && !mayBeInWorldConfig(part)) {
continue;
}
final Object value = entry.getValue();
if (value instanceof ConfigurationSection) {
addWorldConfigSection(config, (ConfigurationSection) value, part, sep);
} else {
config.set(part, value);
}
}
return config;
}
use of org.bukkit.configuration.MemoryConfiguration in project Essentials by EssentialsX.
the class Commandcreatekit method run.
// /createkit <name> <delay>
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (args.length != 2) {
throw new NotEnoughArgumentsException();
}
// Command handler will auto fail if this fails.
long delay = Long.valueOf(args[1]);
String kitname = args[0];
ItemStack[] items = user.getBase().getInventory().getContents();
List<String> list = new ArrayList<>();
for (ItemStack is : items) {
if (is != null && is.getType() != null && is.getType() != Material.AIR) {
String serialized = ess.getItemDb().serialize(is);
list.add(serialized);
}
}
// Some users might want to directly write to config knowing the consequences. *shrug*
if (!ess.getSettings().isPastebinCreateKit()) {
ess.getKits().addKit(kitname, list, delay);
user.sendMessage(tl("createdKit", kitname, list.size(), delay));
} else {
ConfigurationSection config = new MemoryConfiguration();
config.set("kits." + kitname + ".delay", delay);
config.set("kits." + kitname + ".items", list);
final Yaml yaml = new Yaml(yamlConstructor, yamlRepresenter, yamlOptions);
String fileContents = "# Copy the kit code below into the kits section in your config.yml file\n";
fileContents += yaml.dump(config.getValues(false));
uploadPaste(user.getSource(), kitname, delay, fileContents);
}
}
use of org.bukkit.configuration.MemoryConfiguration in project Essentials by drtshock.
the class Kits method _getKits.
private ConfigurationSection _getKits() {
if (config.isConfigurationSection("kits")) {
final ConfigurationSection section = config.getConfigurationSection("kits");
final ConfigurationSection newSection = new MemoryConfiguration();
for (String kitItem : section.getKeys(false)) {
if (section.isConfigurationSection(kitItem)) {
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
}
}
return newSection;
}
return null;
}
use of org.bukkit.configuration.MemoryConfiguration in project Essentials by drtshock.
the class Settings method _getKits.
private ConfigurationSection _getKits() {
if (config.isConfigurationSection("kits")) {
final ConfigurationSection section = config.getConfigurationSection("kits");
final ConfigurationSection newSection = new MemoryConfiguration();
for (String kitItem : section.getKeys(false)) {
if (section.isConfigurationSection(kitItem)) {
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
}
}
return newSection;
}
return null;
}
Aggregations