|
5 | 5 |
|
6 | 6 | import java.util.Arrays;
|
7 | 7 |
|
| 8 | +import org.bukkit.NamespacedKey; |
| 9 | +import org.bukkit.Registry; |
8 | 10 | import org.bukkit.potion.PotionEffectType;
|
9 | 11 | import org.junit.jupiter.api.AfterEach;
|
10 | 12 | import org.junit.jupiter.api.BeforeEach;
|
@@ -96,6 +98,34 @@ void executionTestWithPotionEffectArgumentAllPotionEffects() {
|
96 | 98 | assertNoMoreResults(results);
|
97 | 99 | }
|
98 | 100 |
|
| 101 | + @Test |
| 102 | + void executionTestWithPotionEffectArgumentNamespaced() { |
| 103 | + Mut<NamespacedKey> results = Mut.of(); |
| 104 | + |
| 105 | + new CommandAPICommand("test") |
| 106 | + .withArguments(new PotionEffectArgument.NamespacedKey("potion")) |
| 107 | + .executesPlayer((player, args) -> { |
| 108 | + results.set((NamespacedKey) args.get("potion")); |
| 109 | + }) |
| 110 | + .register(); |
| 111 | + |
| 112 | + PlayerMock player = server.addPlayer(); |
| 113 | + |
| 114 | + server.dispatchCommand(player, "test speed"); |
| 115 | + assertEquals(NamespacedKey.minecraft("speed"), results.get()); |
| 116 | + |
| 117 | + server.dispatchCommand(player, "test minecraft:speed"); |
| 118 | + assertEquals(NamespacedKey.minecraft("speed"), results.get()); |
| 119 | + |
| 120 | + server.dispatchCommand(player, "test unknowneffect"); |
| 121 | + assertEquals(NamespacedKey.minecraft("unknowneffect"), results.get()); |
| 122 | + |
| 123 | + server.dispatchCommand(player, "test custom:unknowneffect"); |
| 124 | + assertEquals(NamespacedKey.fromString("custom:unknowneffect"), results.get()); |
| 125 | + |
| 126 | + assertNoMoreResults(results); |
| 127 | + } |
| 128 | + |
99 | 129 | /********************
|
100 | 130 | * Suggestion tests *
|
101 | 131 | ********************/
|
|
0 commit comments