Hi Guys, have some Problems with my code. I want it to build a tower after I activate the plugin and placed a Dirt Block, but Ingame nothing happens. Not even an error messsage occurs. Here the code: Creating the Tower: Code: public void Tower1( BlockPlaceEvent event) { Player player = event.getPlayer( ); Block block = event.getBlock( ); ItemStack hand = event.getItemInHand( ); if ( block.getType( ) == Material.DIRT && JMPlayerListener.plugin.jEnabled( player ) == true && hand.getAmount() >= 60 ) { for (int i = 0 ; i < 63 ; i++) { Block newBlock = player.getWorld( ).getBlockAt(block.getX( ), block.getY( ) + i, block.getZ( ) ); newBlock.setTypeId(3); hand.setAmount(hand.getAmount()-1); plugin.toogleVision( player ); } } } Toogle the Plugin: Code: public void onPlayerCommand(PlayerChatEvent event) { String[] split = event.getMessage().split(" "); Player player = event.getPlayer( ); if ((split[0].equalsIgnoreCase("/JMod") || split[0].equalsIgnoreCase("/j"))) { if ((split[1].equalsIgnoreCase("toogle"))) { plugin.toogleVision(player); event.setCancelled(true); } } } Code: public void toogleVision(Player player) { if (jEnabled(player)) { this.jUsers.remove(player); player.sendMessage("JMod disabled"); } else { this.jUsers.put(player, null); player.sendMessage("JMod enabled"); } } If something is missing pls ask Thanks for your Help, Zero9195
Looks like you intend your Tower1 to handle onBlockPlace. Either call it from that method or rename Tower1 to onBlockPlace, assuming that it's declared in a BlockListener class.
Ah thx, it works I may missunderstood some things. I thought this Method is called when "BlockPlaceEvent event" happens. Thanks
would i be able to request a .jar of this adapted to support the placement of a less avidly available block, such as one that would ahve to be invedited, such as a portal block? much obliged -quickslash78
Don't know what you mean. Portal-Blocks are Blocks as any other Block, so its as easy as placing a dirt Block.
Portal blocks? You mean obsidian? Change the newBlock.setTypeId(3); to newBlock.setType(Material.OBSIDIAN); (easier than using the id number)