From ae1f4656f43cf62c57945de0739837d47ecf5119 Mon Sep 17 00:00:00 2001 From: Take-John <105504345+takejohn@users.noreply.github.com> Date: Sun, 10 Mar 2024 05:42:05 +0900 Subject: [PATCH] Throw an exception when attempting to register an abstract class (#6307) --- src/main/java/ch/njol/skript/lang/SyntaxElementInfo.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/lang/SyntaxElementInfo.java b/src/main/java/ch/njol/skript/lang/SyntaxElementInfo.java index fe280fef471..3945d2eb02b 100644 --- a/src/main/java/ch/njol/skript/lang/SyntaxElementInfo.java +++ b/src/main/java/ch/njol/skript/lang/SyntaxElementInfo.java @@ -18,6 +18,9 @@ */ package ch.njol.skript.lang; +import ch.njol.skript.SkriptAPIException; + +import java.lang.reflect.Modifier; import java.util.Arrays; /** @@ -30,8 +33,11 @@ public class SyntaxElementInfo { public final Class elementClass; public final String[] patterns; public final String originClassPath; - + public SyntaxElementInfo(String[] patterns, Class 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;