Skip to content

Commit eb5ce4c

Browse files
committed
1 parent 5fd230e commit eb5ce4c

File tree

7 files changed

+63
-12
lines changed

7 files changed

+63
-12
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016-2018 Bryan Terce
3+
Copyright (c) 2016-2020, Bryan Terce, TPGamesNL
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ Downloads: https://github.com/TPGamesNL/skript-mirror/actions (click the version
1111
If you want to talk about this project or something else, contact me on Discord: TPGamesNL#0880
1212

1313
## What's been changed in this fork:
14-
* Custom events
15-
* Support for more Java versions (Java 13, Java 14, OpenJ9)
14+
* Added custom events
15+
* Support for more Java versions (Java 13+, OpenJ9)
1616
* Support for listening to asynchronous events
17-
* Suppression of and/or warnings
18-
* Class proxy fixes
19-
* Some smaller changes
20-
* Fixed issues where local variables are deleted
21-
* Updated documentation
17+
* Class proxy fixes + documentation
18+
* Fixed multiple issues with local variables
19+
* And more

docs/advanced/custom-syntax/README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ event-classes
2424
{% endcode-tabs-item %}
2525
{% endcode-tabs %}
2626

27+
{% hint style="info" %}
28+
When used with [the raw expression](../../basics/utilities.md#raw-expression), you can set it to a value, which will change the input value from that argument. This can be used to store data in variables in the calling trigger.
29+
{% code-tabs %}
30+
{% code-tabs-item title="example.sk" %}
31+
```text
32+
import:
33+
ch.njol.skript.lang.Variable
34+
35+
effect put %objects% in %objects%:
36+
parse:
37+
expr-2 is an instance of Variable # to check if the second argument is a variable
38+
continue
39+
trigger:
40+
set raw expr-2 to expr-1
41+
```
42+
{% endcode-tabs-item %}
43+
{% endcode-tabs %}
44+
{% endhint %}
45+
2746
### Matched Pattern
2847

2948
{% code-tabs %}
@@ -72,5 +91,4 @@ continue
7291

7392
{% page-ref page="expressions.md" %}
7493

75-
76-
94+
{% page-ref page="events.md" %}

docs/basics/utilities.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,25 @@ This value may be read from and written to.
8686

8787
Returns the underlying object of an expression.
8888

89+
{% hint style="info" %}
90+
When used with [the expression-expression](../advanced/custom-syntax/README.md#expression), you can set it to a value, which will change the input value from that argument. This can be used to store data in variables in the calling trigger.
91+
{% code-tabs %}
92+
{% code-tabs-item title="example.sk" %}
93+
```text
94+
import:
95+
ch.njol.skript.lang.Variable
96+
97+
effect put %objects% in %objects%:
98+
parse:
99+
expr-2 is an instance of Variable # to check if the second argument is a variable
100+
continue
101+
trigger:
102+
set raw expr-2 to expr-1
103+
```
104+
{% endcode-tabs-item %}
105+
{% endcode-tabs %}
106+
{% endhint %}
107+
89108
## Members
90109

91110
{% code-tabs %}

src/main/java/com/btk5h/skriptmirror/skript/custom/ExprRawExpression.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.btk5h.skriptmirror.skript.custom;
22

33
import ch.njol.skript.Skript;
4+
import ch.njol.skript.classes.Changer;
45
import ch.njol.skript.lang.Expression;
56
import ch.njol.skript.lang.ExpressionType;
67
import ch.njol.skript.lang.SkriptParser;
78
import ch.njol.skript.lang.util.SimpleExpression;
89
import ch.njol.util.Kleenean;
10+
import com.btk5h.skriptmirror.WrappedEvent;
911
import com.btk5h.skriptmirror.util.SkriptUtil;
1012
import org.bukkit.event.Event;
1113

@@ -36,6 +38,22 @@ public Class<? extends Expression> getReturnType() {
3638
return Expression.class;
3739
}
3840

41+
@Override
42+
public Class<?>[] acceptChange(Changer.ChangeMode changeMode) {
43+
return expr instanceof ExprExpression ? new Class[] {Object.class} : null;
44+
}
45+
46+
@Override
47+
public void change(Event event, Object[] delta, Changer.ChangeMode changeMode) {
48+
if (!(expr instanceof ExprExpression && event instanceof CustomSyntaxEvent))
49+
return;
50+
51+
Expression<?> expr = ((ExprExpression<?>) this.expr).getExpression(event).getSource();
52+
53+
event = ((WrappedEvent) event).getEvent();
54+
expr.change(event, delta, changeMode);
55+
}
56+
3957
@Override
4058
public String toString(Event e, boolean debug) {
4159
return "raw " + expr.toString(e, debug);

src/main/java/com/btk5h/skriptmirror/skript/custom/condition/CustomCondition.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public class CustomCondition extends Condition {
1818
private ConditionSyntaxInfo which;
1919
private Expression<?>[] exprs;
2020
private SkriptParser.ParseResult parseResult;
21-
private Event parseEvent;
2221
private Object variablesMap;
2322

2423
@Override

src/main/java/com/btk5h/skriptmirror/skript/custom/effect/CustomEffect.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class CustomEffect extends Effect {
1616
private EffectSyntaxInfo which;
1717
private Expression<?>[] exprs;
1818
private SkriptParser.ParseResult parseResult;
19-
private Event parseEvent;
2019
private Object variablesMap;
2120

2221
@Override

0 commit comments

Comments
 (0)