Smiting a target player?

Hi again everyone,
I’ve been trying to smite a target player as per the title and encountering difficulties in doing so. I’ve flipped through the API/JavaDocs and found the lightning and lightningstrikeevent but I couldn’t quite wrap my head around it. So far what I’ve done is this

So if anyone can help me out with this and maybe give some clarification if I missed anything I’d greatly appreciate it and my apologies for my noobiness still.

The gist isn’t loading @DarkIcicle

1 Like

You may want to look here:

Apologies for my noobiness again but I couldn’t quite get my head around on how to use it properly in the way I’d like to, I’ve tried some things but have had no luck in using what you mentioned. (On an off tangent note, fixed the gist in my post thanks to @mmonkey pointing it out and @The_Doctors_Life showing I copied the clone URL and not the actual URL my bad)

Firing the event from your plugin will likely do nothing.
What you need to do is create a lightning entity at the location of the player

Player target = (Player) args.getOne("target").get();
Location loc = target.getLocation(); 
Optional<Entity> optional = target.getWorld().createEntity(
                            EntityTypes.LIGHTNING, loc.getPosition());
if (optional.isPresent()) {
    Lightning lightning = (Lightning) optional.get();
    if (player.getWorld().spawnEntity(lightning)) {
        return CommandResult.success();
// Show error here

Note: this code is not tested

I’ve made some alterations to the code you provided and had no luck. Such threw the error: java.lang.NoSuchMethodException: No such accessable constructor on object net.minecraft.entity.effect.EntityLightningBolt
Here’s the updated gist:

Try making an issue on the implementation bug tracker, if it occurs in both SpongeVanilla and Sponge or individually on whichever one caused the error.

I have submitted a fix for this crash,