use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer in project Denizen-For-Bukkit by DenizenScript.
the class DenizenNetworkManagerImpl method setNetworkManager.
public static void setNetworkManager(Player player) {
ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
ServerGamePacketListenerImpl playerConnection = entityPlayer.connection;
setNetworkManager(playerConnection, new DenizenNetworkManagerImpl(entityPlayer, playerConnection.connection));
}
use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer in project Denizen-For-Bukkit by DenizenScript.
the class PlayerHelperImpl method deTrackEntity.
@Override
public void deTrackEntity(Player player, Entity entity) {
ServerPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
ServerLevel world = (ServerLevel) nmsPlayer.level;
ChunkMap.TrackedEntity tracker = world.getChunkProvider().chunkMap.G.get(entity.getEntityId());
if (tracker == null) {
return;
}
sendEntityDestroy(player, entity);
tracker.removePlayer(nmsPlayer);
}
use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer in project Denizen-For-Bukkit by DenizenScript.
the class Handler method getPlayerProfile.
@Override
public PlayerProfile getPlayerProfile(Player player) {
GameProfile gameProfile = ((CraftPlayer) player).getProfile();
Property property = Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
return new PlayerProfile(gameProfile.getName(), gameProfile.getId(), property != null ? property.getValue() : null, property != null ? property.getSignature() : null);
}
use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer in project Denizen-For-Bukkit by DenizenScript.
the class AdvancementHelperImpl method grant.
@Override
public void grant(com.denizenscript.denizen.nms.util.Advancement advancement, Player player) {
if (advancement.length > 1) {
grantPartial(advancement, player, advancement.length);
return;
}
if (advancement.temporary) {
Advancement nmsAdvancement = asNMSCopy(advancement);
AdvancementProgress progress = new AdvancementProgress();
progress.update(IMPOSSIBLE_CRITERIA, IMPOSSIBLE_REQUIREMENTS);
// complete impossible criteria
progress.grantProgress(IMPOSSIBLE_KEY);
PacketHelperImpl.send(player, new ClientboundUpdateAdvancementsPacket(false, Collections.singleton(nmsAdvancement), Collections.emptySet(), Collections.singletonMap(nmsAdvancement.getId(), progress)));
} else {
Advancement nmsAdvancement = getAdvancementDataWorld().advancements.advancements.get(asResourceLocation(advancement.key));
((CraftPlayer) player).getHandle().getAdvancements().award(nmsAdvancement, IMPOSSIBLE_KEY);
}
}
use of org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer in project Denizen-For-Bukkit by DenizenScript.
the class AdvancementHelperImpl method grantPartial.
@Override
public void grantPartial(com.denizenscript.denizen.nms.util.Advancement advancement, Player player, int len) {
if (advancement.length <= 1) {
grant(advancement, player);
return;
}
if (advancement.temporary) {
Advancement nmsAdvancement = asNMSCopy(advancement);
AdvancementProgress progress = new AdvancementProgress();
Map<String, Criterion> criteria = new HashMap<>();
String[][] requirements = new String[advancement.length][];
for (int i = 0; i < advancement.length; i++) {
criteria.put(IMPOSSIBLE_KEY + i, new Criterion(new ImpossibleTrigger.TriggerInstance()));
requirements[i] = new String[] { IMPOSSIBLE_KEY + i };
}
progress.update(IMPOSSIBLE_CRITERIA, IMPOSSIBLE_REQUIREMENTS);
for (int i = 0; i < len; i++) {
// complete impossible criteria
progress.grantProgress(IMPOSSIBLE_KEY + i);
}
PacketHelperImpl.send(player, new ClientboundUpdateAdvancementsPacket(false, Collections.singleton(nmsAdvancement), Collections.emptySet(), Collections.singletonMap(nmsAdvancement.getId(), progress)));
} else {
Advancement nmsAdvancement = getAdvancementDataWorld().advancements.advancements.get(asResourceLocation(advancement.key));
for (int i = 0; i < len; i++) {
((CraftPlayer) player).getHandle().getAdvancements().award(nmsAdvancement, IMPOSSIBLE_KEY + i);
}
}
}
Aggregations