PluginBugs / Issues-ItemsAdder

Repository used to keep track of issues of my plugin ItemsAdder
https://itemsadder.devs.beer
55 stars 21 forks source link

FabledSkyblock furniture removal permission not working #1411

Closed waiching514 closed 2 years ago

waiching514 commented 2 years ago

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

```shell metrics: true update-checker: true disable-plugin-loading-messages_DONT_ASK_ME_FOR_SUPPORT_IF_YOU_SET_TRUE__THANKS: false resource-pack: hosting: no-host: enabled: true auto-external-host: enabled: false self-host: enabled: false server-ip: 127.0.0.1 pack-port: 8163 external-host: enabled: false url: '' skip-url-file-type-check___DONT_ASK_HELP_IF_SET_TRUE: false apply-on-join: false kick-player-on-decline: false kick-player-on-fail: false delay-ticks: 1 notify-other-plugins-interfering: true title: enabled: true protect-player: black-screen: true hide-hud: true cancel-movement: true lock-player: true command: usage-cooldown-seconds: 60 custom-font: enabled: false name: ipaexg.ttf shift: '[0,0]' size: 11.0 oversample: 2.0 thin-font: enabled: false zip: protect-file-from-unzip: enabled: false extreme: false compress-png-files: true compress-json-files: true overwrite-vanilla-models: false overwrite-vanilla-lang-json: false generate-custom-armors-textures: _: 'Available values: VANILLA_1_17 or OPTIFINE' enabled: true mode: VANILLA_1_17 fix_transparent_noteblocks__disable-for-more-performance: false ignore-files-ext: - db - yml - xcf - html disable-overwrite-leather-armor-layers-textures: false items: CustomModelData-starting-value: ALL: 10000 DIAMOND: 11000 config_files: lang: en dictionaries-lang: en extract-default-items: false extract-default-resources: false blocks: light-api: true fix-glitched-blocks: enabled: true only-new-chunks: false search-also-in-these-biomes: enabled: false biomes: - BEACH - BIRCH_FOREST - BIRCH_FOREST_HILLS - FOREST - MOUNTAINS - MOUNTAIN_EDGE - GRAVELLY_MOUNTAINS - PLAINS - RIVER cancel-break-wrong-tool: enabled: true send-actionbar: true campfire: unlit-on-place: true allow-any-item: true disable-REAL: true disable-REAL_TRANSPARENT: true disable-REAL_NOTE: true disable-REAL_WIRE: true disable-FIRE: true items: fix-show-attack-and-damage-as-lore: false give_death_location_maps: false hide-custom-durability-lore: false liquids: enabled: true huds: enabled: true mobs: disable-MOB-behaviour__DISABLE_AT_YOUR_OWN_RISK: false font_images: chat: enabled: true doublecheck-permission__disable-for-more-performance: false add-hover-suggestion: true command: enabled: true commandblocks: true excluded: - home - sethome - tpa sign: enabled: true book: enabled: true anvil: enabled: true inventory-title: enabled: true tab-header-footer: enabled: true vault-prefix-suffix: enabled: true update-every-ticks: 1200 scoreboard-teams: enabled: false update-every-ticks: 3600 player-display-name: enabled: true update-every-ticks: 1200 replace-in-customitems-name-and-lore: true effects: hide-scoreboard-numbers: false text-effects: enabled: true replace-in-customitems-name-and-lore: true chat: enabled: true sign: enabled: true book: enabled: true anvil: enabled: true tab-header-footer: enabled: true entities: max-furniture-vehicles-per-chunk: 30 allow-removing-old-furnitures_2_3_11: false recipes: hide-vanilla-unrecognized-recipe-errors: true custom-recipes: unlock: all-on-join: false on-pickup: any: false ingredients: true remove-vanilla-recipes: enabled: true list: DIAMOND_SWORD: false IRON_INGOT: false fix-packet-too-large-kick: false debug: items: log-files-loading: false log-items-loading: false log-items-loading-disabled: false log-font-images-loading: false log-huds-loading: false log-attribute-modifiers-loading: false log-warnings: false log-loots-loading: false log-loots-loading-disabled: false log-armors-loading: false recipes: log-recipes-loading: false log-recipes-loading-disabled: false log-recipes-removed-vanilla: false log-fix-packet-too-large: false resource-pack: log-extract-default-resources: false log-not-extract-default-resources-already-exist: false blocks: log-save: false log-save-on-unload: false log-mined-unknown-blocks: true worlds-populators: log-loading: false log-loading-disabled: false log-loading-no-populators: false log-loading-no-world: true log-generation: false trees-populators: log-loading: false log-loading-disabled: false log-loading-no-populators: false log-loading-no-world: true log-generation: false surface-decorators: log-loading: false log-loading-disabled: false log-loading-no-decorators: false log-loading-no-world: true log-generation: false player-stats: log-save: false performance: loading-ms: true huds: log-triggers: false other: log-dictionaries-loading: false log-liquids-loading: false log-minecraft_lang_overwrite-loading: false categories: log-total-loaded: true log-single-loaded: false log-single-loaded-overwrite: false log-single-skip: false ```
LoneDev6 commented 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

LoneDev6 commented 2 years ago

Contact its developers and link them this issue page.

LoneDev6 commented 2 years ago

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;
LoneDev6 commented 2 years ago

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);
    }