Skip to content

Commit

Permalink
Make ModBase.MOD_BASES thread-safe, Closes #189
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jul 30, 2024
1 parent 5e7e805 commit 6d07b3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ protected static InfoSection buildSection(IInfoBook infoBook, InfoSection parent
String[] split = tagString.split(":");
modRecipe = ModBase.get(split[0]);
if (modRecipe == null) {
throw new IllegalArgumentException("The mod " + split[0] + " could not be found as ModBase.");
throw new IllegalArgumentException("The mod " + split[0] + " could not be found as ModBase in " + ModBase.getMods().keySet());
}
tagString = split[1];
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/cyclops/cyclopscore/init/ModBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
*/
public abstract class ModBase<T extends ModBase> {

private static final Map<String, ModBase<?>> MOD_BASES = Maps.newHashMap();
private static final Map<String, ModBase<?>> MOD_BASES = Maps.newConcurrentMap();

public static final EnumReferenceKey<String> REFKEY_TEXTURE_PATH_GUI = EnumReferenceKey.create("texture_path_gui", String.class);
public static final EnumReferenceKey<String> REFKEY_TEXTURE_PATH_MODELS = EnumReferenceKey.create("texture_path_models", String.class);
Expand Down Expand Up @@ -489,6 +489,10 @@ public static ModBase get(String modId) {
return MOD_BASES.get(modId);
}

public static Map<String, ModBase<?>> getMods() {
return MOD_BASES;
}

/**
* Unique references to values that can be registered inside a mod.
* @param <T> The type of value.
Expand Down

0 comments on commit 6d07b3c

Please sign in to comment.