I am making a Checkers plugin wherein if a player in an ArrayList right-clicks a skeleton skull, it will send them a message. If they right click a zombie skull and are in a different ArrayList, it sends them a different message. How can I test which type of skull they clicked on? I am currently able to test whether they clicked on a skull or different block.
I believe each skull block has a different data value? So you can use this: Code: if(block.getData() == (byte) <whatever> && arraylist.contains(player)) { //Rest of code stuff }
I can't seem to get that to work, try as I might. Here's my code. Code: @EventHandler public void onBlock(PlayerInteractEvent ev){ Player p = ev.getPlayer(); Action a = ev.getAction(); if(a == Action.RIGHT_CLICK_BLOCK){ Block b = ev.getClickedBlock(); if(b.getType() == Material.SKULL){ p.sendMessage("testtt"); if(b.getData() == (byte)3){ p.sendMessage("Test"); } } } } When I click on any skull, it will say "testtt", and this works fine. But I can't even get it to say "Test" by only clicking the Steve skull. I left out the ArrayList part just because it's not essential for solving this problem. I can test for that easily enough, too. I just can't seem to get the Skull data.
Are you sure you have the right skull data? Prehaps try printing out the data value in the chat when the block is clicked just so you can check if it's correct: Code: p.sendMessage(block.getData() + "")
@JTGaming2012 Thanks for the idea! I did Code: p.sendMessage("testtt"); p.sendMessage(b.getData() + ""); p.sendMessage(""+b.getTypeId()); p.sendMessage(""+b.getMetadata("")); And it returned testtt 1 144 [] When the skull is placed on the side of a block instead of on the ground, the data was 3. I can't seem to do much with the metadata, but I'm not sure if that has to do with the type of skull anyways. The Data is based on where it is placed. face of block and data are shown below. Top = 1 North = 2 South = 3 West = 4 East = 5 There is nothing about the direction it's facing though.