Help: Lightning strike on Join

Discussion in 'Plugin Development' started by Smalltrout, Sep 15, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Smalltrout

    Hello,

    I am trying to make a plugin that strikes lightning when a player joins. I am new to coding and still learning.

    This is what i have been thinking of as a start:

    Code:java
    1. @EventHandler
    2. public void onPlayerJoin(PlayerJoinEvent event){
    3. Player player = event.getPlayer();
    4. player.getWorld().strikeLightning(player.getLocation());
    5. }


    Please help!

    Thanks!
     
  2. Offline

    adam753

    That should work, pretty simple. If it doesn't work, you've probably forgotten to register your events. Do that by putting this line in your onEnable method:
    Code:
    getServer().getPluginManager().registerEvents(this, this);
    (assuming you don't have a separate listener class)
     
  3. Offline

    Zarkopafilis

    Oh and the player may not see the lightning unless you cast it 1 tick after
     
Thread Status:
Not open for further replies.

Share This Page