Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7f9356f
WIP with new DSL (it compiles lol)
jamailun Oct 21, 2025
1ee1a03
Tokenizer test
jamailun Oct 22, 2025
405c78e
Basic logic
jamailun Oct 22, 2025
6addd1e
Function declaration
jamailun Oct 22, 2025
849ad0d
Variable declaration with VAR
jamailun Oct 22, 2025
5037d3f
Function call is parsed
jamailun Oct 22, 2025
ffb0c92
blocks tests are passing
jamailun Oct 22, 2025
802e503
cleaned up tests
jamailun Oct 23, 2025
7a474b1
map and array literal parsing
jamailun Oct 23, 2025
2e1e5c9
renamed some elements
jamailun Oct 23, 2025
89ee02d
Prepare validation
jamailun Oct 24, 2025
6a0f315
Validation of assignment
jamailun Oct 24, 2025
83bbf40
Function validation
jamailun Oct 24, 2025
bdae58c
Cleanup, added tests
jamailun Oct 24, 2025
304a41c
Increment/decrement are now expressions
jamailun Oct 24, 2025
5bd077a
Bad increment tests.
jamailun Oct 24, 2025
a20f808
Fixed console type, caller functions, global functions
jamailun Oct 25, 2025
2cf8eda
Functions call properly register their new variables.
jamailun Oct 25, 2025
8015d13
Fixed a bug with time keywords
jamailun Oct 25, 2025
3280eec
one lomre duration test
jamailun Oct 26, 2025
32c2987
Tree validation for functions
jamailun Oct 26, 2025
35d82b6
Cleaned up unused elements
jamailun Oct 30, 2025
c0ecbb0
Starting to push changes to the whole plugin
jamailun Oct 30, 2025
e53f73c
Basic functions loaded for entity
jamailun Oct 31, 2025
c78db2e
Added console object
jamailun Oct 31, 2025
6ca0b48
Cleaning the mess, upgraded runtime builders
jamailun Nov 1, 2025
db1e815
It compiles... it's alive
jamailun Nov 1, 2025
facdcdf
Fixed some minors issues
jamailun Nov 1, 2025
d4b0096
Fixed compilation, unicity of functions on signatureinstead of name o…
jamailun Nov 2, 2025
1ffd7a2
Fixed a bug with post-fix increment operator
jamailun Nov 2, 2025
2473993
Disabled old DSL module
jamailun Nov 2, 2025
ed2a92e
Properly register functions in runner
jamailun Nov 2, 2025
f938835
Fixed handler with function definitions.
jamailun Nov 2, 2025
b659756
Added more compiler syntax hints
jamailun Nov 2, 2025
e6f851b
Deleted old DSL folder
jamailun Nov 2, 2025
0d3d43d
Preparation for tests framework, register basic structs
jamailun Nov 2, 2025
d6729e5
Added list operators back to DSLv2
jamailun Nov 9, 2025
c39e52f
Added list operators back to plugin runner
jamailun Nov 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>ultimate-spell-system-api</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>

<parent>
<groupId>fr.jamailun.paper</groupId>
<artifactId>ultimate-spell-system</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>

<properties>
Expand All @@ -22,8 +22,8 @@
<dependencies>
<dependency>
<groupId>fr.jamailun.paper</groupId>
<version>2.6.1-SNAPSHOT</version>
<artifactId>ultimate-spell-system-dsl</artifactId>
<version>3.0.0-SNAPSHOT</version>
<artifactId>ultimate-spell-system-dsl2</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.jamailun.ultimatespellsystem.api.bind;

import fr.jamailun.ultimatespellsystem.api.spells.Spell;
import fr.jamailun.ultimatespellsystem.dsl.nodes.type.Duration;
import fr.jamailun.ultimatespellsystem.dsl2.nodes.type.Duration;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.jamailun.ultimatespellsystem.api.bind;

import fr.jamailun.ultimatespellsystem.api.spells.Spell;
import fr.jamailun.ultimatespellsystem.dsl.nodes.type.Duration;
import fr.jamailun.ultimatespellsystem.dsl2.nodes.type.Duration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import fr.jamailun.ultimatespellsystem.api.runner.RuntimeStatement;
import fr.jamailun.ultimatespellsystem.api.runner.SpellRuntime;
import fr.jamailun.ultimatespellsystem.dsl.objects.CallbackEvent;
import fr.jamailun.ultimatespellsystem.dsl2.callbacks.CallbackEvent;
import lombok.Getter;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,15 @@ public void remove() {
public @NotNull PersistentDataContainer getNBT() {
return transientDataContainer;
}

@Override
public <T extends Entity> Optional<T> getEntityAs(Class<T> clazz) {
return getBukkitEntity().map(e -> {
try {
return clazz.cast(e);
} catch(Exception ex) {
return null;
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public interface SpellEntity {
* Get the UUID of the entity.
* @return a non-null, unique UUID.
*/
@Contract(pure = true)
@NotNull UUID getUniqueId();

/**
Expand All @@ -31,10 +32,21 @@ public interface SpellEntity {
@Contract(pure = true)
@NotNull Optional<Entity> getBukkitEntity();

/**
* Get the entity as a specific bukkit class.
* @param clazz the class to cast the bukkit entity to.
* @return an empty optional if the entity is not bukkit-based, or if the instance cannot be
* cast to the parameter.
* @param <T> the output requested type.
*/
@Contract(pure = true)
<T extends Entity> Optional<T> getEntityAs(Class<T> clazz);

/**
* Test if the current entity has a bukkit representation.
* @return true if a call to {@link #getBukkitEntity()} returns something.
*/
@Contract(pure = true)
default boolean isBukkit() {
return getBukkitEntity().isPresent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import fr.jamailun.ultimatespellsystem.api.runner.SpellRuntime;
import fr.jamailun.ultimatespellsystem.api.utils.AttributesHolder;
import fr.jamailun.ultimatespellsystem.dsl.nodes.type.Duration;
import fr.jamailun.ultimatespellsystem.dsl2.nodes.type.Duration;
import org.bukkit.Location;
import org.bukkit.event.Event;
import org.bukkit.scheduler.BukkitRunnable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.jamailun.ultimatespellsystem.api.providers;

import fr.jamailun.ultimatespellsystem.api.entities.CallbackAction;
import fr.jamailun.ultimatespellsystem.dsl.objects.CallbackEvent;
import fr.jamailun.ultimatespellsystem.dsl.registries.CallbackEventRegistry;
import fr.jamailun.ultimatespellsystem.dsl2.callbacks.CallbackEvent;
import fr.jamailun.ultimatespellsystem.dsl2.registries.CallbackEventRegistry;
import org.jetbrains.annotations.NotNull;

import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.jamailun.ultimatespellsystem.api.providers;

import fr.jamailun.ultimatespellsystem.api.entities.UssEntityType;
import fr.jamailun.ultimatespellsystem.dsl.registries.EntityTypeRegistry;
import fr.jamailun.ultimatespellsystem.dsl2.registries.EntityTypeRegistry;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.jamailun.ultimatespellsystem.api.providers;

import fr.jamailun.ultimatespellsystem.api.runner.functions.RunnableJavaFunction;
import fr.jamailun.ultimatespellsystem.dsl.registries.FunctionDefinitionsRegistry;
import fr.jamailun.ultimatespellsystem.dsl2.registries.FunctionDefinitionsRegistry;
import org.jetbrains.annotations.NotNull;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package fr.jamailun.ultimatespellsystem.api.runner;

import fr.jamailun.ultimatespellsystem.api.runner.functions.GlobalFunction;
import fr.jamailun.ultimatespellsystem.dsl2.nodes.expressions.functions.FunctionSignature;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* A set of functions.
*/
public interface FunctionsSet {

/**
* Get a function.
* @param signature the function signature key.
* @return the content of the variable, or {@code null} if not defined.
*/
@Nullable GlobalFunction get(@NotNull FunctionSignature signature);

/**
* Create an inherited functions set.
* @return a new instance. Mutating existing vars of the instance will mutate {@code this} instance.
* But adding new functions will not.
*/
@Contract(" -> new")
@NotNull FunctionsSet inherit();

/**
* Register a new function.
* @param function the function to register.
*/
void register(@NotNull GlobalFunction function);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.jamailun.ultimatespellsystem.api.runner;

import fr.jamailun.ultimatespellsystem.api.entities.SpellEntity;
import fr.jamailun.ultimatespellsystem.api.runner.structs.Struct;
import fr.jamailun.ultimatespellsystem.api.spells.Spell;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -32,16 +33,16 @@ public interface SpellRuntime {
@NotNull VariablesSet variables();

/**
* Test if the runtime has been stopped.
* @return true if no more statements should be executed.
* A reference to the functions set.
* @return the final reference to the functions.
*/
boolean isStopped();
@NotNull FunctionsSet functions();

/**
* Stop the current execution.
* @param exitCode the exit code to use.
* Test if the runtime has been stopped.
* @return true if no more statements should be executed.
*/
void stop(int exitCode);
boolean isStopped();

/**
* Break the flow.
Expand All @@ -58,6 +59,12 @@ public interface SpellRuntime {
*/
void acceptContinue();

/**
* Handle a return statement.
* @param value output-ed value.
*/
void statementReturn(@Nullable Object value);

/**
* Get the state of the control flow.
* @return a state.
Expand All @@ -69,7 +76,17 @@ public interface SpellRuntime {
* @return a new instance of a runtime, with the same context.
*/
@Contract(" -> new")
@NotNull SpellRuntime makeChild();
default @NotNull SpellRuntime makeChild() {
return makeChild(false);
}

/**
* Create a child of this runtime.
* @param function if {@code true}, the child runtime will be a function.
* @return a new instance of a runtime, with the same context.
*/
@Contract("_ -> new")
@NotNull SpellRuntime makeChild(boolean function);

/**
* Create a child instance of this runtime, but with a different caster.
Expand All @@ -80,11 +97,26 @@ public interface SpellRuntime {
@NotNull SpellRuntime makeChildNewCaster(@NotNull SpellEntity newCaster);

/**
* Get the final exit code.
* @return {@code zero} if it's a success (or not stopped). Any other value means an error occurred.
* Get the structure out of a value.
* @param structDefinitionName name of the structure of the type.
* @param value the value to wrap.
* @return {@code null} if cannot match.
*/
@Contract("_,null->null;_,!null->!null")
@Nullable Struct getStructOf(@NotNull String structDefinitionName, @Nullable Object value);

/**
* Get the returned value.
* @return something.
* @see #isStopped()
*/
int getFinalExitCode();
@Nullable Object getReturnedValue();

/**
* Test if the returned value is considered as a success.
* @return true if return value is {@code null}, or {@code 0}, or {@code true}.
*/
boolean isReturnValueSuccess();

/**
* Evaluate a value.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package fr.jamailun.ultimatespellsystem.api.runner.functions;

import fr.jamailun.ultimatespellsystem.api.runner.RuntimeExpression;
import fr.jamailun.ultimatespellsystem.api.runner.SpellRuntime;
import fr.jamailun.ultimatespellsystem.dsl2.nodes.expressions.functions.FunctionSignature;
import fr.jamailun.ultimatespellsystem.dsl2.tokenization.TokenPosition;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
* A global function. Either from the Java code, or from the USS script.
*/
public interface GlobalFunction {

/**
* Get the signature of the function.
* @return the instance function signature.
*/
@NotNull FunctionSignature getSignature();

/**
* Call the function with parameters.
* @param pos token position.
* @param arguments params of the function.
* @param runtime spell runtime.
* @return the output value.
*/
@Nullable Object call(@NotNull TokenPosition pos, @NotNull List<RuntimeExpression> arguments, @NotNull SpellRuntime runtime);

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@

import fr.jamailun.ultimatespellsystem.api.runner.RuntimeExpression;
import fr.jamailun.ultimatespellsystem.api.runner.SpellRuntime;
import fr.jamailun.ultimatespellsystem.dsl.nodes.expressions.functions.FunctionArgument;
import fr.jamailun.ultimatespellsystem.dsl.nodes.expressions.functions.FunctionDefinition;
import fr.jamailun.ultimatespellsystem.dsl.nodes.type.Type;
import fr.jamailun.ultimatespellsystem.dsl2.nodes.expressions.functions.FunctionArgument;
import fr.jamailun.ultimatespellsystem.dsl2.nodes.expressions.functions.FunctionDefinition;
import fr.jamailun.ultimatespellsystem.dsl2.nodes.expressions.functions.FunctionSignature;
import fr.jamailun.ultimatespellsystem.dsl2.nodes.type.Type;
import fr.jamailun.ultimatespellsystem.dsl2.tokenization.TokenPosition;
import lombok.Getter;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
* A runnable code declaration
*/
@Getter
public abstract class RunnableJavaFunction {
public abstract class RunnableJavaFunction implements GlobalFunction {

private final @NotNull String id;
private final @NotNull Type type;
Expand All @@ -34,6 +37,16 @@ public RunnableJavaFunction(@NotNull String id, @NotNull Type type, @NotNull Lis
this.arguments = arguments;
}

@Override
public @NotNull FunctionSignature getSignature() {
return FunctionSignature.of(id, arguments);
}

@Override
public @Nullable Object call(@NotNull TokenPosition pos, @NotNull List<RuntimeExpression> arguments, @NotNull SpellRuntime runtime) {
return compute(arguments, runtime);
}

/**
* Compute the value, using the arguments.
* @param arguments the arguments values returned. Must be computed in the runtime.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package fr.jamailun.ultimatespellsystem.api.runner.structs;

import fr.jamailun.ultimatespellsystem.dsl2.tokenization.TokenPosition;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
* Instance of a structured object.
*/
public interface Struct {

/**
* Get a field value.
* @param pos token position requesting the data.
* @param fieldName name of the field.
* @return the field value.
*/
@Nullable Object getField(@NotNull TokenPosition pos, @NotNull String fieldName);

/**
* Set a field value.
* @param pos token position requesting the data.
* @param fieldName name of the field.
* @param value the field new value.
*/
void setField(@NotNull TokenPosition pos, @NotNull String fieldName, @Nullable Object value);

/**
* Call a function of the object.
* @param pos token position requesting the data.
* @param functionName name fo the function.
* @param parameters parameters of the function.
* @return the function output.
*/
@Nullable Object callFunction(@NotNull TokenPosition pos, @NotNull String functionName, @NotNull List<Object> parameters);

}
Loading
Loading