Cross-Package Variable Manipulation

Discussion in 'Plugin Development' started by danthonywalker, Oct 20, 2013.

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

    danthonywalker

    Can someone tell me what I'm doing wrong? Basically I'm just trying to add an EntityID into a HashSet so I can track it to set off an explosion when certain parameters are met when it was initially fired.

    This is from my main class:
    Code:java
    1. public class Core extends JavaPlugin implements Listener
    2. {
    3. private ExplosiveTip explosiveTip = new ExplosiveTip();
    4. private Functions funct = new Functions(this);
    5.  
    6. public void onEnable()
    7. {
    8. getCommand("admin").setExecutor(new AdminCommands(this));
    9. getServer().getPluginManager().registerEvents(this, this);
    10. getServer().getPluginManager().registerEvents(new ExplosiveTip(), this);
    11. getLogger().info(getName() + " Has Been Enabled! v" + getDescription().getVersion());
    12. }
    13.  
    14. public void onDisable()
    15. {
    16. getLogger().info(getName() + " Has Been Disabled! v" + getDescription().getVersion());
    17. }
    18.  
    19. // CORE EVENTS - REDIRECTION CLASSES \\
    20.  
    21. @EventHandler
    22. public void projectileLaunch(ProjectileLaunchEvent event)
    23. {
    24.  
    25. if(event.getEntity().getShooter() instanceof Player)
    26. {
    27. Player player = (Player) event.getEntity().getShooter();
    28.  
    29. for(ItemStack item : player.getInventory().getContents())
    30. {
    31.  
    32. if(item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName())
    33. {
    34. System.out.print(event.getEntity().getEntityId()); //DEBUGGING PURPOSES
    35. if(item.getItemMeta().getDisplayName().contains("Explosive Tip") && funct.manaManipulation(player, -20))
    36. explosiveTip.explosive.add(event.getEntity().getEntityId());
    37. }
    38.  
    39. }
    40.  
    41. }
    42.  
    43. }
    44.  
    45. }



    This is from the class the last line is trying to contact with. If it helps, its' in a different package:
    Code:java
    1. public class ExplosiveTip implements Listener
    2. {
    3. public HashSet<Integer> explosive = new HashSet<Integer>();
    4.  
    5. @EventHandler
    6. public void explosiveHit(ProjectileHitEvent event)
    7. {
    8. System.out.print(event.getEntity().getEntityId()); //DEBUGGING PURPOSES
    9.  
    10. if(explosive.contains(event.getEntity().getEntityId()))
    11. {
    12. event.getEntity().getWorld().createExplosion(event.getEntity().getLocation(), (float)event.getEntity().getVelocity().length());
    13. System.out.print(event.getEntity().getVelocity().length()); //DEBUGGING PURPOSES
    14. explosive.remove(event.getEntity().getEntityId());
    15. }
    16.  
    17. }
    18.  
    19. }


    I've ruled out that the EntityIDs are different, but when I tried doing for(int numbers : explosive) in the second set of code it came up with nothing, so I'm sure my problem is that it's not adding the number into the HashSet, but I've also ruled out that it isn't getting into that part because I was able to do other sets of code within that if statement parameter. So I'm sure my command for adding it in is wrong, but I don't know why.
     
Thread Status:
Not open for further replies.

Share This Page