@Override public List<String> tabCompleteInternalMaterialName(String token, List<String> completions) { List<String> materialNames = new ArrayList<>(Material.values().length); for (Material mat : Material.values()) { materialNames.add(mat.name().toLowerCase()); } return StringUtil.copyPartialMatches(token, materialNames, completions); }
private static void generateMaterialStatistics() { for (Material material : Material.values()) { String name = ItemIds.getKeyName(material); if (material.isBlock()) { set(MINE_BLOCK, material, "mineBlock.minecraft." + name); } if (material.isItem()) { set(USE_ITEM, material, "useItem.minecraft." + name); set(CRAFT_ITEM, material, "craftItem.minecraft." + name); if (material.getMaxDurability() != 0) { set(BREAK_ITEM, material, "breakItem.minecraft." + name); } } set(DROP, material, "drop.minecraft." + name); set(PICKUP, material, "pickup.minecraft." + name); } }
private boolean checkMaterial(String setMaterial) { return Arrays.asList(Material.values()).contains(Material.valueOf(setMaterial)); } }
@Override public LuaValue call(LuaValue c) { return CoerceJavaToLua.coerce(Material.values()); } });
/** * Get a HashSet containing every transparent block * * @return HashSet with the IDs of every transparent block */ public static HashSet<Material> getTransparentBlocks() { HashSet<Material> transparentBlocks = new HashSet<Material>(); for (Material material : Material.values()) { if (material.isTransparent()) { transparentBlocks.add(material); } } return transparentBlocks; }
private Material[] getMaterials() { List<Material> list = new ArrayList<>(); for (Material material : Material.values()) { if (material == Material.AIR || material == Material.CAVE_AIR || material == Material.VOID_AIR) { continue; } try { Field field = Material.class.getField(material.name()); // Ignore all legacies materials if (field.isAnnotationPresent(Deprecated.class)) { continue; } list.add(material); } catch (NoSuchFieldException e) { e.printStackTrace(); } } return list.toArray(new Material[0]); }
/** * Collect non-block items by suffix of their Material name (case insensitive). * @param suffix * @return */ public static List<Material> collectItemsBySuffix(String suffix) { suffix = suffix.toLowerCase(); final List<Material> res = new LinkedList<Material>(); for (final Material mat : Material.values()) { if (!mat.isBlock() && mat.name().toLowerCase().endsWith(suffix)) { res.add(mat); } } return res; }
/** * Collect non-block items by suffix of their Material name (case insensitive). * @param prefix * @return */ public static List<Material> collectItemsByPrefix(String prefix) { prefix = prefix.toLowerCase(); final List<Material> res = new LinkedList<Material>(); for (final Material mat : Material.values()) { if (!mat.isBlock() && mat.name().toLowerCase().startsWith(prefix)) { res.add(mat); } } return res; }
/** * Handles changes for minecraft 1.13. * Returns the material from the given id. * * @param id id * @return material */ public static Material getMaterialFromId(int id) { try { if (getMaterialFromIdMethod != null) { return (Material) getMaterialFromIdMethod.invoke(null, id); } else { for (final Material material : Material.values()) { if (getIdFromMaterial(material) == id) { return material; } } throw new RuntimeException("Material not found!"); } } catch (final IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } }
@Nullable public static Material toMaterial(Object o) { if (o instanceof Material) { return (Material)o; } if (o instanceof Integer) { return Material.values()[(Integer)o]; } if (o instanceof String) { String matName = (String)o; try { int value = Integer.parseInt(matName); return CompatibilityUtils.getMaterial(value); } catch (NumberFormatException ignored) { } return Material.getMaterial(matName.toUpperCase()); } return null; }
@Override public Collection<String> getBrushKeys() { List<String> names = new ArrayList<>(); Material[] materials = Material.values(); for (Material material : materials) { // Only show blocks if (material.isBlock()) { names.add(material.name().toLowerCase()); } } // Add special materials for (String brushName : MaterialBrush.SPECIAL_MATERIAL_KEYS) { names.add(brushName.toLowerCase()); } // Add schematics Collection<String> schematics = getSchematicNames(); for (String schematic : schematics) { names.add("schematic:" + schematic); } return names; }
@Override public void getParameterOptions(Spell spell, String parameterKey, Collection<String> examples) { if (parameterKey.equals("material")) { examples.addAll(MagicPlugin.getAPI().getBrushes()); } else if (parameterKey.equals("item")) { for (Material material : Material.values()) { examples.add(material.name().toLowerCase()); } Collection<String> allItems = spell.getController().getItemKeys(); for (String itemKey : allItems) { examples.add(itemKey); } } else if (parameterKey.equals("armor_slot")) { examples.add("0"); examples.add("1"); examples.add("2"); examples.add("3"); } else if (parameterKey.equals("use_item")) { examples.addAll(Arrays.asList(BaseSpell.EXAMPLE_BOOLEANS)); } else { super.getParameterOptions(spell, parameterKey, examples); } }
public TARDISPrefsTabComplete(TARDIS plugin) { List<String> mats = new ArrayList<>(); TARDISWalls.BLOCKS.forEach((key) -> mats.add(key.toString())); MAT_SUBS = ImmutableList.copyOf(mats); if (plugin.getConfig().getBoolean("travel.give_key") && !plugin.getConfig().getBoolean("allow.all_blocks")) { KEY_SUBS = ImmutableList.copyOf(plugin.getBlocksConfig().getStringList("keys")); } else { List<String> keys = new ArrayList<>(); Material[] materialValues = Material.values(); for (Material key : materialValues) { if (!key.isBlock()) { keys.add(key.toString()); } } KEY_SUBS = ImmutableList.copyOf(keys); } }
/** * Gives you a Material from a String (doesn't have to be fully typed in) * * @param name Name of the material * @return Material found */ public static Material getMaterial(String name) { String formatted = name.replaceAll("([a-z])([A-Z1-9])", "$1_$2").replace(' ', '_').toUpperCase(); Material material = MATERIAL_CACHE.get(formatted); if (material != null) { return material; } material = Material.matchMaterial(name); if (material != null) { MATERIAL_CACHE.put(formatted, material); return material; } material = new EnumParser<Material>().parse(name, Material.values()); if (material != null) { MATERIAL_CACHE.put(formatted, material); } return material; }
private static MapperEntry getMaterialMapping(Material lookup) { if (mapping.isEmpty()) { Material[] materials = Material.values();
@Override public void setupBlockProperties(final WorldConfigProvider<?> worldConfigProvider) { final Set<Material> itchyBlocks = new LinkedHashSet<Material>(); for (final Material mat : Material.values()) { if (!mat.isBlock()) { continue; } else if (guessItchyBlock(mat)) { // Uncertain bounding-box, allow passing through. long flags = BlockProperties.F_IGN_PASSABLE; if ((BlockFlags.hasAnyFlag(flags, BlockFlags.SOLID_GROUND))) { // Block can be ground, so allow standing on any height. flags |= BlockProperties.F_GROUND | BlockProperties.F_GROUND_HEIGHT; } /* * TODO: Might have to set all blocks to ground here, rather * catch flowers and the like with MaterialUtil. */ BlockFlags.addFlags(mat, flags); itchyBlocks.add(mat); } } if (!itchyBlocks.isEmpty()) { StaticLog.logDebug("The following blocks can not be modeled correctly: " + StringUtil.join(itchyBlocks, ", ")); } }
for (Material temp : Material.values()) { String mat; try{
VaultController vault = VaultController.getInstance(); for (Material material : Material.values()) { ItemStack testItem = new ItemStack(material, 1); inventory.setItem(itemSlot, testItem);
addIfPermissible(sender, options, "Magic.create.", wandKey); for (Material material : Material.values()) { addIfPermissible(sender, options, "Magic.create.", material.name().toLowerCase());
for (Material mat : Material.values()) set(mat.name(), CoerceJavaToLua.coerce(mat));