Solved Help: Metadata Problem

Discussion in 'Plugin Development' started by XvBaseballkidvX, Aug 24, 2013.

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

    XvBaseballkidvX

    Hello everyone!

    I am currently making a Custom Weapons/Wand plugin and I have come across a problem.

    Code:

    Code:java
    1. @EventHandler
    2. public void HealingEvent(PlayerInteractEvent event){
    3.  
    4. ItemStack is = new ItemStack(Material.STICK);
    5. ItemMeta im = is.getItemMeta();
    6. im.setDisplayName(ChatColor.AQUA + "Healing Wand");
    7. im.setLore(Arrays.asList(ChatColor.GOLD + "Spawns a Healing Potion"));
    8. is.setItemMeta(im);
    9.  
    10. Player player = event.getPlayer();
    11. if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK){
    12. if(player.getItemInHand().equals(is)){
    13. if(player.hasPermission("wand.healing")){
    14.  
    15. //Just a cooldown, is not apart of the Problem
    16.  
    17. if(healingcooldown.containsKey(player.getName())){
    18. player.sendMessage(ChatColor.GOLD + "Woah there, You can't use this spell for another: " +
    19. ChatColor.RED + getTimeLeft(player, healingcooldown) + ChatColor.GOLD + " seconds!");
    20.  
    21. }else{
    22.  
    23. //Where the Problem Begins
    24.  
    25. player.launchProjectile(Egg.class).setMetadata("Projectile", new FixedMetadataValue(p, true));
    26.  
    27.  
    28.  
    29.  
    30.  
    31.  
    32. }
    33. }else{
    34. player.sendMessage(deny);
    35. }
    36. }
    37. }
    38.  
    39.  
    40.  
    41.  
    42. }
    43.  
    44. @EventHandler
    45. public void healthspawn(ProjectileHitEvent event){
    46.  
    47. Entity projectile = event.getEntity();
    48.  
    49. if(projectile.equals(Egg.class)){
    50.  
    51. if(projectile.hasMetadata("Projectile")){
    52.  
    53. Egg egg = (Egg) projectile;
    54.  
    55. event.getEntity().getWorld().spawnCreature(egg.getLocation(), CreatureType.ZOMBIE);
    56.  
    57.  
    58.  
    59. }
    60. }
    61. }
    62. //Where the Problem Ends
    63.  
    64.  
    65. }



    So, what I am trying to accomplish is, to spawn a Zombie (Just as a test to make sure that it works properly! I am going to spawn a Heath Potion when this problem is fixed) where the egg lands. I am not sure what is wrong, it all looks right to me, and I have no errors in Eclipse or in the Server Console.

    NOTE: It does launch the Egg, but when the egg lands it does not spawn a Zombie.

    Thank you for reading!

    All help is much appreciated! :D
     
  2. Offline

    metalhedd

    this:

    if (projectile.equals(Egg.class))

    should be this:

    if (projectile instanceof Egg)
     
  3. Offline

    XvBaseballkidvX

    metalhedd Thank you so much! I am about to try this out and see if it works!
     
Thread Status:
Not open for further replies.

Share This Page