(function () {
    let ClientboundSetEntityMotionPacket = Java.loadClass('net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket');

    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:stockpile_debuffs')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))
            .addProperty("score_value_1", "string", "Broken.Arm.Right", "Broken Arm Score")
            .addProperty("score_value_2", "string", "Broken.Finger.1", "Broken Finger one")
            .addProperty("score_value_3", "string", "Broken.Finger.2", "Broken Finger two")
            .addProperty("score_value_4", "string", "Broken.Finger.3", "Broken Finger three")
            .addProperty("score_value_5", "string", "Broken.Finger.4", "Broken Finger four")
            .addProperty("score_value_6", "string", "Broken.Finger.5", "Broken Finger five")
            .addProperty("score_value_7", "string", "Broken.Legs", "Broken Legs")

            .tick((entity, entry, holder, enabled) => {
                if (enabled) {
                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
                    let scoreboard = Utils.server.scoreboard;
					
                    let scoreboard_obj_1 = scoreboard.getObjective(entry.getPropertyByName("score_value_1"));
                    let scoreboard_obj_2 = scoreboard.getObjective(entry.getPropertyByName("score_value_2"));
                    let scoreboard_obj_3 = scoreboard.getObjective(entry.getPropertyByName("score_value_3"));
                    let scoreboard_obj_4 = scoreboard.getObjective(entry.getPropertyByName("score_value_4"));
                    let scoreboard_obj_5 = scoreboard.getObjective(entry.getPropertyByName("score_value_5"));
                    let scoreboard_obj_6 = scoreboard.getObjective(entry.getPropertyByName("score_value_6"));
                    let scoreboard_obj_7 = scoreboard.getObjective(entry.getPropertyByName("score_value_7"));
                    let score_1 = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_1);
                    let score_2 = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_2);
                    let score_3 = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_3);
                    let score_4 = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_4);
                    let score_5 = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_5);
                    let score_6 = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_6);
                    let score_7 = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_7);
                    let value_1 = score_1.getScore();
                    let value_2 = score_2.getScore();
                    let value_3 = score_3.getScore();
                    let value_4 = score_4.getScore();
                    let value_5 = score_5.getScore();
                    let value_6 = score_6.getScore();
                    let value_7 = score_7.getScore();

					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier remove a1623906-6eef-11ee-b962-0242ac120002");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier remove b1623906-6eef-11ee-b962-0242ac120002");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier remove c1623906-6eef-11ee-b962-0242ac120002");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier remove d1623906-6eef-11ee-b962-0242ac120002");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier remove e1623906-6eef-11ee-b962-0242ac120002");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier remove f1623906-6eef-11ee-b962-0242ac120002");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.movement_speed modifier remove f1623906-6eef-11ee-b962-0242ac120002");
					
					
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier add a1623906-6eef-11ee-b962-0242ac120002 Arm " + (-0.05 * value_1) + " multiply");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier add b1623906-6eef-11ee-b962-0242ac120002 Finger_1 " + (-0.004 * value_2) + " multiply");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier add c1623906-6eef-11ee-b962-0242ac120002 Finger_2 " + (-0.004 * value_3) + " multiply");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier add d1623906-6eef-11ee-b962-0242ac120002 Finger_3 " + (-0.004 * value_4) + " multiply");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier add e1623906-6eef-11ee-b962-0242ac120002 Finger_4 " + (-0.004 * value_5) + " multiply");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.attack_damage modifier add f1623906-6eef-11ee-b962-0242ac120002 Finger_5 " + (-0.004 * value_6) + " multiply");
					entity.server.runCommandSilent("execute as " + username + " at @s run attribute @s minecraft:generic.movement_speed modifier add f1623906-6eef-11ee-b962-0242ac120002 Legs " + (-0.1 * value_7) + " multiply");

					
					
                }
            });
    });
})();