Kr4ken-9 / NewEssentials

The Essential plugin for Unturned, built on OpenMod
GNU General Public License v3.0
13 stars 13 forks source link

Exception on user connect #55

Closed iamsilk closed 3 years ago

iamsilk commented 3 years ago
[14:32:27 INF][SDG.Unturned] Connecting: PlayerID: 76561198138667988 Name: SilK Character: SilK
[14:32:27 ERR][OpenMod.Core.Eventing.EventBus] Exception occured during event UnturnedUserConnected
System.ArgumentException: An item with the same key has already been added. Key: lastMovement
  at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000c1] in <eae584ce26bc40229c1b1aa476bfa589>:0
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0
  at NewEssentials.Players.AfkChecker+<PlayerJoin>d__13.MoveNext () [0x000a3] in <79202660374d463aac7eb86420e7fd30>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <eae584ce26bc40229c1b1aa476bfa589>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <eae584ce26bc40229c1b1aa476bfa589>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <eae584ce26bc40229c1b1aa476bfa589>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <eae584ce26bc40229c1b1aa476bfa589>:0
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0
  at OpenMod.Core.Eventing.EventBus+<EmitAsync>d__13.MoveNext () [0x00394] in <1d9eafe1055147818e4fd0269e7d2150>:0
Kr4ken-9 commented 3 years ago

https://github.com/Kr4ken-9/NewEssentials/commit/961520ba32eb5abee02e591af6dde72a1baea0a1 should fix this issue. I have not experienced it so I cannot test on my own. Will close once it is on NuGet and has been confirmed

Kr4ken-9 commented 3 years ago

Similar error:

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
  at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x0001e] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at NewEssentials.Players.AfkChecker+<CheckAfkPlayers>d__10.MoveNext () [0x0016a] in <8f92286e4a7946dca1934ee34c728081>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`1[TStateMachine].GetResult (System.Int16 token) [0x00000] in <3bd43acd2c244074bad33eb13fe9766a>:0 
  at NewEssentials.Players.AfkChecker+<<-ctor>b__8_1>d.MoveNext () [0x00065] in <8f92286e4a7946dca1934ee34c728081>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
  at OpenMod.Core.Helpers.AsyncHelper+<>c__DisplayClass5_0+<<Schedule>b__0>d.MoveNext () [0x0006d] in <697917086c4243a4bcfa341b7991101f>:0 

Not sure of the cause yet. If I remember correctly connected players should always have this key, even when reloading