From cb7581b7f56ae2b5105ec543a3d2153a1c7cfa98 Mon Sep 17 00:00:00 2001 From: TheLimeGlass Date: Thu, 28 Mar 2024 14:43:18 -0600 Subject: [PATCH 1/2] Disallow addon list to be modified --- .../skriptparser/registration/SkriptAddon.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/syst3ms/skriptparser/registration/SkriptAddon.java b/src/main/java/io/github/syst3ms/skriptparser/registration/SkriptAddon.java index bc9c8277..2b8d0e3f 100644 --- a/src/main/java/io/github/syst3ms/skriptparser/registration/SkriptAddon.java +++ b/src/main/java/io/github/syst3ms/skriptparser/registration/SkriptAddon.java @@ -5,22 +5,28 @@ import io.github.syst3ms.skriptparser.lang.Trigger; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** * The base for all addons, modules that hook into the API to register syntax and handle triggers. */ public abstract class SkriptAddon { - private static final List addons = new ArrayList<>(); - private String name; + private final List> handledEvents = new ArrayList<>(); + private static final List ADDONS = new ArrayList<>(); { - addons.add(this); + ADDONS.add(this); } + /** + * Returns all SkriptAddons that are registered globally. + * + * @return SkriptAddons that are registered. + */ public static List getAddons() { - return addons; + return Collections.unmodifiableList(ADDONS); } /** @@ -51,4 +57,5 @@ public final boolean canHandleEvent(SkriptEvent event) { void addHandledEvent(Class event) { handledEvents.add(event); } + } From 88faace3663214132641fd020c0e5367be2f3406 Mon Sep 17 00:00:00 2001 From: TheLimeGlass Date: Thu, 28 Mar 2024 14:46:05 -0600 Subject: [PATCH 2/2] define javadoc better --- .../github/syst3ms/skriptparser/registration/SkriptAddon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/syst3ms/skriptparser/registration/SkriptAddon.java b/src/main/java/io/github/syst3ms/skriptparser/registration/SkriptAddon.java index 2b8d0e3f..285117ee 100644 --- a/src/main/java/io/github/syst3ms/skriptparser/registration/SkriptAddon.java +++ b/src/main/java/io/github/syst3ms/skriptparser/registration/SkriptAddon.java @@ -21,7 +21,7 @@ public abstract class SkriptAddon { } /** - * Returns all SkriptAddons that are registered globally. + * Returns unmodifiable list of all SkriptAddons that are registered globally. * * @return SkriptAddons that are registered. */