#Using the CitizensAPI
1 messages · Page 1 of 1 (latest)
Ok
pom.xml
<repository>
<id>everything</id>
<url>https://repo.citizensnpcs.co/</url>
</repository>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizensapi</artifactId>
<version>2.0.29-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
plugin.yml
name: Mobarobot
version: '${project.version}'
main: ttomek.mobarobot.Mobarobot
api-version: 1.18
authors: [ ttomek ]
description: a
website: cyber-man.pl
i'm following : https://wiki.citizensnpcs.co/API
You need to depend on Citizens in your plugin.yml
Depending on it will make sure it loads before your plugin so there won't be any issues
pretty sure it's loading before. I have plugin manager and im reloading my plugin and citizens stay loaded
but will add anyway
Don't do that
Always restart
No reloads and no plugin managers if you don't know what they are and how they work
name: Mobarobot
version: '${project.version}'
main: ttomek.mobarobot.Mobarobot
api-version: 1.18
authors: [ ttomek ]
description: a
website: cyber-man.pl
depend:
- Citizens
like this?
Yeah
i think i kinda know how they work
Doubt it
well, i restart as u said
pluginmanager unload and load is performing natual loading lpugin and reload in this case is doing just unload then load
Lol
when i added the depend
now in the console my plugin logs appear much before Citizens [Citizens] Loaded 0 NPCs.
However it fixed Citizens 2.0 not found or not enabled
The thing is there is no natural unload
but still java.lang.IllegalStateException: no implementation set at net.citizensnpcs.api.CitizensAPI.getImplementation(CitizensAPI.java:79)
Oh ok, i meant that they do same messages as they are in the server startup
Anyways classloading and internals of how Spigot work isn't important here
If this isn't caused by you just ignore it
Now where are you using Citizens in your code
My plugin is causing it. It's not loading
Could you send the entire error
?paste
Ow not working here
Anyways full error in a paste
https://wiki.citizensnpcs.co/API
First block of code here:
https://imgur.com/a/lCWA2tg
Do you need a trait or are you just copy pasting stuff
What do you want your NPC to do
If trait is npc with coded by me behavior then yes
I'm trying to spawn a custom npc at first
then the npc talks to nearby players
via chat
while playing villager sounds
wanders around
and do some actions
like take random item from chest
run towards creepers
Ah good that you're using Citizens and not your own NPCs then
Because that would have been real hard for you
Spawning an NPC is one thing. Having it move and interact is much harder
All right now let's get your NPC moving
but
We'll get to that later
XD
Now create a way for your NPC to be spawned
This can be an event listener or a command. Use something simple for testing
Okay that works
Now spawn your npc with;
NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, "name");
Then use npc.spawn(location)
This will spawn a new NPC where you want it
You can customize that a bit more later for now let's focus on the main behaviour
It didn't 😦
Location loc = e.getBlock().getLocation();
World world = e.getBlock().getWorld();
System.out.println("spawn npc");
NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, "mobara01");
npc.spawn(loc);
[16:47:23 INFO]: [Mobarobot] [STDOUT] spawn npc
[16:47:23 ERROR]: Could not pass event BlockPlaceEvent to Mobarobot v1.0
java.lang.IllegalStateException: no implementation set
wdm
How are you starting your server
-Xmx3750M only XD
With the Paperclip jar correct?
Starting org.bukkit.craftbukkit.Main
System Info: Java 17 (OpenJDK 64-Bit Server VM 17+35-2724) Host: Linux 3.10.0-1062.1.1.el7.x86_64 (amd64)
Loading libraries, please wait...
2022-01-07 16:24:50,979 ServerMain WARN Advanced terminal features are not available in this environment
[16:25:04 INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[16:25:04 INFO]: Reloading ResourceManager: Default, bukkit
[16:25:05 INFO]: Loaded 7 recipes
[16:25:06 INFO]: Starting minecraft server version 1.18.1
[16:25:06 INFO]: Loading properties
[16:25:06 INFO]: This server is running Paper version git-Paper-117 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) (Git: 64f9225)
[16:25:06 INFO]: Server Ping Player Sample Count: 12
[16:25:06 INFO]: Using 4 threads for Netty based IO
[16:25:06 INFO]: Default game type: SURVIVAL
[16:25:06 INFO]: Generating keypair
[16:25:06 INFO]: Starting Minecraft server on REDACTED:40205
[16:25:07 INFO]: Using epoll channel type
[16:25:07 INFO]: Paper: Using libdeflate (Linux x86_64) compression from Velocity.
[16:25:07 INFO]: Paper: Using OpenSSL 1.1.x (Linux x86_64) cipher from Velocity.
[16:25:08 ERROR]: [STDERR] [org.bukkit.craftbukkit.v1_18_R1.legacy.CraftLegacy] Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
[16:25:13 WARN]: Legacy plugin LoginSecurity v3.1 does not specify an api-version.
aight
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Ah then upload that jar
why delete it tho?
To stop people from using illeagally distributed jars
There is a reason spigot does not have direct downloads
i don't quite get why.
The whole craftbukkit project got DMCAd
That's why
This way we can avoid sharing mojangs code
So we don't get taken down
Did it fix the problem
same error
Guess it's just broken atm
You could keep trying older build or report the issue
I don't have access to a pc until tomorrow so can't help more until then
when it's trying to getNPCRegistry it asks the implementation which can be set via CitizensAPI.setImplementation( -> https://imgur.com/a/2e7Rm4J . i'm trying to get the plugin from server.pluginmanager but it returns Just plugin not CitizensPlugin
maybe i will ask on the main chat
I have Citizens-2.0.29-b2446.jar on my spigot 1.18.1 server with all libs. Loading just fine.
I have added depend: [ Citizens ] to my plugin.yml HOWEVER
this: ```java
NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, "mobara01");
Produces error:
Caused by: java.lang.IllegalStateException: no implementation set
at net.citizensnpcs.api.CitizensAPI.getImplementation(CitizensAPI.java:79) ~[?:?]
at net.citizensnpcs.api.CitizensAPI.getNPCRegistry(CitizensAPI.java:111) ~[?:?]
Like citizens didn't load. (commands from citizens works etc)
i tried changing citizens version
You could try asking in the Citizens discord
i already did
Ah what did they say
nothing
Thank you for all the help
You can work on other stuff while you wait
Such as a system for determening where it should walk
it didn't solve problem
in fact i didn't even notice the message there
and didn't add it
Thankfully Citizens makes this quite easy. See the AI section of the API page