PR: 4.3.0-PVP hooks for PVE plugins.
Hello! I propose adding universal hooks OnPlayerEnterPVP
and OnPlayerExitPVP
for adding/removing players to/from a PvP mode/zone.
These universal hooks are specifically intended for PvE plugins. They allow PvP makers to notify PvE plugins about which players to mark/unmark with a PvP flag, especially by passing zone IDs, as players can be in multiple zones at once.
This also allows unsubscribing from the OnEnterZone/OnLeaveZone(ZoneManager)
hooks and avoids unnecessary calls to the API method IsDynamicPVPZone(DynamicPVP)
every time the ZoneManager
hooks are triggered, especially when there are many other zones aside from yours.
Additionally, the OnPlayerExitPVP
hook includes the option to pass the PvP delay, which helps avoid extra hooks for PvP delay, as a player might still be in other PvP zones when leaving one, causing your PvP delay hook to trigger frequently and making it less useful.
In your case, in version 4.3.0, you only need to add 3 lines.
If you modify the conditions in OnLeaveZone
, it's just 2 lines.
At line 1717:
Interface.CallHook("OnPlayerEnterPVP", player, zoneId);// Inform PvE plugins that they need to mark the player with a PvP flag and pass the unique PvP zone ID
At line 1754:
Interface.CallHook("OnPlayerExitPVP", player, zoneId);// Inform PvE plugins when a player leaves a PvP zone, passing the unique PvP zone ID, WITHOUT the PvP delay
At line 1757:
Interface.CallHook("OnPlayerExitPVP", player, zoneId, baseEvent.PvpDelayTime);// Inform PvE plugins when a player leaves a PvP zone, passing the unique PvP zone ID, WITH the PvP delay