From c6e7ce65f5001b6eacccb7b09252d028e6df8532 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sun, 18 Dec 2022 13:25:08 +0800 Subject: [PATCH] Add /npc camel, minor code cleanup --- main/pom.xml | 2 +- .../trait/versioned/CamelTrait.java | 75 +++++++++++++++++++ .../java/net/citizensnpcs/util/Messages.java | 1 + .../main/java/net/citizensnpcs/util/NMS.java | 5 ++ .../java/net/citizensnpcs/util/NMSBridge.java | 35 +++++++-- .../src/main/resources/messages_en.properties | 1 + .../nms/v1_10_R1/util/NMSImpl.java | 23 +----- .../nms/v1_11_R1/util/NMSImpl.java | 23 +----- .../nms/v1_12_R1/util/NMSImpl.java | 23 +----- .../nms/v1_13_R2/util/NMSImpl.java | 23 +----- .../nms/v1_14_R1/util/NMSImpl.java | 19 +---- .../nms/v1_15_R1/util/NMSImpl.java | 15 +--- .../nms/v1_16_R3/util/NMSImpl.java | 11 +-- .../nms/v1_17_R1/util/NMSImpl.java | 11 +-- .../nms/v1_18_R2/util/NMSImpl.java | 11 +-- .../nms/v1_19_R2/util/NMSImpl.java | 32 +++++++- .../nms/v1_8_R3/util/NMSImpl.java | 38 +--------- 17 files changed, 158 insertions(+), 190 deletions(-) create mode 100644 main/src/main/java/net/citizensnpcs/trait/versioned/CamelTrait.java diff --git a/main/pom.xml b/main/pom.xml index 04aa23ab7..758445edb 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -9,7 +9,7 @@ citizens-main UTF-8 - 1.19.2-R0.1-SNAPSHOT + 1.19.3-R0.1-SNAPSHOT 2.11.2 ${project.version} 7.0.4 diff --git a/main/src/main/java/net/citizensnpcs/trait/versioned/CamelTrait.java b/main/src/main/java/net/citizensnpcs/trait/versioned/CamelTrait.java new file mode 100644 index 000000000..5b4edca1b --- /dev/null +++ b/main/src/main/java/net/citizensnpcs/trait/versioned/CamelTrait.java @@ -0,0 +1,75 @@ +package net.citizensnpcs.trait.versioned; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Camel; + +import net.citizensnpcs.api.command.Command; +import net.citizensnpcs.api.command.CommandContext; +import net.citizensnpcs.api.command.CommandMessages; +import net.citizensnpcs.api.command.Flag; +import net.citizensnpcs.api.command.Requirements; +import net.citizensnpcs.api.command.exception.CommandException; +import net.citizensnpcs.api.npc.NPC; +import net.citizensnpcs.api.persistence.Persist; +import net.citizensnpcs.api.trait.Trait; +import net.citizensnpcs.api.trait.TraitName; +import net.citizensnpcs.api.trait.trait.MobType; +import net.citizensnpcs.api.util.Messaging; +import net.citizensnpcs.util.Messages; +import net.citizensnpcs.util.NMS; + +@TraitName("cameltrait") +public class CamelTrait extends Trait { + @Persist + private CamelPose pose; + + public CamelTrait() { + super("cameltrait"); + } + + @Override + public void run() { + if (npc.isSpawned() && npc.getEntity() instanceof Camel) { + Camel camel = (Camel) npc.getEntity(); + if (pose != null) { + NMS.setCamelPose(npc.getEntity(), pose); + } + } + } + + public void setPose(CamelPose pose) { + this.pose = pose; + } + + public enum CamelPose { + PANIC, + SITTING, + STANDING + } + + @Command( + aliases = { "npc" }, + usage = "camel (--pose pose) (--strength strength)", + desc = "Sets camel modifiers", + modifiers = { "camel" }, + min = 1, + max = 1, + permission = "citizens.npc.camel") + @Requirements(selected = true, ownership = true) + public static void camel(CommandContext args, CommandSender sender, NPC npc, @Flag("pose") CamelPose pose) + throws CommandException { + if (npc.getOrAddTrait(MobType.class).getType().name().equals("CAMEL")) + throw new CommandException(CommandMessages.REQUIREMENTS_INVALID_MOB_TYPE); + CamelTrait trait = npc.getOrAddTrait(CamelTrait.class); + String output = ""; + + if (pose != null) { + trait.setPose(pose); + output += Messaging.tr(Messages.CAMEL_POSE_SET, pose); + } + + if (!output.isEmpty()) { + Messaging.send(sender, output); + } + } +} diff --git a/main/src/main/java/net/citizensnpcs/util/Messages.java b/main/src/main/java/net/citizensnpcs/util/Messages.java index c846a0ebc..c08687b4c 100644 --- a/main/src/main/java/net/citizensnpcs/util/Messages.java +++ b/main/src/main/java/net/citizensnpcs/util/Messages.java @@ -31,6 +31,7 @@ public class Messages { public static final String BEHAVIOUR_HELP = "citizens.commands.npc.behaviour.help"; public static final String BEHAVIOURS_ADDED = "citizens.commands.npc.behaviour.added"; public static final String BEHAVIOURS_REMOVED = "citizens.commands.npc.behaviour.removed"; + public static final String CAMEL_POSE_SET = "citizens.commands.npc.camel.pose-set"; public static final String CANNOT_TELEPORT_ACROSS_WORLDS = "citizens.commands.npc.tphere.multiworld-not-allowed"; public static final String CAT_COLLAR_COLOR_SET = "citizens.commands.npc.cat.collar-color-set"; public static final String CAT_STARTED_LYING = "citizens.commands.npc.cat.lying-start"; diff --git a/main/src/main/java/net/citizensnpcs/util/NMS.java b/main/src/main/java/net/citizensnpcs/util/NMS.java index f6498b217..98ccf6739 100644 --- a/main/src/main/java/net/citizensnpcs/util/NMS.java +++ b/main/src/main/java/net/citizensnpcs/util/NMS.java @@ -43,6 +43,7 @@ import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.versioned.CamelTrait.CamelPose; public class NMS { private NMS() { @@ -532,6 +533,10 @@ public class NMS { BRIDGE.setBodyYaw(entity, yaw); } + public static void setCamelPose(Entity entity, CamelPose pose) { + BRIDGE.setCamelPose(entity, pose); + } + public static void setCustomName(Entity entity, Object component) { BRIDGE.setCustomName(entity, component); } diff --git a/main/src/main/java/net/citizensnpcs/util/NMSBridge.java b/main/src/main/java/net/citizensnpcs/util/NMSBridge.java index e7f2b2a63..8101c466f 100644 --- a/main/src/main/java/net/citizensnpcs/util/NMSBridge.java +++ b/main/src/main/java/net/citizensnpcs/util/NMSBridge.java @@ -37,6 +37,7 @@ import net.citizensnpcs.api.util.BoundingBox; import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator; import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator; import net.citizensnpcs.npc.skin.SkinnableEntity; +import net.citizensnpcs.trait.versioned.CamelTrait.CamelPose; public interface NMSBridge { public boolean addEntityToWorld(Entity entity, SpawnReason custom); @@ -51,7 +52,9 @@ public interface NMSBridge { public BlockBreaker getBlockBreaker(Entity entity, Block targetBlock, BlockBreakerConfiguration config); - public Object getBossBar(Entity entity); + public default Object getBossBar(Entity entity) { + throw new UnsupportedOperationException(); + } public BoundingBox getBoundingBox(Entity handle); @@ -145,10 +148,16 @@ public interface NMSBridge { public void sendTeamPacket(Player recipient, Team team, int mode); - public void setAllayDancing(Entity entity, boolean dancing); + public default void setAllayDancing(Entity entity, boolean dancing) { + throw new UnsupportedOperationException(); + }; public void setBodyYaw(Entity entity, float yaw); + public default void setCamelPose(Entity entity, CamelPose pose) { + throw new UnsupportedOperationException(); + } + public void setCustomName(Entity entity, Object component); public void setDestination(Entity entity, double x, double y, double z, float speed); @@ -159,21 +168,31 @@ public interface NMSBridge { public void setKnockbackResistance(LivingEntity entity, double d); - public void setLyingDown(Entity cat, boolean lying); + public default void setLyingDown(Entity cat, boolean lying) { + throw new UnsupportedOperationException(); + }; public void setNavigationTarget(Entity handle, Entity target, float speed); public void setNoGravity(Entity entity, boolean nogravity); - public void setPandaSitting(Entity entity, boolean sitting); + public default void setPandaSitting(Entity entity, boolean sitting) { + throw new UnsupportedOperationException(); + }; - public void setPeekShulker(Entity entity, int peek); + public default void setPeekShulker(Entity entity, int peek) { + throw new UnsupportedOperationException(); + }; - public void setPiglinDancing(Entity entity, boolean dancing); + public default void setPiglinDancing(Entity entity, boolean dancing) { + throw new UnsupportedOperationException(); + }; public void setPitch(Entity entity, float pitch); - public void setPolarBearRearing(Entity entity, boolean rearing); + public default void setPolarBearRearing(Entity entity, boolean rearing) { + throw new UnsupportedOperationException(); + }; public void setProfile(SkullMeta meta, GameProfile profile); @@ -209,5 +228,5 @@ public interface NMSBridge { public void updateNavigationWorld(Entity entity, World world); - public void updatePathfindingRange(NPC npc, float pathfindingRange); + public void updatePathfindingRange(NPC npc, float pathfindingRange);; } diff --git a/main/src/main/resources/messages_en.properties b/main/src/main/resources/messages_en.properties index c97c1929a..6d5bfeea3 100644 --- a/main/src/main/resources/messages_en.properties +++ b/main/src/main/resources/messages_en.properties @@ -48,6 +48,7 @@ citizens.commands.npc.cat.sitting-stop=[[{0}]] stopped sitting. citizens.commands.npc.cat.lying-start=[[{0}]] started lying down. citizens.commands.npc.cat.lying-stop=[[{0}]] stopped lying down. citizens.commands.npc.cat.type-set=Type set to [[{0}]]. +citizens.commands.npc.camel.pose-set=Pose set to [[{0}]]. citizens.commands.npc.chunkload.set=[[{0}]] will now force chunks to be loaded. citizens.commands.npc.chunkload.unset=[[{0}]] will no longer force chunks to be loaded. citizens.commands.npc.collidable.set=[[{0}]] will now collide with entities. diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java index 5412709c1..97893c766 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java @@ -1038,10 +1038,6 @@ public class NMSImpl implements NMSBridge { } } - @Override - public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) { getHandle(entity).yaw = yaw; @@ -1089,10 +1085,6 @@ public class NMSImpl implements NMSBridge { handle.getAttributeInstance(GenericAttributes.c).setValue(d); } - @Override - public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) { - } - @Override public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) { NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed); @@ -1103,19 +1095,11 @@ public class NMSImpl implements NMSBridge { getHandle(entity).setNoGravity(enabled); } - @Override - public void setPandaSitting(org.bukkit.entity.Entity entity, boolean sitting) { - } - @Override public void setPeekShulker(org.bukkit.entity.Entity shulker, int peek) { ((EntityShulker) getHandle(shulker)).a((byte) peek); } - @Override - public void setPiglinDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setPitch(org.bukkit.entity.Entity entity, float pitch) { getHandle(entity).pitch = pitch; @@ -1664,10 +1648,6 @@ public class NMSImpl implements NMSBridge { return ((CraftEntity) entity).getHandle(); } - public static float getHeadYaw(EntityLiving handle) { - return handle.aP; - } - public static NavigationAbstract getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof EntityInsentient ? ((EntityInsentient) handle).getNavigation() @@ -1746,7 +1726,8 @@ public class NMSImpl implements NMSBridge { radius *= radius; final org.bukkit.World world = location.getWorld(); for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) { - if (world != player.getWorld() || (from != null && !player.canSee(from)) || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { + if (world != player.getWorld() || (from != null && !player.canSee(from)) + || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { continue; } for (Packet packet : packets) { diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java index fc5e326ce..2f3699998 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java @@ -1095,10 +1095,6 @@ public class NMSImpl implements NMSBridge { } } - @Override - public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) { getHandle(entity).yaw = yaw; @@ -1147,10 +1143,6 @@ public class NMSImpl implements NMSBridge { handle.getAttributeInstance(GenericAttributes.c).setValue(d); } - @Override - public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) { - } - @Override public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) { NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed); @@ -1161,19 +1153,11 @@ public class NMSImpl implements NMSBridge { getHandle(entity).setNoGravity(enabled); } - @Override - public void setPandaSitting(org.bukkit.entity.Entity entity, boolean sitting) { - } - @Override public void setPeekShulker(org.bukkit.entity.Entity shulker, int peek) { ((EntityShulker) getHandle(shulker)).a((byte) peek); } - @Override - public void setPiglinDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setPitch(org.bukkit.entity.Entity entity, float pitch) { getHandle(entity).pitch = pitch; @@ -1728,10 +1712,6 @@ public class NMSImpl implements NMSBridge { return ((CraftEntity) entity).getHandle(); } - public static float getHeadYaw(EntityLiving handle) { - return handle.getHeadRotation(); - } - public static NavigationAbstract getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof EntityInsentient ? ((EntityInsentient) handle).getNavigation() @@ -1810,7 +1790,8 @@ public class NMSImpl implements NMSBridge { radius *= radius; final org.bukkit.World world = location.getWorld(); for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) { - if (world != player.getWorld() || (from != null && !player.canSee(from)) || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { + if (world != player.getWorld() || (from != null && !player.canSee(from)) + || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { continue; } for (Packet packet : packets) { diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java index b4b8bf64f..3d97f2963 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java @@ -1105,10 +1105,6 @@ public class NMSImpl implements NMSBridge { } } - @Override - public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) { getHandle(entity).yaw = yaw; @@ -1157,10 +1153,6 @@ public class NMSImpl implements NMSBridge { handle.getAttributeInstance(GenericAttributes.c).setValue(d); } - @Override - public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) { - } - @Override public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) { NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed); @@ -1171,19 +1163,11 @@ public class NMSImpl implements NMSBridge { getHandle(entity).setNoGravity(enabled); } - @Override - public void setPandaSitting(org.bukkit.entity.Entity entity, boolean sitting) { - } - @Override public void setPeekShulker(org.bukkit.entity.Entity shulker, int peek) { ((EntityShulker) getHandle(shulker)).a((byte) peek); } - @Override - public void setPiglinDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setPitch(org.bukkit.entity.Entity entity, float pitch) { getHandle(entity).pitch = pitch; @@ -1738,10 +1722,6 @@ public class NMSImpl implements NMSBridge { return ((CraftEntity) entity).getHandle(); } - public static float getHeadYaw(EntityLiving handle) { - return handle.getHeadRotation(); - } - public static NavigationAbstract getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof EntityInsentient ? ((EntityInsentient) handle).getNavigation() @@ -1820,7 +1800,8 @@ public class NMSImpl implements NMSBridge { radius *= radius; final org.bukkit.World world = location.getWorld(); for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) { - if (world != player.getWorld() || (from != null && !player.canSee(from)) || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { + if (world != player.getWorld() || (from != null && !player.canSee(from)) + || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { continue; } for (Packet packet : packets) { diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java index 467afb573..d5909023d 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java @@ -1141,10 +1141,6 @@ public class NMSImpl implements NMSBridge { } } - @Override - public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) { getHandle(entity).yaw = yaw; @@ -1193,10 +1189,6 @@ public class NMSImpl implements NMSBridge { handle.getAttributeInstance(GenericAttributes.c).setValue(d); } - @Override - public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) { - } - @Override public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) { NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed); @@ -1207,19 +1199,11 @@ public class NMSImpl implements NMSBridge { getHandle(entity).setNoGravity(enabled); } - @Override - public void setPandaSitting(org.bukkit.entity.Entity entity, boolean sitting) { - } - @Override public void setPeekShulker(org.bukkit.entity.Entity shulker, int peek) { ((EntityShulker) getHandle(shulker)).a((byte) peek); } - @Override - public void setPiglinDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setPitch(org.bukkit.entity.Entity entity, float pitch) { getHandle(entity).pitch = pitch; @@ -1829,10 +1813,6 @@ public class NMSImpl implements NMSBridge { return ((CraftEntity) entity).getHandle(); } - public static float getHeadYaw(EntityLiving handle) { - return handle.getHeadRotation(); - } - public static NavigationAbstract getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof EntityInsentient ? ((EntityInsentient) handle).getNavigation() @@ -1937,7 +1917,8 @@ public class NMSImpl implements NMSBridge { radius *= radius; final org.bukkit.World world = location.getWorld(); for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) { - if (world != player.getWorld() || (from != null && !player.canSee(from)) || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { + if (world != player.getWorld() || (from != null && !player.canSee(from)) + || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { continue; } for (Packet packet : packets) { diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java index 1aae92bda..c6989bebb 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java @@ -1196,10 +1196,6 @@ public class NMSImpl implements NMSBridge { } } - @Override - public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) { getHandle(entity).yaw = yaw; @@ -1263,19 +1259,11 @@ public class NMSImpl implements NMSBridge { getHandle(entity).setNoGravity(enabled); } - @Override - public void setPandaSitting(org.bukkit.entity.Entity entity, boolean sitting) { - } - @Override public void setPeekShulker(org.bukkit.entity.Entity shulker, int peek) { ((EntityShulker) getHandle(shulker)).a((byte) peek); } - @Override - public void setPiglinDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setPitch(org.bukkit.entity.Entity entity, float pitch) { getHandle(entity).pitch = pitch; @@ -1976,10 +1964,6 @@ public class NMSImpl implements NMSBridge { return ((CraftEntity) entity).getHandle(); } - public static float getHeadYaw(EntityLiving handle) { - return handle.getHeadRotation(); - } - public static NavigationAbstract getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof EntityInsentient ? ((EntityInsentient) handle).getNavigation() @@ -2075,7 +2059,8 @@ public class NMSImpl implements NMSBridge { radius *= radius; final org.bukkit.World world = location.getWorld(); for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) { - if (world != player.getWorld() || (from != null && !player.canSee(from)) || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { + if (world != player.getWorld() || (from != null && !player.canSee(from)) + || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { continue; } for (Packet packet : packets) { diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java index 442d268d2..02a913bee 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java @@ -1208,10 +1208,6 @@ public class NMSImpl implements NMSBridge { } } - @Override - public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) { getHandle(entity).yaw = yaw; @@ -1305,10 +1301,6 @@ public class NMSImpl implements NMSBridge { ((EntityShulker) getHandle(shulker)).a((byte) peek); } - @Override - public void setPiglinDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setPitch(org.bukkit.entity.Entity entity, float pitch) { getHandle(entity).pitch = pitch; @@ -2010,10 +2002,6 @@ public class NMSImpl implements NMSBridge { return (EntityLiving) NMSImpl.getHandle((org.bukkit.entity.Entity) entity); } - public static float getHeadYaw(EntityLiving handle) { - return handle.getHeadRotation(); - } - public static NavigationAbstract getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof EntityInsentient ? ((EntityInsentient) handle).getNavigation() @@ -2130,7 +2118,8 @@ public class NMSImpl implements NMSBridge { radius *= radius; final org.bukkit.World world = location.getWorld(); for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) { - if (world != player.getWorld() || (from != null && !player.canSee(from)) || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { + if (world != player.getWorld() || (from != null && !player.canSee(from)) + || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { continue; } for (Packet packet : packets) { diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java index a8ec7086a..d286d27b6 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java @@ -1238,10 +1238,6 @@ public class NMSImpl implements NMSBridge { } } - @Override - public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) { getHandle(entity).yaw = yaw; @@ -1972,10 +1968,6 @@ public class NMSImpl implements NMSBridge { return (EntityLiving) NMSImpl.getHandle((org.bukkit.entity.Entity) entity); } - public static float getHeadYaw(EntityLiving handle) { - return handle.getHeadRotation(); - } - public static NavigationAbstract getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof EntityInsentient ? ((EntityInsentient) handle).getNavigation() @@ -2102,7 +2094,8 @@ public class NMSImpl implements NMSBridge { radius *= radius; final org.bukkit.World world = location.getWorld(); for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) { - if (world != player.getWorld() || (from != null && !player.canSee(from)) || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { + if (world != player.getWorld() || (from != null && !player.canSee(from)) + || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { continue; } for (Packet packet : packets) { diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java index 32c624133..a422bdd28 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java @@ -1234,10 +1234,6 @@ public class NMSImpl implements NMSBridge { } } - @Override - public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) { getHandle(entity).setYRot(yaw); @@ -1969,10 +1965,6 @@ public class NMSImpl implements NMSBridge { return (LivingEntity) NMSImpl.getHandle((org.bukkit.entity.Entity) entity); } - public static float getHeadYaw(LivingEntity handle) { - return handle.getYHeadRot(); - } - public static PathNavigation getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof Mob ? ((Mob) handle).getNavigation() @@ -2096,7 +2088,8 @@ public class NMSImpl implements NMSBridge { radius *= radius; final org.bukkit.World world = location.getWorld(); for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) { - if (world != player.getWorld() || (from != null && !player.canSee(from)) || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { + if (world != player.getWorld() || (from != null && !player.canSee(from)) + || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { continue; } for (Packet packet : packets) { diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java index d624574d6..0639c72e0 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/NMSImpl.java @@ -1241,10 +1241,6 @@ public class NMSImpl implements NMSBridge { } } - @Override - public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) { getHandle(entity).setYRot(yaw); @@ -1976,10 +1972,6 @@ public class NMSImpl implements NMSBridge { return (LivingEntity) NMSImpl.getHandle((org.bukkit.entity.Entity) entity); } - public static float getHeadYaw(LivingEntity handle) { - return handle.getYHeadRot(); - } - public static PathNavigation getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof Mob ? ((Mob) handle).getNavigation() @@ -2103,7 +2095,8 @@ public class NMSImpl implements NMSBridge { radius *= radius; final org.bukkit.World world = location.getWorld(); for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) { - if (world != player.getWorld() || (from != null && !player.canSee(from)) || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { + if (world != player.getWorld() || (from != null && !player.canSee(from)) + || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { continue; } for (Packet packet : packets) { diff --git a/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/NMSImpl.java b/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/NMSImpl.java index 92c179608..551a90df8 100644 --- a/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/NMSImpl.java +++ b/v1_19_R2/src/main/java/net/citizensnpcs/nms/v1_19_R2/util/NMSImpl.java @@ -222,6 +222,8 @@ import net.citizensnpcs.trait.versioned.AllayTrait; import net.citizensnpcs.trait.versioned.AxolotlTrait; import net.citizensnpcs.trait.versioned.BeeTrait; import net.citizensnpcs.trait.versioned.BossBarTrait; +import net.citizensnpcs.trait.versioned.CamelTrait; +import net.citizensnpcs.trait.versioned.CamelTrait.CamelPose; import net.citizensnpcs.trait.versioned.CatTrait; import net.citizensnpcs.trait.versioned.FoxTrait; import net.citizensnpcs.trait.versioned.FrogTrait; @@ -304,6 +306,7 @@ import net.minecraft.world.entity.animal.Rabbit; import net.minecraft.world.entity.animal.Turtle; import net.minecraft.world.entity.animal.allay.Allay; import net.minecraft.world.entity.animal.axolotl.Axolotl; +import net.minecraft.world.entity.animal.camel.Camel; import net.minecraft.world.entity.animal.horse.AbstractHorse; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; import net.minecraft.world.entity.boss.wither.WitherBoss; @@ -824,6 +827,7 @@ public class NMSImpl implements NMSBridge { registerTraitWithCommand(manager, AxolotlTrait.class); registerTraitWithCommand(manager, BeeTrait.class); registerTraitWithCommand(manager, BossBarTrait.class); + registerTraitWithCommand(manager, CamelTrait.class); registerTraitWithCommand(manager, CatTrait.class); registerTraitWithCommand(manager, FoxTrait.class); registerTraitWithCommand(manager, FrogTrait.class); @@ -1292,6 +1296,30 @@ public class NMSImpl implements NMSBridge { getHandle(entity).setYRot(yaw); } + @Override + public void setCamelPose(org.bukkit.entity.Entity entity, CamelPose pose) { + if (entity.getType() != EntityType.CAMEL) + throw new IllegalStateException(); + Camel camel = (Camel) getHandle(entity); + switch (pose) { + case STANDING: + if (!camel.isStanding()) { + camel.standUp(); + } + return; + case SITTING: + if (!camel.isPoseSitting()) { + camel.sitDown(); + } + return; + case PANIC: + if (!camel.isPanicking()) { + camel.standUpPanic(); + } + return; + } + } + @Override public void setCustomName(org.bukkit.entity.Entity entity, Object component) { getHandle(entity).setCustomName((Component) component); @@ -2018,10 +2046,6 @@ public class NMSImpl implements NMSBridge { return (LivingEntity) NMSImpl.getHandle((org.bukkit.entity.Entity) entity); } - public static float getHeadYaw(LivingEntity handle) { - return handle.getYHeadRot(); - } - public static PathNavigation getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof Mob ? ((Mob) handle).getNavigation() diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java index f80614e00..52ee46a5a 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java @@ -340,11 +340,6 @@ public class NMSImpl implements NMSBridge { return new CitizensBlockBreaker(entity, targetBlock, config); } - @Override - public Object getBossBar(org.bukkit.entity.Entity entity) { - return null; - } - @Override public BoundingBox getBoundingBox(org.bukkit.entity.Entity handle) { AxisAlignedBB bb = NMSImpl.getHandle(handle).getBoundingBox(); @@ -979,10 +974,6 @@ public class NMSImpl implements NMSBridge { } } - @Override - public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) { getHandle(entity).yaw = yaw; @@ -1028,10 +1019,6 @@ public class NMSImpl implements NMSBridge { handle.getAttributeInstance(GenericAttributes.c).setValue(d); } - @Override - public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) { - } - @Override public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) { NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed); @@ -1046,29 +1033,11 @@ public class NMSImpl implements NMSBridge { entity.setVelocity(vector); } - @Override - public void setPandaSitting(org.bukkit.entity.Entity entity, boolean sitting) { - } - - @Override - public void setPeekShulker(org.bukkit.entity.Entity shulker, int peek) { - throw new UnsupportedOperationException(); - } - - @Override - public void setPiglinDancing(org.bukkit.entity.Entity entity, boolean dancing) { - } - @Override public void setPitch(org.bukkit.entity.Entity entity, float pitch) { getHandle(entity).pitch = pitch; } - @Override - public void setPolarBearRearing(org.bukkit.entity.Entity entity, boolean rearing) { - throw new UnsupportedOperationException(); - } - @Override public void setProfile(SkullMeta meta, GameProfile profile) { if (SKULL_PROFILE_FIELD == null) { @@ -1558,10 +1527,6 @@ public class NMSImpl implements NMSBridge { return ((CraftEntity) entity).getHandle(); } - public static float getHeadYaw(EntityLiving handle) { - return handle.aJ; - } - public static NavigationAbstract getNavigation(org.bukkit.entity.Entity entity) { Entity handle = getHandle(entity); return handle instanceof EntityInsentient ? ((EntityInsentient) handle).getNavigation() @@ -1626,7 +1591,8 @@ public class NMSImpl implements NMSBridge { radius *= radius; final org.bukkit.World world = location.getWorld(); for (Player player : CitizensAPI.getLocationLookup().getNearbyPlayers(location, radius)) { - if (world != player.getWorld() || (from != null && !player.canSee(from)) || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { + if (world != player.getWorld() || (from != null && !player.canSee(from)) + || (location.distanceSquared(player.getLocation(PACKET_CACHE_LOCATION)) > radius)) { continue; } for (Packet packet : packets) {