Add flag to control the arm swing when updating npc (#106)

* fancynpcs: Add overloaded update and updateForAll methods to skip swing animation.

* fancynpcs: remove unnecessary changes to other calls of update(player).

* Revert version change

* fancynpcs: pull default update(Player) method out to NPC class, and make non-abstract.

* fancynpcs: make swinging arm default update behavior.
This commit is contained in:
Phoenic
2025-09-17 13:47:48 -05:00
committed by GitHub
parent d8f1a4ecae
commit 061d2fa42d
11 changed files with 32 additions and 25 deletions

View File

@@ -118,12 +118,20 @@ public abstract class Npc {
public abstract void lookAt(Player player, Location location);
public abstract void update(Player player);
public abstract void update(Player player, boolean swingArm);
public void update(Player player) {
update(player, true);
}
public void updateForAll(boolean swingArm) {
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
update(onlinePlayer, swingArm);
}
}
public void updateForAll() {
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
update(onlinePlayer);
}
updateForAll(true);
}
public abstract void move(Player player, boolean swingArm);

View File

@@ -190,7 +190,7 @@ public class Npc_1_19_4 extends Npc {
}
@Override
public void update(Player player) {
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
@@ -271,7 +271,7 @@ public class Npc_1_19_4 extends Npc {
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, true);
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");

View File

@@ -191,7 +191,7 @@ public class Npc_1_20_1 extends Npc {
}
@Override
public void update(Player player) {
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
@@ -271,7 +271,7 @@ public class Npc_1_20_1 extends Npc {
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, true);
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");

View File

@@ -188,7 +188,7 @@ public class Npc_1_20_2 extends Npc {
}
@Override
public void update(Player player) {
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
@@ -266,7 +266,7 @@ public class Npc_1_20_2 extends Npc {
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, true);
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");

View File

@@ -187,7 +187,7 @@ public class Npc_1_20_4 extends Npc {
}
@Override
public void update(Player player) {
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
@@ -265,7 +265,7 @@ public class Npc_1_20_4 extends Npc {
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, true);
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");

View File

@@ -187,7 +187,7 @@ public class Npc_1_20_6 extends Npc {
}
@Override
public void update(Player player) {
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
@@ -265,7 +265,7 @@ public class Npc_1_20_6 extends Npc {
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, true);
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");

View File

@@ -199,7 +199,7 @@ public class Npc_1_21_1 extends Npc {
}
@Override
public void update(Player player) {
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
@@ -277,7 +277,7 @@ public class Npc_1_21_1 extends Npc {
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, true);
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");

View File

@@ -210,7 +210,7 @@ public class Npc_1_21_3 extends Npc {
}
@Override
public void update(Player player) {
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
@@ -288,7 +288,7 @@ public class Npc_1_21_3 extends Npc {
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, true);
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");

View File

@@ -210,7 +210,7 @@ public class Npc_1_21_4 extends Npc {
}
@Override
public void update(Player player) {
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
@@ -288,7 +288,7 @@ public class Npc_1_21_4 extends Npc {
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, true);
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");

View File

@@ -208,9 +208,8 @@ public class Npc_1_21_5 extends Npc {
ClientboundRotateHeadPacket rotateHeadPacket = new ClientboundRotateHeadPacket(npc, (byte) (location.getYaw() * angelMultiplier));
serverPlayer.connection.send(rotateHeadPacket);
}
@Override
public void update(Player player) {
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
@@ -288,7 +287,7 @@ public class Npc_1_21_5 extends Npc {
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, true);
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");

View File

@@ -210,7 +210,7 @@ public class Npc_1_21_6 extends Npc {
}
@Override
public void update(Player player) {
public void update(Player player, boolean swingArm) {
if (npc == null) {
return;
}
@@ -298,7 +298,7 @@ public class Npc_1_21_6 extends Npc {
refreshEntityData(player);
if (data.isSpawnEntity() && data.getLocation() != null) {
move(player, true);
move(player, swingArm);
}
NpcAttribute playerPoseAttr = FancyNpcsPlugin.get().getAttributeManager().getAttributeByName(org.bukkit.entity.EntityType.PLAYER, "pose");