Block b = p.getTargetBlock(null, 5); Error

Discussion in 'Spigot Plugin Development' started by Robotkubo, Jun 10, 2015.

  1. Okay, so I'm making a plugin, and I'm getting this error on Block b = p.getTargetBlock(null, 5);
    It says The method getTargetBlock(HashSet<Byte>, int) is ambiguous for the type Player, This is the only bug in my plugin, and I really need it done soon! If anyone could help that would be great! Here is the code http://pastebin.com/n2kaRb5J
     
  2. Please!! USE the code BB Code given... it's very hard to read otherwise..
     
  3. @fujiboy4 Whats so hard to read about it?
     
  4. Nvm....
     
  5. @fujiboy4 I guess you can't help me, can you
     
  6. Is null a Set <Byte> or a Set <Material>? The compiler is just asking you to specify because it doesnt know which method to use otherwise. Cast it and all should be well :)
     
  7. @MrBlobman I didn't think I had to put any Material in it, I'm making it so when you type a command looking at a Chest/Trapped Chest the command works
     
  8. You are completly right in understanding how the method works and should be called to do what you want. Giving it null will get the block that the player is looking at with no obstructions, ie all air blocks. But is null a set of bytes or a set of materials? Thats all that the compiler is wondering. There are two methods with very similar signatures and the compiler has no way of knowing which one you are trying to call. Cast null to a Set<Material> and the compiler will know tou wish to call the one that takes a set of materials rather than a set of bytes.