Search in sources :

Example 1 with MaterialAliases

use of me.botsko.elixr.MaterialAliases in project Prism-Bukkit by prism.

the class BlockParameter method process.

/**
	 * 
	 */
@Override
public void process(QueryParameters query, String alias, String input, CommandSender sender) {
    final String[] blocks = input.split(",");
    if (blocks.length > 0) {
        for (final String b : blocks) {
            // if user provided id:subid
            if (b.contains(":") && b.length() >= 3) {
                final String[] ids = b.split(":");
                if (ids.length == 2 && TypeUtils.isNumeric(ids[0]) && TypeUtils.isNumeric(ids[1])) {
                    query.addBlockFilter(Integer.parseInt(ids[0]), Short.parseShort(ids[1]));
                } else {
                    throw new IllegalArgumentException("Invalid block name '" + b + "'. Try /pr ? for help");
                }
            } else {
                // It's id without a subid
                if (TypeUtils.isNumeric(b)) {
                    query.addBlockFilter(Integer.parseInt(b), (short) 0);
                } else {
                    // Lookup the item name, get the ids
                    final MaterialAliases items = Prism.getItems();
                    final ArrayList<int[]> itemIds = items.getIdsByAlias(b);
                    if (itemIds.size() > 0) {
                        for (final int[] ids : itemIds) {
                            if (ids.length == 2) {
                                // because it's a whole different item
                                if (ItemUtils.dataValueUsedForSubitems(ids[0])) {
                                    query.addBlockFilter(ids[0], (short) ids[1]);
                                } else {
                                    query.addBlockFilter(ids[0], (short) 0);
                                }
                            }
                        }
                    } else {
                        throw new IllegalArgumentException("Invalid block name '" + b + "'. Try /pr ? for help");
                    }
                }
            }
        }
    }
}
Also used : MaterialAliases(me.botsko.elixr.MaterialAliases)

Example 2 with MaterialAliases

use of me.botsko.elixr.MaterialAliases in project Prism-Bukkit by prism.

the class Prism method loadConfig.

/**
     * Load configuration and language files
     */
@SuppressWarnings("unchecked")
public void loadConfig() {
    final PrismConfig mc = new PrismConfig(this);
    config = mc.getConfig();
    // Cache config arrays we check constantly
    illegalBlocks = (ArrayList<Integer>) getConfig().getList("prism.appliers.never-place-block");
    illegalEntities = (ArrayList<String>) getConfig().getList("prism.appliers.never-spawn-entity");
    final ConfigurationSection alertBlocks = getConfig().getConfigurationSection("prism.alerts.ores.blocks");
    alertedOres.clear();
    if (alertBlocks != null) {
        for (final String key : alertBlocks.getKeys(false)) {
            alertedOres.put(key, alertBlocks.getString(key));
        }
    }
    // Load language files
    // language = new Language( mc.getLang() );
    // Load items db
    items = new MaterialAliases();
}
Also used : MaterialAliases(me.botsko.elixr.MaterialAliases) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Aggregations

MaterialAliases (me.botsko.elixr.MaterialAliases)2 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1