Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playeffect - support new data types #2678

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.denizenscript.denizencore.scripts.commands.AbstractCommand;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.Particle;
import org.bukkit.Vibration;
Expand Down Expand Up @@ -86,6 +87,10 @@ public PlayEffectCommand() {
// - For BLOCK_MARKER, FALLING_DUST, BLOCK_CRACK, or BLOCK_DUST particles, the input is any valid MaterialTag, eg "stone".
// - For VIBRATION, the input is <duration>|<origin>|<destination> where origin is a LocationTag and destination is either LocationTag or EntityTag, for example "5s|<context.location>|<player>"
// - For ITEM_CRACK particles, the input is any valid ItemTag, eg "stick".
// - For TARGET_COLOR, the input is of format: <color>|<location>, for example "red|<player.cursor_on>". Color input is any valid ColorTag object.
// - For COLOR, the input is any valid ColorTag.
// - For FLOAT, the input is any valid ElementTag(Decimal).
// - For INTEGER, the input is any valid ElementTag(Integer).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'd be (Number) but also just say any valid number, don't be overly technical when you don't need to be

Also what the heck is an integer particle? That For x y z particles, half should name particles that use a format, not the format's java class name

//
// Optionally specify a velocity vector for standard particles to move. Note that this ignores the 'data' input if used.
//
Expand All @@ -104,6 +109,24 @@ public PlayEffectCommand() {
// @Usage
// Use to play some effects at spawn.
// - playeffect effect:FIREWORKS_SPARK at:<world[world].spawn_location> visibility:100 quantity:375 data:0 offset:50.0
//
// @Usage
// Use to spawn a cloud of rainbow-colored ENTITY_EFFECT particles around yourself.
// - foreach <util.color_names> as:color:
// - playeffect effect:ENTITY_EFFECT at:<player.eye_location> quantity:25 special_data:<[color]>
//
// @Usage
// Use to shoot a laser in to the direction you're looking at.
// - playeffect effect:TRAIL at:<player.eye_location> quantity:100 offset:0 special_data:RED|<player.eye_location.ray_trace[default=air]>
//
// @Usage
// Use to spawn a SCULK_CHARGE effect upside down.
// - playeffect effect:SCULK_CHARGE at:<player.eye_location.add[0,1,0]> quantity:1 offset:0 special_data:<element[180].to_radians>
//
// @Usage
// Use to play a SHRIEK effect with a 5-second delay.
// - playeffect effect:SHRIEK at:<player.eye_location.add[0,1,0]> quantity:1 special_data:100
//
// -->

@Override
Expand Down Expand Up @@ -345,6 +368,27 @@ else if (clazz == Vibration.class) {
dataObject = new Vibration(origin, destObj, duration.getTicksAsInt());
}
}
else if (clazz == Particle.TargetColor.class) {
ListTag dataList = ListTag.valueOf(special_data.asString(), scriptEntry.getContext());
if (dataList.size() != 2) {
Debug.echoError("TargetColor special_data must have 2 list entries for particle: " + particleEffect.name());
return;
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format

ColorTag color = dataList.getObject(0).asType(ColorTag.class, scriptEntry.context);
LocationTag target = dataList.getObject(1).asType(LocationTag.class, scriptEntry.context);
dataObject = new Particle.TargetColor(target, BukkitColorExtensions.getColor(color));
}
}
else if (clazz == Color.class) {
ColorTag color = ColorTag.valueOf(special_data.asString(), scriptEntry.context);
dataObject = BukkitColorExtensions.getColor(color);
}
else if (clazz == Integer.class) {
dataObject = special_data.asInt();
}
else if (clazz == Float.class) {
dataObject = special_data.asFloat();
}
else {
Debug.echoError("Unknown particle data type: " + clazz.getCanonicalName() + " for particle: " + particleEffect.name());
return;
Expand Down