Minecraft: sword that does no harm?

to
2

Can I use Minecraft with a command to get a sword, which can't do any harm?

If so which command would that be?

Th

With a plugin that is definitely possible. For example, With Essentials (you have to activate in the Config but before) you can do / enchant sharpness -10000. (That does not do any negative damage but just no damage).
You could google for a give command generator. Maybe it works with it too

Je

Yes it would with / testfor [player name] {Inventory: [{id: "minecraft: diamond_sword"}]}

this command would have to be constantly retrieved and then a comparator would need another command block with the command

/ effect give [player name] 18 1 true