Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow addon list to be modified #162

Merged
merged 2 commits into from
Mar 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 unmodifiable list of 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);
}

}
Loading