moved the files around added demo examples and fixed a bunch of stuff!
This commit is contained in:
40
lua/PluginFSHandler.py
Normal file
40
lua/PluginFSHandler.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from pathlib import Path
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
from log.Logger import *
|
||||
logger = Logger()
|
||||
|
||||
class PluginFSHandler(FileSystemEventHandler):
|
||||
def __init__(self, manager):
|
||||
self.manager = manager
|
||||
|
||||
def on_modified(self, event):
|
||||
try:
|
||||
if event.is_directory:
|
||||
return
|
||||
if event.src_path.endswith(".lua"):
|
||||
logger.log_lua_info(f"Plugin changed: {event.src_path}, reloading")
|
||||
self.manager.reload_plugin(Path(event.src_path))
|
||||
except Exception as e:
|
||||
logger.log_lua_error(f"Error in on_modified: {e}")
|
||||
|
||||
def on_created(self, event):
|
||||
try:
|
||||
if event.is_directory:
|
||||
return
|
||||
if event.src_path.endswith(".lua"):
|
||||
logger.log_lua_info(f"New plugin: {event.src_path}, loading")
|
||||
self.manager.load_plugin(Path(event.src_path))
|
||||
except Exception as e:
|
||||
logger.error(f"Error in on_created: {e}")
|
||||
|
||||
def on_deleted(self, event):
|
||||
try:
|
||||
if event.is_directory:
|
||||
return
|
||||
p = Path(event.src_path)
|
||||
if p.suffix == ".lua":
|
||||
logger.log_lua_info(f"Plugin removed: {p.name}")
|
||||
self.manager.unload_plugin(p.name)
|
||||
except Exception as e:
|
||||
logger.log_lua_error(f"Error in on_deleted: {e}")
|
||||
Reference in New Issue
Block a user