Add missing initialisation and nonNull filter
This commit is contained in:
parent
4b835187b5
commit
3d5201329b
@ -3,6 +3,7 @@ package net.tomatentum.marinara.registry;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import net.tomatentum.marinara.interaction.InteractionHandler;
|
import net.tomatentum.marinara.interaction.InteractionHandler;
|
||||||
@ -18,6 +19,7 @@ public class InteractionRegistry {
|
|||||||
private LibraryWrapper wrapper;
|
private LibraryWrapper wrapper;
|
||||||
|
|
||||||
public InteractionRegistry(LibraryWrapper wrapper) {
|
public InteractionRegistry(LibraryWrapper wrapper) {
|
||||||
|
this.interactionMethods = new ArrayList<>();
|
||||||
this.wrapper = wrapper;
|
this.wrapper = wrapper;
|
||||||
wrapper.subscribeInteractions(this::handle);
|
wrapper.subscribeInteractions(this::handle);
|
||||||
}
|
}
|
||||||
@ -31,6 +33,7 @@ public class InteractionRegistry {
|
|||||||
public void registerCommands() {
|
public void registerCommands() {
|
||||||
List<SlashCommandDefinition> defs = new ArrayList<>();
|
List<SlashCommandDefinition> defs = new ArrayList<>();
|
||||||
List<ExecutableSlashCommandDefinition> execDefs = interactionMethods.stream()
|
List<ExecutableSlashCommandDefinition> execDefs = interactionMethods.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.filter((x) -> x.getClass().isAssignableFrom(SlashCommandInteractionMethod.class))
|
.filter((x) -> x.getClass().isAssignableFrom(SlashCommandInteractionMethod.class))
|
||||||
.map((x) -> ((SlashCommandInteractionMethod)x).getCommandDefinition())
|
.map((x) -> ((SlashCommandInteractionMethod)x).getCommandDefinition())
|
||||||
.toList();
|
.toList();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user