Renaming Block - BlockPlaceEvent

Discussion in 'Spigot Plugin Development' started by SobkySK, May 10, 2015.

  1. Hi, I want create plugin, which will be Renaming Blocks when Player place block. If he has CreativeMode.
    Code (Text):
    @EventHandler
        public void onPlaceBlock(BlockPlaceEvent event){
            Player player = event.getPlayer();
            if(!(player.hasPermission("cbc.prevent"))){
                if(player.getGameMode() == GameMode.CREATIVE){
    //Rename block on "Block Placed in creative!"
                }
            }
        }
     
  2. You can't rename blocks. If you placed a renamed block, it will be a block without a name after it's broken.
     
  3. Yeah ItemStacks have names, blocks do not. What you can do is save a name in the metadata and on block break restore the name to the dropped itemstack.
     
    • Agree Agree x 1