def getBlockValue(self, value): # Try getting the block as a direct integer type. try: block = chr(int(value)) except ValueError: # OK, try a symbolic type. try: block = chr(globals()['BLOCK_%s' % value.upper()]) except KeyError: return None # Check the block is valid if ord(block) > 49: return None return block
def getBlockValue(self, value): # Try getting the block as a direct integer type. try: block = chr(int(value)) except ValueError: # OK, try a symbolic type. try: block = chr(globals()['BLOCK_%s' % value.upper()]) except KeyError: self.sendServerMessage("'%s' is not a valid block type." % value) return None # Check the block is valid if ord(block) > 49: self.sendServerMessage("'%s' is not a valid block type." % value) return None op_blocks = [BLOCK_SOLID, BLOCK_WATER, BLOCK_LAVA] if ord(block) in op_blocks and not self.isOp(): self.sendServerMessage("Sorry, but you can't use that block.") return return block