From 4a13899975e682e1537e88d09cb709ce06728e51 Mon Sep 17 00:00:00 2001 From: tueem Date: Fri, 25 Oct 2024 20:47:06 +0200 Subject: [PATCH] change to register all commands at once to use bulk overwrite features --- .../net/tomatentum/marinara/registry/InteractionRegistry.java | 3 ++- .../java/net/tomatentum/marinara/wrapper/LibraryWrapper.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/main/java/net/tomatentum/marinara/registry/InteractionRegistry.java b/lib/src/main/java/net/tomatentum/marinara/registry/InteractionRegistry.java index 6f57965..a52d951 100644 --- a/lib/src/main/java/net/tomatentum/marinara/registry/InteractionRegistry.java +++ b/lib/src/main/java/net/tomatentum/marinara/registry/InteractionRegistry.java @@ -2,6 +2,7 @@ package net.tomatentum.marinara.registry; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Optional; @@ -45,7 +46,7 @@ public class InteractionRegistry { defs.add(new ApplicationCommandDefinition(def.applicationCommand()).addExecutableCommand(def)); }); - defs.forEach(wrapper::registerApplicationCommand); + wrapper.registerApplicationCommands(defs.toArray(new ApplicationCommandDefinition[0])); } public void handle(Object context) { diff --git a/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java b/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java index 6b3410c..cd3c5d3 100644 --- a/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java +++ b/lib/src/main/java/net/tomatentum/marinara/wrapper/LibraryWrapper.java @@ -17,7 +17,7 @@ public abstract class LibraryWrapper { interactionSubscriber = new ArrayList<>(); } - public abstract void registerApplicationCommand(ApplicationCommandDefinition def); + public abstract void registerApplicationCommands(ApplicationCommandDefinition[] defs); public void handleInteraction(Object context) { interactionSubscriber.forEach((o) -> o.accept(context));