Block Place and build Tower

Discussion in 'Plugin Development' started by Zero9195, Mar 26, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Zero9195

    So now after the Command works, the Building does not. This is the Code. It should build a Striaght Tower up in the Sky, it worked the whole time but now while updating it doesn't. When I place a Block the Block disappears and i have the same amount as before.

    Code:
    public void tower1(BlockPlaceEvent event)
        {
            Player player = event.getPlayer( );
            Block block = event.getBlockPlaced( );
            Material mat = Material.getMaterial(block.getTypeId( ) );
            ItemStack hand = event.getItemInHand( );
            if ( JMPlayerListener.plugin.tower1Enabled( player ) == true )
            {
                int j = hand.getAmount();
                for (int i = 0 ; i < j - 1 ; i++)
                {
                    Block newBlock = player.getWorld( ).getBlockAt(block.getX( ), block.getY( ) + i, block.getZ( ) );
                    newBlock.setType( mat );
                    hand.setAmount( hand.getAmount( )-1);
                }
                event.setCancelled(true);
                plugin.toogleTower1( player );
                hand.setAmount(hand.getAmount( ) - 1);
            }
    
        }
    Thanks for Helping ;)
    Zero
     
  2. Offline

    Sammy

    I'm getting a similar problem since the change from BLOCK_PLACED to BLOCK_PLACE, maybe they changed something else too?
     
  3. Offline

    Zero9195

    It seems so, maybe someone knows a solution for that?
     
  4. Code:
                plugin.toogleTower1( player );
    Isn't it supposed to be toggleTower1 ? :eek:
    And if you cancel the event - isn't the block removed?

    Though I'm unsure how it works, I'm fairly new :D
     
  5. Offline

    Zero9195

    No no, thats allright, as I said everything worked fine in the past, and I just changed the BLOCK_PLACE. Isn't someone out there who has the same problem and a solution?
     
  6. Offline

    Zero9195

    It seems I found the Problem. The method event.getItemInHand().getAmount() always returns 1. Even if I have a Full stack in my Hands. It looks like a Problem in Bukkit itself rather than a problem I caused.
     
Thread Status:
Not open for further replies.

Share This Page