Skip to content

Commit

Permalink
Throw an exception when attempting to register an abstract class (#6307)
Browse files Browse the repository at this point in the history
  • Loading branch information
takejohn authored Mar 9, 2024
1 parent f603e9d commit ae1f465
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/ch/njol/skript/lang/SyntaxElementInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package ch.njol.skript.lang;

import ch.njol.skript.SkriptAPIException;

import java.lang.reflect.Modifier;
import java.util.Arrays;

/**
Expand All @@ -30,8 +33,11 @@ public class SyntaxElementInfo<E extends SyntaxElement> {
public final Class<E> elementClass;
public final String[] patterns;
public final String originClassPath;

public SyntaxElementInfo(String[] patterns, Class<E> elementClass, String originClassPath) throws IllegalArgumentException {
if (Modifier.isAbstract(elementClass.getModifiers()))
throw new SkriptAPIException("Class " + elementClass.getName() + " is abstract");

this.patterns = patterns;
this.elementClass = elementClass;
this.originClassPath = originClassPath;
Expand Down

0 comments on commit ae1f465

Please sign in to comment.