class ActionSignListener(BaseListener): default_config = { 'signs': [ { 'coordinates': [0, 0, 0], 'type': 'teleport', 'destination': [0, 0, 0] } ] } def __init__(self, plugin): self.plugin = plugin def onEnable(self): self.config_manager = ConfigManager(path.join(self.plugin.getDataFolder().getAbsolutePath(), 'signs.yml'), default=self.default_config) self.config_manager.load_config() self.register_event(self.onPlayerInteract, PlayerInteractEvent) register_command(self.reload_command, 'reload-sign-config', permission="omneity.actionsigns.reload") def onDisable(self): self.config_manager.save_config() def onPlayerInteract(self, event): block = event.getClickedBlock() if block is None: return block_state = block.getState() if not isinstance(block_state, Sign): return sign = block_state sign_coords = [block.getX(), block.getY(), block.getZ()] for sign_instance in self.config_manager.config['signs']: if sign_instance['coordinates'] == sign_coords: type_handler = sign_types[sign_instance['type']] if event.getAction() == Action.LEFT_CLICK_BLOCK: type_handler.onLeftClick(sign_instance, self.plugin, event, sign) elif event.getAction() == Action.RIGHT_CLICK_BLOCK: type_handler.onRightClick(sign_instance, self.plugin, event, sign) else: return #Something is f****d, should raise a exception event.setCancelled(True) return def reload_command(self, sender, label, args): self.config_manager.reload_config() sender.sendMessage("Reloaded sign config")