Skip to content
ChanceSD edited this page Oct 19, 2025 · 20 revisions

Maven details

Maven Repo:

<repository>
    <id>CodeMC</id>
    <url>https://repo.codemc.org/repository/maven-public/</url>
</repository>

Artifact Information:

<dependency>
    <groupId>me.chancesd.pvpmanager</groupId>
    <artifactId>pvpmanager</artifactId>
    <version>4.0.4</version>
    <scope>provided</scope>
</dependency>

Get a CombatPlayer

In most cases you will need a CombatPlayer instance. The static CombatPlayer.get() method should be preferred for compatibility with both the premium and free versions.

PvPManager pvpmanager;
// Check if PvPManager is enabled 
if (Bukkit.getPluginManager().isPluginEnabled("PvPManager"))
    pvpmanager = (PvPManager) Bukkit.getPluginManager().getPlugin("PvPManager");
if (pvpmanager == null)
    return;

Player player = Bukkit.getPlayerExact("ChanceSD");

// You can get a CombatPlayer either through the playerManager or directly with the static get method
CombatPlayer combatPlayer = CombatPlayer.get(player);
CombatPlayer combatPlayer = pvpmanager.getPlayerManager().get(player);

// Let's say we want to know if the player has newbie protection or is tagged
if (combatPlayer.isNewbie())
    combatPlayer.message("You are a newbie!");

if (combatPlayer.isInCombat())
    combatPlayer.message("You are in combat!");

Check if two players can PvP

CombatPlayer combatPlayer = CombatPlayer.get(player);
// You can check each individual protection like this
if (combatPlayer.hasRespawnProtection())
    combatPlayer.message("You can't be attacked");

// Or ideally, what you probably want is to check if there's any protections at all
// This returns a boolean, true if the two players can attack each other, false otherwise
boolean canAttack = pvpmanager.getPlayerManager().canAttack(Player attacker, Player defender);

// This returns a ProtectionResult with the reason why the attack was blocked
ProtectionResult result = pvpmanager.getPlayerManager().checkProtection(Player attacker, Player defender);
if (result.isProtected())
    // One of the players is protected, attack should be cancelled
if (result.type() == ProtectionType.NEWBIE)
    // Specifically blocked due to newbie protection

// You can also check if they can attack (opposite of isProtected)
if (result.isVulnerable())
    // Players can attack each other

Additionally, there are events you can listen to, see below for a list.

PvPManager Events

There are some PvPManager events you can listen to. You can find a current list here
At the time of writing these are the existing events:

You can listen to them as you would any other Bukkit event.
Feel free to suggest more events or improvements to them.

Combat Log NPCs

The premium version of PvPManager spawns NPCs on combat log instead of killing on logout.
For the convenience of other plugins that need to check for this, they have a few metadata values.

Player player;
if (player.hasMetadata("NPC"))
    // Easy check if you need to ignore Player NPCs, Citizens also uses this afaik

if (player.hasMetadata("combat_log_npc"))
    // Specific check for PvPManager combat log NPCs
    // If the player is a combat log NPC, you can get the original player's UUID (the one that logged out) like this
    UUID playerUUID = (UUID) player.getMetadata("combat_log_npc").get(0).value();

Pull Requests are always welcome if you have anything you would like added or fixed.
If you have questions, feel free to ask in discord or in the Spigot/Bukkit thread.

Clone this wiki locally