|
2 | 2 |
|
3 | 3 | import java.util.Objects; |
4 | 4 |
|
| 5 | +/** |
| 6 | + * Namespaced identifiers are two-part strings that uniquely point to content in Minecraft. |
| 7 | + * The two parts are the namespace and the identifier. They can be combined into a single |
| 8 | + * string representation as namespace:identifier (the namespace, followed by the identifier, |
| 9 | + * separated by a colon). |
| 10 | + * <p> |
| 11 | + * A namespace is a domain for content. It is used not to point to specific content, but to |
| 12 | + * differentiate between different content sources or publishers. The use of namespaces can |
| 13 | + * prevent conflicts between mods, resource packs, or data packs, in cases where the same |
| 14 | + * identifier is used. |
| 15 | + * <p> |
| 16 | + * The identifier is a unique name for content within a namespace. It should be descriptive |
| 17 | + * to avoid naming conflicts with other content. The preferred format is snake_case. |
| 18 | + * <p> |
| 19 | + * Namespaces may only contain alphanumeric characters [a-zA-Z0-9] and special characters |
| 20 | + * [-._]. Identifiers may also contain the special character [/]. |
| 21 | + * <p> |
| 22 | + * This class is essentially equivalent to Vanilla's {@code Identifier}. It was added for a |
| 23 | + * few reasons. For one, Vanilla's {@code Identifier} was only added in 13w21a, and then was |
| 24 | + * client-only until 14w27b. Implementation details of this class also changed a few times, |
| 25 | + * and only since 17w43a were {@code Identifiers} validated in any way. |
| 26 | + * <br> This class is available for all Minecraft versions, without any version-specific |
| 27 | + * implementation details. |
| 28 | + */ |
5 | 29 | public final class NamespacedIdentifier { |
6 | 30 |
|
| 31 | + /** |
| 32 | + * The separator between the namespace and identifier in the {@code String} |
| 33 | + * representation of a {@code NamespacedIdentifier}. |
| 34 | + */ |
7 | 35 | public static final char SEPARATOR = ':'; |
8 | 36 |
|
| 37 | + /** |
| 38 | + * The namespace of this {@code NamespacedIdentifier}. |
| 39 | + */ |
9 | 40 | private final String namespace; |
| 41 | + /** |
| 42 | + * The identifier of this {@code NamespacedIdentifier}. |
| 43 | + */ |
10 | 44 | private final String identifier; |
11 | 45 |
|
12 | 46 | NamespacedIdentifier(String namespace, String identifier) { |
@@ -36,10 +70,16 @@ public String toString() { |
36 | 70 | return namespace + SEPARATOR + identifier; |
37 | 71 | } |
38 | 72 |
|
| 73 | + /** |
| 74 | + * @return the namespace of this {@code NamespacedIdentifier}. |
| 75 | + */ |
39 | 76 | public String getNamespace() { |
40 | 77 | return namespace; |
41 | 78 | } |
42 | 79 |
|
| 80 | + /** |
| 81 | + * @return the identifier of this {@code NamespacedIdentifier}. |
| 82 | + */ |
43 | 83 | public String getIdentifier() { |
44 | 84 | return identifier; |
45 | 85 | } |
|
0 commit comments