mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-02 13:37:43 -05:00
[ci skip] Some cleanup for Platform class and other platform-specific stuff (#201)
* Ensure paths returned by Platform are absolute, add javadocs to Platform Signed-off-by: Max <maxh2709@gmail.com> * Use putIfAbsent for event buses to clean up some minor nastyness Signed-off-by: Max <maxh2709@gmail.com> * Remove explicit NotNull annotation
This commit is contained in:
@@ -32,9 +32,7 @@ public final class EventBuses {
|
||||
private static final Map<String, List<Consumer<IEventBus>>> ON_REGISTERED = new HashMap<>();
|
||||
|
||||
public static void registerModEventBus(String modId, IEventBus bus) {
|
||||
IEventBus previous = EVENT_BUS_MAP.put(modId, bus);
|
||||
if (previous != null) {
|
||||
EVENT_BUS_MAP.put(modId, previous);
|
||||
if (EVENT_BUS_MAP.putIfAbsent(modId, bus) != bus) {
|
||||
throw new IllegalStateException("Can't register event bus for mod '" + modId + "' because it was previously registered!");
|
||||
}
|
||||
|
||||
|
||||
@@ -91,11 +91,11 @@ public class PlatformImpl {
|
||||
private final ModInfo info;
|
||||
|
||||
public ModImpl(String id) {
|
||||
this.container = ModList.get().getModContainerById(id).get();
|
||||
this.container = ModList.get().getModContainerById(id).orElseThrow();
|
||||
this.info = ModList.get().getMods().stream()
|
||||
.filter(modInfo -> Objects.equals(modInfo.getModId(), id))
|
||||
.findAny()
|
||||
.get();
|
||||
.orElseThrow();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user