fixed the event handler registration stuff

This commit is contained in:
Luuk van Oijen
2023-11-13 16:57:45 +01:00
parent a0db8aa8be
commit e781bbac8e
4 changed files with 63 additions and 35 deletions

View File

@@ -1,8 +1,8 @@
pub mod backend_lua;
use std::sync::Arc;
use std::collections::HashMap;
use tokio::runtime::Runtime;
use tokio::sync::Mutex;
use tokio::sync::mpsc::{self, Sender, Receiver};
use tokio::sync::oneshot;
@@ -28,21 +28,23 @@ pub enum Argument {
#[derive(Debug)]
pub enum ScriptEvent {
OnPluginLoaded,
OnPlayerAuthenticated,
}
#[derive(Debug)]
pub enum PluginBoundPluginEvent {
CallEventHandler((ScriptEvent, Vec<Argument>)),
PlayerCount(usize),
Players(HashMap<u8, String>),
}
#[derive(Debug)]
pub enum ServerBoundPluginEvent {
PluginLoaded,
/// Arguments: (event name, handler function name)
RegisterEventHandler((String, String)),
RequestPlayerCount(oneshot::Sender<PluginBoundPluginEvent>),
RequestPlayers(oneshot::Sender<PluginBoundPluginEvent>),
}
pub struct Plugin {