2020-12-12 15:02:58 +00:00
|
|
|
extern crate plugin_rt;
|
2020-12-12 13:01:54 +00:00
|
|
|
|
|
|
|
use plugin_rt::*;
|
2020-12-12 19:26:42 +00:00
|
|
|
use plugin_rt::api::{Action, event::*};
|
2020-12-09 20:47:42 +00:00
|
|
|
|
2020-12-12 13:22:51 +00:00
|
|
|
#[event_handler]
|
2020-12-11 23:37:22 +00:00
|
|
|
pub fn on_load(load: PluginLoadEvent) -> () {
|
2020-12-12 19:26:42 +00:00
|
|
|
emit_action(Action::Print("This is a test".to_owned()));
|
2020-12-11 23:37:22 +00:00
|
|
|
println!("Hello world");
|
|
|
|
}
|
|
|
|
|
2020-12-12 15:02:58 +00:00
|
|
|
#[event_handler]
|
|
|
|
pub fn on_command_testplugin(command: ChatCommandEvent) -> Result<Vec<String>, String> {
|
|
|
|
Ok(vec![format!("Player of id {:?} sended command with args {:?}",command.player,command.command_args)])
|
|
|
|
}
|
|
|
|
|
2020-12-12 13:22:51 +00:00
|
|
|
#[event_handler]
|
2020-12-11 23:37:22 +00:00
|
|
|
pub fn on_player_join(input: PlayerJoinEvent) -> PlayerJoinResult {
|
2020-12-12 19:26:42 +00:00
|
|
|
emit_action(Action::PlayerSendMessage(input.player_id,format!("Welcome {} on our server",input.player_name)));
|
2020-12-11 23:37:22 +00:00
|
|
|
if input.player_name == "Cheater123" {
|
|
|
|
PlayerJoinResult::CloseConnection
|
|
|
|
} else {
|
|
|
|
PlayerJoinResult::None
|
|
|
|
}
|
2020-12-09 20:47:42 +00:00
|
|
|
}
|