
    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:empathic_copy')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))
			.addProperty("radius_score", "string", "Heroes.Empathic.Radius", "Determins radius that you absorb powers")
            .tick((entity, entry, holder, enabled) => {
                if (enabled) {
					const radius_score = entry.getPropertyByName('radius_score');
                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard objectives add " + radius_score + " dummy");


					let scoreboard_temp_1 = Utils.server.scoreboard.getObjective(entry.getPropertyByName("radius_score"));
					if (scoreboard_temp_1 != null) {
					let score = Utils.server.scoreboard.getOrCreatePlayerScore(username, Utils.server.scoreboard.getObjective(entry.getPropertyByName("radius_score")));
                    let value = score.getScore();
					
							
					const targets = entity.serverLevel().getEntities(entity, AABB.ofSize(entity.position(), value, value, value)).toArray();
          
					let power_max = global.power_amount;
						for (let empathic_power = 0; empathic_power <= power_max; empathic_power++) {
							let power = global['ability_' + empathic_power];
						if (power != 'Ability_Absorption' && power != 'Ability_Transferal' && power != 'Interplay' && power != 'Empathic_Mimicry' && power != 'Catalyst') {
							
						let empathic_power_test = Utils.server.scoreboard.getObjective("Powers.Empathic." + power);
						if (empathic_power_test != null) {
						let empathic_score = Utils.server.scoreboard.getOrCreatePlayerScore(username, Utils.server.scoreboard.getObjective("Powers.Empathic." + power));
						let empathic_value = empathic_score.getScore();
						let power_hold = empathic_value
								if (empathic_value == 3) {
							power_hold = 1
									}
							
						for (let j = 0; j < targets.length; j++) {
						if (targets[j] != entity && targets[j].type != "minecraft:item" && targets[j].type != "minecraft:item_frame" && targets[j].type != "minecraft:glow_item_frame" && targets[j].type != "minecraft:armor_stand" && targets[j].type != "palladium:suit_stand") {
							
						let suppresion_score = 0
						if (!targets[j].isPlayer()) {
						let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers.Suppresed");
						if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].uuid, Utils.server.scoreboard.getObjective("Powers.Suppresed"));
						let value_temp = score_temp.getScore();
						suppresion_score = value_temp
							}
						} else {
						let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers.Suppresed");
						if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].getGameProfile().getName(), Utils.server.scoreboard.getObjective("Powers.Suppresed"));
						let value_temp = score_temp.getScore();
						suppresion_score = value_temp
							}
						}
						if (containsTag(targets[j].getTags().toArray(), 'Heroes.Enabled') && suppresion_score == 0) {
							
						
						if (power == 'Levitation') {
							let scoreboard_temp_2 = Utils.server.scoreboard.getObjective("Heroes.Levitation.Speed.Base.Empathic");
							if (scoreboard_temp_2 != null) {
							let score_temp_1 = Utils.server.scoreboard.getOrCreatePlayerScore(username, Utils.server.scoreboard.getObjective("Heroes.Levitation.Speed.Base.Empathic"));
							let value_temp_1 = score_temp_1.getScore();
							
						let value_temp_2 = 0
						if (!targets[j].isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Levitation.Speed.Base");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].uuid, Utils.server.scoreboard.getObjective("Heroes.Levitation.Speed.Base"));
						let value_temp = score_temp.getScore();
						value_temp_2 = value_temp
							}
						} else {
						let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Levitation.Speed.Base");
						if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].getGameProfile().getName(), Utils.server.scoreboard.getObjective("Heroes.Levitation.Speed.Base"));
						let value_temp = score_temp.getScore();
						value_temp_2 = value_temp
							}
						}
						
						let value_temp_3 = 0
						if (!targets[j].isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Levitation.Speed.Base.Intuitive");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].uuid, Utils.server.scoreboard.getObjective("Heroes.Levitation.Speed.Base.Intuitive"));
						let value_temp = score_temp.getScore();
						value_temp_3 = value_temp
							}
						} else {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Levitation.Speed.Base.Intuitive");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].getGameProfile().getName(), Utils.server.scoreboard.getObjective("Heroes.Levitation.Speed.Base.Intuitive"));
						let value_temp = score_temp.getScore();
						value_temp_3 = value_temp
							}
						}
							if (value_temp_2 > value_temp_1) {
							entity.server.runCommandSilent("scoreboard players set " + username + " Heroes.Levitation.Speed.Base.Empathic " + value_temp_2 + "");
								}
							
							if (value_temp_3 > value_temp_1) {
							entity.server.runCommandSilent("scoreboard players set " + username + " Heroes.Levitation.Speed.Base.Empathic " + value_temp_3 + "");
								}
							}
						}
						if (power == 'Ability_Replication') {
							let scoreboard_temp_1 = Utils.server.scoreboard.getObjective("Heroes.Replication.Slots.Empathic");
							if (scoreboard_temp_1 != null) {
							let score_temp_1 = Utils.server.scoreboard.getOrCreatePlayerScore(username, Utils.server.scoreboard.getObjective("Heroes.Replication.Slots.Empathic"));
							let value_temp_1 = score_temp_1.getScore();
							
							let value_temp_2 = 0
						if (!targets[j].isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Replication.Slots.True");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].uuid, Utils.server.scoreboard.getObjective("Heroes.Replication.Slots.True"));
						let value_temp = score_temp.getScore();
						value_temp_2 = value_temp
						}
						} else {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Replication.Slots.True");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].getGameProfile().getName(), Utils.server.scoreboard.getObjective("Heroes.Replication.Slots.True"));
						let value_temp = score_temp.getScore();
						value_temp_2 = value_temp
						}
						}
						
						let value_temp_3 = 0
						if (!targets[j].isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Replication.Slots.Intuitive");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].uuid, Utils.server.scoreboard.getObjective("Heroes.Replication.Slots.Intuitive"));
						let value_temp = score_temp.getScore();
						value_temp_3 = value_temp
						}
						} else {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Replication.Slots.Intuitive");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].getGameProfile().getName(), Utils.server.scoreboard.getObjective("Heroes.Replication.Slots.Intuitive"));
						let value_temp = score_temp.getScore();
						value_temp_3 = value_temp
						}
						}

							if (value_temp_2 > value_temp_1) {
							entity.server.runCommandSilent("scoreboard players set " + username + " Heroes.Replication.Slots.Empathic " + value_temp_2 + "");
								}
							
							if (value_temp_3 > value_temp_1) {
							entity.server.runCommandSilent("scoreboard players set " + username + " Heroes.Replication.Slots.Empathic " + value_temp_3 + "");
								}
							}
						}
						if (power == 'Bone_Protrusion') {
							let scoreboard_temp_1 = Utils.server.scoreboard.getObjective("Heroes.Bone.Var.Empathic");
							if (scoreboard_temp_1 != null) {
							let score_temp_1 = Utils.server.scoreboard.getOrCreatePlayerScore(username, Utils.server.scoreboard.getObjective("Heroes.Bone.Var.Empathic"));
							let value_temp_1 = score_temp_1.getScore();
							
						let value_temp_2 = 0
						if (!targets[j].isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Bone.Var.Base");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].uuid, Utils.server.scoreboard.getObjective("Heroes.Bone.Var.Base"));
						let value_temp = score_temp.getScore();
						value_temp_2 = value_temp
						}
						} else {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Bone.Var.Base");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].getGameProfile().getName(), Utils.server.scoreboard.getObjective("Heroes.Bone.Var.Base"));
						let value_temp = score_temp.getScore();
						value_temp_2 = value_temp
						}
						}
						
						let value_temp_3 = 0
						if (!targets[j].isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Bone.Var.Intuitive");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].uuid, Utils.server.scoreboard.getObjective("Heroes.Bone.Var.Intuitive"));
						let value_temp = score_temp.getScore();
						value_temp_3 = value_temp
						}
						} else {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Heroes.Bone.Var.Intuitive");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].getGameProfile().getName(), Utils.server.scoreboard.getObjective("Heroes.Bone.Var.Intuitive"));
						let value_temp = score_temp.getScore();
						value_temp_3 = value_temp
						}
						}


							if (value_temp_2 > value_temp_1) {
							entity.server.runCommandSilent("scoreboard players set " + username + " Heroes.Bone.Var.Empathic " + value_temp_2 + "");
								}
							
							if (value_temp_3 > value_temp_1) {
							entity.server.runCommandSilent("scoreboard players set " + username + " Heroes.Bone.Var.Empathic " + value_temp_3 + "");
								}
							}
						}

						
						let power_score = 0
						let intuitive_power_score = 0
						if (!targets[j].isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers." + power);
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].uuid, Utils.server.scoreboard.getObjective("Powers." + power));
						let value_temp = score_temp.getScore();
						power_score = value_temp
						}
						} else {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers." + power);
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].getGameProfile().getName(), Utils.server.scoreboard.getObjective("Powers." + power));
						let value_temp = score_temp.getScore();
						power_score = value_temp
						}
						}
						
						if (!targets[j].isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers.Intuitive." + power);
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].uuid, Utils.server.scoreboard.getObjective("Powers.Intuitive." + power));
						let value_temp = score_temp.getScore();
						intuitive_power_score = value_temp
						}
						} else {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers.Intuitive." + power);
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(targets[j].getGameProfile().getName(), Utils.server.scoreboard.getObjective("Powers.Intuitive." + power));
						let value_temp = score_temp.getScore();
						intuitive_power_score = value_temp
						}
						}
						
						if (power_score >= 1 || intuitive_power_score >= 1 && power_score != null && intuitive_power_score != null) {
							if (empathic_value != 2) {
							if (containsTag(entity.getTags().toArray(), 'Heroes.Empathic.StopRadial')) {
							power_hold = 1
							} else {
							power_hold = 3
										}
									}
								}
							}
										}
									}
									if (power_hold != empathic_value && power_hold != null) {
						entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Empathic." + power + " " + power_hold + "");
									}
								}
							}
						}
					}
				}
            });
    });
	
	function containsTag(tags, tag) {
    for (let i = 0; i < tags.length; i++) {
        if(tags[i].equals(tag)) {
            return true;
        }
    }
    return false;
}