pub struct PlayerAdvancement {
pub(crate) progress: AdvancementProgressMap,
is_first_packet: bool,
roots_to_update: FxHashSet<AdvancementNodeRef>,
visible: FxHashSet<AdvancementRef>,
progress_changed: FxHashSet<AdvancementRef>,
pub last_selected_tab: Option<AdvancementRef>,
}Expand description
Manages a player’s collection of advancements.
This handles saving, loading, and tracking the state of granted / revoked advancements.
Fields§
§progress: AdvancementProgressMapthe progress of the player for each advancement
is_first_packet: bool§roots_to_update: FxHashSet<AdvancementNodeRef>§visible: FxHashSet<AdvancementRef>§progress_changed: FxHashSet<AdvancementRef>§last_selected_tab: Option<AdvancementRef>represent the las selected advancement tab
Implementations§
Source§impl PlayerAdvancement
impl PlayerAdvancement
Sourcepub(crate) fn award(
&mut self,
player: &Player,
advancement: AdvancementRef,
criterion: &str,
) -> bool
pub(crate) fn award( &mut self, player: &Player, advancement: AdvancementRef, criterion: &str, ) -> bool
Award a criterion to a player. If this completes the advancement, grant the advancement along with its rewards and display the corresponding chat message.
Sourcepub fn revoke(&mut self, advancement: AdvancementRef, criterion: &str) -> bool
pub fn revoke(&mut self, advancement: AdvancementRef, criterion: &str) -> bool
revoke the specified criterion for a player.
Sourcefn mark_for_visibility_update(&mut self, advancement: AdvancementRef)
fn mark_for_visibility_update(&mut self, advancement: AdvancementRef)
mark the advancement to be sent to the client next tick
Sourcefn update_tree_visibility(
&mut self,
root: AdvancementNodeRef,
added: &mut Vec<AdvancementNodeRef>,
removed: &mut Vec<Identifier>,
)
fn update_tree_visibility( &mut self, root: AdvancementNodeRef, added: &mut Vec<AdvancementNodeRef>, removed: &mut Vec<Identifier>, )
modify the added and the removed from the available tree status
Sourcepub fn flush_dirty(&mut self, player: &Player, show_advancement: bool)
pub fn flush_dirty(&mut self, player: &Player, show_advancement: bool)
send the advancement update packet to a player with the updated tree
Sourcepub fn set_selected_tab(
&mut self,
player: &Player,
advancement: Option<AdvancementRef>,
)
pub fn set_selected_tab( &mut self, player: &Player, advancement: Option<AdvancementRef>, )
change the selected tab and update the client with it
Sourcepub(crate) fn persisted_progress(
&self,
) -> Vec<(Identifier, AdvancementProgress)>
pub(crate) fn persisted_progress( &self, ) -> Vec<(Identifier, AdvancementProgress)>
Snapshots the advancements that still have progress for persistence.
Sourcepub(crate) fn apply_persisted_progress(
&mut self,
entries: impl IntoIterator<Item = (Identifier, AdvancementProgress)>,
)
pub(crate) fn apply_persisted_progress( &mut self, entries: impl IntoIterator<Item = (Identifier, AdvancementProgress)>, )
Replaces the current progress with entries loaded from storage.
The first flush after this call sends the full tree to the client, so a domain switch also clears progress that belonged to the previous domain.
Trait Implementations§
Source§impl Clone for PlayerAdvancement
impl Clone for PlayerAdvancement
Source§impl Debug for PlayerAdvancement
impl Debug for PlayerAdvancement
Auto Trait Implementations§
impl !RefUnwindSafe for PlayerAdvancement
impl !UnwindSafe for PlayerAdvancement
impl Freeze for PlayerAdvancement
impl Send for PlayerAdvancement
impl Sync for PlayerAdvancement
impl Unpin for PlayerAdvancement
impl UnsafeUnpin for PlayerAdvancement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>