fix(core): fix wrong equality method and refactor a bit

This commit is contained in:
Tueem 2025-03-17 00:15:10 +01:00
parent bce4ce7812
commit d4a91f3251
Signed by: tueem
GPG Key ID: F2CE0513D231AD7A

View File

@ -40,11 +40,12 @@ public class InteractionRegistry {
for (Method method : interactionHandler.getClass().getMethods()) { for (Method method : interactionHandler.getClass().getMethods()) {
InteractionMethod iMethod = InteractionMethod.create(method, interactionHandler, marinara); InteractionMethod iMethod = InteractionMethod.create(method, interactionHandler, marinara);
if (iMethod != null) { if (iMethod != null) {
Optional<InteractionEntry> entry = this.interactions.stream().filter(iMethod::equals).findFirst(); Optional<InteractionEntry> oentry = this.interactions.stream()
if (entry.isEmpty()) { .filter(i -> i.identifier().equals(iMethod.identifier()))
interactions.add(new InteractionEntry(iMethod.identifier()).addMethod(iMethod)); .findFirst();
}else
entry.get().addMethod(iMethod); InteractionEntry entry = oentry.orElse(new InteractionEntry(iMethod.identifier())).addMethod(iMethod);
if (oentry.isEmpty()) this.interactions.add(entry);
logger.debug("Added {} method from {}", iMethod.method().getName(), interactionHandler.getClass().getSimpleName()); logger.debug("Added {} method from {}", iMethod.method().getName(), interactionHandler.getClass().getSimpleName());
} }
} }