pumpkinplus/mirror_types/
interaction.rs1use serde::{Deserialize, Serialize};
6use std::fmt;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Hash)]
12#[serde(rename_all = "PascalCase")]
13pub enum InteractAction {
14 RightClickBlock,
15 RightClickAir,
16 LeftClickBlock,
17 LeftClickAir,
18}
19
20impl InteractAction {
21 pub fn matches_config(&self, allowed: &[Self]) -> bool {
23 allowed.is_empty() || allowed.contains(self)
24 }
25}
26
27impl fmt::Display for InteractAction {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 write!(f, "{:?}", self)
30 }
31}
32
33impl From<pumpkin_plugin_api::events::InteractAction> for InteractAction {
38 fn from(value: pumpkin_plugin_api::events::InteractAction) -> Self {
39 #[allow(unreachable_patterns)]
40 match value {
41 pumpkin_plugin_api::events::InteractAction::RightClickBlock => Self::RightClickBlock,
42 pumpkin_plugin_api::events::InteractAction::RightClickAir => Self::RightClickAir,
43 pumpkin_plugin_api::events::InteractAction::LeftClickBlock => Self::LeftClickBlock,
44 pumpkin_plugin_api::events::InteractAction::LeftClickAir => Self::LeftClickAir,
45 _ => Self::RightClickBlock,
46 }
47 }
48}