CitizensDev / Citizens2

Citizens - the premier plugin and API for creating server-side NPCs in Minecraft.
https://citizensnpcs.co
Open Software License 3.0
589 stars 313 forks source link

Error in console #2472

Closed Gafn3r closed 3 years ago

Gafn3r commented 3 years ago

Hello, I'm new with plugins but i have a serious bug that i can't solve. This bug may happend when there is a oder player in the server.

Version server : This server is running Paper version git-Paper-416 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT) You are running the latest version

version citizens: Citizens version 2.0.27-SNAPSHOT (build 2263) Website: http://www.citizensnpcs.co Author: [fullwall]

bug 11.02.2021.txt

Thank you to check this bug and have a nice day :)

mcmonkey4eva commented 3 years ago
andris155 commented 3 years ago

I have a same problem when I use cooldowns for ncp commands.

Gafn3r commented 3 years ago

Sorry for the late reponse... I know that the problem is not the version of paper because i've already tried in the lastest version 1.16.5 and i've got the same problem.

I can't post the .yml so i've just copy it in a .txt. Is that ok ?

saves.txt

latest.log

mcmonkey4eva commented 3 years ago

@fullwall this error appears to be a mistake in the reify update. I believe what happens is:

https://github.com/CitizensDev/Citizens2/blob/9bbe9ae3c480b106953c5621103d3b36ad8cc068/main/src/main/java/net/citizensnpcs/trait/CommandTrait.java#L57-L58

^ Field is type Map<String, PlayerNPCCommand>

https://github.com/CitizensDev/CitizensAPI/blob/6bc7733aaf3de1118e1369abb48f7a119dcf44d5/src/main/java/net/citizensnpcs/api/persistence/PersistenceLoader.java#L62-L71

^ That code will generate a persistence loader for the field, which will initially take the field.getType() as Map, then recognize it as parameterized, and thus take the first param, which is String, and produce a persistence loader for that.

It, of course, needs to generate a loader for the value rather than the key in this case.


The stack trace reported in the original issue:

java.lang.ClassCastException: java.lang.String cannot be cast to net.citizensnpcs.trait.CommandTrait$PlayerNPCCommand
    at net.citizensnpcs.trait.CommandTrait$1$3.run(CommandTrait.java:223) ~[?:?]
    at net.citizensnpcs.trait.CommandTrait$1.runCommand(CommandTrait.java:242) ~[?:?]
    at net.citizensnpcs.trait.CommandTrait$1.run(CommandTrait.java:212) ~[?:?]
    at net.citizensnpcs.trait.CommandTrait.dispatch(CommandTrait.java:249) ~[?:?]

Full latest log properly pasted: https://paste.denizenscript.com/View/80833

Relevant saves.yml section:

        commands:
          '0':
            command: server lobbypractice
            hand: RIGHT
            player: true
            op: false
            cooldown: 0
            globalcooldown: 0
            n: -1
            delay: 0
          '1':
            command: clearinventory
            hand: RIGHT
            player: true
            op: false
            cooldown: 0
            globalcooldown: 0
            n: -1
            delay: 0
        cooldowns:
          92e5742e-c437-4887-9a08-b4adb4a94eaa:
            lastUsedId: 1
Gafn3r commented 3 years ago

Can you help me with discord ? : Gafner#2850 I'm not good enought to understand your answer sorry...

mcmonkey4eva commented 3 years ago

@Gafn3r the issue was a bug in Citizens itself, all the information I wrote was just tracking down the details so fullwall could fix it.

Which he now fixed via https://github.com/CitizensDev/CitizensAPI/commit/f4235450d7e588dfd342d058f79436be326189da and the fix is available in build 2269+ from https://ci.citizensnpcs.co/job/Citizens2/