Create a Tower

Discussion in 'Plugin Development' started by Zero9195, Jan 29, 2011.

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

    Zero9195

    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
     
  2. Offline

    mjmr89

    How does Tower1 get called?
     
  3. Offline

    void420

    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.
     
  4. Offline

    Zero9195

    Ah thx, it works ;)
    I may missunderstood some things. I thought this Method is called when "BlockPlaceEvent event" happens. Thanks ;)
     
  5. Offline

    quickslash78

    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
     
  6. Offline

    Zero9195

    Don't know what you mean. Portal-Blocks are Blocks as any other Block, so its as easy as placing a dirt Block.
     
  7. Offline

    mjmr89

    Portal blocks? You mean obsidian? Change the
    newBlock.setTypeId(3);
    to
    newBlock.setType(Material.OBSIDIAN);
    (easier than using the id number)
     
Thread Status:
Not open for further replies.

Share This Page