1515import ch .njol .util .Kleenean ;
1616import com .sovdee .skriptparticles .particles .Particle ;
1717import com .sovdee .skriptparticles .particles .ParticleMotion ;
18- import com .sovdee .skriptparticles .util .ParticleUtil ;
1918import org .bukkit .event .Event ;
2019import org .bukkit .util .Vector ;
2120import org .checkerframework .checker .nullness .qual .Nullable ;
21+ import org .skriptlang .skript .bukkit .particles .particleeffects .ParticleEffect ;
2222import org .skriptlang .skript .lang .entry .EntryContainer ;
2323import org .skriptlang .skript .lang .entry .EntryValidator ;
2424import org .skriptlang .skript .lang .entry .util .ExpressionEntryData ;
3535 "\t velocity: vector - the velocity of the particle. Can be a vector or a motion (inwards/clockwise/etc.). (default: 0, 0, 0)" ,
3636 "\t extra: number - the extra value of the particle. Forces `count` to be 0 and cannot be combined with `offset`. " +
3737 "See the Minecraft wiki on /particle for more info. (default: 0)" ,
38- "\t data: object - the data value of the particle. For example, `dustOptions()` for the dust particle. See the Minecraft wiki on /particle for more info. (default: null)" ,
3938 "\t force: boolean - whether or not to force the particle to be seen at long range. (default: false)"
4039})
4140@ Examples ({
4645 "\t force: true" ,
4746 "set {_particle} to last created particle" ,
4847 "" ,
49- "create a new custom dust particle with:" ,
48+ "create a new custom red dust particle with:" ,
5049 "\t count: 0" ,
5150 "\t velocity: inwards" ,
5251 "\t extra: 0.5" ,
5352 "\t force: true" ,
54- "\t data: dustOption(red, 5)" ,
5553 "set {_particle} to last created particle" ,
5654})
5755@ Since ("1.0.2" )
@@ -63,7 +61,6 @@ public class SecParticle extends Section {
6361 .addEntryData (new ExpressionEntryData <>("offset" , null , true , Vector .class ))
6462 .addEntryData (new ExpressionEntryData <>("velocity" , null , true , Object .class ))
6563 .addEntryData (new ExpressionEntryData <>("extra" , null , true , Number .class ))
66- .addEntryData (new ExpressionEntryData <>("data" , null , true , Object .class ))
6764 .addEntryData (new ExpressionEntryData <>("force" , null , true , Boolean .class ))
6865 .build ();
6966
@@ -73,14 +70,13 @@ public class SecParticle extends Section {
7370 //- offset: vector
7471 //- velocity: vector or inwards/outwards (exclusive w/ offset & count)
7572 //- extra: double
76- //- data: dustOptions, item, etc. (take skbee code)
7773 //- - if particle is dust, allow "color: color" and "size: double"
7874 //- force: boolean
7975 static {
8076 Skript .registerSection (SecParticle .class , "create [a] [new] custom %particle% [particle] [with]" );
8177 }
8278
83- private Expression <org . bukkit . Particle > particle ;
79+ private Expression <ParticleEffect > particle ;
8480 @ Nullable
8581 private Expression <Number > count ;
8682 @ Nullable
@@ -90,8 +86,6 @@ public class SecParticle extends Section {
9086 @ Nullable
9187 private Expression <Number > extra ;
9288 @ Nullable
93- private Expression <Object > data ;
94- @ Nullable
9589 private Expression <Boolean > force ;
9690
9791 @ SuppressWarnings ("unchecked" )
@@ -101,7 +95,7 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
10195 if (entryContainer == null )
10296 return false ;
10397
104- particle = (Expression <org . bukkit . Particle >) expressions [0 ];
98+ particle = (Expression <ParticleEffect >) expressions [0 ];
10599 count = (Expression <Number >) entryContainer .getOptional ("count" , Expression .class , true );
106100 offset = (Expression <Vector >) entryContainer .getOptional ("offset" , Expression .class , true );
107101 extra = (Expression <Number >) entryContainer .getOptional ("extra" , Expression .class , true );
@@ -116,15 +110,6 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
116110 }
117111 }
118112
119- data = (Expression <Object >) entryContainer .getOptional ("data" , Expression .class , true );
120- if (data != null ) {
121- data = LiteralUtils .defendExpression (data );
122- if (!LiteralUtils .canInitSafely (data )){
123- Skript .error ("Invalid value for data! Must be a dust options, item, or other particle data!" );
124- return false ;
125- }
126- }
127-
128113 if (offset != null && velocity != null ) {
129114 Skript .error ("You cannot have both an offset and a velocity for a particle!" );
130115 return false ;
@@ -141,18 +126,17 @@ protected TriggerItem walk(Event event) {
141126 }
142127
143128 private void execute (Event event ) {
144- org . bukkit . @ Nullable Particle bukkitParticle = this .particle .getSingle (event );
145- if (bukkitParticle == null )
129+ @ Nullable ParticleEffect particleEffect = this .particle .getSingle (event );
130+ if (particleEffect == null )
146131 return ;
147132 @ Nullable Number count = this .count .getSingle (event );
148133 if (count == null )
149134 return ;
150135 @ Nullable Vector offset = this .offset != null ? this .offset .getSingle (event ) : null ;
151136 @ Nullable Number extra = this .extra != null ? this .extra .getSingle (event ) : null ;
152- @ Nullable Object data = this .data != null ? this .data .getSingle (event ) : null ;
153137 @ Nullable Boolean force = this .force != null ? this .force .getSingle (event ) : null ;
154138
155- Particle particle = ( Particle ) new Particle ( bukkitParticle ).count (count .intValue ());
139+ Particle particle = Particle . of ( particleEffect ).count (count .intValue ());
156140
157141 if (velocity != null ) {
158142 @ Nullable Object v = velocity .getSingle (event );
@@ -169,12 +153,6 @@ private void execute(Event event) {
169153 if (extra != null )
170154 particle .extra (extra .doubleValue ());
171155
172- if (data != null ) {
173- data = ParticleUtil .getData (particle .particle (), data );
174- if (data != null )
175- particle .data (data );
176- }
177-
178156 if (force != null )
179157 particle .force (force );
180158
0 commit comments