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)
| 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()) { |
no test coverage detected