File tree Expand file tree Collapse file tree
main/java/io/github/thebusybiscuit/slimefun4
test/java/io/github/thebusybiscuit/slimefun4/api/events Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232 architecture : x64
3333
3434 - name : Cache Maven packages
35- uses : actions/cache@v3
35+ uses : actions/cache@v4
3636 with :
3737 path : ~/.m2
3838 key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Original file line number Diff line number Diff line change 3636 architecture : x64
3737
3838 - name : Cache Maven packages
39- uses : actions/cache@v3
39+ uses : actions/cache@v4
4040 with :
4141 path : ~/.m2
4242 key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Original file line number Diff line number Diff line change 3030 architecture : x64
3131
3232 - name : Cache Maven packages
33- uses : actions/cache@v3
33+ uses : actions/cache@v4
3434 with :
3535 path : ~/.m2
3636 key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Original file line number Diff line number Diff line change @@ -32,14 +32,14 @@ jobs:
3232 architecture : x64
3333
3434 - name : Cache SonarCloud packages
35- uses : actions/cache@v3
35+ uses : actions/cache@v4
3636 with :
3737 path : ~/.sonar/cache
3838 key : ${{ runner.os }}-sonar
3939 restore-keys : ${{ runner.os }}-sonar
4040
4141 - name : Cache Maven packages
42- uses : actions/cache@v3
42+ uses : actions/cache@v4
4343 with :
4444 path : ~/.m2
4545 key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Original file line number Diff line number Diff line change 1+ package io .github .thebusybiscuit .slimefun4 .api .events ;
2+
3+ import javax .annotation .Nonnull ;
4+
5+ import org .bukkit .event .Event ;
6+ import org .bukkit .event .HandlerList ;
7+
8+ import io .github .thebusybiscuit .slimefun4 .api .items .SlimefunItem ;
9+ import io .github .thebusybiscuit .slimefun4 .implementation .Slimefun ;
10+
11+
12+ /**
13+ * This {@link Event} is fired after {@link Slimefun} finishes loading the
14+ * {@link SlimefunItem} registry. We recommend listening to this event if you
15+ * want to register recipes using items from other addons.
16+ *
17+ * @author ProfElements
18+ */
19+ public class SlimefunItemRegistryFinalizedEvent extends Event {
20+
21+ private static final HandlerList handlers = new HandlerList ();
22+
23+ public SlimefunItemRegistryFinalizedEvent () {}
24+
25+ @ Nonnull
26+ public static HandlerList getHandlerList () {
27+ return handlers ;
28+ }
29+
30+ @ Nonnull
31+ @ Override
32+ public HandlerList getHandlers () {
33+ return getHandlerList ();
34+ }
35+ }
Original file line number Diff line number Diff line change 2424import com .google .gson .JsonElement ;
2525import com .google .gson .JsonObject ;
2626
27+ import io .github .thebusybiscuit .slimefun4 .api .events .SlimefunItemRegistryFinalizedEvent ;
2728import io .github .thebusybiscuit .slimefun4 .api .items .SlimefunItem ;
2829import io .github .thebusybiscuit .slimefun4 .implementation .Slimefun ;
2930import io .github .thebusybiscuit .slimefun4 .implementation .SlimefunItems ;
@@ -77,6 +78,8 @@ public static void loadItems() {
7778 }
7879 }
7980
81+ Bukkit .getPluginManager ().callEvent (new SlimefunItemRegistryFinalizedEvent ());
82+
8083 loadOreGrinderRecipes ();
8184 loadSmelteryRecipes ();
8285
Original file line number Diff line number Diff line change 1+ package io .github .thebusybiscuit .slimefun4 .api .events ;
2+
3+ import org .junit .jupiter .api .Assertions ;
4+
5+ import org .junit .jupiter .api .AfterAll ;
6+ import org .junit .jupiter .api .BeforeAll ;
7+ import org .junit .jupiter .api .DisplayName ;
8+ import org .junit .jupiter .api .Test ;
9+
10+ import be .seeseemelk .mockbukkit .MockBukkit ;
11+ import be .seeseemelk .mockbukkit .ServerMock ;
12+ import io .github .thebusybiscuit .slimefun4 .implementation .Slimefun ;
13+ import io .github .thebusybiscuit .slimefun4 .implementation .setup .PostSetup ;
14+
15+ class TestSlimefunRegistryFinalizedEvent {
16+
17+ private static ServerMock server ;
18+ private static Slimefun plugin ;
19+
20+ @ BeforeAll
21+ public static void load () {
22+ server = MockBukkit .mock ();
23+ plugin = MockBukkit .load (Slimefun .class );
24+ }
25+
26+ @ AfterAll
27+ public static void unload () {
28+ MockBukkit .unmock ();
29+ }
30+
31+ @ Test
32+ @ DisplayName ("Test that SlimefunRegistryFinalizedEvent is fired" )
33+ void testEventIsFired () {
34+ // Make sure post setup does not throw
35+ Assertions .assertDoesNotThrow (() -> PostSetup .loadItems ());
36+
37+ // Make sure post setup sent the event
38+ server .getPluginManager ().assertEventFired (SlimefunItemRegistryFinalizedEvent .class , ignored -> true );
39+
40+ server .getPluginManager ().clearEvents ();
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments