Skip to content

Commit 153bd88

Browse files
committed
tests
dunno how it worked on my server without registering? maybe skbee has them undocumented?
1 parent 62cefec commit 153bd88

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

src/main/java/org/skriptlang/skript/bukkit/misc/MiscModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.skriptlang.skript.addon.AddonModule;
44
import org.skriptlang.skript.addon.SkriptAddon;
5+
import org.skriptlang.skript.bukkit.misc.expressions.ExprDustingProgress;
56
import org.skriptlang.skript.bukkit.misc.expressions.ExprWithYawPitch;
67
import org.skriptlang.skript.registration.SyntaxRegistry;
78

@@ -11,6 +12,7 @@ public class MiscModule implements AddonModule {
1112
public void load(SkriptAddon addon) {
1213
SyntaxRegistry registry = addon.syntaxRegistry();
1314
ExprWithYawPitch.register(registry);
15+
ExprDustingProgress.register(registry);
1416
}
1517

1618
@Override

src/main/java/org/skriptlang/skript/bukkit/misc/expressions/ExprDustingProgress.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
8989
public void change(Event event, Object @Nullable [] delta, ChangeMode mode) {
9090
int level = delta == null ? 0 : (Integer) delta[0];
9191
Function<Brushable, Integer> getValue = switch (mode) {
92-
case ADD -> brushable -> level + brushable.getDusted();
93-
case REMOVE -> brushable -> level - brushable.getDusted();
92+
case ADD -> brushable -> brushable.getDusted() + level;
93+
case REMOVE -> brushable -> brushable.getDusted() - level;
9494
case SET,RESET -> brushable -> level;
9595
default -> throw new IllegalArgumentException("should not be able to change with mode " + mode);
9696
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
test "dusting progress" when running minecraft "1.20":
2+
set {_old} to block data of test-block
3+
set block at test-block to suspicious gravel
4+
set {_block} to block at test-block
5+
set {_blockdata} to block data of {_block}
6+
7+
# test getting initial value
8+
assert dusting progress of {_block} is 0 with "Initial dusting progress should be 0"
9+
10+
# test setting
11+
set dusting progress of {_block} to 2
12+
assert dusting progress of {_block} is 2 with "Failed to set dusting progress to 2"
13+
14+
# test max dusting progress
15+
assert max dusting progress of {_block} is 3 with "Max dusting progress should be 3"
16+
assert maximum dusting progress of {_block} is 3 with "Maximum dusting progress should be 3"
17+
18+
# test adding
19+
set dusting progress of {_block} to 1
20+
add 1 to dusting progress of {_block}
21+
assert dusting progress of {_block} is 2 with "Failed to add 1 to dusting progress"
22+
23+
# test clamping at max
24+
add 99 to dusting progress of {_block}
25+
assert dusting progress of {_block} is 3 with "Dusting progress should be clamped at max"
26+
27+
# test removing
28+
set dusting progress of {_block} to 2
29+
remove 1 from dusting progress of {_block}
30+
assert dusting progress of {_block} is 1 with "Failed to remove 1 from dusting progress"
31+
32+
# test clamping at min
33+
remove 99 from dusting progress of {_block}
34+
assert dusting progress of {_block} is 0 with "Dusting progress should be clamped at 0"
35+
36+
# test reset
37+
set dusting progress of {_block} to 2
38+
assert dusting progress of {_block} is 2 with "Failed to set dusting progress"
39+
reset dusting progress of {_block}
40+
assert dusting progress of {_block} is 0 with "Failed to reset dusting progress"
41+
42+
# test with blockdata
43+
set dusting progress of {_blockdata} to 2
44+
assert dusting progress of {_blockdata} is 2 with "Failed to set dusting progress on blockdata"
45+
46+
# test alternative syntax (excavation)
47+
set block at test-block to suspicious sand
48+
set {_sand} to block at test-block
49+
set excavation progress of {_sand} to 1
50+
assert excavation progress of {_sand} is 1 with "Failed to set excavation progress"
51+
assert max excavation progress of {_sand} is 3 with "Max excavation progress should be 3"
52+
53+
set block data of test-block to {_old}

0 commit comments

Comments
 (0)