Im not sure how to use events.

Discussion in 'Plugin Development' started by LordFox, May 7, 2014.

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

    LordFox

    hi im making a next gen pvp plugin and i'm not sure about how to use the events to make an explosions that hurts everyone nerby besides the person who did it...i'm really new to bukkit and ive checked sources and i'm still confused. can some one please help
     
  2. Offline

    EnderTroll68

  3. Offline

    LordFox

    EnderTroll68 that doesnt explain the how to make that happen on landing of a jump at a certain height
     
  4. Offline

    coasterman10

    Read the Plugin Tutorial, and then look over the javadocs for events you could use.
     
  5. Offline

    Bobit

    Example:

    Code:java
    1. @Override
    2. onEnable(){
    3. getServer().getPluginManager().registerEvents(this, this);
    4. }
    5.  
    6. @EventHandler
    7. public void interaction(PlayerInteractEvent event) {
    8. //what you want to do when the player interacts with something
    9. }
     
  6. Offline

    LordFox

    no, i want a player move event...like i said i dont know much D:
     
  7. Offline

    Esophose


    PlayerMoveEvent... Check the javadocs for all the Bukkit events.
     
  8. Offline

    Bobit

    javadocs
    Learn to read them, or you won't be able to do anything.
     
  9. Offline

    UHoplite


    Try this. Note that 'EntityMoveEvent' doesn't exist, so you have to create a method / look it up on the javadocs.

    Code:java
    1. @EventHandler
    2. public void onPlayerMove(EntityMoveEvent e){
    3.  
    4. if (!(e.getEntity() instanceof Player))
    5. return;
    6.  
    7. Player p = (Player) e.getEntity();
    8.  
    9. //rest of the code
    10.  
    11. }
     
  10. Offline

    Bobit

    Also note that most things that happen on playerMoveEvent cause significant lag, because player move event is called even when you change what direction you're looking.
     
  11. Offline

    coasterman10

    Bobit If you are running hundreds of lines of code or iterations, yes. Not necessarily though. Most servers are not potatoes, and code you put in there has to be quite big to cause lag.
     
    Konkz likes this.
  12. Offline

    xMrPoi

    If you want to make an explosion every time the player takes fall damager, you'd use the EntityDamageEvent and then check the way the player was damaged.

    Here's something that could work but you have to find out what the actual methods are called.
    Code:java
    1. @EventHandler
    2. public void explodeFall(EntityDamageEvent event){
    3. if(!(event.getEntity() instanceof Player)) return;
    4. if(event.getCause() = DamageCause.FALL){
    5. //make the explosion here
    6. }
    7. }
    You're also going to have to make some sort of an effort to at least look for how to do this. People on here are not going to spoon feed you all the code you need to make this. We will help you though. Good luck.
     
Thread Status:
Not open for further replies.

Share This Page