EngineHub / WorldGuard

🛡️ Protect your Minecraft server and lets players claim areas
https://enginehub.org/worldguard/
Other
812 stars 528 forks source link

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

Closed SirLeezus closed 3 months ago

SirLeezus commented 3 months ago

WorldEdit Version

7.3.0

WorldGuard Version

7.0.9

Platform Version

Paper-450 1.20.4

Confirmations

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

wizjany commented 3 months ago

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.

SirLeezus commented 3 months ago

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.

SirLeezus commented 3 months ago

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

SirLeezus commented 3 months ago

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.