elementalgodz11 You need an SignChangeEvent Because, if you will do some command/events with a sign, you must do a sign change event, other you can do a interactevent then you must put the sign in Material.SIGN and not in "sign" Code:java @EventHandlerpublic void onPlayerInteract (PlayerInteractEvent e) {Player p = e.getPlayer();if (e.getClickedBlock == Material.SIGN) {If (e.getAction() == Action.RIGHT_CLICK_BLOCK) {Block block = e.getClickedBlock();String Line 3 = sign.getLine(2);String Line2 = sign.getLine(1);if (Line3.equals("Clear")p.getInventory.clear();p.getInventory.setArnourContents (null);} elementalgodz11 This should work Other you can do a signChangeEvent, you started with a new event and do some stuff with your event EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Here is what your Code should look like Code:text @EventHandlerpublic void onPlayerInteract (PlayerInteractEvent e) {Player p = e.getPlayer();if (e.getClickedBlock == Material.SIGN) {if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {Block block = e.getClickedBlock();BlockState st = block.getState();if (st instanceof Sign) {String Line 3 = sign.getLine(2);if (Line3.equals("Clear") {p.getInventory.setContents(null);p.getInventory.setArmorContents(null);}}}} I did not rewrite this in Eclipse so the Spacing might be off.
FatAussieFatBoy Thats the first code from elementalgodz11 Why you coppied that and edit it with one more line! If you dont know what your doing, post nothing
jusjus112 I posted him a Working code, so I think I do know what I'm doing... Maybe you should consider thinking before you type. EDIT: Sorry I meant to put "if(e.getClickedBlock == Material.SIGN)" in the code.
FatAussieFatBoy If you set that in your code, i dont say nothing. but i say it because your code dont work. now its work. elementalgodz11 p.getInventory.setContents(null); p.getInventory.setArmorContents(null); put that in your code and it should work and remove p.getInventory.clear FatAussieFatBoy it should work, but your now setting 1 item in air. if i get the point, he will remove all items EDIT by Moderator: merged posts, please use the edit button instead of double posting.
jusjus112 Never Mind, I will delete the Post, I wasn't thinking. It's like 11:00pm here so I'm kind of starting to drift to sleep. To many late nights I think
Code:java @EventHandlerpublic void onPlayerInteract (PlayerInteractEvent e) {Player p = e.getPlayer();if (e.getClickedBlock == Material.SIGN // Sign or Wall.Sign) {If (e.getAction() == Action.RIGHT_CLICK_BLOCK) {Block block = e.getClickedBlock();// Block StateString Line 3 = sign.getLine(2);String Line2 = sign.getLine(1);if (Line3.equals("Clear")p.getInventory.clear();p.getInventory.setArnourContents (null);} elementalgodz11
elementalgodz11 Here is a Working code : Code:java @EventHandlerpublic void onSignClick(PlayerInteractEvent e) {Player p = e.getPlayer();Block b = e.getClickedBlock();if(b.getType() == Material.SIGN) {Sign s = (Sign) b;s.update();if(s.getLine(3).equals("Clear")) {p.getInventory().setContents(null);p.getInventory().setArmorContents(null);p.setItemInHand(null);}}} Note: Not tested but it should work...
elementalgodz11 As i said, use the signchangeevent, try that? if you dont know how to make a sign, then watch the tutorial on youtube www.youtube.com/user/Pogostick29Dev
elementalgodz11 did you set the word "Clear" on the 3rd line of the Sign, In The Minecraft Game? If so then change the code where is says : if(s.getLine(3).equals("Clear")) { To : if(s.getLine(2).equals("Clear")) { If you did put the word "Clear" on the 4th Line of the Minecraft Sign then just msg me back and I will do a quick debug of my Code... elementalgodz11 I did a quick De-Bug and this is what my New Code is : Code:java @EventHandler public void onSignClick(PlayerInteractEvent e) { Player p = e.getPlayer(); Block b = e.getClickedBlock(); if(b.equals(Material.SIGN)) { Sign s = (Sign) b; s.update(); if(s.getLine(3).equals("Clear")) { p.getInventory().setContents(null); p.getInventory().setArmorContents(null); p.setItemInHand(null); } } } Note: Not Tested! elementalgodz11 Give this a Try : Code:java @EventHandlerpublic void onSignClick(PlayerInteractEvent e) {Player p = e.getPlayer();Block b = e.getClickedBlock();if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {if(b.getType().equals(Material.SIGN)) {Sign s = (Sign) b;s.update();if(s.getLine(3).equals("Clear")) {p.getInventory().setContents(null);p.getInventory().setArmorContents(null);p.setItemInHand(null);}}}} Note: Not Tested! The Reason I believe the last 2 Codes haven't worked is simply because we haven't been checking what Action the Player has been using, so in theory this should work, and If not try changing the : if(b.getType().equals(Material.SIGN)) { to if(b.getType() == Material.SIGN) { EDIT: Change if(b.getType().equals(Material.SIGN)) { to if(b.getType().equals(Material.SIGN) || b.getType().equals(Material.WALL_SIGN) || b.getType().equals(Material.SIGN_POST)) { EDIT by Moderator: merged posts, please use the edit button instead of double posting.
what about Code:text if (b.getType() == Material.SIGN) Since you check if a block == Material and that is not working. So you need to get the blocktype first (which is a Material) thus you can compare it if it is Material.SIGN
Could everyone please stop suggesting the use of Material.SIGN here? Material.SIGN is the sign item (not a block), and will never be the result of event.getClickedBlock(). Additionally, setContents(null) is not the way to clear an inventory's contents. There's a method for this: .clear(). Try this code (untested): PHP: Block b = event.getClickedBlock();if (b != null && (b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST)) { Sign sign = (Sign) b.getState(); if (sign.getLine(3).equals("Clear")) { // or whichever line you need event.getPlayer().getInventory().clear(); // I can't remember offhand if the above will clear equipment too; if not, use this: event.getPlayer().getEquipment().clear(); }} PHP: player.setItemInHand(null);// next method is deprecated but use it; it's// the only way currently to ensure the client// sees the change right awayplayer.updateInventory(); By the way, a quick google for "bukkit clear item in hand" found that solution pretty quickly. EDIT by Moderator: merged posts, please use the edit button instead of double posting.