EngineHub/WorldGuard

Invincible flag bug when riding entities you normally can't outside the protected region

SirLeezus opened this issue · 4 comments

WorldEdit Version

7.3.0

WorldGuard Version

7.0.9

Platform Version

Paper-450 1.20.4

Confirmations

  • I am using the most recent Minecraft release.
  • I am using a version of WorldEdit compatible with my Minecraft version.
  • I am using a version of WorldGuard compatible with my Minecraft version.
  • I am using the latest or recommended version of my platform software.
  • I am NOT using a hybrid server, e.g. a server that combines Bukkit and Forge. Examples include Arclight, Mohist, and Cardboard.
  • I am NOT using a fork of WorldEdit, such as FastAsyncWorldEdit (FAWE) or AsyncWorldEdit (AWE)

Bug Description

I created a pet plugin where the player can ride entities they normally can't. On a very fundamental level the plugin just simply adds the player as a passenger on the entity entity.addPassenger(player) and has a custom controller for movement. For some reason when a player rides one of these custom pets in a protected region with the flag "invincible" on and then leaves that region they are still invincible, as if they were still in the region. As soon as the player unmounts they'll start taking damage again.

Expected Behavior

I expected to not be invincible when leaving the region on a entity you normally can't ride.

Reproduction Steps

  1. Create a region with the invincible flag on
  2. Ride custom entity entity.addPassenger(player) in region
  3. Move outside of region while still riding entity and try and take damage
    https://gyazo.com/2c611052b8c21bf33c7ade6401295a2f

Optional WorldGuard-Report

No response

Anything Else?

No response

i would guess this is because the platform doesn't throw VehicleMoveEvent for non-Vehicle entities, and since spigot also doesn't have EntityMoveEvent, there's no way for us to track this really.

i would guess this is because the platform doesn't throw VehicleMoveEvent for non-Vehicle entities, and since spigot also doesn't have EntityMoveEvent, there's no way for us to track this really.

Yup, you are 100% correct, resolved it with this code:

@EventHandler
  public void onRidingPet(PlayerMoveEvent e) {
    if (e.getPlayer().getVehicle() == null) return;
    if (!pets.getPetManager().isPet(e.getPlayer().getVehicle())) return;
    Bukkit.getServer().getPluginManager().callEvent(new VehicleMoveEvent((Vehicle) e.getPlayer().getVehicle(), e.getFrom(), e.getTo()));
  }

Thank you! I'll close this now.

nvm, that did not resolve the problem. Not sure why but it sometimes works correctly, threw me off.

Due to not being able to track this, I'll just go ahead and close it again. I resolved it by simply not allowing pet riding in regions.