22
33import de .z0rdak .yawp .constants .Constants ;
44import de .z0rdak .yawp .core .flag .*;
5- import net .minecraft .ResourceLocationException ;
6- import net .minecraft .resources .ResourceLocation ;
5+ import net .minecraft .IdentifierException ;
6+ import net .minecraft .resources .Identifier ;
77import org .jetbrains .annotations .NotNull ;
88import org .jetbrains .annotations .Nullable ;
99
@@ -15,21 +15,21 @@ public class FlagRegister {
1515 private FlagRegister () {
1616 }
1717
18- private static final Map <ResourceLocation , Flag > flagRegister = new HashMap <>();
18+ private static final Map <Identifier , Flag > flagRegister = new HashMap <>();
1919
20- private static ResourceLocation flagId (final String flagName ) {
21- return ResourceLocation .fromNamespaceAndPath (Constants .MOD_ID , flagName );
20+ private static Identifier flagId (final String flagName ) {
21+ return Identifier .fromNamespaceAndPath (Constants .MOD_ID , flagName );
2222 }
2323
2424 /**
2525 * Checks if the given flag ID matches the specified Flag.
2626 *
2727 * @param flagId The string representation of the flag ID.
2828 * @param flag The flag to compare against.
29- * @return True if the flag ID matches the flag's ResourceLocation , false otherwise.
29+ * @return True if the flag ID matches the flag's Identifier , false otherwise.
3030 */
3131 public static boolean isSame (String flagId , Flag flag ) {
32- ResourceLocation left = ResourceLocation .parse (flagId );
32+ Identifier left = Identifier .parse (flagId );
3333 return left .equals (flag .id ());
3434 }
3535
@@ -38,20 +38,20 @@ public static boolean isSame(String flagId, Flag flag) {
3838 *
3939 * @param left The first flag.
4040 * @param right The second flag.
41- * @return True if both flags have the same ResourceLocation , false otherwise.
41+ * @return True if both flags have the same Identifier , false otherwise.
4242 */
4343 public static boolean isSame (Flag left , Flag right ) {
4444 return isSame (left .id (), right );
4545 }
4646
4747 /**
48- * Checks if the given ResourceLocation matches the specified Flag.
48+ * Checks if the given Identifier matches the specified Flag.
4949 *
50- * @param flagId The ResourceLocation of the flag.
50+ * @param flagId The Identifier of the flag.
5151 * @param flag The flag to compare against.
52- * @return True if the ResourceLocation matches the flag's ResourceLocation , false otherwise.
52+ * @return True if the Identifier matches the flag's Identifier , false otherwise.
5353 */
54- public static boolean isSame (ResourceLocation flagId , Flag flag ) {
54+ public static boolean isSame (Identifier flagId , Flag flag ) {
5555 return flagId .equals (flag .id ());
5656 }
5757
@@ -71,14 +71,14 @@ private static boolean registerFlag(Flag flag) {
7171 }
7272
7373 /**
74- * Registers a flag in the internal flag registry using a {@link ResourceLocation } and {@link FlagMetaInfo}.
74+ * Registers a flag in the internal flag registry using a {@link Identifier } and {@link FlagMetaInfo}.
7575 * If a flag with the same resource location already exists, registration is skipped.
7676 *
7777 * @param flagRl The unique resource location of the flag.
7878 * @param flagMetaInfo The metadata associated with the flag.
7979 * @return {@code true} if the flag was successfully registered, {@code false} if it was already registered.
8080 */
81- public static boolean registerFlag (@ NotNull ResourceLocation flagRl , @ NotNull FlagMetaInfo flagMetaInfo ) {
81+ public static boolean registerFlag (@ NotNull Identifier flagRl , @ NotNull FlagMetaInfo flagMetaInfo ) {
8282 if (flagRl .getNamespace ().equalsIgnoreCase (Constants .MOD_ID )) {
8383 throw new IllegalArgumentException ("You are not permitted to register flags with the YAWP namespace!" );
8484 }
@@ -95,7 +95,7 @@ public static boolean registerFlag(@NotNull ResourceLocation flagRl, @NotNull Fl
9595 * @return {@code true} if the flag was successfully registered, {@code false} if it was already registered.
9696 */
9797 public static boolean registerFlag (@ NotNull String modId , @ NotNull String flagId , @ NotNull FlagMetaInfo flagMetaInfo ) {
98- var rl = ResourceLocation .fromNamespaceAndPath (modId , flagId );
98+ var rl = Identifier .fromNamespaceAndPath (modId , flagId );
9999 return registerFlag (rl , flagMetaInfo );
100100 }
101101
@@ -112,12 +112,12 @@ public static Set<Flag> getFlagsByFrequency(FlagFrequency frequency) {
112112 }
113113
114114 /**
115- * Checks if a flag is registered based on its ResourceLocation .
115+ * Checks if a flag is registered based on its Identifier .
116116 *
117- * @param rl The ResourceLocation of the flag.
117+ * @param rl The Identifier of the flag.
118118 * @return True if the flag is registered, false otherwise.
119119 */
120- public static boolean isFlagRegistered (ResourceLocation rl ) {
120+ public static boolean isFlagRegistered (Identifier rl ) {
121121 return flagRegister .containsKey (rl );
122122 }
123123
@@ -129,9 +129,9 @@ public static boolean isFlagRegistered(ResourceLocation rl) {
129129 */
130130 public static boolean isRegistered (String flagIdentifier ) {
131131 try {
132- ResourceLocation rl = ResourceLocation .parse (flagIdentifier );
132+ Identifier rl = Identifier .parse (flagIdentifier );
133133 return isFlagRegistered (rl );
134- } catch (ResourceLocationException rle ) {
134+ } catch (IdentifierException rle ) {
135135 return false ;
136136 }
137137 }
@@ -145,29 +145,29 @@ public static boolean isRegistered(String flagIdentifier) {
145145 */
146146 public static Flag byId (String flagIdentifier ) throws IllegalArgumentException {
147147 if (isRegistered (flagIdentifier )) {
148- return flagRegister .get (ResourceLocation .parse (flagIdentifier ));
148+ return flagRegister .get (Identifier .parse (flagIdentifier ));
149149 }
150150 throw new IllegalArgumentException ("Invalid region flag identifier supplied" );
151151 }
152152
153153 /**
154154 * Retrieves an Optional containing the Flag if it exists.
155155 *
156- * @param rl The ResourceLocation of the flag.
156+ * @param rl The Identifier of the flag.
157157 * @return An Optional containing the flag if registered, otherwise empty.
158158 */
159- public static Optional <Flag > getFlagOptional (ResourceLocation rl ) {
159+ public static Optional <Flag > getFlagOptional (Identifier rl ) {
160160 return isFlagRegistered (rl ) ? Optional .of (flagRegister .get (rl )) : Optional .empty ();
161161 }
162162
163163 /**
164- * Retrieves a Flag by its ResourceLocation , or null if not found.
164+ * Retrieves a Flag by its Identifier , or null if not found.
165165 *
166- * @param rl The ResourceLocation of the flag.
166+ * @param rl The Identifier of the flag.
167167 * @return The corresponding Flag if registered, otherwise null.
168168 */
169169 @ Nullable
170- public static Flag getFlag (ResourceLocation rl ) {
170+ public static Flag getFlag (Identifier rl ) {
171171 return isFlagRegistered (rl ) ? flagRegister .get (rl ) : null ;
172172 }
173173
@@ -178,7 +178,7 @@ public static Flag getFlag(ResourceLocation rl) {
178178 */
179179 public static List <String > getFlagNames () {
180180 return flagRegister .keySet ().stream ()
181- .map (ResourceLocation ::toString )
181+ .map (Identifier ::toString )
182182 .collect (Collectors .toList ());
183183 }
184184
0 commit comments