How to make a player take damage when they hit a mob with a specific custom item?

So I wanted to make a custom item called a “Noobs sword” … I’ve made the item but how do I make the player take damage when the player hits a mob with the noob sword??
and how do I add an effect to the mob it hits… I wanna add poison to the mob it hits. how do I do that?

I am not the best Developer but i would use the “EntityDamageByEntityEvent” Event to get the two Entitys and Trigger the Effects on them.

( First Checking if Damager is a Player and when yes checking for Item in Main Hand. With this you can check for the Item name and Trigger your Effects )

Here a Link to the API Page from the Event:

EntityDamageByEntityEvent (Paper-API 1.16.5-R0.1-SNAPSHOT API) (papermc.io)