Skip to content

Commit

Permalink
Added option methods to allow classes for registering
Browse files Browse the repository at this point in the history
  • Loading branch information
srnyx committed Oct 7, 2023
1 parent e65ef31 commit 55917e4
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import xyz.srnyx.javautilities.parents.Stringable;

import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
Expand Down Expand Up @@ -122,6 +123,37 @@ public RegistrationOptions toRegister(@NotNull Registrable... toRegister) {
return toRegister(Arrays.asList(toRegister));
}

/**
* Adds the specified {@link Registrable}s to {@link #toRegister}
*
* @param plugin the plugin instance
* @param toRegister the {@link Registrable}s to add
*
* @return this {@link RegistrationOptions} instance for chaining
*/
@NotNull
public RegistrationOptions toRegister(@NotNull AnnoyingPlugin plugin, @NotNull Collection<Class<? extends Registrable>> toRegister) {
for (final Class<? extends Registrable> registrable : toRegister) try {
this.toRegister.add(registrable.getConstructor(plugin.getClass()).newInstance(plugin));
} catch (final NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
return this;
}

/**
* Adds the specified {@link Registrable}s to {@link #toRegister}
*
* @param plugin the plugin instance
* @param toRegister the {@link Registrable}s to add
*
* @return this {@link RegistrationOptions} instance for chaining
*/
@NotNull
public RegistrationOptions toRegister(@NotNull AnnoyingPlugin plugin, @NotNull Class<? extends Registrable>... toRegister) {
return toRegister(plugin, Arrays.asList(toRegister));
}

/**
* Sets the {@link #papiExpansionToRegister}
*
Expand Down

0 comments on commit 55917e4

Please sign in to comment.