MCPcopy Create free account
hub / github.com/Bukkit/Bukkit / matchMaterial

Method matchMaterial

src/main/java/org/bukkit/Material.java:384–399  ·  view source on GitHub ↗

Attempts to match the Material with the given name. This is a match lookup; names will be converted to uppercase, then stripped of special characters in an attempt to format it like the enum @param name Name of the material to get @return Material if found, or null

(final String name)

Source from the content-addressed store, hash-verified

382 * @return Material if found, or null
383 */
384 public static Material matchMaterial(final String name) {
385 Material result = null;
386
387 try {
388 result = getMaterial(Integer.parseInt(name));
389 } catch (NumberFormatException ex) {}
390
391 if (result == null) {
392 String filtered = name.toUpperCase();
393
394 filtered = filtered.replaceAll("\\s+", "_").replaceAll("\\W", "");
395 result = lookupName.get(filtered);
396 }
397
398 return result;
399 }
400
401 static {
402 for (Material material : values()) {

Callers 1

executeMethod · 0.95

Calls 2

getMaterialMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected