Skip to content

fix: apply the pve flag of a plot to attackers standing on the road - #4972

Open
TheMeinerLP wants to merge 1 commit into
IntellectualSites:mainfrom
TheMeinerLP:fix/pve-flag-for-attackers-on-road
Open

TheMeinerLP wants to merge 1 commit into
IntellectualSites:mainfrom
TheMeinerLP:fix/pve-flag-for-attackers-on-road

Conversation

@TheMeinerLP

Copy link
Copy Markdown
Member

Overview

The pve flag of a plot decides whether mobs and other non-player attackers may damage players and animals inside it. That only held for attackers standing on a plot. An attacker standing on the road next to the plot was not bound by the flag: with pve left at its default false, it could still damage a player or an animal inside the plot, while the very same attacker standing on a plot could not.

Checked in game on 7.6.1 with damage attributed to a wither, an ender dragon and a zombie placed over the road (/damage ... by <mob>): a cow in the plot went from 10 to 7 health and a player from 20 to about 17, and the same attacker placed inside the plot was refused. It could not be shown with a naturally behaving mob: a real wither left the road within a second and a hovering dragon dealt no damage in the time observed. So this closes an inconsistency in the rule rather than a demonstrated griefing method.

What changed

For attackers that are not players (and not projectiles fired by players), the pve flag of the victim's plot now decides regardless of whether the attacker stands on a plot or on the road.

Unchanged: attackers standing on a plot, attacker and victim both on the road (road flags decide as before), fireworks, plots with pve set to true, and everything about player attackers (pvp, animal-attack, hostile-attack, tamed-attack, misc-break, vehicle-break).

The end of BukkitEntityUtil#entityDamage moved into a small class without Bukkit types, NonPlayerDamage, so the rule can be tested. Apart from the one changed line the previous order of checks is kept.

Side effects

  • This applies to every non-player attacker outside a plot, not only withers and dragons: primed TNT, creepers, end crystals, area effect clouds, tamed wolves standing on the road.
  • As pve is off by default, nothing standing on the road damages players and animals inside a plot on a default setup any more, which is how it already worked inside plots.

Tests

14 cases for the rule: attacker on the road and victim in a plot (with and without pve, with the road flag set, arrows, fireworks), both in a plot, attacker in a plot and victim on the road, and both on the road. With the previous rule the two cases for a plot without pve fail.

These are the first tests in the Bukkit module; :plotsquared-bukkit:test runs them without changes to the build files.

Not covered

  • entityDamage itself, i.e. how locations, flags and entity types are turned into the inputs of the rule.
  • The opposite direction is left as it is: an attacker standing on a plot never damages a victim on the road, even if the pve road flag is set. A test records that as current behaviour.

A mob or other non-player attacker standing on the road could damage players and animals inside a plot whose pve flag is false, while the same attacker standing on a plot could not. The victim's plot now decides in both cases.
@TheMeinerLP
TheMeinerLP requested a review from a team as a code owner November 26, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant