How to give a Potion Effect on spawn?

Discussion in 'Plugin Development' started by UaVxChallenge, Jul 11, 2014.

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

    UaVxChallenge

    In my plugin I am trying to give people speed on their respawn but even though it works half way. It gives them the stick like its supposed to but not the speed and I don't understand why.

    Code:java
    1. @EventHandler
    2. public void onPlayerSpawn(PlayerRespawnEvent e) {
    3. e.getPlayer().getInventory().addItem(new ItemStack(Material.STICK));
    4.  
    5. e.getPlayer().addPotionEffect(
    6. new PotionEffect(PotionEffectType.SPEED, 20 * 10000, 99));
    7.  
    8. }
     
  2. Offline

    Onlineids

  3. Offline

    xAstraah

    UaVxChallenge, use a PlayerInteractEvent to check if the Player has RIGHT_CLICK_AIR or RIGHT_CLICK_BLOCK using event.getAction() and check if the Players itemInHand is a Stick. then run that code.
     
  4. Offline

    UaVxChallenge

    Onlineids
    That didnt work it still does nothing

    xAstraah
    I can't use a Player Interact Event because I am already using it for another feature. I also tried to scan the inventory for the stick but that didn't work either
     
  5. Offline

    xAstraah

    UaVxChallenge, You can use the Event more than once mate.. Just use another method name such as
    ' onPlayerInteract2 ' ?
     
  6. Offline

    UaVxChallenge

    xAstraah Yea but its like a X-Run plugin so I want them to spawn with it so where they dont just cheat
     
Thread Status:
Not open for further replies.

Share This Page