Skip to content

Commit

Permalink
feat(api): add EventManager to FeatureContext.Registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Siroshun09 committed Apr 11, 2024
1 parent 41e2834 commit b5f6fc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.okocraft.box.api.feature;

import net.okocraft.box.api.message.DefaultMessageCollector;
import net.okocraft.box.api.model.manager.EventManager;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Contract;
Expand All @@ -18,8 +19,10 @@ public final class FeatureContext {
*
* @param dataDirectory a plugin's data directory
* @param defaultMessageCollector a {@link DefaultMessageCollector} to collect default messages
* @param eventManager a {@link EventManager}
*/
public record Registration(@NotNull Path dataDirectory, @NotNull DefaultMessageCollector defaultMessageCollector) {
public record Registration(@NotNull Path dataDirectory, @NotNull DefaultMessageCollector defaultMessageCollector,
@NotNull EventManager eventManager) {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public final class BoxBootstrapContext implements net.okocraft.box.api.bootstrap
private final BoxMessageProvider.Collector defaultMessageCollector;
private final Map<Locale, Loader<Locale, Map<String, String>>> localizationLoaderMap = new HashMap<>();
private final List<BoxFeature> boxFeatureList = new ArrayList<>();
private final FeatureContext.Registration featureRegistrationContext;

@VisibleForTesting
BoxBootstrapContext(@NotNull Path pluginDirectory, @NotNull String version) {
Expand All @@ -50,6 +51,7 @@ public final class BoxBootstrapContext implements net.okocraft.box.api.bootstrap
this.storageRegistry = new StorageRegistry();
this.eventManager = BoxEventManager.create();
this.defaultMessageCollector = BoxMessageProvider.createCollector();
this.featureRegistrationContext = new FeatureContext.Registration(this.dataDirectory, this.defaultMessageCollector, this.eventManager);
}

@Override
Expand All @@ -75,7 +77,7 @@ public final class BoxBootstrapContext implements net.okocraft.box.api.bootstrap
@Override
@Contract("_ -> this")
public @NotNull BoxBootstrapContext addFeature(@NotNull FeatureFactory factory) {
this.boxFeatureList.add(factory.create(new FeatureContext.Registration(this.dataDirectory, this.defaultMessageCollector)));
this.boxFeatureList.add(factory.create(this.featureRegistrationContext));
return this;
}

Expand Down

0 comments on commit b5f6fc4

Please sign in to comment.