org.bukkit.configuration.MemoryConfiguration Java Examples

The following examples show how to use org.bukkit.configuration.MemoryConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandTemplate.java    From TrMenu with MIT License 6 votes vote down vote up
private ConfigurationSection display(ItemStack item) {
    ConfigurationSection section = new MemoryConfiguration();
    ItemMeta meta = item.getItemMeta();
    String mat = item.getType().name();
    if (meta instanceof SkullMeta) {
        String texture = Skulls.getTexture(item);
        mat = texture != null ? "<skull:" + Skulls.getTexture(item) + ">" : mat;
    }
    if (item.getAmount() > 1) {
        section.set("amount", item.getAmount());
    }
    if (meta != null) {
        if (meta.hasDisplayName()) {
            section.set("name", meta.getDisplayName());
        }
        if (meta.hasLore()) {
            section.set("lore", meta.getLore());
        }
    }
    section.set("mats", mat);
    return section;
}
 
Example #2
Source File: DeluxeMenusMigrater.java    From TrMenu with MIT License 5 votes vote down vote up
public ConfigurationSection toTrMenuSection(int priority, boolean useSlot) {
    MemorySection section = new MemoryConfiguration();
    if (getRequirement() != null) {
        section.set("condition", getRequirement());
    }
    if (priority >= 0) {
        section.set("priority", priority);
    }
    section.set("display.material", getMaterial());
    if (getName() != null) {
        section.set("display.name", getName());
    }
    if (getLore() != null) {
        section.set("display.lore", getLore());
    }
    if (getAmount() != null) {
        section.set("display.amount", getAmount());
    }
    if (getShiny() != null && !"false".equalsIgnoreCase(getShiny())) {
        if (Boolean.parseBoolean(getShiny())) {
            section.set("display.shiny", true);
        } else {
            section.set("display.shiny", getShiny());
        }
    }
    if (getFlags() != null && !getFlags().isEmpty()) {
        section.set("display.flags", getFlags());
    }
    if (!getSlots().isEmpty() && useSlot) {
        if (getSlots().size() == 1) {
            section.set("display.slot", getSlots().get(0));
        } else {
            section.set("display.slots", getSlots());
        }
    }
    actions.forEach((type, actions) -> section.set("actions." + type, actions));
    return section;
}
 
Example #3
Source File: TabooMenuMigrater.java    From TrMenu with MIT License 5 votes vote down vote up
private static ConfigurationSection migrateButtons(Map<Integer, Icon> value) {
    ConfigurationSection buttons = new MemoryConfiguration();
    value.forEach((slot, button) -> {
        ConfigurationSection b = new MemoryConfiguration();
        ConfigurationSection defIcon = migrateIcon(button, slot);

        b.set("display", defIcon.getConfigurationSection("display"));
        if (defIcon.isSet("actions")) {
            b.set("actions", defIcon.getConfigurationSection("actions"));
        }
        List<ConfigurationSection> priorityIcons = new ArrayList<>();

        List<Requirement> requirements = button.getRequirements();
        requirements.sort(Collections.reverseOrder(Comparator.comparingInt(Requirement::getPriority)));
        AtomicInteger priority = new AtomicInteger(1);
        requirements.forEach(requirement -> {
            ConfigurationSection pIcon = new MemoryConfiguration();
            ConfigurationSection migrated = migrateIcon(requirement.getIcon(), -1);
            pIcon.set("condition", requirement.getExpression());
            pIcon.set("priority", priority.getAndIncrement());
            pIcon.set("display", migrated.getConfigurationSection("display"));
            if (migrated.contains("actions")) {
                pIcon.set("actions", migrated.getConfigurationSection("actions"));
            }
            priorityIcons.add(pIcon);
        });
        if (!priorityIcons.isEmpty()) {
            b.set("icons", priorityIcons);
        }
        buttons.set(button.getIconName(), b);
    });
    return buttons;
}
 
Example #4
Source File: TabooMenuMigrater.java    From TrMenu with MIT License 5 votes vote down vote up
private static ConfigurationSection migrateIcon(Icon button, int slot) {
    ConfigurationSection icons = new MemoryConfiguration();

    icons.set("display.mats", migrateMat(button));
    if (slot > 0) {
        icons.set("display.slots", migrateSlots(slot, button));
    }
    if (Strings.nonEmpty(button.getName())) {
        icons.set("display.name", button.getName());
    }
    if (button.getLore() != null) {
        icons.set("display.lore", button.getLore());
    }
    if (button.getAmount() != 1) {
        icons.set("display.amount", button.getAmount());
    }
    if (button.isShiny()) {
        icons.set("display.shiny", true);
    }
    if (!button.isHideAttribute()) {
        icons.set("display.flags", Collections.singletonList("HIDE_ATTRIBUTES"));
    }
    migrateIconActions(button.getIconCommands()).forEach((type, actions) -> {
        if (!actions.isEmpty()) {
            icons.set("actions." + type, actions);
        }
    });
    return icons;
}
 
Example #5
Source File: ConfigUtils.java    From EffectLib with MIT License 5 votes vote down vote up
public static ConfigurationSection toConfigurationSection(Map<?, ?> nodeMap) {
    ConfigurationSection newSection = new MemoryConfiguration();
    for (Map.Entry<?, ?> entry : nodeMap.entrySet()) {
        set(newSection, entry.getKey().toString(), entry.getValue());
    }

    return newSection;
}
 
Example #6
Source File: ConfigUtils.java    From EffectLib with MIT License 5 votes vote down vote up
public static ConfigurationSection toStringConfiguration(Map<String, String> stringMap) {
    if (stringMap == null) {
        return null;
    }
    ConfigurationSection configMap = new MemoryConfiguration();
    for (Map.Entry<String, String> entry : stringMap.entrySet()) {
        configMap.set(entry.getKey(), entry.getValue());
    }

    return configMap;
}
 
Example #7
Source File: FileConfigurationOptions.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
protected FileConfigurationOptions(MemoryConfiguration configuration) {
    super(configuration);
}