NPE on 'empty' line D:

Discussion in 'Plugin Development' started by Hoolean, Nov 24, 2012.

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

    Hoolean

    This is from one of my schedulers! Can anyone tell me why it is giving me an error on line 25 when there is just a parentheses :(

    Even though the content of line 25 has changed, it STILL always gives me an error there :(

    Code:java
    1. package com.puffybugs.CloneZ.Runnables;
    2.  
    3. import net.minecraft.server.MobEffect;
    4. import net.minecraft.server.Packet42RemoveMobEffect;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.craftbukkit.entity.CraftLivingEntity;
    8. import org.bukkit.craftbukkit.entity.CraftPlayer;
    9. import org.bukkit.entity.Entity;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.entity.Zombie;
    12. import org.bukkit.potion.PotionEffect;
    13. import org.bukkit.potion.PotionEffectType;
    14.  
    15. import com.puffybugs.CloneZ.CloneZ;
    16.  
    17. public class TargetFinder implements Runnable {
    18.  
    19. CloneZ cloneZ;
    20.  
    21. public TargetFinder(CloneZ instance) {
    22.  
    23. cloneZ = instance;
    24.  
    25. }
    26.  
    27. /**
    28.   * Finds the target for zombies
    29.   */
    30. @Override
    31. public void run() {
    32.  
    33. for (final Player player : Bukkit.getServer().getOnlinePlayers()) {
    34.  
    35. if(!CloneZ.playerVisibility.containsKey(player.getName())) {
    36.  
    37. CloneZ.playerVisibility.put(player.getName(), 1);
    38.  
    39. }
    40.  
    41. int playerVisibilityRadius = CloneZ.playerVisibility.get(player.getName()) * 5;
    42.  
    43. for (Entity e : player.getNearbyEntities(playerVisibilityRadius, playerVisibilityRadius, playerVisibilityRadius)) {
    44. if (e instanceof Zombie) {
    45. if (CloneZ.alphas.containsKey(e)) {
    46. ((Zombie) e).setTarget(player);
    47.  
    48. final PotionEffect effect = new PotionEffect(
    49. PotionEffectType.SPEED, 60,
    50. (int) (CloneZ.zombieSpeed / 2));
    51.  
    52. ((CraftLivingEntity) e).addPotionEffect(effect);
    53.  
    54. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(cloneZ, new Runnable() {
    55.  
    56. @Override
    57. public void run() {
    58. ((CraftPlayer) player).getHandle().netServerHandler
    59. .sendPacket(new Packet42RemoveMobEffect(
    60. ((CraftPlayer) player).getHandle().id,
    61. new MobEffect(effect.getType().getId(), 0,
    62. 0)));
    63. }
    64.  
    65. }, 1L);
    66. }
    67. }
    68. }
    69.  
    70. }
    71.  
    72. }
    73.  
    74. }
    75.  
     
  2. Offline

    gomeow

    My programming teacher once told me that stack traces aren't always accurate. It could be from the cloneZ = instance
     
  3. Offline

    Hoolean

    Oh OK :D
     
  4. Offline

    gomeow

    Where do you call that method?
     
  5. Offline

    Hoolean

    It is a scheduler! (scheduleSyncRepeatingTask)

    All of my other ones work :(
     
Thread Status:
Not open for further replies.

Share This Page