2
2
3
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
4
import static org .junit .jupiter .api .Assertions .assertTrue ;
5
- import static org .junit .jupiter .api .Assumptions .assumeTrue ;
6
5
7
6
import java .util .Set ;
8
7
import java .util .concurrent .ThreadLocalRandom ;
9
8
10
9
import org .bukkit .Color ;
11
- import org .bukkit .Location ;
12
10
import org .bukkit .Material ;
13
11
import org .bukkit .Particle ;
14
12
import org .bukkit .Particle .DustOptions ;
15
- import org .bukkit .Particle .DustTransition ;
16
- import org .bukkit .Vibration ;
17
- import org .bukkit .Vibration .Destination .BlockDestination ;
18
13
import org .bukkit .block .data .BlockData ;
19
14
import org .bukkit .block .data .Snowable ;
20
15
import org .bukkit .inventory .ItemStack ;
25
20
26
21
import be .seeseemelk .mockbukkit .entity .PlayerMock ;
27
22
import dev .jorel .commandapi .CommandAPICommand ;
28
- import dev .jorel .commandapi .MCVersion ;
29
23
import dev .jorel .commandapi .arguments .ParticleArgument ;
30
24
import dev .jorel .commandapi .test .MockPlatform ;
31
25
import dev .jorel .commandapi .test .Mut ;
@@ -51,14 +45,7 @@ public void tearDown() {
51
45
super .tearDown ();
52
46
}
53
47
54
- // Just checks block coords, doesn't check yaw/pitch or world
55
- private void assertBlockLocationCoordsEquals (Location loc1 , Location loc2 ) {
56
- assertEquals (loc1 .getBlockX (), loc2 .getBlockX (), 0.0001 );
57
- assertEquals (loc1 .getBlockY (), loc2 .getBlockY (), 0.0001 );
58
- assertEquals (loc1 .getBlockZ (), loc2 .getBlockZ (), 0.0001 );
59
- }
60
-
61
- Set <Particle > dodgyParticles = Set .of (
48
+ private Set <Particle > dodgyParticles = Set .of (
62
49
Particle .SNOW_SHOVEL , // "item_snowball" -> SNOWBALL
63
50
Particle .SUSPENDED_DEPTH // "underwater" -> SUSPENDED
64
51
);
@@ -186,92 +173,6 @@ void executionTestWithParticleArgumentBlock() {
186
173
assertNoMoreResults (results );
187
174
}
188
175
189
- @ Test
190
- void executionTestWithParticleArgumentShriek () {
191
- assumeTrue (version .greaterThanOrEqualTo (MCVersion .V1_19 ));
192
- Mut <ParticleData <?>> results = Mut .of ();
193
-
194
- new CommandAPICommand ("test" )
195
- .withArguments (new ParticleArgument ("particle" ))
196
- .executesPlayer ((player , args ) -> {
197
- results .set ((ParticleData <?>) args .get ("particle" ));
198
- })
199
- .register ();
200
-
201
- PlayerMock player = server .addPlayer ();
202
-
203
- // shriek delay
204
- server .dispatchCommand (player , "test shriek 10" );
205
- @ SuppressWarnings ("unchecked" )
206
- ParticleData <Integer > result = (ParticleData <Integer >) results .get ();
207
-
208
- // Check the particle type is correct
209
- assertEquals (Particle .valueOf ("SHRIEK" ), result .particle ());
210
-
211
- // Check the particle properties
212
- assertEquals (10 , result .data ());
213
-
214
- assertNoMoreResults (results );
215
- }
216
-
217
- @ Test
218
- void executionTestWithParticleArgumentSculkCharge () {
219
- assumeTrue (version .greaterThanOrEqualTo (MCVersion .V1_19 ));
220
- Mut <ParticleData <?>> results = Mut .of ();
221
-
222
- new CommandAPICommand ("test" )
223
- .withArguments (new ParticleArgument ("particle" ))
224
- .executesPlayer ((player , args ) -> {
225
- results .set ((ParticleData <?>) args .get ("particle" ));
226
- })
227
- .register ();
228
-
229
- PlayerMock player = server .addPlayer ();
230
-
231
- // sculk_charge angle
232
- server .dispatchCommand (player , "test sculk_charge 2" );
233
- @ SuppressWarnings ("unchecked" )
234
- ParticleData <Float > result = (ParticleData <Float >) results .get ();
235
-
236
- // Check the particle type is correct
237
- assertEquals (Particle .valueOf ("SCULK_CHARGE" ), result .particle ());
238
-
239
- // Check the particle properties
240
- assertEquals (2 , result .data ());
241
-
242
- assertNoMoreResults (results );
243
- }
244
-
245
- @ Test
246
- void executionTestWithParticleArgumentVibration () {
247
- assumeTrue (version .greaterThanOrEqualTo (MCVersion .V1_19 ));
248
- Mut <ParticleData <?>> results = Mut .of ();
249
-
250
- new CommandAPICommand ("test" )
251
- .withArguments (new ParticleArgument ("particle" ))
252
- .executesPlayer ((player , args ) -> {
253
- results .set ((ParticleData <?>) args .get ("particle" ));
254
- })
255
- .register ();
256
-
257
- PlayerMock player = server .addPlayer ();
258
-
259
- // vibration x y z ticks
260
- server .dispatchCommand (player , "test vibration 5.0 64.0 0.0 200" );
261
- @ SuppressWarnings ("unchecked" )
262
- ParticleData <Vibration > result = (ParticleData <Vibration >) results .get ();
263
-
264
- // Check the particle type is correct
265
- assertEquals (Particle .VIBRATION , result .particle ());
266
-
267
- // Check the particle properties. We only support BlockDestination for commands.
268
- assertBlockLocationCoordsEquals (player .getLocation (), result .data ().getOrigin ());
269
- assertBlockLocationCoordsEquals (new Location (player .getWorld (), 5.0 , 64.0 , 0.0 ), ((BlockDestination ) result .data ().getDestination ()).getLocation ());
270
- assertEquals (200 , result .data ().getArrivalTime ());
271
-
272
- assertNoMoreResults (results );
273
- }
274
-
275
176
@ Test
276
177
void executionTestWithParticleArgumentItem () {
277
178
Mut <ParticleData <?>> results = Mut .of ();
@@ -299,33 +200,4 @@ void executionTestWithParticleArgumentItem() {
299
200
assertNoMoreResults (results );
300
201
}
301
202
302
- @ Test
303
- void executionTestWithParticleArgumentDustTransition () {
304
- Mut <ParticleData <?>> results = Mut .of ();
305
-
306
- new CommandAPICommand ("test" )
307
- .withArguments (new ParticleArgument ("particle" ))
308
- .executesPlayer ((player , args ) -> {
309
- results .set ((ParticleData <?>) args .get ("particle" ));
310
- })
311
- .register ();
312
-
313
- PlayerMock player = server .addPlayer ();
314
-
315
- // dust_color_transition red1 green1 blue1 size red2 green2 blue2
316
- server .dispatchCommand (player , "test dust_color_transition 1.0 0.0 0.0 3.0 0.0 0.0 1.0" );
317
- @ SuppressWarnings ("unchecked" )
318
- ParticleData <DustTransition > result = (ParticleData <DustTransition >) results .get ();
319
-
320
- // Check the particle type is correct
321
- assertEquals (Particle .DUST_COLOR_TRANSITION , result .particle ());
322
-
323
- // Check the particle properties
324
- assertEquals (Color .RED , ((DustTransition ) result .data ()).getColor ());
325
- assertEquals (Color .BLUE , ((DustTransition ) result .data ()).getToColor ());
326
- assertEquals (3.0f , ((DustTransition ) result .data ()).getSize ());
327
-
328
- assertNoMoreResults (results );
329
- }
330
-
331
203
}
0 commit comments