Skip to content

Commit

Permalink
refactor: AllayAPI.API_VERSION shouldn't be internal
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Oct 16, 2024
1 parent aeb7baf commit 246a0c6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/src/main/java/org/allaymc/api/AllayAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/
@Slf4j
@Getter
@ApiStatus.Internal
public final class AllayAPI {

/**
Expand Down Expand Up @@ -65,6 +64,7 @@ public static AllayAPI getInstance() {
* @throws MissingImplementationException If there are interface which are not been implemented
*/
@SuppressWarnings("unchecked")
@ApiStatus.Internal
public void implement(String coreName) throws MissingImplementationException {
if (!i18nSet) throw new MissingImplementationException("Missing i18n implementation!");
for (var entry : bindings.entrySet()) {
Expand All @@ -86,6 +86,7 @@ public void implement(String coreName) throws MissingImplementationException {
implemented = true;
}

@ApiStatus.Internal
public <T> void requireImpl(Class<T> api) {
requireImpl(api, null);
}
Expand All @@ -95,11 +96,13 @@ public <T> void requireImpl(Class<T> api) {
*
* @param api the api
*/
@ApiStatus.Internal
public <T> void requireImpl(Class<T> api, Consumer<T> apiInstanceConsumer) {
bindings.put(api, null);
if (apiInstanceConsumer != null) consumers.put(api, apiInstanceConsumer);
}

@ApiStatus.Internal
public <T> void bind(Class<T> api, Supplier<T> supplier) {
bind(api, supplier, null);
}
Expand All @@ -112,12 +115,14 @@ public <T> void bind(Class<T> api, Supplier<T> supplier) {
* @param afterBound the consumer which will be called after the api instance has been bound.
* @param <T> the type of the api class.
*/
@ApiStatus.Internal
public <T> void bind(Class<T> api, Supplier<T> bindingAction, Consumer<T> afterBound) {
Objects.requireNonNull(api);
Objects.requireNonNull(bindingAction);
bindings.put(api, new ApiBindingAction<>(bindingAction, afterBound));
}

@ApiStatus.Internal
public void bindI18n(I18n i18nImpl) {
Objects.requireNonNull(i18nImpl);
I18n.I18N.set(i18nImpl);
Expand All @@ -134,6 +139,7 @@ public void bindI18n(I18n i18nImpl) {
* @return the implementation instance of the specific interface
* @throws RuntimeException if the interface has not been implemented
*/
@ApiStatus.Internal
public <T> T getAPIInstance(Class<T> api) {
if (!implemented)
throw new RuntimeException("AllayAPI::getAPIInstance cannot be called before it been implemented");
Expand Down

0 comments on commit 246a0c6

Please sign in to comment.