Skip to content

Commit 69efb98

Browse files
Merge branch 'dev/patch' into dev/feature
2 parents f442ca9 + 145882c commit 69efb98

File tree

9 files changed

+41
-14
lines changed

9 files changed

+41
-14
lines changed

src/main/java/ch/njol/skript/effects/EffWorldLoad.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class EffWorldLoad extends Effect {
3434

3535
static {
3636
Skript.registerEffect(EffWorldLoad.class,
37-
"load [[the] world[s]] %strings% [with environment %-environment%]",
37+
"load [the] world[s] %strings% [with environment %-environment%]",
3838
"unload [[the] world[s]] %worlds% [:without saving]"
3939
);
4040
}

src/main/java/ch/njol/skript/expressions/ExprLocationVectorOffset.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class ExprLocationVectorOffset extends SimpleExpression<Location> {
3131

3232
static {
33-
Skript.registerExpression(ExprLocationVectorOffset.class, Location.class, ExpressionType.COMBINED,
33+
Skript.registerExpression(ExprLocationVectorOffset.class, Location.class, ExpressionType.PROPERTY,
3434
"%location% offset by [[the] vectors] %vectors%",
3535
"%location%[ ]~[~][ ]%vectors%");
3636
}

src/main/java/ch/njol/skript/expressions/ExprSortedList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
public class ExprSortedList extends SimpleExpression<Object> {
3030

3131
static {
32-
Skript.registerExpression(ExprSortedList.class, Object.class, ExpressionType.COMBINED, "sorted %objects%");
32+
Skript.registerExpression(ExprSortedList.class, Object.class, ExpressionType.PROPERTY, "sorted %objects%");
3333
}
3434

3535
@SuppressWarnings("NotNullFieldNotInitialized")

src/main/java/ch/njol/skript/test/runner/EffRunRunnable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class EffRunRunnable extends Effect {
1515

1616
static {
1717
if (TestMode.ENABLED)
18-
Skript.registerEffect(EffRunRunnable.class, "run %object%");
18+
Skript.registerEffect(EffRunRunnable.class, "run runnable %object%");
1919
}
2020

2121
private Expression<?> task;
@@ -38,7 +38,7 @@ protected void execute(Event event) {
3838

3939
@Override
4040
public String toString(Event event, boolean debug) {
41-
return "run " + task.toString(event, debug);
41+
return "run runnable " + task.toString(event, debug);
4242
}
4343

4444
}

src/main/java/org/skriptlang/skript/registration/DefaultSyntaxInfosImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public Class<R> returnType() {
4343

4444
@Override
4545
public boolean equals(Object other) {
46+
if (this == other) {
47+
return true;
48+
}
4649
return other instanceof Expression<?, ?> expression &&
4750
super.equals(other) &&
4851
returnType() == expression.returnType();
@@ -129,6 +132,9 @@ public NodeType nodeType() {
129132

130133
@Override
131134
public boolean equals(Object other) {
135+
if (this == other) {
136+
return true;
137+
}
132138
return other instanceof Structure<?> structure &&
133139
super.equals(other) &&
134140
Objects.equals(entryValidator(), structure.entryValidator()) &&

src/main/java/org/skriptlang/skript/registration/SyntaxRegister.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ final class SyntaxRegister<I extends SyntaxInfo<?>> {
1919
return 0;
2020
}
2121
int result = a.priority().compareTo(b.priority());
22-
// when elements have the same priority, the oldest element comes first
23-
return result != 0 ? result : 1;
22+
// when elements have the same priority, order by hashcode
23+
return result != 0 ? result : Integer.compare(a.hashCode(), b.hashCode());
2424
};
2525

2626
final Set<I> syntaxes = new ConcurrentSkipListSet<>(SET_COMPARATOR);

src/test/java/org/skriptlang/skript/registration/SyntaxRegistryTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,25 @@ public void testOrdering() {
9090
assertArrayEquals(new SyntaxInfo[]{info2, info1, info3}, unmodifiable.syntaxes(key()).toArray());
9191
}
9292

93+
@Test
94+
public void testLargeRegistryUnregistration() {
95+
final SyntaxRegistry registry = syntaxRegistry();
96+
final SyntaxRegistry unmodifiable = registry.unmodifiableView();
97+
final var info = info();
98+
99+
for (int i = 0; i < 25; i++) {
100+
registry.register(key(), info.toBuilder().addPattern("pattern" + i).build());
101+
}
102+
registry.register(key(), info);
103+
for (int i = 25; i < 50; i++) {
104+
registry.register(key(), info.toBuilder().addPattern("pattern" + i).build());
105+
}
106+
107+
// make sure info can be successfully unregistered
108+
registry.unregister(info);
109+
assertThrows(UnsupportedOperationException.class, () -> unmodifiable.unregister(info));
110+
assertFalse(registry.elements().contains(info));
111+
assertFalse(unmodifiable.elements().contains(info));
112+
}
113+
93114
}

src/test/skript/tests/misc/expression sections.sk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ test "expression sections":
55

66
assert {_var} is false with "expression section ran too early!"
77

8-
run {_runnable}
8+
run runnable {_runnable}
99
assert {_var} is true with "expression section didn't run!"
1010

1111
# try it again in case it stops working for some reason
1212
set {_var} to false
13-
run {_runnable}
13+
run runnable {_runnable}
1414
assert {_var} is true with "expression section didn't run again!"
1515

1616
# section in a section!
1717
set {_runnable} to a new runnable:
1818
set {_runnable2} to a new runnable:
1919
set {_var} to true
20-
run {_runnable2}
20+
run runnable {_runnable2}
2121
set {_var} to false
22-
run {_runnable}
22+
run runnable {_runnable}
2323
assert {_var} is true with "expression section in expression section didn't run"
2424

2525
# test proper logging behavior

src/test/skript/tests/syntaxes/effects/EffScriptFile.sk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ test "unload + load script":
2626

2727
set {_script} to script named {_path}
2828
assert {_script} exists with "script wasn't found"
29-
unload {_script}
29+
unload the script within {_script}
3030

3131
# Unloading no longer disables the script
3232
# so the script should be in the same place
3333

3434
set {EffScriptFile} to false
3535
set {_script} to script named {_path}
3636
assert {_script} exists with "script moved when unloaded"
37-
load {_script}
37+
load the script within {_script}
3838
# we make sure the script loaded even though it wasn't disabled
3939
assert {EffScriptFile} is true with "load event didn't run"
4040

4141
set {EffScriptFile} to false
42-
load {_script}
42+
load the script within {_script}
4343
# we attempt to load a loaded script
4444
# this used to throw an exception, now it should be skipped
4545
assert {EffScriptFile} is false with "load ran when already loaded"

0 commit comments

Comments
 (0)