PVP Flagging
Lets players flag themselves in or out of PvP. Both players must be flagged for combat to happen, and admins can define PvP zones.
📖 Introduction
PVP Flagging is a server utility mod that lets players opt themselves into or out of PvP. The core rule is simple: both players must be flagged for PvP to occur. If either side is unflagged, no damage passes between them.
Commands (from PvpFlagCommand and PvpZoneCommand in the source)
- /pvpFlag — with no argument it flips your current state; on, off and status also work. Permission level 0, so anyone can use it.
- /pvpZone add — define a zone; buffer is the margin in which the approach warning fires.
- /pvpZone add_chunk [buffer] — turn the chunk you are standing in into a zone; buffer defaults to 8.
- /pvpZone remove and /pvpZone list — remove and inspect. The pvpZone commands require permission level 2 (OP).
Zones are defined by x/z only. There is no height bound, so the same x/z covers everything from bedrock to build limit.
Unflagging is delayed. Turning PvP off isn't instant: it takes 15 seconds by default (configurable). Taking or dealing damage during that window cancels the request, and logging out resets the timer. It exists so nobody can flag out mid-fight and walk away.
PvP zones — entering an admin-defined zone flags you automatically. A warning appears as you approach, and the size of that warning area is configurable.
Status display — flagged players get a red sword marker on their nametag and in the tab list. Your own state shows as a separate HUD icon whose corner (bottom-left by default) and visibility are configurable.
⚠ Scoreboard teams bypass the flag rule entirely. The canHarmPlayer mixin only checks both players' flags when the attacker is not on a team. On a team it defers to vanilla team rules: allies follow the friendly-fire setting, and players on a different team can be hit regardless of flags. Servers that use teams need to account for this first.
Server note — on a dedicated server, pvp=true must be set in server.properties for the mod to work. Single-player LAN worlds need no setup.
Config — six server options and four client options. player_login_state (default PRESERVE) and player_respawn_state (default UNFLAG) choose whether joining or respawning preserves, sets or clears your flag; then unflag_wait_time_ticks (default 300 ticks = 15s), pvp_zone_bounds_check_ticks (default 20), display_welcome_message (on), and pvp_damage_multiplier (default 1.0), which scales player-versus-player damage. The client side covers the HUD icon: enabled, corner, and x/y offset.
🕒 When to Use This Mod
On friend or small multiplayer servers where you want to prevent unwanted PvP, or open only specific areas to combat.
📦 Where It Matters Most
Multiplayer servers with PvP enabled, where you want only consented duels and no incidental player damage.
🎮 How It Changes Your Playthrough
Players simply can't hurt each other by default; combat only starts when both sides have opted in.
🚀 Getting Started — First 30 Minutes
Step 1 — On a server, confirm pvp=true in server.properties.
Step 2 — Run /pvpFlag status to see your own state.
Step 3 — For a duel, both players run /pvpFlag on. For a permanent combat area, an admin defines one with /pvpZone add.
💡 Gameplay Tips
- On a dedicated server, check
pvp=trueinserver.propertiesfirst — the mod does nothing without it. - A duel needs both sides to run
/pvpFlag on— one-sided flagging does nothing. - Create arenas with
/pvpZone add— you can set the size of the approach-warning area too. - For a single-chunk arena use
/pvpZone add_chunk— it turns the chunk you are standing in into a zone with no coordinates to type.
⚠️ Common Confusing Points
- • Turning PvP off doesn't take effect immediately — there's a 15-second delay by default, and any damage in that window cancels it.
- • "My attacks don't land" usually isn't a bug — if the other player isn't flagged, that's the intended behavior. Check the nametag overlay.
- • You cannot unflag while inside a PvP zone — the request is refused with "You cannot unflag inside a PVP zone." Step outside first.
- • Being on a team overrides flagging — players on another team can hit you regardless of flags. That is the behavior in the source, not a bug.
❓ FAQ
How does it work?
Each player toggles their own state with /pvpFlag on|off. Both sides must be flagged for damage to pass between them. Admins can define auto-flagging zones with /pvpZone.
Why the 15-second wait to unflag?
To stop players flagging out mid-fight. Taking or dealing damage during the wait cancels the request, and logging out resets the timer. The delay is configurable.
How do I tell if someone is flagged?
A nametag overlay shows PvP status, and /pvpFlag status reports your own.
Does the server need extra setup?
A dedicated server needs pvp=true in server.properties. Single-player LAN worlds need nothing.
Does it still work on a server that uses teams?
Not as you would expect. The canHarmPlayer mixin checks both players' flags only when the attacker is not on a scoreboard team. On a team it falls through to vanilla rules: allies follow the friendly-fire setting, and other teams can be attacked regardless of flags.