-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved Initializing Process to CelestialInitializer. All Events are automatically added to it. Now Events without a Time Manager are initialized properly.
- Loading branch information
Showing
4 changed files
with
41 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../src/main/java/net/modificationstation/stationapi/api/celestial/CelestialInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.modificationstation.stationapi.api.celestial; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
/** | ||
* Automatically handles initialization of celestial events. | ||
* Ensures that all celestial events are loaded correctly. | ||
*/ | ||
public class CelestialInitializer { | ||
private static final List<CelestialEvent> ALL_EVENTS = new LinkedList<>(); | ||
|
||
/** | ||
* Called automatically by every celestial event. | ||
* @param celestialEvent The event to be added. | ||
*/ | ||
public static void addEvent(CelestialEvent celestialEvent) { | ||
ALL_EVENTS.add(celestialEvent); | ||
} | ||
|
||
/** | ||
* Prevents duplicates when worlds are switched. | ||
*/ | ||
public static void clearList() { | ||
ALL_EVENTS.clear(); | ||
} | ||
|
||
/** | ||
* Initializes all events when the world is loaded, ensures correct loading of active events. | ||
*/ | ||
public static void initializeEvents() { | ||
for (CelestialEvent celestialEvent : ALL_EVENTS) { | ||
if (celestialEvent == null) continue; | ||
celestialEvent.markForInitialization(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters