Solved Can anyone help me?

Discussion in 'Spigot Plugin Development' started by SledgeR6, Dec 8, 2018 at 5:54 PM.

  1. SOLVED
     
    #1 SledgeR6, Dec 8, 2018 at 5:54 PM
    Last edited: Dec 8, 2018 at 8:41 PM
  2. Of course it is.
     
  3. And how do I set the command for that specific block, which can only be done by looking at the specific block?
    Can you give me some advice?
     
  4. Try do this in the onCommand method.

    Code (Text):
    if(p.getTargetBlock(null, 3).getType().equals(Material.BLOCK))
    {
        //Code Here
    }
     
  5. The method getTargetBlock(HashSet<Byte>, int) is ambiguous for the type Player
     
  6. player.getTargetBlock((Set<Material>) null, 3)
     
  7. player cannot be resolved
     
  8. Don't just copy and paste the code. Do you have a player object in your code? If so, use that.
     
  9. Ok, but where can I post the message to verify that the block it is watching is right, and if it is not right to send it another warning message.

    Another error: The method getTargetBlock(HashSet<Byte>, int) in the type LivingEntity is not applicable for the arguments (Set<Material>, int)
     
  10. player.getTargetBlock((Set<Material>) null, 3) -> returns a block object.
    Use Block#getType to get the block's material and then add an if statement comparing it to whatever material type (block) you want.
     

Share This Page