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

New Registration API #6246

Open
wants to merge 145 commits into
base: dev/feature
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
1c62976
First api design
kiip1 Jan 5, 2023
f913c6b
Rework and implement for expression
kiip1 Jan 5, 2023
43d4cee
Implement for all syntax elements
kiip1 Jan 5, 2023
42fe5ca
Rename to Skript and other small refactors
kiip1 Jan 5, 2023
3297132
Registration closing
kiip1 Jan 5, 2023
5c69bdc
Child key
kiip1 Jan 6, 2023
d74c11f
Cleanup
kiip1 Jan 6, 2023
0fd91f4
Moving
kiip1 Jan 6, 2023
98f6b3d
hashcode
kiip1 Jan 6, 2023
7b5c8b8
Oops
kiip1 Jan 6, 2023
c5ac2d0
TODO
kiip1 Jan 6, 2023
3e1849f
Move event pattern transformation to the correct place
kiip1 Jan 6, 2023
a44c08e
Merge branch 'master' into feature/api-rework
kiip1 Jan 6, 2023
e467eb0
Moves key implementation away
kiip1 Jan 6, 2023
8b82bb8
Apply suggestions from code review
kiip1 Jan 7, 2023
501573a
Apply suggestions from code review
kiip1 Jan 7, 2023
513a008
Requested changes
kiip1 Jan 7, 2023
552e7b5
Package rename
kiip1 Jan 7, 2023
678cb85
Refactoring
kiip1 Jan 7, 2023
a85016f
Deprecation
kiip1 Jan 7, 2023
11ffcf4
Merge branch 'master' into feature/api-rework
kiip1 Jan 7, 2023
9807e83
Merge remote-tracking branch 'origin/feature/api-rework' into feature…
kiip1 Jan 7, 2023
f5498a7
Builders
kiip1 Jan 7, 2023
2d7f4fb
Use builders
kiip1 Jan 7, 2023
51782ec
Certified license header moment
kiip1 Jan 7, 2023
4a00130
Not too proud of this one
kiip1 Jan 7, 2023
3f877f1
Merge branch 'master' into feature/api-rework
kiip1 Jan 21, 2023
04505e0
Merge branch 'master' into feature/api-rework
kiip1 Jan 26, 2023
63957ea
Fix tests
kiip1 Jan 26, 2023
69b5960
Refactoring
kiip1 Jan 26, 2023
5976231
Replace with shorter version
kiip1 Jan 26, 2023
241f97e
Fix order
kiip1 Jan 28, 2023
eafffac
Merge branch 'master' into feature/api-rework
kiip1 Jan 28, 2023
5b686c0
Refactoring
kiip1 Jan 28, 2023
abab4f7
Merge branch 'master' into feature/api-rework
kiip1 Jan 28, 2023
6cd6215
Merge branch 'master' into feature/api-rework
kiip1 Feb 12, 2023
b9ed60f
Merge branch 'master' into feature/api-rework
kiip1 Feb 17, 2023
7983cf5
Cherry-pick docs-tool into api-rework
kiip1 Feb 27, 2023
db7b807
Merge branch 'master' into feature/api-rework
kiip1 Feb 27, 2023
c983079
Fix documentation
kiip1 Feb 27, 2023
8726396
Merge remote-tracking branch 'origin/feature/api-rework' into feature…
kiip1 Feb 27, 2023
af6c9b7
Merge branch 'master' into feature/api-rework
kiip1 May 1, 2023
d768af4
Double tabbing
kiip1 May 1, 2023
131d07b
Fix registrations
kiip1 May 1, 2023
e07efe7
Attempt 2
kiip1 May 1, 2023
0c281fa
Merge branch 'master' into feature/api-rework
kiip1 May 18, 2023
78443ff
Apply suggestions from code review
kiip1 May 18, 2023
f4238e9
Allows updating of Skript instance.
kiip1 May 18, 2023
72049bd
Fix error
kiip1 May 18, 2023
238ab4f
Deprecation
kiip1 May 18, 2023
159da8f
Simpler keys
kiip1 May 18, 2023
130933b
SimpleSkriptRegistry
kiip1 May 18, 2023
5dbdf41
Priority stuff
kiip1 May 18, 2023
f402417
Allow for multiple Skript instances
kiip1 May 19, 2023
3eab3d1
Suppliers for syntax elements
kiip1 May 19, 2023
b2a9ef1
Merge branch 'dev/feature' into feature/registration-rework
APickledWalrus Dec 19, 2023
db97884
Fixes for event parsing changes
APickledWalrus Dec 19, 2023
9f912e7
Improve BukkitOrigin; Remove LegacyEventImpl
APickledWalrus Dec 19, 2023
3d6b116
Origin improvements
APickledWalrus Dec 19, 2023
1b9587e
Rework SyntaxInfo/Builder system
APickledWalrus Dec 21, 2023
53cba39
Improve Registry and Key system
APickledWalrus Dec 21, 2023
61205ea
Improve SyntaxRegister docs
APickledWalrus Dec 21, 2023
387b57c
Improve SyntaxInfo implementations
APickledWalrus Dec 21, 2023
93fe78c
Add missing JavaDocs
APickledWalrus Dec 21, 2023
5870190
Require builders for creating SyntaxInfos
APickledWalrus Dec 21, 2023
bab67ee
Initial implementation of new Addon API
APickledWalrus Dec 22, 2023
f376b7b
Merge branch 'dev/feature' into feature/registration-rework
Moderocky Dec 23, 2023
c67420f
Address UnderscoreTud's review
APickledWalrus Dec 26, 2023
c983968
Address Moderocky's review
APickledWalrus Dec 26, 2023
98a4e1d
Improve compatibility implementation
APickledWalrus Dec 26, 2023
30ceb36
Remove Skript State system
APickledWalrus Dec 26, 2023
f59ae28
Merge branch 'dev/feature' into feature/registration-rework
APickledWalrus Jan 12, 2024
6816377
Minor Tweaks
APickledWalrus Jan 13, 2024
88ecd23
Localizer system draft
APickledWalrus Jan 13, 2024
966beb2
Merge branch 'dev/feature' into feature/registration-rework
APickledWalrus Feb 2, 2024
3edc884
Localizer Fixes
APickledWalrus Feb 9, 2024
7ad773f
Merge branch 'dev/feature' into feature/registration-rework
APickledWalrus Feb 9, 2024
dc2872b
Add support for property registration methods
APickledWalrus Feb 10, 2024
e763810
Add support for unregistering syntax infos
APickledWalrus Mar 11, 2024
7759fcd
First pass at SkriptAddon rework
APickledWalrus Mar 12, 2024
eadae09
Implement child registries for addons
APickledWalrus Mar 12, 2024
65ad3a6
Fix language and addon compatibility
APickledWalrus Mar 12, 2024
bce2323
Fix building and tests
APickledWalrus Mar 12, 2024
17937f2
Merge branch 'dev/feature' into feature/registration-rework
APickledWalrus Mar 12, 2024
2560021
Block registration of interfaces/abstract classes
APickledWalrus Mar 13, 2024
fc5c637
Origin reworks
APickledWalrus Mar 13, 2024
9c60638
First pass at priority rework
APickledWalrus Mar 13, 2024
397b831
Add priority support to info builders
APickledWalrus Mar 13, 2024
3f7f973
Revert Structure priority changes
APickledWalrus Mar 14, 2024
39f26b2
Pivot to a relational priority system
APickledWalrus Mar 14, 2024
2316060
Replace ExpressionType with priority system
APickledWalrus Mar 14, 2024
bb47855
Revert some unnecessary changes
APickledWalrus Mar 14, 2024
cc6394f
Add missing EventValueExpression registration api
APickledWalrus Mar 14, 2024
2ec8806
Rework Expression priorities to be for all SyntaxInfos
APickledWalrus Mar 14, 2024
7dbe48b
Change Skript.createInstance to also return modifiable addon
APickledWalrus Mar 14, 2024
97f0603
Add SyntaxPriority
APickledWalrus Mar 15, 2024
b025c15
Move module loading out of registration
APickledWalrus Mar 15, 2024
e4a28a0
Add missing PriorityImpl checks
APickledWalrus Mar 15, 2024
efaa4fe
SyntaxPriority improvements and clarifications
APickledWalrus Mar 15, 2024
eaf5c4e
Limitations on SyntaxPriority
APickledWalrus Mar 15, 2024
3333273
Alternative module loading method
APickledWalrus Apr 17, 2024
6efbb55
Remove unnecessary SyntaxRegister interface
APickledWalrus Apr 17, 2024
3b22fe9
Merge branch 'dev/feature' into feature/registration-rework
APickledWalrus Jun 1, 2024
c165765
Fix simple structure support
APickledWalrus Jun 1, 2024
92712ef
Merge branch 'dev/feature' into feature/registration-rework
APickledWalrus Jun 3, 2024
a9c414b
Implement Registry interface
APickledWalrus Jun 3, 2024
dd7903e
Remove SyntaxPriority Implementation
APickledWalrus Jun 3, 2024
f296812
Disconnect Event Info from Structure Info
APickledWalrus Jun 3, 2024
f272892
Allow structures to be simple or section
APickledWalrus Jun 3, 2024
a2b9264
Improve SyntaxInfo parameter checks
APickledWalrus Jun 7, 2024
a886b25
Add class loading utilities
APickledWalrus Jun 14, 2024
8998a2e
Replace ClassLoader Java 11 methods
APickledWalrus Jun 14, 2024
bd18917
SkriptAddon: remove unnecessary annotations
APickledWalrus Jun 14, 2024
5f483a5
ClassLoader: add default loadClasses method
APickledWalrus Jun 14, 2024
a11a9a9
Use builder method for Expression return type
APickledWalrus Jun 28, 2024
b97269e
Remove license headers
APickledWalrus Jun 28, 2024
776129e
Prevent SkriptImpl from exposing its addons
APickledWalrus Jun 28, 2024
a7d5088
Use the same registry across all addons
APickledWalrus Jun 28, 2024
ce2e82e
Rename SkriptAddon#registry to SkriptAddon#syntaxRegistry
APickledWalrus Jun 28, 2024
e73da23
Add ViewProvider interface
APickledWalrus Jun 29, 2024
55fa670
Improve annotation usage and placement
APickledWalrus Jun 29, 2024
681585c
Remove deprecation annotations
APickledWalrus Jun 29, 2024
a0839ef
Add listening behavior to Event SyntaxInfo
APickledWalrus Jun 29, 2024
65507f8
Add missing experimental annotations
APickledWalrus Jun 29, 2024
537fc4a
Rename BukkitInfos to BukkitSyntaxInfos
APickledWalrus Jun 29, 2024
ec1f772
Merge branch 'dev/feature' into feature/registration-rework
APickledWalrus Jun 29, 2024
dbc48af
Add unmodifiableView for Skript
APickledWalrus Jun 29, 2024
82d1978
Add registry storage to SkriptAddon
APickledWalrus Jun 30, 2024
036d0b5
Add source requirement to SkriptAddon
APickledWalrus Jun 30, 2024
2d94cf5
Remove source from Localizer
APickledWalrus Jun 30, 2024
7414f40
Fix old addon registration
APickledWalrus Jul 1, 2024
6956294
Merge branch 'dev/feature' into feature/registration-rework
Moderocky Aug 15, 2024
5ffc974
SyntaxInfo equals/hashCode improvements
APickledWalrus Aug 28, 2024
3687940
Implementation optimizations
APickledWalrus Sep 2, 2024
a15d3cc
Merge branch 'dev/feature' into feature/registration-rework
APickledWalrus Sep 2, 2024
f1f4915
Fix ConditionType support
APickledWalrus Sep 2, 2024
96874c5
Return the constructed info for static registration methods
APickledWalrus Sep 2, 2024
fd9bb95
Builder interface
APickledWalrus Sep 5, 2024
b99b686
Merge branch 'dev/feature' into feature/registration-rework
sovdeeth Sep 29, 2024
73a61cd
Remove unncessary package infos
APickledWalrus Sep 29, 2024
f4d1df6
Implement Buildable interface
APickledWalrus Sep 29, 2024
f609017
Improve legacy collection methods
APickledWalrus Sep 29, 2024
0c30aba
Use a map for modern addon tracking
APickledWalrus Sep 29, 2024
865ddd0
Fix SkriptEventInfo Compatibility
APickledWalrus Sep 29, 2024
3077f8d
Allow Skript#getAddon to return Skript's addon instance
APickledWalrus Sep 30, 2024
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
353 changes: 214 additions & 139 deletions src/main/java/ch/njol/skript/Skript.java

Large diffs are not rendered by default.

119 changes: 92 additions & 27 deletions src/main/java/ch/njol/skript/SkriptAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,60 @@

import java.io.File;
import java.io.IOException;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.Nullable;

import ch.njol.skript.localization.Language;
import ch.njol.skript.util.Utils;
import ch.njol.skript.util.Version;
import org.jetbrains.annotations.ApiStatus;
import org.skriptlang.skript.localization.Localizer;
import org.skriptlang.skript.registration.SyntaxRegistry;
import org.skriptlang.skript.util.Registry;

/**
* Utility class for Skript addons. Use {@link Skript#registerAddon(JavaPlugin)} to create a SkriptAddon instance for your plugin.
*/
public final class SkriptAddon {
public final class SkriptAddon implements org.skriptlang.skript.addon.SkriptAddon {

public final JavaPlugin plugin;
public final Version version;
private final String name;

private final org.skriptlang.skript.addon.SkriptAddon addon;

/**
* Package-private constructor. Use {@link Skript#registerAddon(JavaPlugin)} to get a SkriptAddon for your plugin.
*
* @param p
*/
SkriptAddon(final JavaPlugin p) {
plugin = p;
name = "" + p.getName();
Version v;
SkriptAddon(JavaPlugin plugin) {
this(plugin, Skript.skript.registerAddon(plugin.getClass(), plugin.getName()));
}

SkriptAddon(JavaPlugin plugin, org.skriptlang.skript.addon.SkriptAddon addon) {
this.addon = addon;
this.plugin = plugin;
this.name = plugin.getName();
Version version;
try {
v = new Version("" + p.getDescription().getVersion());
} catch (final IllegalArgumentException e) {
final Matcher m = Pattern.compile("(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?").matcher(p.getDescription().getVersion());
version = new Version(plugin.getDescription().getVersion());
} catch (IllegalArgumentException e) {
final Matcher m = Pattern.compile("(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?").matcher(plugin.getDescription().getVersion());
if (!m.find())
throw new IllegalArgumentException("The version of the plugin " + p.getName() + " does not contain any numbers: " + p.getDescription().getVersion());
v = new Version(Utils.parseInt("" + m.group(1)), m.group(2) == null ? 0 : Utils.parseInt("" + m.group(2)), m.group(3) == null ? 0 : Utils.parseInt("" + m.group(3)));
Skript.warning("The plugin " + p.getName() + " uses a non-standard version syntax: '" + p.getDescription().getVersion() + "'. Skript will use " + v + " instead.");
throw new IllegalArgumentException("The version of the plugin " + name + " does not contain any numbers: " + plugin.getDescription().getVersion());
version = new Version(Utils.parseInt(m.group(1)), m.group(2) == null ? 0 : Utils.parseInt(m.group(2)), m.group(3) == null ? 0 : Utils.parseInt(m.group(3)));
Skript.warning("The plugin " + name + " uses a non-standard version syntax: '" + plugin.getDescription().getVersion() + "'. Skript will use " + version + " instead.");
}
version = v;
this.version = version;
}

@Override
public final String toString() {
return name;
return getName();
}

public String getName() {
Expand All @@ -83,9 +94,6 @@ public SkriptAddon loadClasses(String basePackage, String... subPackages) throws
return this;
}

@Nullable
private String languageFileDirectory = null;

/**
* Makes Skript load language files from the specified directory, e.g. "lang" or "skript lang" if you have a lang folder yourself. Localised files will be read from the
* plugin's jar and the plugin's data folder, but the default English file is only taken from the jar and <b>must</b> exist!
Expand All @@ -94,19 +102,13 @@ public SkriptAddon loadClasses(String basePackage, String... subPackages) throws
* @return This SkriptAddon
*/
public SkriptAddon setLanguageFileDirectory(String directory) {
if (languageFileDirectory != null)
throw new IllegalStateException();
directory = "" + directory.replace('\\', '/');
if (directory.endsWith("/"))
directory = "" + directory.substring(0, directory.length() - 1);
languageFileDirectory = directory;
Language.loadDefault(this);
localizer().setSourceDirectories(directory, plugin.getDataFolder().getAbsolutePath() + directory);
return this;
}

@Nullable
public String getLanguageFileDirectory() {
return languageFileDirectory;
return localizer().languageFileDirectory();
}

@Nullable
Expand All @@ -126,4 +128,67 @@ public File getFile() {
return file;
}

//
// Modern SkriptAddon Compatibility
//

@ApiStatus.Experimental
static SkriptAddon fromModern(org.skriptlang.skript.addon.SkriptAddon addon) {
return new SkriptAddon(JavaPlugin.getProvidingPlugin(addon.source()), addon);
}

@Override
@ApiStatus.Experimental
public Class<?> source() {
return addon.source();
}

@Override
@ApiStatus.Experimental
public String name() {
return addon.name();
}

@Override
@ApiStatus.Experimental
public <R extends Registry<?>> void storeRegistry(Class<R> registryClass, R registry) {
addon.storeRegistry(registryClass, registry);
}

@Override
@ApiStatus.Experimental
public void removeRegistry(Class<? extends Registry<?>> registryClass) {
addon.removeRegistry(registryClass);
}

@Override
@ApiStatus.Experimental
public boolean hasRegistry(Class<? extends Registry<?>> registryClass) {
return addon.hasRegistry(registryClass);
}

@Override
@ApiStatus.Experimental
public <R extends Registry<?>> R registry(Class<R> registryClass) {
return addon.registry(registryClass);
}

@Override
@ApiStatus.Experimental
public <R extends Registry<?>> R registry(Class<R> registryClass, Supplier<R> putIfAbsent) {
return addon.registry(registryClass, putIfAbsent);
}

@Override
@ApiStatus.Experimental
public SyntaxRegistry syntaxRegistry() {
return addon.syntaxRegistry();
}

@Override
@ApiStatus.Experimental
public Localizer localizer() {
return addon.localizer();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Checker;
import ch.njol.util.Kleenean;
import org.jetbrains.annotations.ApiStatus;
import org.skriptlang.skript.registration.SyntaxInfo;
import org.skriptlang.skript.registration.SyntaxRegistry;
import org.skriptlang.skript.util.Priority;

/**
* This class can be used for an easier writing of conditions that contain only one type in the pattern,
Expand All @@ -54,6 +58,14 @@
*/
public abstract class PropertyCondition<T> extends Condition implements Checker<T> {

/**
* A priority for {@link PropertyCondition}s.
* They will be registered before {@link SyntaxInfo#PATTERN_MATCHES_EVERYTHING} expressions
* but after {@link SyntaxInfo#COMBINED} expressions.
*/
@ApiStatus.Experimental
public static final Priority DEFAULT_PRIORITY = Priority.before(SyntaxInfo.PATTERN_MATCHES_EVERYTHING);

/**
* See {@link PropertyCondition} for more info
*/
Expand Down Expand Up @@ -83,14 +95,53 @@ public enum PropertyType {
WILL
}

private Expression<? extends T> expr;
/**
* @param registry The SyntaxRegistry to register with.
* @param condition The class to register
* @param property The property name, for example <i>fly</i> in <i>players can fly</i>
* @param type Must be plural, for example <i>players</i> in <i>players can fly</i>
* @param <E> The Condition type.
* @return The registered {@link SyntaxInfo}.
*/
@ApiStatus.Experimental
public static <E extends Condition> SyntaxInfo<E> register(SyntaxRegistry registry, Class<E> condition, String property, String type) {
return register(registry, condition, PropertyType.BE, property, type);
}

/**
* @param registry The SyntaxRegistry to register with.
* @param condition The class to register
* @param propertyType The property type, see {@link PropertyType}
* @param property The property name, for example <i>fly</i> in <i>players can fly</i>
* @param type Must be plural, for example <i>players</i> in <i>players can fly</i>
* @param <E> The Condition type.
* @return The registered {@link SyntaxInfo}.
*/
@ApiStatus.Experimental
public static <E extends Condition> SyntaxInfo<E> register(SyntaxRegistry registry, Class<E> condition, PropertyType propertyType, String property, String type) {
if (type.contains("%"))
throw new SkriptAPIException("The type argument must not contain any '%'s");
SyntaxInfo.Builder<?, E> builder = SyntaxInfo.builder(condition).priority(DEFAULT_PRIORITY);
switch (propertyType) {
case BE -> builder.addPatterns("%" + type + "% (is|are) " + property,
"%" + type + "% (isn't|is not|aren't|are not) " + property);
case CAN -> builder.addPatterns("%" + type + "% can " + property,
"%" + type + "% (can't|cannot|can not) " + property);
case HAVE -> builder.addPatterns("%" + type + "% (has|have) " + property,
"%" + type + "% (doesn't|does not|do not|don't) have " + property);
case WILL -> builder.addPatterns("%" + type + "% will " + property,
"%" + type + "% (will (not|neither)|won't) " + property);
}
SyntaxInfo<E> info = builder.build();
registry.register(SyntaxRegistry.CONDITION, info);
return info;
}

/**
* @param condition the class to register
* @param property the property name, for example <i>fly</i> in <i>players can fly</i>
* @param type must be plural, for example <i>players</i> in <i>players can fly</i>
*/

public static void register(Class<? extends Condition> condition, String property, String type) {
register(condition, PropertyType.BE, property, type);
}
Expand All @@ -101,7 +152,6 @@ public static void register(Class<? extends Condition> condition, String propert
* @param property the property name, for example <i>fly</i> in <i>players can fly</i>
* @param type must be plural, for example <i>players</i> in <i>players can fly</i>
*/

public static void register(Class<? extends Condition> condition, PropertyType propertyType, String property, String type) {
if (type.contains("%"))
throw new SkriptAPIException("The type argument must not contain any '%'s");
Expand Down Expand Up @@ -132,6 +182,8 @@ public static void register(Class<? extends Condition> condition, PropertyType p
}
}

private Expression<? extends T> expr;

@Override
@SuppressWarnings("unchecked")
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
import ch.njol.skript.util.Getter;
import ch.njol.skript.util.Utils;
import ch.njol.util.Kleenean;
import org.skriptlang.skript.registration.SyntaxInfo;
import org.skriptlang.skript.registration.SyntaxRegistry;
import org.skriptlang.skript.util.Priority;
import org.bukkit.event.Event;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

/**
Expand All @@ -65,6 +69,37 @@
*/
public class EventValueExpression<T> extends SimpleExpression<T> implements DefaultExpression<T> {

/**
* A priority for {@link EventValueExpression}s.
* They will be registered before {@link SyntaxInfo#COMBINED} expressions
* but after {@link SyntaxInfo#SIMPLE} expressions.
*/
@ApiStatus.Experimental
public static final Priority DEFAULT_PRIORITY = Priority.before(SyntaxInfo.COMBINED);

/**
* Registers an event value expression with the provided pattern.
* The syntax info will be forced to use the {@link #DEFAULT_PRIORITY} priority.
* This also adds '[the]' to the start of the pattern.
*
* @param registry The SyntaxRegistry to register with.
* @param expressionClass The EventValueExpression class being registered.
* @param returnType The class representing the expression's return type.
* @param pattern The pattern to match for creating this expression.
* @param <T> The return type.
* @param <E> The Expression type.
* @return The registered {@link SyntaxInfo}.
*/
@ApiStatus.Experimental
public static <E extends EventValueExpression<T>, T> SyntaxInfo.Expression<E, T> register(SyntaxRegistry registry, Class<E> expressionClass, Class<T> returnType, String pattern) {
SyntaxInfo.Expression<E, T> info = SyntaxInfo.Expression.builder(expressionClass)
.returnType(returnType)
.priority(DEFAULT_PRIORITY)
.addPattern("[the] " + pattern)
.build();
registry.register(SyntaxRegistry.EXPRESSION, info);
return info;
}

/**
* Registers an expression as {@link ExpressionType#EVENT} with the provided pattern.
Expand Down
Loading
Loading