Skip to content

Commit

Permalink
Initial update to 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Dec 8, 2022
1 parent 2681e05 commit 139158c
Show file tree
Hide file tree
Showing 154 changed files with 1,006 additions and 995 deletions.
2 changes: 1 addition & 1 deletion dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>citizens-v1_19_R1</artifactId>
<artifactId>citizens-v1_19_R2</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public void cancelNavigation() {
stopNavigating(CancelReason.PLUGIN);
}

@Override
public void cancelNavigation(CancelReason reason) {
stopNavigating(reason);
}

@Override
public NavigatorParameters getDefaultParameters() {
return defaultParams;
Expand Down
39 changes: 11 additions & 28 deletions main/src/main/java/net/citizensnpcs/npc/skin/SkinPacketTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,15 @@ public void run() {
}

private void scheduleRemovePacket(final PlayerEntry entry) {
if (isRemoved || !CitizensAPI.hasImplementation() || !CitizensAPI.getPlugin().isEnabled())
if (isRemoved || !CitizensAPI.hasImplementation() || !CitizensAPI.getPlugin().isEnabled()
|| !shouldRemoveFromTabList())
return;

entry.removeTask = Bukkit.getScheduler().runTaskLater(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
if (shouldRemoveFromTabList()) {
TAB_LIST_REMOVER.sendPacket(entry.player, entity);
}
}
}, PACKET_DELAY_REMOVE);
entry.removeTask = Bukkit.getScheduler().runTaskLater(CitizensAPI.getPlugin(),
() -> TAB_LIST_REMOVER.sendPacket(entry.player, entity), PACKET_DELAY_REMOVE);
}

private void scheduleRemovePacket(PlayerEntry entry, int count) {
if (!shouldRemoveFromTabList())
return;

entry.removeCount = count;
scheduleRemovePacket(entry);
}
Expand All @@ -171,22 +163,13 @@ private boolean shouldRemoveFromTabList() {
* The radius.
*/
public void updateNearbyViewers(double radius) {
org.bukkit.World world = entity.getBukkitEntity().getWorld();
Player from = entity.getBukkitEntity();
Location location = from.getLocation();

for (Player player : world.getPlayers()) {
if (player == null || player.hasMetadata("NPC"))
continue;

if (!location.getWorld().equals(player.getLocation(CACHE_LOCATION).getWorld()) || !player.canSee(from))
continue;

if (location.distance(CACHE_LOCATION) > radius)
continue;

CitizensAPI.getLocationLookup().getNearbyPlayers(from.getLocation(CACHE_LOCATION), radius).forEach(player -> {
if (!player.canSee(from) || player.hasMetadata("NPC"))
return;
updateViewer(player);
}
});
}

/**
Expand All @@ -212,9 +195,9 @@ public void updateViewer(final Player player) {

inProgress.put(player.getUniqueId(), entry);
skin.apply(entity);
NMS.sendTabListAdd(player, entity.getBukkitEntity());

scheduleRemovePacket(entry, 2);
if (NMS.sendTabListAdd(player, entity.getBukkitEntity())) {
scheduleRemovePacket(entry, 2);
}
}

private class PlayerEntry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void sendPacket(Player player, SkinnableEntity entity) {

private class PlayerEntry {
Player player;
Set<SkinnableEntity> toRemove = new HashSet<SkinnableEntity>(30);
Set<SkinnableEntity> toRemove = new HashSet<SkinnableEntity>(20);

PlayerEntry(Player player) {
this.player = player;
Expand Down
4 changes: 2 additions & 2 deletions main/src/main/java/net/citizensnpcs/util/NMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ public static void sendRotationNearby(Entity entity, float bodyYaw, float headYa
BRIDGE.sendRotationNearby(entity, bodyYaw, headYaw, pitch);
}

public static void sendTabListAdd(Player recipient, Player listPlayer) {
BRIDGE.sendTabListAdd(recipient, listPlayer);
public static boolean sendTabListAdd(Player recipient, Player listPlayer) {
return BRIDGE.sendTabListAdd(recipient, listPlayer);
}

public static void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
Expand Down
2 changes: 1 addition & 1 deletion main/src/main/java/net/citizensnpcs/util/NMSBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public interface NMSBridge {

public void sendRotationNearby(Entity from, float bodyYaw, float headYaw, float pitch);

public void sendTabListAdd(Player recipient, Player listPlayer);
public boolean sendTabListAdd(Player recipient, Player listPlayer);

public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs);

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<module>v1_16_R3</module>
<module>v1_17_R1</module>
<module>v1_18_R2</module>
<module>v1_19_R1</module>
<module>v1_19_R2</module>
<module>dist</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -983,14 +983,15 @@ public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, flo
}

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
public boolean sendTabListAdd(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);

EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();

NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entity));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,14 +1040,15 @@ public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, flo
}

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
public boolean sendTabListAdd(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);

EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();

NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entity));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,14 +1050,15 @@ public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, flo
}

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
public boolean sendTabListAdd(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);

EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();

NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entity));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1086,14 +1086,15 @@ public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, flo
}

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
public boolean sendTabListAdd(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);

EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();

NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entity));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,14 +1141,15 @@ public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, flo
}

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
public boolean sendTabListAdd(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);

EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();

NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entity));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,14 +1153,15 @@ public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, flo
}

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
public boolean sendTabListAdd(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);

EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();

NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entity));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1183,14 +1183,15 @@ public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, flo
}

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
public boolean sendTabListAdd(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);

EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();

NMSImpl.sendPacket(recipient,
new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entity));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1174,14 +1174,15 @@ public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, flo
}

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
public boolean sendTabListAdd(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);

ServerPlayer entity = ((CraftPlayer) listPlayer).getHandle();

NMSImpl.sendPacket(recipient,
new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, entity));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1181,14 +1181,15 @@ public void sendRotationNearby(org.bukkit.entity.Entity from, float bodyYaw, flo
}

@Override
public void sendTabListAdd(Player recipient, Player listPlayer) {
public boolean sendTabListAdd(Player recipient, Player listPlayer) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(listPlayer);

ServerPlayer entity = ((CraftPlayer) listPlayer).getHandle();

NMSImpl.sendPacket(recipient,
new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, entity));
return true;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions v1_19_R1/pom.xml → v1_19_R2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<artifactId>citizens-parent</artifactId>
<version>2.0.30-SNAPSHOT</version>
</parent>
<artifactId>citizens-v1_19_R1</artifactId>
<artifactId>citizens-v1_19_R2</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.19.2-R0.1-SNAPSHOT</craftbukkit.version>
<craftbukkit.version>1.19.3-R0.1-SNAPSHOT</craftbukkit.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.citizensnpcs.nms.v1_19_R1.entity;
package net.citizensnpcs.nms.v1_19_R2.entity;

import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftAllay;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftAllay;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity;
import org.bukkit.util.Vector;

import com.google.common.collect.Lists;
Expand All @@ -13,8 +13,8 @@
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_19_R1.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_19_R1.util.NMSImpl;
import net.citizensnpcs.nms.v1_19_R2.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_19_R2.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package net.citizensnpcs.nms.v1_19_R1.entity;
package net.citizensnpcs.nms.v1_19_R2.entity;

import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftAxolotl;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftAxolotl;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity;
import org.bukkit.util.Vector;

import com.mojang.serialization.Dynamic;

import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_19_R1.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_19_R1.util.NMSImpl;
import net.citizensnpcs.nms.v1_19_R2.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_19_R2.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package net.citizensnpcs.nms.v1_19_R1.entity;
package net.citizensnpcs.nms.v1_19_R2.entity;

import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftBat;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftBat;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity;
import org.bukkit.util.Vector;

import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_19_R1.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_19_R1.util.NMSImpl;
import net.citizensnpcs.nms.v1_19_R2.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_19_R2.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package net.citizensnpcs.nms.v1_19_R1.entity;
package net.citizensnpcs.nms.v1_19_R2.entity;

import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftBee;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftBee;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftEntity;
import org.bukkit.util.Vector;

import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.nms.v1_19_R1.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_19_R1.util.NMSImpl;
import net.citizensnpcs.nms.v1_19_R2.util.ForwardingNPCHolder;
import net.citizensnpcs.nms.v1_19_R2.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
Expand Down
Loading

0 comments on commit 139158c

Please sign in to comment.