Skip to content

Commit

Permalink
Disallow addon list to be modified
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLimeGlass committed Mar 28, 2024
1 parent 139997f commit cb7581b
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SkriptAddon> addons = new ArrayList<>();
private String name;

private final List<Class<? extends SkriptEvent>> handledEvents = new ArrayList<>();
private static final List<SkriptAddon> ADDONS = new ArrayList<>();

{
addons.add(this);
ADDONS.add(this);
}

/**
* Returns all SkriptAddons that are registered globally.
*
* @return SkriptAddons that are registered.
*/
public static List<SkriptAddon> getAddons() {
return addons;
return Collections.unmodifiableList(ADDONS);
}

/**
Expand Down Expand Up @@ -51,4 +57,5 @@ public final boolean canHandleEvent(SkriptEvent event) {
void addHandledEvent(Class<? extends SkriptEvent> event) {
handledEvents.add(event);
}

}

0 comments on commit cb7581b

Please sign in to comment.