ChanceSD / PvPManager

A Spigot/Paper plugin to toggle PvP, stop combat log, protect new players and much more
https://www.spigotmc.org/resources/pvpmanager.845/
Other
128 stars 44 forks source link

Does PvPManager take over the playerKillPlayer event entirely? #497

Closed TomLewis closed 2 months ago

TomLewis commented 2 months ago

Describe the bug

My CMI playerKillPlayer EventCommands stopped working recently, but all the other event commands work fine, the only thing I can think of is that PvPmanager could also be listning to this server event and somehow taking it over, this has been working for a long time and seems to be a recent issue.

If this is likley, is it possible to work with CMI to make sure that the eventCommands are not broken.

I have just noticed you also have Player Kills.Commands On Kill with and so I could migrate my commands to PvPmanager, BUT the issue I have is that sometimes we get a confict where the commands will run Via CMI and I presume, the other times when they dont run in CMI they are trying to be run in PvPManager, Im not sure if disabeling CMIs playerKillPlayer event lets PvPManager listen entirely or vice versa

This is my CMI config just incase you wanted to re-produce. Sends kill titles, resets back and sends a sound, /ho is just a staff message to try and diagnose if it was even firing!

CMI does have quite a few more options/placeholders when it comes to options too, might be worth adding a few so you match!

playerKillPlayer:
  # [sourceName] to insert source player name
  # [sourceDisplayName] to insert player display name
  # [sourceLvl] to insert player level
  # [sourceExp] to insert player total exp
  # [sourceHp] to insert player health
  # [sourceMaxHp] to insert player max health
  # [sourceHunger] to insert player hunger level
  # [sourceGameMode] to insert player gamemode
  # Keep in mind that in case you are using specialized commands, then Commands section will be performed on player who died and SourceCommands will be performed on player who killed
  Enabled: true
  Commands:
  - cmi titlemsg [sourceName] &4&l⚔ &4Killed &c[playerName]\n&7%otherplayer_iteminhand_[sourceName]%
    -in:20 -out:20 -keep:80
  - cmi sound chime [sourceName]
  - cmi titlemsg [playerName] &c[sourceName]&7 Killed you!\n%otherplayer_iteminhand_[sourceName]%
    -in:20 -out:20 -keep:100
  - cmi resetback [playerName] -death
  - ho [sourceName] killed [playerName]
  SourceCommands: []

To reproduce the bug

  1. Use CMI and in Settings/modules.yml enable eventCommands: true Reboot the server to enable.
  2. In Settings/EventCommands.yml set playerKillPlayer Enabled: true and set some commands
  3. Commands do not fire from CMI playerKillPlayer

Plugin and Server version

[15:28:07] [Server thread/INFO]: PvPManager version 3.32.13 [15:28:07] [Server thread/INFO]: A powerful plugin to manage various PvP combat features [15:28:07] [Server thread/INFO]: Website: https://www.spigotmc.org/resources/pvpmanager.10610/ [15:28:07] [Server thread/INFO]: Author: ChanceSD

Additional information

Also posted to CMI to see which plugin is at fault here https://github.com/Zrips/CMI/issues/8737

TomLewis commented 2 months ago

Update; I moved all commands to PvPManager kill commands and it does fire the commands now, so ive figured out this is the issue and you cant have 2 plugins listening to the same event!

But the use of is horrendus in PvPManager, it just says the material name! Oof. CMI's placeholder %otherplayer_iteminhand_[sourceName]% shows the items name if it has one, and formats the text if its not got one so its not a title with a big underscore in it!

image

ChanceSD commented 2 months ago

There is no playerKillPlayer event or commands, only the player death event and no plugin can take it over. If CMI isn't running commands that's a CMI issue obviously.

Edit: Also, %otherplayeriteminhand[sourceName]% seems like a placeholder from a PlaceholderAPI expansion https://api.extendedclip.com/expansions/otherplayer/, not from CMI, but could be mistaken. PvPManager isn't currently parsing placeholders on those commands though.

TomLewis commented 2 months ago

I think you missed the point of this ticket. PvPManager is preventing CMI from being able to use its playerKillPlayer event tracker that fires commands.

ChanceSD commented 2 months ago

Like I said, there is no such event in the Bukkit API, nor can any plugin stop others from detecting deaths and check if they were caused by other players.

ChanceSD commented 2 months ago

Well there it is, the placeholder should now display the item's name, if there is one. About CMI's issue, that's up to them, completely unrelated to PvPManager in case that wasn't made clear.

TomLewis commented 2 months ago

Thats why I made 2 tickets, all I could do was testing with removing plugins to see why the CMI player PvP event via CMI wasnt firing the commands.

I will try the CMI placeholder in PvPmanager if placehodler API is supported.

ChanceSD commented 2 months ago

I understand, I was just trying to explain that there is no event for commands, every plugin just listens to the death event and then can do whatever they want. In this case, both the plugins run commands on death (caused by player), but each plugin could run 100 commands if they wanted and they wouldn't affect each other. Currently the commands aren't parsed for placeholderAPI placeholders though, so the CMI one won't work, only <item> should work.

TomLewis commented 2 months ago

Msut have been lost in translaton, I was just observing the outcome of removing PvPManger allwoed it to work again, so I preusmed it was blocking the death event being read by CMI, becuase of the oddities of sometimes CMI would run its commands and others PvPManger would run its commands.

Which is weird, as I assumed you couldnt block game events as its a listening, wasnt sure why, hecne a ticket on each plugin to see if someone could figure out why.

Currently the commands aren't parsed for placeholderAPI placeholders though

Oof. Can they? That then solves showing the item name if it has one so you dont have to go through adding that to your <item>. Or alterantivly upgrade to match CMI's placeholder feature.

ChanceSD commented 2 months ago

Oof. Can they? That then solves showing the item name if it has one so you dont have to go through adding that to your

That's what I was saying in the comment 8h ago, I already added it, the <item> placeholder from pvpmanager displays the item name now, if using the latest version uploaded to spigot. But if it's really really necessary I could make commands parse placeholders I guess.

As for why removing one plugin made the commands run, no idea, could be a coincidence. As far as I know there could be no interference, maybe if one of the plugins throws an error it could do something.

TomLewis commented 2 months ago

the update now popped up on Spigot for me, maybe it was cached at Cloudflare.

Ill get it updated and get some testing done.