WorldGuard Build Permissions is blocking Damage from Sentinel NPC's that throw Splash Potions
LadyCailinBot opened this issue ยท 6 comments
WORLDGUARD-4015 - Reported by davidbla.1
Hey Guys,
first I'd like to thank you for this awesome work.
I discovered an issue with worldguard's build permissions and splash potions throwed by an sentinel npc.
I'm not realy sure how this is handled in BuildPermissionsListener
From my perspective of view (just quickly scanned this file) maybe Object rootCause = event.getCause().getRootCause();
returns a Player object and thats why it becomes canceled?
I'll try to validate this by setting the .damage
permissions so that :
(!hasBuildPermission(player, "entity." + type.name().toLowerCase() + ".damage") && !hasBuildPermission(player, "entity.damage." + type.name().toLowerCase()))
will be true.
Thank you
Comment by davidbla.1
I was not able to get damage with this permissions:
worldguard.build.entity.player.damage
worldguard.build.entity.damage
worldguard.build.entity.*
worldguard.build.*
worldguard.*
But if I disable build permission nodes in the worldguard config file - all is working like expected.
I created a local server and created this listener for quick debugging
public void onDamage(EntityDamageEvent event){ Object rootCause = event.getCause(); if (rootCause instanceof Player) { System.out.println("rootCause ist instanceOf Player"); } final EntityType type = event.getEntity().getType(); System.out.println("type.getName ist : '" + type.getName()+"'"); }
type.getName()
returns 'null' if damaged entity is a player or a citizens npc.
for normal bukkit npcs it returns "creeper", "skeletton" etc.
But also event.getCause();
was no instance of player - but I was not able to get event.getCause().getRootCause();
seems I linked a wrong library.
Comment by me4502
The root cause of the damage event, will be the Sentinel NPC. As that plugin is making it actually have a Player instance and throw events, you'd have to give the NPC the permissions to allow it to damage entities.
Comment by davidbla.1
Okay, if the root cause is a sentinel npc and if it is a Player instance it's obvious why the event is cannceled - but, this happens only with splash_potions.
Arrow, Sword etc. damage are working.
I'm not sure but I think it don't work this way - I'm not able to grant permissions to an npc.
It seems like the NPC (Player?) has no player.hasPermission();
- or even better, it has no UUID that could be handled by Permission plugin?
I talked with mcmonkey who is the developer of sentinel and contributor of citizen and denizen about his issue and he told me that "other plugins are recommended to not treat npc's behavior by doing metadata checks" (I'm using sth. like boolean isNPC=entity.hasMetadata("NPC");
)
I tried to build worldguard by myselfe and try this change but I was not successfull to get a working jar artifact.... yet ;)
Comment by davidbla.1
Hey @wizjany thank you for your work!
Could you please add the other issue number if you declare some issues as duplicate?
The reason why I was opening this issue is just because I wasn't able to find an issue that addresses this.
To be in touch and give me a opportunity to follow the fixing process and be informed in case of release of this fix, it would be awesome to be able to watch the active ticket.
Thank you again and have a nice day :)
Comment by davidbla
Hey @wizjany thank you for your work!
Could you please add the other issue number if you declare some issues as duplicate?
The reason why I was opening this issue is just because I wasn't able to find an issue that addresses this.
To be in touch and give me a opportunity to follow the fixing process and be informed in case of release of this fix, it would be awesome to be able to watch the active ticket.
Thank you again and have a nice day :)