Перейти к содержимому
Mineforgian

TogglePVPCustom

A simple Paper plugin that lets players individually toggle their PvP status on or off. It supports PlaceholderAPI, TAB below-name displays, and optional CombatLog integration to stop players from disabling PvP while in combat.

Загрузки
110
Подписчики
0
Обновлён
1 мая 2026 г.
Лицензия
MIT

Опубликован 30 апреля 2026 г.

Исходный код

TogglePVPCustom

TogglePVPCustom is a simple Paper Minecraft plugin that lets players turn their PvP status on or off individually.

PvP only works when both players have PvP enabled. If one player has PvP disabled, they cannot attack or be attacked by other players.

The plugin also supports PlaceholderAPI, so PvP status can be displayed in scoreboards, TAB, nametags, or below-name displays.

TogglePVPCustom can optionally hook into Frwostella's CombatLog plugin. It also has its own local combat timer, so players cannot use /pvp off to escape combat after a real successful PvP hit.


Features

  • Players can toggle their own PvP status.
  • Prevents attacking if the attacker has PvP disabled.
  • Prevents attacking players who have PvP disabled.
  • Saves player PvP status.
  • Configurable messages.
  • Reload command without restarting the server.
  • PlaceholderAPI support.
  • Optional native below-name scoreboard display.
  • TAB belowname-objective compatible.
  • Optional CombatLog support.
  • Local combat tracking after successful PvP hits.
  • Blocks /pvp, /pvp on, and /pvp off while combat tagged.
  • Prevents /pvp off from clearing CombatLog tags.
  • Configurable /pvp command cooldown.
  • Optional cooldown bypass permission.

Commands

Command Description
/pvp Toggle your PvP status
/pvp on Enable your PvP
/pvp off Disable your PvP
/pvp status Check your PvP status
/pvp reload Reload the plugin config

Alias:

/togglepvp

Permissions

Permission Description Default
togglepvp.use Allows players to use /pvp Everyone
togglepvp.reload Allows players to reload the plugin config OP
togglepvp.cooldown.bypass Allows players to bypass the /pvp command cooldown False

Optional Dependencies

These plugins are optional, but unlock extra features.

Plugin Required? Purpose
PlaceholderAPI Optional Enables PvP status placeholders
CombatLog Optional Lets TogglePVPCustom also check CombatLog combat status

In plugin.yml, the optional dependencies should be listed like this:

softdepend:
  - PlaceholderAPI
  - CombatLog

CombatLog is optional. TogglePVPCustom will still work without it because it also tracks successful PvP hits locally.


Combat Protection

TogglePVPCustom has two layers of combat protection:

  1. Local combat tracking after successful PvP hits.
  2. Optional CombatLog hook if Frwostella's CombatLog plugin is installed.

When combat protection is enabled, players cannot run PvP-changing commands while combat tagged:

/pvp
/pvp on
/pvp off

They can still use:

/pvp status

This prevents players from using /pvp off to escape combat.

Example config:

settings:
  pvp-toggle-block-seconds: 15

combatlog-hook:
  enabled: true
  plugin-name: "CombatLog"
  block-toggle-while-in-combat: true

Message:

messages:
  cannot-toggle-in-combat: "%prefix%&cYou cannot change your PvP status while in combat."

To disable combat-toggle blocking:

combatlog-hook:
  block-toggle-while-in-combat: false

To disable only the CombatLog hook:

combatlog-hook:
  enabled: false

PvP Command Cooldown

You can add a cooldown to:

/pvp
/pvp on
/pvp off

Example:

settings:
  pvp-command-cooldown-seconds: 5

Set it to 0 to disable the cooldown:

settings:
  pvp-command-cooldown-seconds: 0

Cooldown message:

messages:
  command-cooldown: "%prefix%&cPlease wait &e%time%s &cbefore using this command again."

Players with this permission bypass the cooldown:

togglepvp.cooldown.bypass

By default, this permission is set to false in plugin.yml, so OPs do not bypass the cooldown unless you give them the permission manually.


PlaceholderAPI Placeholders

For the player's own status, use:

%togglepvp_status%
%togglepvp_status_colored%
%togglepvp_value%
%togglepvp_enabled%

Examples:

%togglepvp_status% = ON / OFF
%togglepvp_status_colored% = &aON / &cOFF
%togglepvp_value% = 1 / 0
%togglepvp_enabled% = true / false

For another player's status in nametags, TAB layouts, or relational placeholders, use:

%rel_togglepvp_status%
%rel_togglepvp_status_colored%
%rel_togglepvp_value%
%rel_togglepvp_enabled%

TAB Belowname Setup

If you are using TAB for below-name status, disable the plugin's built-in belowname first in plugins/TogglePVPCustom/config.yml:

belowname:
  enabled: false

Then use this in TAB's config:

belowname-objective:
  enabled: true
  value: "%togglepvp_value%"
  title: ""
  fancy-value: "&cPVP: %togglepvp_status_colored%"
  fancy-value-default: "NPC"
  disable-condition: ""

After editing the configs, run:

/pvp reload
/papi reload
/tab reload

Do not put %togglepvp_status% in TAB's title, because that can show your own PvP status under other players. Use fancy-value instead.


Native Belowname Setup

The plugin also has its own native Minecraft below-name display.

Native below-name objectives can only show numbers, so it will display something like:

1 PvP
0 PvP

Example config:

belowname:
  enabled: true
  objective-name: "pvpstatus"
  display-name: "&cPvP"
  enabled-score: 1
  disabled-score: 0
  remove-on-disable: true

Use this only if you are not using TAB's belowname-objective, because two plugins controlling belowname at the same time can conflict.


Full Example Config

settings:
  # If true, new players have PvP enabled by default.
  default-pvp: true

  # Saves player PvP status into data.yml.
  save-player-status: true

  # Prevents spam when players keep trying to attack PvP-disabled players.
  attack-message-cooldown-seconds: 2

  # Cooldown before a player can use /pvp, /pvp on, or /pvp off again.
  # Set to 0 to disable.
  pvp-command-cooldown-seconds: 5

  # How long players cannot toggle PvP after a real successful PvP hit.
  # Match this with your CombatLog combat-time.
  pvp-toggle-block-seconds: 15

combatlog-hook:
  # Optional hook for Frwostella's CombatLog plugin.
  enabled: true

  # This must match the CombatLog plugin name in its plugin.yml.
  plugin-name: "CombatLog"

  # If true, players cannot change PvP status while they are combat tagged.
  block-toggle-while-in-combat: true

belowname:
  # This is the native Minecraft below-name objective.
  # Native below-name objectives can only show numbers, not text placeholders.
  enabled: true

  objective-name: "pvpstatus"

  # Shows like:
  # 1 PvP
  # 0 PvP
  display-name: "&cPvP"

  enabled-score: 1
  disabled-score: 0

  remove-on-disable: true

placeholders:
  status-on: "ON"
  status-off: "OFF"

  status-colored-on: "&aON"
  status-colored-off: "&cOFF"

messages:
  prefix: "&8[&cPvP&8] "

  no-permission: "%prefix%&cYou do not have permission to use this command."
  players-only: "%prefix%&cOnly players can use this command."
  reload: "%prefix%&aConfiguration reloaded."

  pvp-enabled: "%prefix%&aYour PvP is now ENABLED."
  pvp-disabled: "%prefix%&cYour PvP is now DISABLED."
  pvp-status-enabled: "%prefix%&aYour PvP is currently ENABLED."
  pvp-status-disabled: "%prefix%&cYour PvP is currently DISABLED."

  your-pvp-disabled: "%prefix%&cYou cannot attack while your PvP is disabled."
  target-pvp-disabled: "%prefix%&cYou cannot attack &e%target% &cbecause their PvP is disabled."

  cannot-toggle-in-combat: "%prefix%&cYou cannot change your PvP status while in combat."
  command-cooldown: "%prefix%&cPlease wait &e%time%s &cbefore using this command again."

  usage: "%prefix%&cUsage: /pvp [on|off|status|reload]"

Example plugin.yml

name: TogglePVPCustom
version: 1.1.0
main: jre.frwostella.togglePVPCustom.TogglePVPCustom
api-version: '1.21'
author: Frwostella
description: Allows players to individually toggle their PvP status.
softdepend:
  - PlaceholderAPI
  - CombatLog

commands:
  pvp:
    description: Toggle your PvP status.
    usage: /pvp [on|off|status|reload]
    aliases:
      - togglepvp

permissions:
  togglepvp.use:
    description: Allows players to use /pvp.
    default: true

  togglepvp.reload:
    description: Allows reloading the plugin config.
    default: op

  togglepvp.cooldown.bypass:
    description: Allows players to bypass the /pvp command cooldown.
    default: false

Installation

  1. Download or build the plugin .jar.
  2. Put the .jar file into your server's plugins folder.
  3. Install PlaceholderAPI if you want placeholder support.
  4. Install CombatLog if you want the plugin to also check CombatLog combat tags.
  5. Restart your server after replacing the .jar.
  6. Delete or manually update the old plugins/TogglePVPCustom/config.yml if new settings are missing.
  7. Run:
/pvp reload

Important Notes

After rebuilding the jar, you should restart the server.

Do not only use /pvp reload after changing the jar file.

If new config options are missing, either manually add them or delete the old config so the plugin can generate a new one.

The most important new config options are:

settings:
  pvp-command-cooldown-seconds: 5
  pvp-toggle-block-seconds: 15

combatlog-hook:
  block-toggle-while-in-combat: true

Requirements

  • Paper 1.21+
  • Java 21+

Optional:

  • PlaceholderAPI
  • CombatLog

Ченджлог

1.4.2Релиз26.1, 26.1.1, 26.1.2 · 1 мая 2026 г.

Changelog

TogglePVPCustom v1.4.2

Added

  • Added configurable /pvp command cooldown.
  • Added pvp-command-cooldown-seconds setting in config.yml.
  • Added pvp-toggle-block-seconds setting for local combat toggle protection.
  • Added togglepvp.cooldown.bypass permission.
  • Added local combat tracking after successful PvP hits.
  • Added protection against changing PvP status while combat tagged.
  • Added cannot-toggle-in-combat message.
  • Added command-cooldown message with %time% placeholder.

Changed

  • /pvp, /pvp on, and /pvp off are now blocked while the player is in combat.
  • /pvp status can still be used while in combat.
  • PvP toggle protection now works even if the CombatLog hook fails, because the plugin tracks combat locally.
  • togglepvp.cooldown.bypass now defaults to false, so OPs do not bypass cooldown unless the permission is manually given.

Fixed

  • Fixed an issue where players could escape combat by using /pvp off.
  • Fixed /pvp off removing CombatLog combat status.
  • Fixed command cooldown not working properly for OPs because of the bypass permission default.
  • Fixed combat protection relying only on the external CombatLog plugin.

Config Changes

Added:

settings:
  pvp-command-cooldown-seconds: 5
  pvp-toggle-block-seconds: 15
1.4.2Релиз1.21.9, 1.21.10, 1.21.11 · 1 мая 2026 г.

Changelog

TogglePVPCustom v1.4.2

Added

  • Added configurable /pvp command cooldown.
  • Added pvp-command-cooldown-seconds setting in config.yml.
  • Added pvp-toggle-block-seconds setting for local combat toggle protection.
  • Added togglepvp.cooldown.bypass permission.
  • Added local combat tracking after successful PvP hits.
  • Added protection against changing PvP status while combat tagged.
  • Added cannot-toggle-in-combat message.
  • Added command-cooldown message with %time% placeholder.

Changed

  • /pvp, /pvp on, and /pvp off are now blocked while the player is in combat.
  • /pvp status can still be used while in combat.
  • PvP toggle protection now works even if the CombatLog hook fails, because the plugin tracks combat locally.
  • togglepvp.cooldown.bypass now defaults to false, so OPs do not bypass cooldown unless the permission is manually given.

Fixed

  • Fixed an issue where players could escape combat by using /pvp off.
  • Fixed /pvp off removing CombatLog combat status.
  • Fixed command cooldown not working properly for OPs because of the bypass permission default.
  • Fixed combat protection relying only on the external CombatLog plugin.

Config Changes

Added:

settings:
  pvp-command-cooldown-seconds: 5
  pvp-toggle-block-seconds: 15
1.4.1Релиз26.1, 26.1.1, 26.1.2 · 30 апреля 2026 г.

Changelog

  • Added CombatLog integration to TogglePVPCustom.
  • Blocked PvP hits now clear CombatLog tags when a player has PvP disabled.
  • Added CombatLog as a soft dependency in plugin.yml.
  • Added new config option: combatlog-hook.clear-combat-on-blocked-pvp.
  • Improved event handling so PvP-blocked hits are cancelled earlier and cleaned up after other plugins.
1.4.1Релиз1.21.9, 1.21.10, 1.21.11 · 30 апреля 2026 г.

Changelog

  • Added CombatLog integration to TogglePVPCustom.
  • Blocked PvP hits now clear CombatLog tags when a player has PvP disabled.
  • Added CombatLog as a soft dependency in plugin.yml.
  • Added new config option: combatlog-hook.clear-combat-on-blocked-pvp.
  • Improved event handling so PvP-blocked hits are cancelled earlier and cleaned up after other plugins.
1.3Релиз26.1, 26.1.1, 26.1.2 · 30 апреля 2026 г.

Changelog

  • Updated the README to clarify that the current version supports Paper 26.1+.
  • Added Java 25 as the requirement for the current Paper 26.1+ version.
  • Added a notice directing Paper 1.21+ / 1.21.11 users to release 1.3.
  • Updated the Version Support and Requirements sections for clearer download/build guidance.
1.2Релиз1.21.9, 1.21.10, 1.21.11 · 30 апреля 2026 г.

Changelog

  • Added optional CombatLog plugin support.
  • Players can no longer disable PvP with /pvp off while they are in combat.
  • Added configurable CombatLog hook settings.
  • Added a new message for players who try to disable PvP during combat.

Комментарии

Загружаем…