Player add potion effect not working.

Discussion in 'Plugin Development' started by ShadowWizardMC, Mar 3, 2014.

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

    ShadowWizardMC

    Ok Bukkit, i am here once again seeking help from you. In my plugin CraftableNukes i am currently adding the feature of "Radiation". So when my special tnt blows up i want to it give all nearby players maybe in a 50 block radius a potion effect but if does not work. This is my Radiation class.

    Code:java
    1. package me.ShadowWizard.CraftableNukes;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.entity.EntityType;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.entity.ExplosionPrimeEvent;
    10. import org.bukkit.event.player.PlayerJoinEvent;
    11. import org.bukkit.event.player.PlayerMoveEvent;
    12. import org.bukkit.potion.PotionEffect;
    13. import org.bukkit.potion.PotionEffectType;
    14.  
    15. public class NukeEventListener implements Listener {
    16.  
    17. @EventHandler
    18. public void playerJoin(PlayerJoinEvent event)
    19. {
    20. event.getPlayer().sendMessage(ChatColor.RED + "This server is running CraftableNukes!");
    21. }
    22.  
    23. @EventHandler
    24. public void Nuke(ExplosionPrimeEvent event)
    25. {
    26. if (event.getEntityType() == EntityType.PRIMED_TNT) {
    27. event.setRadius(55.0F);
    28. event.setFire(true);
    29. }
    30. }
    31. @EventHandler
    32. public void Radiation(PlayerMoveEvent e) {
    33. Player player = e.getPlayer();
    34. for (Player p : Bukkit.getOnlinePlayers()) {
    35. if (p != player && p.getWorld() == player.getWorld()
    36. && p.getLocation().distance(player.getLocation()) < 45) {
    37. player.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, 600, 3));
    38. player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 600, 3));
    39. player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 900, 3));
    40. player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 600, 3));
    41. player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 200, 2));
    42. }
    43. }
    44. }
    45. }


    What am i doing wrong?
     
  2. Offline

    Barinade

    Print the results of your conditions.
     
  3. Offline

    ShadowWizardMC


    Excuse me. I don't understand what youre saying. I do not get an error it works fie just the feature is not working.
     
  4. Offline

    Barinade

    Write your conditions to the console

    p != player
    p.getWorld() == player.getWorld()
    p.getLocation().distance(player.getLocation()) < 45
     
  5. Offline

    ShadowWizardMC

    Barinade
    Well in doing so i made a stupid mistake and broke my code but for some reason it still doesen't work.
     
  6. Offline

    chasertw123

    Replace player.addPotionEffect(stuff here) with p.addPotionEffect(stuff here).
     
  7. Offline

    ShadowWizardMC

    chasertw123

    Should this affect the player if he is in creative also?
     
  8. Offline

    chasertw123

    You can check the players gamemode and if they are in creative have nothimg happen.
     
Thread Status:
Not open for further replies.

Share This Page