New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPCs not loading into place at server startup. #1170

Closed
mibby opened this Issue Jun 4, 2017 · 28 comments

Comments

Projects
None yet
5 participants
@mibby

mibby commented Jun 4, 2017

Citizens dev 1476
Paper dev 1104 (Spigot 1.11.2)

I have 4 NPCs configured. I noticed after my server started up, two of them were invisible / not in place. I had to type /citizens reload for them to re-appear. So it seems sometimes citizens do not fully load in on server reboots / startup initialization.

Despite it reporting;

[09:00:38] [Server thread/INFO]: [Citizens] Loaded 4 NPCs.
@mibby

This comment has been minimized.

mibby commented Jun 17, 2017

Still happening for me after restarts. Sometimes the npcs do not initialize in place, they are invisible until I /citizens reload.

@mibby

This comment has been minimized.

mibby commented Jun 21, 2017

Still happening on Citizens dev 1481. Tested with a teleport-delay of -1 and 40. Higher teleport delay, npcs don't show up whatsoever on reload. No teleport delay, sometimes breaks skins and them not showing up on reload/initialization.

@mibby

This comment has been minimized.

mibby commented Oct 12, 2017

@fullwall @mcmonkey4eva Still occurring as of Citizens dev 1494.

Is there anything I can do to force npcs to load / re-load a few seconds after startup? Perhaps citizens aren't appearing during restarts because of too many skin lookup requests in a short period of time due to other plugins requesting lookup (head database plugins). Since citizens is unable to get the skin data for an npc, it stops all loading?

@LeafyMitsuwa

This comment has been minimized.

LeafyMitsuwa commented Oct 12, 2017

Are these npc's on worlds other than world, world_nether, or world_the_end by any chance?

@mibby

This comment has been minimized.

mibby commented Oct 12, 2017

When I initially created the ticket, they were only in world world. However I have recently moved all npcs to a separate void world that is used for my spawn.

@mcmonkey4eva

This comment has been minimized.

Member

mcmonkey4eva commented Oct 12, 2017

Can you perhaps enable debug mode in your config, and see what the console says during restart sequences?

@mibby

This comment has been minimized.

mibby commented Oct 13, 2017

@mcmonkey4eva Here's the full start-up of Citizens (& command NPC) with debug enabled.

[19:52:03] [Server thread/INFO]: [Citizens] Loading Citizens v2.0.22-SNAPSHOT (build 1494)
[19:52:19] [Server thread/INFO]: [Citizens] Enabling Citizens v2.0.22-SNAPSHOT (build 1494)
[19:52:19] [Server thread/INFO]: Unable to find Rhino classes - javascript scripts won't see non-CraftBukkit classes
[19:52:19] [Server thread/INFO]: [CommandNPC] Enabling CommandNPC v1.9.1
[19:52:19] [Server thread/INFO]: [CommandNPC] Vault compatible economy found! Economy support for CommandNPC has been enabled.
[19:52:19] [Server thread/INFO]: [CommandNPC] Initiating Database
[19:52:19] [Server thread/INFO]: [CommandNPC] Injecting command info into Citizens.
[19:52:19] [Server thread/INFO]: [CommandNPC] CommandNPC successfully loaded!
[19:52:19] [Thread-21/INFO]: [CommandNPC] Loading commands complete!
[19:52:25] [Server thread/INFO]: Done (19.315s)! For help, type "help" or "?"
[19:52:29] [Server thread/INFO]: Retrying spawn of 1 later due to chunk being unloaded. Util.isLoaded true
[19:52:29] [Server thread/INFO]: Stored 1 for respawn from NPCNeedsRespawnEvent
[19:52:29] [Server thread/INFO]: Retrying spawn of 6 later due to chunk being unloaded. Util.isLoaded true
[19:52:29] [Server thread/INFO]: Stored 6 for respawn from NPCNeedsRespawnEvent
[19:52:29] [Server thread/INFO]: Retrying spawn of 7 later due to chunk being unloaded. Util.isLoaded true
[19:52:29] [Server thread/INFO]: Stored 7 for respawn from NPCNeedsRespawnEvent
[19:52:29] [Server thread/INFO]: Retrying spawn of 8 later due to chunk being unloaded. Util.isLoaded true
[19:52:29] [Server thread/INFO]: Stored 8 for respawn from NPCNeedsRespawnEvent
[19:52:29] [Server thread/INFO]: [Citizens] Loaded 5 NPCs.
[19:52:29] [Craft Scheduler Thread - 11/INFO]: Fetched profile 70a5d798-479f-4cb0-9279-62d6956afd5c for player Angeleea
[19:52:30] [Craft Scheduler Thread - 11/INFO]: Fetched profile 291c2d6e-a25d-4179-a11e-3011f9a97b2b for player iMxAndyy
[19:52:30] [Craft Scheduler Thread - 11/INFO]: Fetched profile 0d6e7f2b-b16e-4e2e-9f47-4cbe8125cf07 for player Noby_Diver
[19:52:30] [Craft Scheduler Thread - 11/INFO]: Fetched profile fd3732f4-c293-4c3e-9bf4-a0ea4365af2b for player Wenger
[19:52:30] [Server thread/INFO]: Removing 4 from skin tracker due to DespawnReason.PENDING_RESPAWN
[19:52:30] [Server thread/INFO]: Despawned 4 DespawnReason. PENDING_RESPAWN
[19:52:30] [Craft Scheduler Thread - 11/INFO]: Fetched profile d32baf71-3c47-439e-be42-c630a481ddbc for player Cooper1990
[19:52:35] [Server thread/INFO]: Removing 4 from skin tracker due to DespawnReason.CHUNK_UNLOAD
[19:52:35] [Server thread/INFO]: Despawned 4 DespawnReason. CHUNK_UNLOAD
[19:52:35] [Server thread/INFO]: Despawned id 4 due to chunk unload at [-2,0]
[19:52:50] [Server thread/INFO]: Spawned id 8 due to chunk event at [1,0]
[19:52:50] [Server thread/INFO]: Spawned id 4 due to chunk event at [-2,0]
[19:52:50] [Server thread/INFO]: Spawned id 6 due to chunk event at [-2,-1]
[19:52:50] [Server thread/INFO]: Spawned id 7 due to chunk event at [-3,0]
[19:52:50] [Server thread/INFO]: Spawned id 1 due to chunk event at [-3,-1]

During restarts, I also force all connections to idle and reconnect on the BungeeCord proxy so players automatically rejoin the server after restarts. So perhaps with lots of players reconnecting at once, it stops citizens from fully loading when it tries to fetch skins?

Currently all NPCs are in a separate world used for my spawn. With PaperSpigot, spawn chunks should be kept loaded at all times.

    keep-spawn-loaded-range: 10
    keep-spawn-loaded: true

When some of the NPCs don't appear at the spawn after restarts, reloading citizens with /citizens reload forces them to reappear.

@mibby

This comment has been minimized.

mibby commented Oct 13, 2017

@mcmonkey4eva Here is a restart with a confirmed occurrence of npcs disappearing. Caused by what I assumed, too many skin requests stopping npcs from loading. So perhaps load a blank steve skin with the npc so it still exists until the skin can be refetched rather than not load the npc altogether?

[21:00:57] [Craft Scheduler Thread - 24/INFO]: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.citizensnpcs.nms.v1_12_R1.util.NMSImpl.fillProfileProperties(NMSImpl.java:300)
	at net.citizensnpcs.util.NMS.fillProfileProperties(NMS.java:60)
	at net.citizensnpcs.npc.profile.ProfileFetcher$1.onProfileLookupSucceeded(ProfileFetcher.java:81)
	at com.destroystokyo.paper.event.profile.PreLookupProfileEvent$PreProfileLookupCallback.onProfileLookupSucceeded(PreLookupProfileEvent.java:162)
	at com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository.findProfilesByNames(YggdrasilGameProfileRepository.java:63)
	at com.destroystokyo.paper.event.profile.PreLookupProfileEvent.lambda$wrapProfileRepository$0(PreLookupProfileEvent.java:143)
	at net.citizensnpcs.npc.profile.ProfileFetcher.fetchRequests(ProfileFetcher.java:48)
	at net.citizensnpcs.npc.profile.ProfileFetchThread.run(ProfileFetchThread.java:121)
	at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:58)
	at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:52)
	at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time
	at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:79)
	... 18 more

http://paste.ubuntu.com/25730236/

@mibby

This comment has been minimized.

mibby commented Oct 17, 2017

Been an hour post server restart and the npcs haven't loaded /come back automatically. =/
link

Forcing a /citizens reload, they load in.
link2

Still think they should load default steve skins and keep retrying to fetch skins every defined amount of time until they actually can instead of not loading whatsoever.

@LeafyMitsuwa

This comment has been minimized.

LeafyMitsuwa commented Oct 17, 2017

If they're using live-skins, then Mojang will block requests from IP's after a certain amount of requests has been met from said IP, an issue if your host is hosting multiple servers' on the same IP.

If they're using offline skins, (argumented with -p), why should the 1000th attempt to load a skin have any different result than the 4th attempt?

@mibby

This comment has been minimized.

mibby commented Oct 18, 2017

My dedicated box is only hosting a single server. The issue is with using a heads database plugin and if Citizens can't obtain the skin, it stops loading npcs entirely rather than using a steve skin until a skin can be refetched.

Is offline skins something that Citizens supports? As that would resolve the problem of skin fetching preventing loading for me.

@LeafyMitsuwa

This comment has been minimized.

@mibby

This comment has been minimized.

mibby commented Oct 18, 2017

Interesting. This I presume will stop it from trying to fetch the skin online when attached to a specific player name? If so, that'll definitely help and will hopefully prevent the issue of npcs not loading at start-up.

Edit: Where does the copy of the skin save? Or is it still fetched from MC but from a snapshot instead of current?

@mibby

This comment has been minimized.

mibby commented Oct 18, 2017

It seems it still tries to fetch the skin of the npcs even with -p and prevents npcs from loading when it can't make a skin request on server restarts. So this issue will still need to be fixed.

@fullwall

This comment has been minimized.

Member

fullwall commented Oct 18, 2017

Apologies for the delay - I believe I have found the cause of this and will work on a fix tomorrow.

@fullwall

This comment has been minimized.

Member

fullwall commented Oct 19, 2017

Try latest build

@mibby

This comment has been minimized.

mibby commented Oct 20, 2017

@fullwall Doesn't seem to be fixed.

Citizens dev 1496

Post restart.
link3

Reloading via /citizens reload.
link4

I did change all citizens to have -p (for snapshot skins), but it doesn't seem to save the skin itself anywhere to use and still looks up the player name through mojang servers.

      player-skin-use-latest: false
@BloodEko

This comment has been minimized.

BloodEko commented Oct 20, 2017

Is your error maybe related to this one ? #1332

@mibby

This comment has been minimized.

mibby commented Oct 21, 2017

It is possible, but logging into the server post restart after everything should have initialized sometimes has them not showing. Even swapping worlds and back to force reload chunks doesn't force them to re-show. Have to force it with /citizens reload.

@mibby

This comment has been minimized.

mibby commented Oct 23, 2017

@fullwall Bump. :( It is quite frustrating to not have essential npcs loaded after restarts.

Edit: Maybe it is an entity chunk loading? The server restarted and I was reconnected / logged into the same world the npcs are suppose to be in. They weren't there. I tped into another world for a few minutes, walked around, then headed back to the npc world. They reappeared without me reloading.

@mibby

This comment has been minimized.

mibby commented Jan 19, 2018

Bump.

Also experiencing a new issue recently where the skins of the loaded npcs disappear on your client until you switch worlds and back.

@mcmonkey4eva

This comment has been minimized.

Member

mcmonkey4eva commented Oct 12, 2018

Does this affect NPCs not in spawn chunks? (A spawn chunk being, in this case, any chunk that is loaded automatically or would be loaded immediately at startup by players autojoining)

@mibby

This comment has been minimized.

mibby commented Oct 13, 2018

@mcmonkey4eva I'm not sure as I do not personally use many npcs outside of my spawn world and spawn location. I'd have to re-check but generally it is always spawn with missing npcs. I've just setup a script to reload citizens 5 minutes after a restart since this issue has existed forever.

@mcmonkey4eva

This comment has been minimized.

Member

mcmonkey4eva commented Oct 13, 2018

If it's only spawn chunks, it's likely #1332 as the basis of this (NPCs not loading in for chunks that are already loaded when Citizens fully starts up)

@mibby

This comment has been minimized.

mibby commented Oct 13, 2018

It's possible that's related or the actual symptom I'm experiencing. However I've had players login post-restart and claim citizens are missing - requiring a citizens reload to refresh.

Could it be that citizens tries to spawn in the npc before the chunk is actually loaded (spawn chunks kept in memory or normal chunks otherwise), so it thinks the npc exists while in actuality it doesn't due to the event being cancelled for being an unsafe entity spawn location?

@mibby

This comment has been minimized.

mibby commented Oct 13, 2018

Thus a fix would be to verify the integrity of the spawn location before spawning the entity, else force it or retry until succeeding? With a timeout in case the actual chunk is damaged so citizens doesn't just spam checks repeatedly?

@mibby

This comment has been minimized.

mibby commented Oct 13, 2018

Did a quick restart to check what npcs don't spawn in. It only seems to be the ones at spawn where half load in. The ones located in separate worlds loaded fine - though perhaps maybe I just got lucky in the load order based on when they were created.

@mcmonkey4eva

This comment has been minimized.

Member

mcmonkey4eva commented Oct 15, 2018

I'm going to say this should be deferred to #1332 then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment