Hello! How do i use the SlapperHitEvent to create an ongoing tally (in a config) of how many players have hit the npc? The config should have the name of the npc with an integer next to it to show the popularity of that slapper to give me a better idea of what npc's to use and where to put them. Great if someone could talk me through how to do this. Thanks, mc atech.
Hi, in PmmP there exist no "SlapperHitEvent". This event, has certainly been created by a plugin. You should tell us which Slapper plugin you use and show your previous attempts
Please don't post these useless comments. There only is one slapper plugin, https://github.com/jojoe77777/Slapper. Alright, first, I hope you do know how to listen for events? Just implement Listener, register events in the PluginBase. Okay then, let's get to the point. The SlapperHitEvent has a getDamager() function to return the player that hit the slapper, and a getEntity() function to return the entity/slapper that got slapped by that player. You can't see that function in the file, as it extends EntityEvent which has that function already. I'm not sure how exactly you want to do this, but I'd recommend something along the lines of listening for SlapperCreationEvent, getting the name of the entity by doing SlapperCreationEvent->getEntity()->getNameTag(), then storing that name in an array (a property) with 0 as value and the name as key. Then everytime when an entity gets hit, increment that number by one, by checking the nametag of the slapper hit using the method above but on SlapperHitEvent. When your plugin disables, you would want to store that array you made. You could do yaml_emit_file("path/to/file", $arrayMentionedAbove); to store that data. Then when your plugin enables again, you check if that file exists, then fill the array mentioned above with yaml_parse_file("path/to/file"); and the process repeats again.