Closed waiching514 closed 2 years ago
This happens because FabledSkyblock doesn't cancel EntityDamageByEntityEvent event for armorstands/itemframes in players islands if the player is not the owner.
This check is the cause. https://github.com/songoda/FabledSkyBlock/blob/7480e91b2db46f65246339f530f3d6c97cce21f1/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java#L34
Contact its developers and link them this issue page.
But this video show us fabledskyblock canceled damage armorstands/itemframes in players islands if the player is not the owner. https://youtu.be/DxUYTmqVllI
Okay but I have a code which checks for cancellation of this event, so it's strange.
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent
{
public FakeEntityDamageByEntityEvent(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, double damage)
{
super(damager, damagee, cause, damage);
}
public FakeEntityDamageByEntityEvent(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, @NotNull Map<DamageModifier, Double> modifiers, @NotNull Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions)
{
super(damager, damagee, cause, modifiers, modifierFunctions);
}
}
public static boolean canDamage(Entity attacker, Entity damaged) {
FakeEntityDamageByEntityEvent event = new FakeEntityDamageByEntityEvent(attacker, damaged, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
new EnumMap<>(ImmutableMap.of(EntityDamageEvent.DamageModifier.BASE, 0.0D)),
new EnumMap<EntityDamageEvent.DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(EntityDamageEvent.DamageModifier.BASE, Functions.constant(-0.0D)))
);
Bukkit.getPluginManager().callEvent(event);
boolean canDamage = !event.isCancelled();
event.setCancelled(true);
return canDamage;
}
I call it in my remove furniture code.
if(!LocationUtil.canDamage(player, entity)))
return;
I don't own FabledSkyBlock, so I coded a test plugin and it works fine. I can block removal of the furniture if the player has no damage permission.
@EventHandler
void onEntityDamageByEntityEvent(EntityDamageByEntityEvent e)
{
System.out.println("attack cancelled");
e.setCancelled(true);
}
Discord tag (optional)
WaichingXD#3322
What happened?
I got a bug, my server installed "fabledskyblock" skyblock plugin, when vistor no permission break the block and entity, but they can break the itemadder block
Steps to reproduce the issue
https://youtu.be/C-jf_ye9kO0
Server version
[08:59:08 INFO]: Checking version, please wait... [08:59:13 INFO]: This server is running Paper version git-Paper-792 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT) You are 2 version(s) behind Previous version: git-Paper-790 (MC: 1.16.5)
ItemsAdder Version
[08:59:40 INFO]: ItemsAdder version 2.5.2 [08:59:40 INFO]: Customized Minecraft without client mods! [08:59:40 INFO]: Website: devs.beer [08:59:40 INFO]: Author: LoneDev
ProtocolLib Version
[08:59:53 INFO]: ProtocolLib version 4.7.0 [08:59:53 INFO]: Provides read/write access to the Minecraft protocol. [08:59:53 INFO]: Authors: dmulloy2 and comphenix
LoneLibs Version
[09:00:11 INFO]: LoneLibs version 1.0.16b [09:00:11 INFO]: Collection of libs used by my plugins [09:00:11 INFO]: Authors: LoneDev and others
LightAPI Version (optional)
[09:00:28 INFO]: LightAPI version bukkit-5.1.0 (build SNAPSHOT) [09:00:28 INFO]: Bukkit library for edit light levels [09:00:28 INFO]: Website: https://github.com/BeYkeRYkt/LightAPI [09:00:28 INFO]: Authors: BeYkeRYkt and other contributors in GitHub
ItemsAdder config.yml