def chat_command(self, username, parameters): if len(parameters) == 0: return ("Usage: /{0} {1}".format(self.name, self.usage),) elif len(parameters) == 1: block = parameters[0] count = 1 elif len(parameters) == 2: block = parameters[0] count = parameters[1] else: block = " ".join(parameters[:-1]) count = parameters[-1] player = parse_player(factory, username) block = parse_block(block) count = parse_int(count) # Get a location two blocks in front of the player. dest = player.player.location.in_front_of(2) dest.y += 1 coords = int(dest.x * 32), int(dest.y * 32), int(dest.z * 32) factory.give(coords, block, count) # Return an empty tuple for iteration return tuple()
def chat_command(self, username, parameters): if len(parameters) == 0: return ("Usage: /{0} {1}".format(self.name, self.usage), ) elif len(parameters) == 1: block = parameters[0] count = 1 elif len(parameters) == 2: block = parameters[0] count = parameters[1] else: block = " ".join(parameters[:-1]) count = parameters[-1] player = parse_player(self.factory, username) block = parse_block(block) count = int(count) # Get a location two blocks in front of the player. dest = player.player.location.in_front_of(2) dest.y += 1 coords = int(dest.x * 32), int(dest.y * 32), int(dest.z * 32) self.factory.give(coords, block, count) # Return an empty tuple for iteration return tuple()
def test_parse_block_item_named(self): self.assertEqual(parse_block("leather-leggings"), (300, 0))
def test_parse_block_item_hex(self): self.assertEqual(parse_block("0x12C"), (300, 0))
def test_parse_block_item(self): self.assertEqual(parse_block("300"), (300, 0))
def test_parse_block_named(self): self.assertEqual(parse_block("coal-ore"), (16, 0))
def test_parse_block_hex(self): self.assertEqual(parse_block("0x10"), (16, 0))
def test_parse_block(self): self.assertEqual(parse_block("16"), (16, 0))