TogglePVPCustom
TogglePVPCustom 是一款简单的 Paper Minecraft 插件,允许玩家单独开启或关闭自己的 PvP 状态。
只有当两名玩家的 PvP 均处于开启状态时,PvP 才会生效。如果其中一名玩家禁用了 PvP,则无法攻击其他玩家,也不会被其他玩家攻击。
该插件支持 PlaceholderAPI,因此可以在计分板、TAB 列表、名称标签或名字下方的显示中展示 PvP 状态。
TogglePVPCustom 可以选择性地与 Frwostella 的 CombatLog 插件挂钩。它还拥有本地的战斗计时器,以防止玩家在受到真正的 PvP 伤害后使用 /pvp off 来逃避战斗。
功能
- 玩家可以切换自己的 PvP 状态。
- 如果攻击者禁用了 PvP,则阻止其发起攻击。
- 阻止攻击已禁用 PvP 的玩家。
- 保存玩家的 PvP 状态。
- 可自定义消息。
- 无需重启服务器即可重载插件配置。
- 支持 PlaceholderAPI。
- 可选的原生名字下方(below-name)计分板显示。
- 兼容 TAB 的 belowname-objective。
- 可选的 CombatLog 支持。
- 在成功击中 PvP 目标后追踪本地战斗状态。
- 在被标记为战斗状态期间,拦截
/pvp、/pvp on 和 /pvp off 命令。
- 防止
/pvp off 清除 CombatLog 的战斗标签。
- 可配置的
/pvp 命令冷却时间。
- 可选的冷却时间绕过权限。
命令
| 命令 |
描述 |
/pvp |
切换你的 PvP 状态 |
/pvp on |
启用你的 PvP |
/pvp off |
禁用你的 PvP |
/pvp status |
检查你的 PvP 状态 |
/pvp reload |
重载插件配置 |
别名:
/togglepvp
权限
| 权限 |
描述 |
默认值 |
togglepvp.use |
允许玩家使用 /pvp 命令 |
所有人 |
togglepvp.reload |
允许玩家重载插件配置 |
OP |
togglepvp.cooldown.bypass |
允许玩家绕过 /pvp 命令的冷却时间 |
False |
可选依赖
这些插件是可选的,但能解锁额外功能。
| 插件 |
是否必需? |
用途 |
| PlaceholderAPI |
可选 |
启用 PvP 状态的占位符 |
| CombatLog |
可选 |
让 TogglePVPCustom 同时检查 CombatLog 的战斗状态 |
在 plugin.yml 中,可选依赖应按如下方式列出:
softdepend:
- PlaceholderAPI
- CombatLog
CombatLog 是可选的。即使没有安装它,TogglePVPCustom 仍能正常工作,因为它也会在本地追踪成功的 PvP 命中。
战斗保护
TogglePVPCustom 具有两层战斗保护机制:
- 在成功击中 PvP 目标后进行本地战斗追踪。
- 如果安装了 Frwostella 的 CombatLog 插件,则可选地挂钩 CombatLog。
当启用战斗保护时,处于战斗标签状态下的玩家无法运行改变 PvP 状态的命令:
/pvp
/pvp on
/pvp off
他们仍然可以使用:
/pvp status
这可以防止玩家使用 /pvp off 来逃避战斗。
示例配置:
settings:
pvp-toggle-block-seconds: 15
combatlog-hook:
enabled: true
plugin-name: "CombatLog"
block-toggle-while-in-combat: true
消息配置:
messages:
cannot-toggle-in-combat: "%prefix%&cYou cannot change your PvP status while in combat."
要禁用战斗期间的切换拦截:
combatlog-hook:
block-toggle-while-in-combat: false
要仅禁用 CombatLog 挂钩:
combatlog-hook:
enabled: false
PvP 命令冷却时间
你可以为以下命令添加冷却时间:
/pvp
/pvp on
/pvp off
示例:
settings:
pvp-command-cooldown-seconds: 5
将其设置为 0 以禁用冷却时间:
settings:
pvp-command-cooldown-seconds: 0
冷却消息:
messages:
command-cooldown: "%prefix%&cPlease wait &e%time%s &cbefore using this command again."
拥有此权限的玩家将绕过冷却时间:
togglepvp.cooldown.bypass
默认情况下,此权限在 plugin.yml 中设置为 false,因此除非你手动赋予权限,否则 OP 不会绕过冷却时间。
PlaceholderAPI 占位符
对于玩家自身的状态,请使用:
%togglepvp_status%
%togglepvp_status_colored%
%togglepvp_value%
%togglepvp_enabled%
示例:
%togglepvp_status% = ON / OFF
%togglepvp_status_colored% = &aON / &cOFF
%togglepvp_value% = 1 / 0
%togglepvp_enabled% = true / false
对于名称标签、TAB 布局或关系占位符中的其他玩家状态,请使用:
%rel_togglepvp_status%
%rel_togglepvp_status_colored%
%rel_togglepvp_value%
%rel_togglepvp_enabled%
TAB Belowname 设置
如果你正在使用 TAB 进行名字下方状态显示,请先在 plugins/TogglePVPCustom/config.yml 中禁用插件内置的 belowname 功能:
belowname:
enabled: false
然后在 TAB 的配置中使用以下内容:
belowname-objective:
enabled: true
value: "%togglepvp_value%"
title: ""
fancy-value: "&cPVP: %togglepvp_status_colored%"
fancy-value-default: "NPC"
disable-condition: ""
编辑完配置后,运行以下命令:
/pvp reload
/papi reload
/tab reload
不要将 %togglepvp_status% 放入 TAB 的 title 中,因为这会在其他玩家名下显示你自己的 PvP 状态。请改用 fancy-value。
原生 Belowname 设置
该插件还自带原生的 Minecraft 名字下方(below-name)显示功能。
原生 belowname 目标只能显示数字,因此它将显示类似以下内容:
1 PvP
0 PvP
示例配置:
belowname:
enabled: true
objective-name: "pvpstatus"
display-name: "&cPvP"
enabled-score: 1
disabled-score: 0
remove-on-disable: true
仅在未使用 TAB 的 belowname-objective 时使用此功能,因为两个插件同时控制 belowname 可能会发生冲突。
完整示例配置
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
# 玩家再次使用 `/pvp`、`/pvp on` 或 `/pvp off` 之前的冷却时间。
# 设置为 0 以禁用。
pvp-command-cooldown-seconds: 5
# 玩家在成功击中对方后,无法切换 PvP 状态的时长。
# 请与你的 CombatLog combat-time 保持一致。
pvp-toggle-block-seconds: 15
combatlog-hook:
# 可选的 Frwostella's CombatLog 插件钩子。
enabled: true
# 这必须与其 plugin.yml 中的 CombatLog 插件名称匹配。
plugin-name: "CombatLog"
# 如果为 true,玩家在处于战斗标记状态时无法更改 PvP 状态。
block-toggle-while-in-combat: true
belowname:
# 这是原生的 Minecraft below-name 目标。
# 原生 below-name 目标只能显示数字,不能显示文本占位符。
enabled: true
objective-name: "pvpstatus"
# 显示效果如下:
# 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%&c你没有权限使用此命令。"
players-only: "%prefix%&c只有玩家才能使用此命令。"
reload: "%prefix%&a配置已重新加载。"
pvp-enabled: "%prefix%&a你的 PvP 现已启用。"
pvp-disabled: "%prefix%&c你的 PvP 现已禁用。"
pvp-status-enabled: "%prefix%&a你的 PvP 当前处于启用状态。"
pvp-status-disabled: "%prefix%&c你的 PvP 当前处于禁用状态。"
your-pvp-disabled: "%prefix%&c当你的 PvP 被禁用时,你无法进行攻击。"
target-pvp-disabled: "%prefix%&c你无法攻击 &e%target% &c,因为其 PvP 已被禁用。"
cannot-toggle-in-combat: "%prefix%&c在战斗中,你无法更改自己的 PvP 状态。"
command-cooldown: "%prefix%&c请等待 &e%time%s &c后再使用该命令。"
usage: "%prefix%&c用法: /pvp [on|off|status|reload]"
---
## `plugin.yml` 示例
```yml
name: TogglePVPCustom
version: 1.1.0
main: jre.frwostella.togglePVPCustom.TogglePVPCustom
api-version: '1.21'
author: Frwostella
description: 允许玩家单独切换自己的 PvP 状态。
softdepend:
- PlaceholderAPI
- CombatLog
commands:
pvp:
description: 切换你的 PvP 状态。
usage: /pvp [on|off|status|reload]
aliases:
- togglepvp
permissions:
togglepvp.use:
description: 允许玩家使用 /pvp。
default: true
togglepvp.reload:
description: 允许重新加载插件配置。
default: op
togglepvp.cooldown.bypass:
description: 允许玩家绕过 /pvp 命令的冷却时间。
default: false
安装
- 下载或构建插件
.jar 文件。
- 将
.jar 文件放入服务器的 plugins 文件夹中。
- 如果需要占位符支持,请安装 PlaceholderAPI。
- 如果需要插件检查 CombatLog 的战斗标记,请安装 CombatLog。
- 替换
.jar 文件后重启服务器。
- 如果缺少新的设置项,请删除旧的
plugins/TogglePVPCustom/config.yml 或手动更新它。
- 运行:
/pvp reload
重要提示
重新构建 jar 包后,你应该重启服务器。
不要仅在更改 jar 文件后使用 /pvp reload。
如果缺少新的配置选项,请手动添加它们或删除旧配置文件,以便插件生成新的配置文件。
最重要的新配置选项是:
settings:
pvp-command-cooldown-seconds: 5
pvp-toggle-block-seconds: 15
combatlog-hook:
block-toggle-while-in-combat: true
要求
可选:
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:
- Local combat tracking after successful PvP hits.
- 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
- Download or build the plugin
.jar.
- Put the
.jar file into your server's plugins folder.
- Install PlaceholderAPI if you want placeholder support.
- Install CombatLog if you want the plugin to also check CombatLog combat tags.
- Restart your server after replacing the
.jar.
- Delete or manually update the old
plugins/TogglePVPCustom/config.yml if new settings are missing.
- 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
Optional:
评论 0
登录后参与评分
还没有评论,来抢沙发吧