getTargetBlock 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! if you need to see more of the code just ask, Not sure how much to show
     
  2. This should be in "Spigot Plugin Development," not "Spigot Plugin Help."

    You're getting this warning because the method you're using is deprecated, and is ambiguous with another method also provided. This method was deprecated because of magic values, but by casting the null to Set<Material>, you will tell your IDE to recognize that you're using the non-deprecated method.

    Short answer: use #getTargetBlock(Set<Material>, int), not #getTargetBlock(HashSet<Byte>, int).
     
  3. You haven't casted your null value yet.
    Here is the code you used :
    Code (Text):
    Block b = p.getTargetBlock(null, 5);
    You should cast the null value to a Set<Material> so that your IDE knows that you are not trying to use the deprecated method.
    Code (Text):
    Block b = p.getTargetBlock((Set<Material>) null, 5);