Package com.jackdaw.chatwithnpc.npc
Class NPCEntityManager
java.lang.Object
com.jackdaw.chatwithnpc.npc.NPCEntityManager
This class is used to manage the NPC entities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ConcurrentHashMap<UUID,
NPCEntity> private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
End all NPC entities.static void
End the out of time NPC entities.private static List<net.minecraft.entity.Entity>
getEntitiesInRange
(@NotNull net.minecraft.entity.player.PlayerEntity player, double range) getNPCEntities
(net.minecraft.entity.player.PlayerEntity player) Get all NPCs within a certain range of a player.static @Nullable NPCEntity
getNPCEntity
(UUID uuid) Get an NPC entity by its UUID.static @Nullable NPCEntity
getNPCEntity
(net.minecraft.entity.player.PlayerEntity player) Get the closest NPC around a player.static boolean
isRegistered
(UUID uuid) Check if an NPC is registeredstatic void
registerNPCEntity
(@NotNull net.minecraft.entity.Entity entity, boolean isOP) Initialize an NPC entity if the NPC is not conversing.static void
removeNPCEntity
(UUID uuid) Remove an NPC entity from the map.
-
Field Details
-
npcMap
-
outOfTime
private static final long outOfTime- See Also:
-
-
Constructor Details
-
NPCEntityManager
public NPCEntityManager()
-
-
Method Details
-
isRegistered
Check if an NPC is registered- Parameters:
uuid
- The UUID of the NPC- Returns:
- True if the NPC is registered, false otherwise
-
getNPCEntity
Get an NPC entity by its UUID.- Parameters:
uuid
- The UUID of the NPC entity- Returns:
- The NPC entity
-
getNPCEntity
@Nullable public static @Nullable NPCEntity getNPCEntity(net.minecraft.entity.player.PlayerEntity player) Get the closest NPC around a player. This will register all NPCs within the range of the player.- Parameters:
player
- The player to check- Returns:
- The closest NPC to the player
-
getNPCEntities
Get all NPCs within a certain range of a player. If the NPC is not registered, register it.- Parameters:
player
- The player to check- Returns:
- A list of NPCs within the range of the player
-
getEntitiesInRange
private static List<net.minecraft.entity.Entity> getEntitiesInRange(@NotNull @NotNull net.minecraft.entity.player.PlayerEntity player, double range) -
registerNPCEntity
public static void registerNPCEntity(@NotNull @NotNull net.minecraft.entity.Entity entity, boolean isOP) Initialize an NPC entity if the NPC is not conversing.- Parameters:
entity
- The NPC entity to initialize
-
removeNPCEntity
Remove an NPC entity from the map.- Parameters:
uuid
- The UUID of the NPC entity to remove
-
endOutOfTimeNPCEntity
public static void endOutOfTimeNPCEntity()End the out of time NPC entities. -
endAllNPCEntity
public static void endAllNPCEntity()End all NPC entities.
-