java.lang.NullPointerException in mmo example unity

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

piyush1234567
Posts: 4
Joined: 21 Oct 2022, 07:22

java.lang.NullPointerException in mmo example unity

Postby piyush1234567 » 26 Oct 2022, 13:58

Hi i have downloaded unity example and play it on unity but here no NPC are shown
I install latest smartFox_2x on console side i have found these exceptions
please help to resolve this.

java.lang.NullPointerException
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension.simulatePlayers(MMOBasicsExtension.java:77)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension.access$2(MMOBasicsExtension.java:64)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension$UserVariablesUpdateHandler.handleServerEvent(MMOBasicsExtension.java:145)
at com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:773)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:694)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:971)
at com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:66)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
19:03:06,621 WARN [SFSWorker:Ext:3] managers.SFSExtensionManager - com.smartfoxserver.v2.exceptions.SFSRuntimeException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.smartfoxserver.v2.exceptions.SFSRuntimeException
Message: Room is not an MMORoom! null, ( User Name: assa, Id: 0, Priv: 0, Sess: 127.0.0.1:50422 )
Description: Error during event handling: com.smartfoxserver.v2.exceptions.SFSRuntimeException: Room is not an MMORoom! null, ( User Name: assa, Id: 0, Priv: 0, Sess: 127.0.0.1:50422 ) , Listener: { Ext: MMOBasics, Type: JAVA, Lev: ZONE, { Zone: BasicExamples }, {} }
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.api.SFSMMOApi.setUserPosition(SFSMMOApi.java:85)
sfs2x.extensions.games.mmobasics.MMOBasicsExtension$UserVariablesUpdateHandler.handleServerEvent(MMOBasicsExtension.java:175)
com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:773)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:694)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:971)
com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:66)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base/java.lang.Thread.run(Thread.java:829)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

com.smartfoxserver.v2.exceptions.SFSLoginException: Another user is already logged with the same name: NPC#0
at com.smartfoxserver.v2.scala.DefLI.doLogin(c:251)
at com.smartfoxserver.v2.entities.SFSZone.login(SFSZone.java:1362)
at com.smartfoxserver.v2.api.SFSApi.createNPC(SFSApi.java:710)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension.simulatePlayers(MMOBasicsExtension.java:71)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension.access$2(MMOBasicsExtension.java:64)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension$UserVariablesUpdateHandler.handleServerEvent(MMOBasicsExtension.java:145)
at com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:773)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchRoomLevelEvent(SFSExtensionManager.java:715)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:977)
at com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:66)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
19:03:56,618 INFO [SocketReader] sessions.DefaultSessionManager - Session removed: { Id: 1, Type: DEFAULT, Logged: Yes, IP: 127.0.0.1:50422 }
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: java.lang.NullPointerException in mmo example unity

Postby Lapo » 26 Oct 2022, 16:05

Hi,
the example is supposed to work out of the box, having followed the tutorial setup.
http://docs2x.smartfoxserver.com/Exampl ... mmo-basics

The exception indicates that the Extension cannot read some of the basic properties of the MMORoom.
Can you take another look at the "Setup and Run" section of the tutorial and double check each step?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
piyush1234567
Posts: 4
Joined: 21 Oct 2022, 07:22

Re: java.lang.NullPointerException in mmo example unity

Postby piyush1234567 » 27 Oct 2022, 06:00

Hi Lapo,
I already double check it. Its give same error Please to resolve it
Here is Log file

08:41:54,397 INFO [SocketReader] sessions.DefaultSessionManager - Session created: { Id: 1, Type: DEFAULT, Logged: No, IP: 127.0.0.1:49519 } on Server port: 9933 <---> 49519
08:41:54,560 INFO [SFSWorker:Sys:2] api.SFSApi - User login: { Zone: BasicExamples }, ( User Name: sdfds, Id: 0, Priv: 0, Sess: 127.0.0.1:49519 ) , Type: Unity
08:41:54,606 INFO [SFSWorker:Sys:3] managers.SFSRoomManager - Room created: { Zone: BasicExamples }, [ MMORoom: MMOBasics, Id: 2, Group: default, AOI: (25.0, 10.0, 25.0) ], type = MMORoom
08:41:54,607 INFO [SFSWorker:Sys:3] api.SFSApi - Room joined: [ MMORoom: MMOBasics, Id: 2, Group: default, AOI: (25.0, 10.0, 25.0) ], { Zone: BasicExamples }, ( User Name: sdfds, Id: 0, Priv: 0, Sess: 127.0.0.1:49519 ) , asSpect: false
java.lang.NullPointerException
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension.simulatePlayers(MMOBasicsExtension.java:77)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension.access$2(MMOBasicsExtension.java:64)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension$UserVariablesUpdateHandler.handleServerEvent(MMOBasicsExtension.java:145)
at com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:773)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:694)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:971)
at com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:66)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
08:41:55,201 WARN [SFSWorker:Ext:3] managers.SFSExtensionManager - com.smartfoxserver.v2.exceptions.SFSRuntimeException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.smartfoxserver.v2.exceptions.SFSRuntimeException
Message: Room is not an MMORoom! null, ( User Name: sdfds, Id: 0, Priv: 0, Sess: 127.0.0.1:49519 )
Description: Error during event handling: com.smartfoxserver.v2.exceptions.SFSRuntimeException: Room is not an MMORoom! null, ( User Name: sdfds, Id: 0, Priv: 0, Sess: 127.0.0.1:49519 ) , Listener: { Ext: MMOBasics, Type: JAVA, Lev: ZONE, { Zone: BasicExamples }, {} }
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.api.SFSMMOApi.setUserPosition(SFSMMOApi.java:85)
sfs2x.extensions.games.mmobasics.MMOBasicsExtension$UserVariablesUpdateHandler.handleServerEvent(MMOBasicsExtension.java:175)
com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:773)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:694)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:971)
com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:66)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base/java.lang.Thread.run(Thread.java:829)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

com.smartfoxserver.v2.exceptions.SFSLoginException: Another user is already logged with the same name: NPC#0
at com.smartfoxserver.v2.scala.DefLI.doLogin(c:251)
at com.smartfoxserver.v2.entities.SFSZone.login(SFSZone.java:1362)
at com.smartfoxserver.v2.api.SFSApi.createNPC(SFSApi.java:710)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension.simulatePlayers(MMOBasicsExtension.java:71)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension.access$2(MMOBasicsExtension.java:64)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension$UserVariablesUpdateHandler.handleServerEvent(MMOBasicsExtension.java:145)
at com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:773)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchRoomLevelEvent(SFSExtensionManager.java:715)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:977)
at com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:66)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
08:42:03,729 INFO [SocketReader] sessions.DefaultSessionManager - Session removed: { Id: 1, Type: DEFAULT, Logged: Yes, IP: 127.0.0.1:49519 }
08:42:03,732 INFO [SFSWorker:Sys:2] managers.SFSRoomManager - Room removed: { Zone: BasicExamples }, [ MMORoom: MMOBasics, Id: 2, Group: default, AOI: (25.0, 10.0, 25.0) ], Duration: 9131
08:42:03,734 INFO [SFSWorker:Sys:2] api.SFSApi - User disconnected: { Zone: BasicExamples }, ( User Name: sdfds, Id: 0, Priv: 0, Sess: 127.0.0.1:49519 ) , SessionLen: 9174, Type: Unity
08:49:01,239 INFO [SocketReader] sessions.DefaultSessionManager - Session created: { Id: 53, Type: DEFAULT, Logged: No, IP: 127.0.0.1:49624 } on Server port: 9933 <---> 49624
08:49:01,315 INFO [SFSWorker:Sys:3] api.SFSApi - User login: { Zone: BasicExamples }, ( User Name: sdsf, Id: 51, Priv: 0, Sess: 127.0.0.1:49624 ) , Type: Unity
08:49:01,355 INFO [SFSWorker:Sys:4] managers.SFSRoomManager - Room created: { Zone: BasicExamples }, [ MMORoom: MMOBasics, Id: 3, Group: default, AOI: (25.0, 10.0, 25.0) ], type = MMORoom
08:49:01,356 INFO [SFSWorker:Sys:4] api.SFSApi - Room joined: [ MMORoom: MMOBasics, Id: 3, Group: default, AOI: (25.0, 10.0, 25.0) ], { Zone: BasicExamples }, ( User Name: sdsf, Id: 51, Priv: 0, Sess: 127.0.0.1:49624 ) , asSpect: false
08:49:01,957 WARN [SFSWorker:Ext:1] managers.SFSExtensionManager - com.smartfoxserver.v2.exceptions.SFSRuntimeException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.smartfoxserver.v2.exceptions.SFSRuntimeException
Message: Room is not an MMORoom! null, ( User Name: sdsf, Id: 51, Priv: 0, Sess: 127.0.0.1:49624 )
Description: Error during event handling: com.smartfoxserver.v2.exceptions.SFSRuntimeException: Room is not an MMORoom! null, ( User Name: sdsf, Id: 51, Priv: 0, Sess: 127.0.0.1:49624 ) , Listener: { Ext: MMOBasics, Type: JAVA, Lev: ZONE, { Zone: BasicExamples }, {} }
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.api.SFSMMOApi.setUserPosition(SFSMMOApi.java:85)
sfs2x.extensions.games.mmobasics.MMOBasicsExtension$UserVariablesUpdateHandler.handleServerEvent(MMOBasicsExtension.java:175)
com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:773)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:694)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:971)
com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:66)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base/java.lang.Thread.run(Thread.java:829)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

com.smartfoxserver.v2.exceptions.SFSLoginException: Another user is already logged with the same name: NPC#0
at com.smartfoxserver.v2.scala.DefLI.doLogin(c:251)
at com.smartfoxserver.v2.entities.SFSZone.login(SFSZone.java:1362)
at com.smartfoxserver.v2.api.SFSApi.createNPC(SFSApi.java:710)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension.simulatePlayers(MMOBasicsExtension.java:71)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension.access$2(MMOBasicsExtension.java:64)
at sfs2x.extensions.games.mmobasics.MMOBasicsExtension$UserVariablesUpdateHandler.handleServerEvent(MMOBasicsExtension.java:145)
at com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:773)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchRoomLevelEvent(SFSExtensionManager.java:715)
at com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:977)
at com.smartfoxserver.v2.core.SFSEventManager$SFSEventRunner.run(SFSEventManager.java:66)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
08:49:06,866 INFO [SocketReader] sessions.DefaultSessionManager - Session removed: { Id: 53, Type: DEFAULT, Logged: Yes, IP: 127.0.0.1:49624 }
08:49:06,866 INFO [SFSWorker:Sys:2] managers.SFSRoomManager - Room removed: { Zone: BasicExamples }, [ MMORoom: MMOBasics, Id: 3, Group: default, AOI: (25.0, 10.0, 25.0) ], Duration: 5515
08:49:06,868 INFO [SFSWorker:Sys:2] api.SFSApi - User disconnected: { Zone: BasicExamples }, ( User Name: sdsf, Id: 51, Priv: 0, Sess: 127.0.0.1:49624 ) , SessionLen: 5554, Type: Unity
09:55:41,291 INFO [pool-1-thread-4] stats.CCULoggerTask - CCU stats: { Zone: --=={{{ AdminZone }}}==-- }, CCU: 0/0
09:55:41,291 INFO [pool-1-thread-4] stats.CCULoggerTask - CCU stats: { Zone: BasicExamples }, CCU: 8/50
09:55:41,292 INFO [pool-1-thread-4] stats.CCULoggerTask - CCU stats: CCU: 8/50
10:55:52,625 INFO [pool-1-thread-3] stats.CCULoggerTask - CCU stats: { Zone: --=={{{ AdminZone }}}==-- }, CCU: 0/0
10:55:52,626 INFO [pool-1-thread-3] stats.CCULoggerTask - CCU stats: { Zone: BasicExamples }, CCU: 50/50
10:55:52,627 INFO [pool-1-thread-3] stats.CCULoggerTask - CCU stats: CCU: 50/50
11:07:23,676 INFO [http-nio-8080-exec-1] sessions.DefaultSessionManager - Session created: { Id: 55, Type: WEBSOCKET, Logged: No, IP: 127.0.0.1 } on Server port: 8080 <---> 50600
11:07:23,683 INFO [SFSWorker:Ext:4] api.SFSApi - User login: { Zone: --=={{{ AdminZone }}}==-- }, ( User Name: sfsadmin, Id: 52, Priv: 0, Sess: 127.0.0.1:50600 ) , Type: JavaScript
11:07:23,686 INFO [SFSWorker:Ext:4] api.SFSApi - Room joined: [ Room: AdminRoom, Id: 1, Group: default, isGame: false ], { Zone: --=={{{ AdminZone }}}==-- }, ( User Name: sfsadmin, Id: 52, Priv: 0, Sess: 127.0.0.1:50600 ) , asSpect: false
piyush1234567
Posts: 4
Joined: 21 Oct 2022, 07:22

Re: java.lang.NullPointerException in mmo example unity

Postby piyush1234567 » 27 Oct 2022, 06:33

Hi Lapo,
I run that example before 25 oct it run and there is no error also NPC are created. But Now its gives error please help

on admin tool side i create a room MMOBasics room here room extension is disable.
on lobby it shows five tabs runtime room setting, permission & event, run time room variable, room extension , MMO setting
but on MMOBasics room extension is disable and MMO Setting not be there
Attachments
Screenshot 2022-10-27 at 11.53.53 AM.png
(87.38 KiB) Not downloaded yet
Screenshot 2022-10-27 at 11.53.44 AM.png
(116.91 KiB) Not downloaded yet
Screenshot 2022-10-27 at 11.53.53 AM.png
(87.38 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: java.lang.NullPointerException in mmo example unity

Postby Lapo » 27 Oct 2022, 08:24

piyush1234567 wrote:Hi Lapo,
I run that example before 25 oct it run and there is no error also NPC are created. But Now its gives error please help

It sounds like you have installed the example correctly and then made changes that broke the client code.
However it is quite difficult to guess what you might have changed and you didn't provide enough details as to what these changes might be.

My suggestion is to restart from scratch, reinstalling a fresh copy of the Example.

on admin tool side i create a room MMOBasics room here room extension is disable.

There is no need for this. If you check our documentation we don't say to manually create any Room.
Also in one of your screenshots you're showing the "Lobby" Room with attached the example Extension. Again... this is not what the doc says to do, and it will cause problems because the "Lobby" Room is not an MMORoom.

Please stick to the documentation.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Stevenor and 61 guests