Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

1.7.10 Detect if player has mod server-side


Blackout
 Share

Recommended Posts

I know this is not reliable.

 

Its for my mod Forge Creeper Heal.

I've done a profiler, see there :

 

Actually I send a packet to player with profiling data, so if client doesn't have mod he can't see profiling data. So I want to send him a chat message if he doesn't have mod clientside installed.

So this is just for ergonomic purpose, not security ;)

Link to comment
Share on other sites

You can use FMLNetworkEvent.CustomPacketRegistrationEvent to detect when a player registers a network channel:

 

if (event.operation.equals("REGISTER") && event.registrations.contains("myNetworkChannel") && event.handler instanceof NetHandlerPlayServer) {
    // player has your mod
}

 

Now store that information by e.g. registering an IExtendedEntityProperties then you can check if that is present later.

Link to comment
Share on other sites

Hum I can't get Player instance using this way, but I didn't know this annotation. Very interessant functionnality, I could surely be usefull to me on other devs.

I finally find an other solution. Client send a paquet with his mod version when he connect to the server. If server receive this paquet, it fix modVersion with extended properties else it's mean client doesn't have the mod installed.

 

Thanks

Link to comment
Share on other sites

You can indeed not get the player in that method, but you don't need it. In that method you just check that either:

- the client does not have your mod installed (fine)

- the client does have your mod installed and the version is valid (fine)

- the client does have your mod installed and the version is not valid (not fine, FML will not allow the connection)

 

Then later you detect if the network channel is present (= your mod is installed). Here you do not need to check the version since only people with the correct version are allowed to connect.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.