Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ServerPlayerData#Keys.HAS_VIEWED_CREDITS #3092

Merged
merged 1 commit into from
Jul 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@
public interface ServerPlayerEntityAccessor {

@Accessor("enteredNetherPosition") Vec3d accessor$getEnteredNetherPosition();

@Accessor("seenCredits") boolean accessor$getSeenCredits();

@Accessor("seenCredits") void accessor$setSeenCredits(boolean value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.spongepowered.api.entity.living.player.gamemode.GameMode;
import org.spongepowered.api.profile.property.ProfileProperty;
import org.spongepowered.api.statistic.Statistic;
import org.spongepowered.common.accessor.entity.player.ServerPlayerEntityAccessor;
import org.spongepowered.common.bridge.entity.player.ServerPlayerEntityBridge;
import org.spongepowered.common.bridge.stats.StatisticsManagerBridge;
import org.spongepowered.common.data.provider.DataProviderRegistrator;
Expand Down Expand Up @@ -60,6 +61,10 @@ public static void register(final DataProviderRegistrator registrator) {
.get(h -> ((StatisticsManagerBridge) h.getStats()).bridge$getStatsData().entrySet().stream()
.collect(Collectors.toMap(e -> (Statistic)e.getKey(), e -> e.getValue().longValue())))
.set((h, v) -> v.forEach((ik, iv) -> h.getStats().setValue(h, (Stat<?>) ik, iv.intValue())))
.asMutable(ServerPlayerEntityAccessor.class)
.create(Keys.HAS_VIEWED_CREDITS)
.get(ServerPlayerEntityAccessor::accessor$getSeenCredits)
.set(ServerPlayerEntityAccessor::accessor$setSeenCredits)
.asMutable(ServerPlayerEntityBridge.class)
.create(Keys.HEALTH_SCALE)
.defaultValue(Constants.Entity.Player.DEFAULT_HEALTH_SCALE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ public void setWorldBorder(@Nullable WorldBorder border) {
values.add(this.firstJoined().asImmutable());
values.add(this.lastPlayed().asImmutable());
values.add(this.sleepingIgnored().asImmutable());
values.add(this.hasViewedCredits().asImmutable());

// If getSpectatingEntity returns this player, then we are not spectating any other entity, so spectatorTarget would be an Optional.empty()
this.spectatorTarget().map(Value::asImmutable).ifPresent(values::add);
Expand Down