use of net.minecraft.network.protocol.game.ClientboundUpdateAdvancementsPacket in project Denizen-For-Bukkit by DenizenScript.
the class AdvancementHelperImpl method revoke.
@Override
public void revoke(com.denizenscript.denizen.nms.util.Advancement advancement, Player player) {
if (advancement.temporary) {
PacketHelperImpl.send(player, new ClientboundUpdateAdvancementsPacket(false, Collections.emptySet(), Collections.singleton(asResourceLocation(advancement.key)), Collections.emptyMap()));
} else {
Advancement nmsAdvancement = getAdvancementDataWorld().advancements.advancements.get(asResourceLocation(advancement.key));
((CraftPlayer) player).getHandle().getAdvancements().revoke(nmsAdvancement, IMPOSSIBLE_KEY);
}
}
use of net.minecraft.network.protocol.game.ClientboundUpdateAdvancementsPacket in project Denizen-For-Bukkit by DenizenScript.
the class AdvancementHelperImpl method register.
@Override
public void register(com.denizenscript.denizen.nms.util.Advancement advancement) {
if (advancement.temporary || advancement.registered) {
return;
}
Advancement nms = asNMSCopy(advancement);
if (advancement.parent == null) {
Set<Advancement> roots = ReflectionHelper.getFieldValue(AdvancementList.class, ReflectionMappingsInfo.AdvancementList_roots, getAdvancementDataWorld().advancements);
roots.add(nms);
AdvancementList.Listener something = ReflectionHelper.getFieldValue(AdvancementList.class, FIELD_ADVANCEMENTLIST_LISTENER.getName(), getAdvancementDataWorld().advancements);
if (something != null) {
something.onAddAdvancementRoot(nms);
}
} else {
Set<Advancement> branches = ReflectionHelper.getFieldValue(AdvancementList.class, ReflectionMappingsInfo.AdvancementList_tasks, getAdvancementDataWorld().advancements);
branches.add(nms);
AdvancementList.Listener something = ReflectionHelper.getFieldValue(AdvancementList.class, FIELD_ADVANCEMENTLIST_LISTENER.getName(), getAdvancementDataWorld().advancements);
if (something != null) {
something.onAddAdvancementTask(nms);
}
}
getAdvancementDataWorld().advancements.advancements.put(nms.getId(), nms);
advancement.registered = true;
if (!advancement.hidden && advancement.parent != null) {
((CraftServer) Bukkit.getServer()).getHandle().broadcastAll(new ClientboundUpdateAdvancementsPacket(false, Collections.singleton(nms), Collections.emptySet(), Collections.emptyMap()), (net.minecraft.world.entity.player.Player) null);
}
}
Aggregations