from pyspades.constants import *

def apply_script(protocol, connection, config):
    class BlockConnection(connection):
                
        def on_block_destroy(self, x, y, z, mode):
	    block = connection.on_block_destroy(self, x, y, z, mode)
            if not (self.admin or self.user_types.moderator):
                return False
            else:
                return block
            
        def on_block_build_attempt(self, x, y, z):
	    block = connection.on_block_build_attempt(self, x, y, z)     
            if not (self.admin or self.user_types.moderator):
                return False
            else:
                return block            

        def on_line_build_attempt(self, points):
	    block = connection.on_line_build_attempt(self, points)
            if not (self.admin or self.user_types.moderator):
                return False
            else:
                return block
            
    return protocol, BlockConnection          
                
                
         
