
    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:ability_absorption')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))
			.addProperty('reach_range', 'integer', 3.5, 'Range the ability can reach')
			.addProperty('stam_percent', 'float', 1.75, 'Multiplier of how much more stam they can have then you')



				.firstTick((entity, entry, holder, enabled) => {
                if (enabled) {
                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
                    let scoreboard = Utils.server.scoreboard;
					const reach_range = entry.getPropertyByName('reach_range');
					const stam_percent = entry.getPropertyByName('stam_percent');
					
					let scoreboard_obj = scoreboard.getObjective('Heroes.Power.Icon');
                    let score = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj);
                    let value = score.getScore();
					let prock_detc = 0
					let target_entity = entity.rayTrace(reach_range).entity
					let entity_target_true = 0

				
					if (target_entity != null && target_entity.type != "minecraft:item" && target_entity.type != "minecraft:item_frame" && target_entity.type != "minecraft:glow_item_frame" && target_entity.type != "minecraft:armor_stand" && target_entity.type != "palladium:suit_stand") {
					
						if (!target_entity.isPlayer()) {
					entity_target_true = target_entity.uuid;
						} else {
					entity_target_true = target_entity.getGameProfile().getName();
						}
							
							let scoreboard_obj_stam = scoreboard.getObjective('Heroes.Stamina.Max');
							let score_stam = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_stam);
							let value_stam = score_stam.getScore();
							
							let scoreboard_obj_stam_target = scoreboard.getObjective('Heroes.Stamina.Max');
							let score_stam_target = scoreboard.getOrCreatePlayerScore(entity_target_true, scoreboard_obj_stam_target);
							let value_stam_target = score_stam_target.getScore();
							
						if (value_stam_target <= value_stam * stam_percent || containsTag(target_entity.getTags().toArray(), "Heroes.Theft.Enabled")) {
						let power_max = global.power_amount;
						for (let power_list = 0; power_list <= power_max; power_list++) {
						let power = global['ability_' + power_list];
						
						let power_score = 0
						if (!target_entity.isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers." + power);
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(entity_target_true, 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(target_entity.getGameProfile().getName(), Utils.server.scoreboard.getObjective("Powers." + power));
						let value_temp = score_temp.getScore();
						power_score = value_temp
							}
						}
						
						let scoreboard_alpha = Utils.server.scoreboard.getObjective("Powers." + power);
						if (scoreboard_alpha != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(entity.getGameProfile().getName(), Utils.server.scoreboard.getObjective("Powers." + power));
						let value_2 = score_temp.getScore();
					if (power_score >= 1 && value_2 == 0) {
						prock_detc = 1
										}
									}
								}
								let power_suppresed = 0
						if (!target_entity.isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers.Suppresed");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(entity_target_true, Utils.server.scoreboard.getObjective("Powers.Suppresed"));
						let value_temp = score_temp.getScore();
						power_suppresed = value_temp
						}
						} else {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers.Suppresed");
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(target_entity.getGameProfile().getName(), Utils.server.scoreboard.getObjective("Powers.Suppresed"));
						let value_temp = score_temp.getScore();
						power_suppresed = value_temp
							}
						}
								if (prock_detc >= 1 && !containsTag(target_entity.getTags().toArray(), "Heroes.Spatial.Barrier") && containsTag(target_entity.getTags().toArray(), "Heroes.Enabled") && power_suppresed == 0) {
								//detect here	
								superpowerUtil.addSuperpower(target_entity, "heroes:absorption_effect")
								entity.server.runCommandSilent("execute as " + entity_target_true + " at @s run tag @s add Heroes.Theft.Stall");
								}
							}
						}
					}
				})
					
					
            .tick((entity, entry, holder, enabled) => {
                if (enabled) {
                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
                    let scoreboard = Utils.server.scoreboard;
					const reach_range = entry.getPropertyByName('reach_range');
					const stam_percent = entry.getPropertyByName('stam_percent');
					
					let scoreboard_obj = scoreboard.getObjective('Heroes.Power.Icon');
                    let score = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj);
                    let value = score.getScore();
					let prock_detc = 0
					let target_entity = entity.rayTrace(reach_range).entity
					let entity_target_true = 0

				
					if (target_entity != null && target_entity.type != "minecraft:item" && target_entity.type != "minecraft:item_frame" && target_entity.type != "minecraft:glow_item_frame" && target_entity.type != "minecraft:armor_stand" && target_entity.type != "palladium:suit_stand") {
					
						if (!target_entity.isPlayer()) {
					entity_target_true = target_entity.uuid;
						} else {
					entity_target_true = target_entity.getGameProfile().getName();
						}
						if (abilityUtil.hasPower(target_entity, "heroes:absorption_effect")) {
							entity.server.runCommandSilent("execute as " + entity_target_true + " at @s run tag @s add Heroes.Theft.Stall");
						}
						
						if (abilityUtil.isEnabled(target_entity, "heroes:absorption_effect", "Theft_Timer_End")) {
							
							let scoreboard_obj_stam = scoreboard.getObjective('Heroes.Stamina.Max');
							let score_stam = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_stam);
							let value_stam = score_stam.getScore();
							
							let scoreboard_obj_stam_target = scoreboard.getObjective('Heroes.Stamina.Max');
							let score_stam_target = scoreboard.getOrCreatePlayerScore(entity_target_true, scoreboard_obj_stam_target);
							let value_stam_target = score_stam_target.getScore();
							
						if (value_stam_target <= value_stam * stam_percent || containsTag(target_entity.getTags().toArray(), "Heroes.Theft.Enabled")) {
						let power_max = global.power_amount;
					for (let power_list = 0; power_list <= power_max; power_list++) {
						let power = global['ability_' + power_list];
						
						let power_score = 0
						if (!target_entity.isPlayer()) {
							let scoreboard_temp = Utils.server.scoreboard.getObjective("Powers." + power);
							if (scoreboard_temp != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(entity_target_true, 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(target_entity.getGameProfile().getName(), Utils.server.scoreboard.getObjective("Powers." + power));
						let value_temp = score_temp.getScore();
						power_score = value_temp
						}
						}
						
						let scoreboard_alpha = Utils.server.scoreboard.getObjective("Powers." + power);
						if (scoreboard_alpha != null) {
						let score_temp = Utils.server.scoreboard.getOrCreatePlayerScore(entity.getGameProfile().getName(), Utils.server.scoreboard.getObjective("Powers." + power));
						let value_2 = score_temp.getScore();
					if (power_score >= 1 && value_2 == 0) {
						prock_detc = 1
					}
						
						if (power != 'Ability_Transferal') {
					if (power == 'Ability_Replication') {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[scores={Heroes.Replication.Slots.True=1..}] Heroes.ReplicationPower1 >< " + username + " Heroes.ReplicationPower1");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[scores={Heroes.Replication.Slots.True=2..}] Heroes.ReplicationPower2 >< " + username + " Heroes.ReplicationPower2");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[scores={Heroes.Replication.Slots.True=3..}] Heroes.ReplicationPower3 >< " + username + " Heroes.ReplicationPower3");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[scores={Heroes.Replication.Slots.True=4..}] Heroes.ReplicationPower4 >< " + username + " Heroes.ReplicationPower4");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[scores={Heroes.Replication.Slots.True=5..}] Heroes.ReplicationPower5 >< " + username + " Heroes.ReplicationPower5");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Replication.Slots.True >< " + username + " Heroes.Replication.Slots.True");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Stockpile.Replicated.Energy >< " + username + " Heroes.Stockpile.Replicated.Energy");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Bone.Var.Replicated >< " + username + " Heroes.Bone.Var.Replicated");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Levitation.Speed.Base.Replication >< " + username + " Heroes.Levitation.Speed.Base.Replication");
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Pocket.Id.Replicated >< " + username + " Heroes.Pocket.Id.Replicated");
					}
					
					if (power == 'Levitation') {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Levitation.Speed.Base >< " + username + " Heroes.Levitation.Speed.Base");
					}
					if (power == 'Bone_Protrusion') {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Bone.Var.Base >< " + username + " Heroes.Bone.Var.Base");
					}
					if (power == 'Empathic_Mimicry') {
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Stockpile.Empathic.Energy >< " + username + " Heroes.Stockpile.Empathic.Energy");
						
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Bone.Var.Empathic >< " + username + " Heroes.Bone.Var.Empathic");
						
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Levitation.Speed.Base.Empathic >< " + username + " Heroes.Levitation.Speed.Base.Empathic");
						
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Pocket.Id.Empathic >< " + username + " Heroes.Pocket.Id.Empathic");
						
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Replication.Slots.Empathic >< " + username + " Heroes.Replication.Slots.Empathic");
						for (let power_empathic_max = 0; power_empathic_max <= power_max; power_empathic_max++) {
						let power_empathic = global['ability_' + power_empathic_max];
						let scoreboard_obj_temp = scoreboard.getObjective('Powers.Empathic.' + power_empathic);
							if (scoreboard_obj_temp != null) {
							let score_temp = scoreboard.getOrCreatePlayerScore(entity_target_true, scoreboard_obj_temp);
							let value_temp = score_temp.getScore();
							if (value_temp >= 2) {
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s unless score " + username + " Powers.Empathic_Mimicry matches 1.. run scoreboard players set @s Powers.Empathic." + power_empathic + " 1");
									}
								}
							}
							
						for (let power_empathic_max = 0; power_empathic_max <= power_max; power_empathic_max++) {
						let power_empathic = global['ability_' + power_empathic_max];
						let scoreboard_obj_temp = scoreboard.getObjective('Powers.Empathic.' + power_empathic);
							if (scoreboard_obj_temp != null) {
							let score_temp = scoreboard.getOrCreatePlayerScore(entity_target_true, scoreboard_obj_temp);
							let value_temp = score_temp.getScore();
							if (value_temp >= 1) {
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s unless score " + username + " Powers.Empathic_Mimicry matches 1.. run scoreboard players operation " + entity_target_true + " Powers.Empathic." + power_empathic + " >< " + username + " Powers.Empathic." + power_empathic + "");
									}
								}
							}

						}	
						
						if (power == 'Intuitive_Aptitude') {
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s Heroes.Stockpile.Intuitive.Energy >< " + username + " Heroes.Stockpile.Intuitive.Energy");
						
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s Heroes.Bone.Var.Intuitive >< " + username + " Heroes.Bone.Var.Intuitive");
						
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s Heroes.Levitation.Speed.Base.Intuitive >< " + username + " Heroes.Levitation.Speed.Base.Intuitive");
						
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s Heroes.Pocket.Id.Intuitive >< " + username + " Heroes.Pocket.Id.Intuitive");
						
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s Heroes.Replication.Slots.Intuitive >< " + username + " Heroes.Replication.Slots.Intuitive");
						
						
						for (let power_intuitive_max = 0; power_intuitive_max <= power_max; power_intuitive_max++) {
						let power_intuitive = global['ability_' + power_intuitive_max];
						let scoreboard_obj_temp = scoreboard.getObjective('Powers.Intuitive.' + power_intuitive);
							if (scoreboard_obj_temp != null) {
							let score_temp = scoreboard.getOrCreatePlayerScore(entity_target_true, scoreboard_obj_temp);
							let value_temp = score_temp.getScore();
							if (value_temp >= 1) {
						entity.server.runCommandSilent("execute as " + entity_target_true + " at @s unless score " + username + " Powers.Intuitive_Aptitude matches 1.. run scoreboard players operation " + entity_target_true + " Powers.Intuitive." + power_intuitive + " >< " + username + " Powers.Intuitive." + power_intuitive + "");
										}
									}
								}
							}
						
						if (power == 'Stockpile') {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Stockpile.True.Energy >< " + username + " Heroes.Stockpile.True.Energy");
					}
					
					if (power == 'Pocket_Reality') {
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. unless score " + username + " Powers." + power + " matches 1.. if score " + entity_target_true + " Powers." + power + " matches 1.. run scoreboard players operation @s[tag=Heroes.Enabled] Heroes.Pocket.Id.True >< " + username + " Heroes.Pocket.Id.True");
					}
					
					
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if entity @e[name=" + username + ",tag=Heroes.Uncatalyzed] unless score " + username + " Powers." + power + " matches 1.. run tag @s add Heroes.Uncatalyzed");
					
					entity.server.runCommandSilent("execute as " + entity_target_true + " at @s[tag=Heroes.Enabled,tag=!Heroes.Spatial.Barrier,tag=!Heroes.Invalid.Target] unless score @s Powers.Suppresed matches 1.. if score @s Powers." + power + " matches 1.. unless score " + username + " Powers." + power + " matches 1.. run scoreboard players operation @s Powers." + power + " >< " + username + " Powers." + power + "");
					
				
							}
						}
					}
						if (prock_detc == 1) {
					entity.server.runCommandSilent("execute as " + username + " at @s run tag @s add Heroes.Prock");
					entity.server.runCommandSilent("execute as " + username + " at @s run playsound minecraft:entity.warden.agitated master @a ~ ~ ~ 1 2");
							}
						}
					}
				}
			}
            });
    });
	
	function containsTag(tags, tag) {
    for (let i = 0; i < tags.length; i++) {
        if(tags[i].equals(tag)) {
            return true;
        }
    }
    return false;
}
