also add contributors to /pumpkin command Co-Authored-By: Fyor <90567841+fyordev@users.noreply.github.com> Co-Authored-By: MartV0 <34748938+martv0@users.noreply.github.com> Co-Authored-By: FabseGP <fabsegp@fabseman.space>
15 lines
418 B
Rust
15 lines
418 B
Rust
use serde::{Serialize, Serializer};
|
|
|
|
use crate::codec::var_int::VarInt;
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub struct OptionalInt(pub Option<i32>);
|
|
|
|
impl Serialize for OptionalInt {
|
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
|
// Vanilla logic: empty is 0, otherwise value + 1
|
|
let val = self.0.map_or(0, |id| id + 1);
|
|
VarInt(val).serialize(serializer)
|
|
}
|
|
}
|