mod block;
mod bus;
mod chat;
mod container;
mod crafting;
#[cfg(feature = "raw-packets")]
mod packet;
mod player;
mod traits;
pub use block::{BlockBrokenEvent, BlockPlacedEvent, PlayerInteractEvent};
pub use bus::EventBus;
pub use chat::{ChatMessageEvent, CommandEvent};
pub use container::*;
pub use crafting::{
CraftingCraftedEvent, CraftingGridChangedEvent, CraftingPreCraftEvent,
CraftingRecipeClearedEvent, CraftingRecipeMatchedEvent, CraftingShiftClickBatchEvent,
RecipeBookFillRequestEvent, RecipeBookFilledEvent, RecipeLockedEvent, RecipeRegisterEvent,
RecipeRegisteredEvent, RecipeUnlockedEvent, RecipeUnregisteredEvent,
};
#[cfg(feature = "raw-packets")]
pub use packet::RawPacketEvent;
pub use player::{PlayerJoinedEvent, PlayerLeftEvent, PlayerMovedEvent};
pub use traits::{BusKind, Event, EventRouting, Stage};
#[macro_export]
macro_rules! instant_event {
($name:ident) => {
impl $crate::events::Event for $name {
fn is_cancelled(&self) -> bool {
false
}
fn cancel(&mut self) {}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
fn bus_kind(&self) -> $crate::events::BusKind {
$crate::events::BusKind::Instant
}
}
impl $crate::events::EventRouting for $name {
const BUS: $crate::events::BusKind = $crate::events::BusKind::Instant;
}
};
}
#[macro_export]
macro_rules! instant_cancellable_event {
($name:ident) => {
impl $crate::events::Event for $name {
fn is_cancelled(&self) -> bool {
self.cancelled
}
fn cancel(&mut self) {
self.cancelled = true;
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
fn bus_kind(&self) -> $crate::events::BusKind {
$crate::events::BusKind::Instant
}
}
impl $crate::events::EventRouting for $name {
const BUS: $crate::events::BusKind = $crate::events::BusKind::Instant;
}
};
}
#[macro_export]
macro_rules! game_event {
($name:ident) => {
impl $crate::events::Event for $name {
fn is_cancelled(&self) -> bool {
false
}
fn cancel(&mut self) {}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
fn bus_kind(&self) -> $crate::events::BusKind {
$crate::events::BusKind::Game
}
}
impl $crate::events::EventRouting for $name {
const BUS: $crate::events::BusKind = $crate::events::BusKind::Game;
}
};
}
#[macro_export]
macro_rules! game_cancellable_event {
($name:ident) => {
impl $crate::events::Event for $name {
fn is_cancelled(&self) -> bool {
self.cancelled
}
fn cancel(&mut self) {
self.cancelled = true;
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
fn bus_kind(&self) -> $crate::events::BusKind {
$crate::events::BusKind::Game
}
}
impl $crate::events::EventRouting for $name {
const BUS: $crate::events::BusKind = $crate::events::BusKind::Game;
}
};
}