Search in sources :

Example 1 with PlayerAdvancements

use of net.minecraft.server.PlayerAdvancements in project Denizen-For-Bukkit by DenizenScript.

the class AdvancementHelperImpl method update.

@Override
public void update(Player player) {
    ServerPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
    nmsPlayer.connection.send(new ClientboundUpdateAdvancementsPacket(true, Collections.emptySet(), Collections.emptySet(), Collections.emptyMap()));
    PlayerAdvancements data = nmsPlayer.getAdvancements();
    // save progress
    data.save();
    // clear progress
    data.reload(DedicatedServer.getServer().getAdvancements());
    // load progress and update client
    data.flushDirty(nmsPlayer);
}
Also used : ClientboundUpdateAdvancementsPacket(net.minecraft.network.protocol.game.ClientboundUpdateAdvancementsPacket) PlayerAdvancements(net.minecraft.server.PlayerAdvancements) ServerPlayer(net.minecraft.server.level.ServerPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)

Example 2 with PlayerAdvancements

use of net.minecraft.server.PlayerAdvancements in project Denizen-For-Bukkit by DenizenScript.

the class AdvancementHelperImpl method update.

@Override
public void update(Player player) {
    ServerPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
    nmsPlayer.connection.send(new ClientboundUpdateAdvancementsPacket(true, Collections.emptySet(), Collections.emptySet(), Collections.emptyMap()));
    PlayerAdvancements data = nmsPlayer.getAdvancements();
    // save progress
    data.save();
    // clear progress
    data.reload(DedicatedServer.getServer().getAdvancements());
    // load progress and update client
    data.flushDirty(nmsPlayer);
}
Also used : ClientboundUpdateAdvancementsPacket(net.minecraft.network.protocol.game.ClientboundUpdateAdvancementsPacket) PlayerAdvancements(net.minecraft.server.PlayerAdvancements) ServerPlayer(net.minecraft.server.level.ServerPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)

Aggregations

ClientboundUpdateAdvancementsPacket (net.minecraft.network.protocol.game.ClientboundUpdateAdvancementsPacket)2 PlayerAdvancements (net.minecraft.server.PlayerAdvancements)2 ServerPlayer (net.minecraft.server.level.ServerPlayer)2 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)1