Add /npc aggressive
This commit is contained in:
parent
367cbd330f
commit
72c136e97a
|
@ -224,6 +224,20 @@ public class NPCCommands {
|
|||
trait.setAge(age);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "aggressive [true|false]",
|
||||
desc = "Sets the aggressive status of the entity",
|
||||
modifiers = { "aggressive" },
|
||||
min = 1,
|
||||
max = 2,
|
||||
permission = "citizens.npc.aggressive")
|
||||
public void aggressive(CommandContext args, CommandSender sender, NPC npc, @Arg(1) Boolean aggressive) {
|
||||
boolean aggro = aggressive != null ? aggressive : !npc.data().get(NPC.Metadata.AGGRESSIVE, false);
|
||||
npc.data().set(NPC.Metadata.AGGRESSIVE, aggro);
|
||||
NMS.setAggressive(npc.getEntity(), aggro);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "ai (true|false)",
|
||||
|
|
|
@ -387,6 +387,8 @@ public class CitizensNPC extends AbstractNPC {
|
|||
if (type == EntityType.PLAYER) {
|
||||
NMS.replaceTrackerEntry((Player) getEntity());
|
||||
PlayerUpdateTask.registerPlayer(getEntity());
|
||||
} else if (data().has(NPC.Metadata.AGGRESSIVE)) {
|
||||
NMS.setAggressive(entity, data().<Boolean> get(NPC.Metadata.AGGRESSIVE));
|
||||
}
|
||||
|
||||
if (SUPPORT_NODAMAGE_TICKS && (Setting.DEFAULT_SPAWN_NODAMAGE_TICKS.asInt() != 20
|
||||
|
|
|
@ -554,6 +554,10 @@ public class NMS {
|
|||
BRIDGE.sendTeamPacket(recipient, team, mode);
|
||||
}
|
||||
|
||||
public static void setAggressive(Entity entity, boolean aggro) {
|
||||
BRIDGE.setAggressive(entity, aggro);
|
||||
}
|
||||
|
||||
public static void setAllayDancing(Entity entity, boolean dancing) {
|
||||
BRIDGE.setAllayDancing(entity, dancing);
|
||||
}
|
||||
|
@ -709,6 +713,7 @@ public class NMS {
|
|||
private static Object UNSAFE;
|
||||
private static MethodHandle UNSAFE_FIELD_OFFSET;
|
||||
private static MethodHandle UNSAFE_PUT_OBJECT;
|
||||
|
||||
private static MethodHandle UNSAFE_STATIC_FIELD_OFFSET;
|
||||
|
||||
static {
|
||||
|
|
|
@ -165,13 +165,16 @@ public interface NMSBridge {
|
|||
|
||||
public void sendTeamPacket(Player recipient, Team team, int mode);
|
||||
|
||||
default public void setAggressive(Entity entity, boolean aggro) {
|
||||
}
|
||||
|
||||
public default void setAllayDancing(Entity entity, boolean dancing) {
|
||||
throw new UnsupportedOperationException();
|
||||
};
|
||||
}
|
||||
|
||||
public void setBodyYaw(Entity entity, float yaw);
|
||||
|
||||
public void setBoundingBox(Entity entity, BoundingBox box);
|
||||
public void setBoundingBox(Entity entity, BoundingBox box);;
|
||||
|
||||
public default void setCamelPose(Entity entity, CamelPose pose) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -179,11 +182,11 @@ public interface NMSBridge {
|
|||
|
||||
public void setCustomName(Entity entity, Object component, String string);;
|
||||
|
||||
public void setDestination(Entity entity, double x, double y, double z, float speed);;
|
||||
public void setDestination(Entity entity, double x, double y, double z, float speed);
|
||||
|
||||
public void setDimensions(Entity entity, EntityDim desired);
|
||||
public void setDimensions(Entity entity, EntityDim desired);;
|
||||
|
||||
public void setEndermanAngry(Enderman enderman, boolean angry);;
|
||||
public void setEndermanAngry(Enderman enderman, boolean angry);
|
||||
|
||||
public void setHeadYaw(Entity entity, float yaw);
|
||||
|
||||
|
|
|
@ -1256,6 +1256,14 @@ public class NMSImpl implements NMSBridge {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAggressive(org.bukkit.entity.Entity entity, boolean aggro) {
|
||||
Entity handle = getHandle(entity);
|
||||
if (!(handle instanceof EntityInsentient))
|
||||
return;
|
||||
((EntityInsentient) handle).q(aggro);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
|
||||
getHandle(entity).yaw = yaw;
|
||||
|
|
|
@ -1274,6 +1274,14 @@ public class NMSImpl implements NMSBridge {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAggressive(org.bukkit.entity.Entity entity, boolean aggro) {
|
||||
Entity handle = getHandle(entity);
|
||||
if (!(handle instanceof EntityInsentient))
|
||||
return;
|
||||
((EntityInsentient) handle).q(aggro);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
|
||||
getHandle(entity).yaw = yaw;
|
||||
|
|
|
@ -1304,6 +1304,14 @@ public class NMSImpl implements NMSBridge {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAggressive(org.bukkit.entity.Entity entity, boolean aggro) {
|
||||
Entity handle = getHandle(entity);
|
||||
if (!(handle instanceof EntityInsentient))
|
||||
return;
|
||||
((EntityInsentient) handle).setAggressive(aggro);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
|
||||
getHandle(entity).yaw = yaw;
|
||||
|
|
|
@ -1300,6 +1300,14 @@ public class NMSImpl implements NMSBridge {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAggressive(org.bukkit.entity.Entity entity, boolean aggro) {
|
||||
Entity handle = getHandle(entity);
|
||||
if (!(handle instanceof Mob))
|
||||
return;
|
||||
((Mob) handle).setAggressive(aggro);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
|
||||
getHandle(entity).setYRot(yaw);
|
||||
|
|
|
@ -1308,6 +1308,14 @@ public class NMSImpl implements NMSBridge {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAggressive(org.bukkit.entity.Entity entity, boolean aggro) {
|
||||
Entity handle = getHandle(entity);
|
||||
if (!(handle instanceof Mob))
|
||||
return;
|
||||
((Mob) handle).setAggressive(aggro);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBodyYaw(org.bukkit.entity.Entity entity, float yaw) {
|
||||
getHandle(entity).setYRot(yaw);
|
||||
|
|
|
@ -1408,6 +1408,14 @@ public class NMSImpl implements NMSBridge {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAggressive(org.bukkit.entity.Entity entity, boolean aggro) {
|
||||
Entity handle = getHandle(entity);
|
||||
if (!(handle instanceof Mob))
|
||||
return;
|
||||
((Mob) handle).setAggressive(aggro);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllayDancing(org.bukkit.entity.Entity entity, boolean dancing) {
|
||||
Allay allay = (Allay) getHandle(entity);
|
||||
|
@ -2438,7 +2446,6 @@ public class NMSImpl implements NMSBridge {
|
|||
EntityType.SILVERFISH, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT,
|
||||
EntityType.SLIME, EntityType.DOLPHIN, EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST,
|
||||
EntityType.SHULKER, EntityType.PHANTOM);
|
||||
|
||||
private static final MethodHandle BEHAVIOR_TREE_MAP = NMS.getGetter(Brain.class, "f");
|
||||
private static final MethodHandle BUKKITENTITY_FIELD_SETTER = NMS.getSetter(Entity.class, "bukkitEntity");
|
||||
private static final MethodHandle CHUNKMAP_UPDATE_PLAYER_STATUS = NMS.getMethodHandle(ChunkMap.class, "a", true,
|
||||
|
|
Loading…
Reference in New Issue