
    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:spatial_repair_or_damage')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))
			.addProperty("repair_or_damage", "boolean", true, "true = repair false = damage")
            .tick((entity, entry, holder, enabled) => {
                if (enabled) {
					const repair_or_damage = entry.getPropertyByName('repair_or_damage');

                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
					let scoreboard = Utils.server.scoreboard;
					let scoreboard_obj = scoreboard.getObjective("Heroes.Stamina");
                    let score = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj);
                    let value = score.getScore();
	if (value >= 1) {
		if (entity.headArmorItem.nbt != null) {
			if (repair_or_damage == true && entity.headArmorItem.nbt.Damage >= 1) {
					entity.headArmorItem.nbt.Damage = entity.headArmorItem.nbt.Damage - 2
						if (entity.headArmorItem.nbt.Damage < 0) {
						entity.headArmorItem.nbt.Damage = 0
				}
			}
			if (repair_or_damage == false && entity.headArmorItem.nbt.Damage < entity.headArmorItem.maxDamage) {
					entity.headArmorItem.nbt.Damage = entity.headArmorItem.nbt.Damage + 2
						if (entity.headArmorItem.nbt.Damage > entity.headArmorItem.maxDamage) {
						entity.headArmorItem.nbt.Damage = entity.headArmorItem.maxDamage
				}
			}
		}
		if (entity.chestArmorItem.nbt != null) {
			if (repair_or_damage == true && entity.chestArmorItem.nbt.Damage >= 1) {
					entity.chestArmorItem.nbt.Damage = entity.chestArmorItem.nbt.Damage - 2
						if (entity.chestArmorItem.nbt.Damage < 0) {
						entity.chestArmorItem.nbt.Damage = 0
				}
			}
			if (repair_or_damage == false && entity.chestArmorItem.nbt.Damage < entity.chestArmorItem.maxDamage) {
					entity.chestArmorItem.nbt.Damage = entity.chestArmorItem.nbt.Damage + 2
						if (entity.chestArmorItem.nbt.Damage > entity.chestArmorItem.maxDamage) {
						entity.chestArmorItem.nbt.Damage = entity.chestArmorItem.maxDamage
				}
			}
		}
		if (entity.legsArmorItem.nbt != null) {
			if (repair_or_damage == true && entity.legsArmorItem.nbt.Damage >= 1) {
					entity.legsArmorItem.nbt.Damage = entity.legsArmorItem.nbt.Damage - 2
						if (entity.legsArmorItem.nbt.Damage < 0) {
						entity.legsArmorItem.nbt.Damage = 0
				}
			}
			if (repair_or_damage == false && entity.legsArmorItem.nbt.Damage < entity.legsArmorItem.maxDamage) {
					entity.legsArmorItem.nbt.Damage = entity.legsArmorItem.nbt.Damage + 2
						if (entity.legsArmorItem.nbt.Damage > entity.legsArmorItem.maxDamage) {
						entity.legsArmorItem.nbt.Damage = entity.legsArmorItem.maxDamage
				}
			}
		}
		if (entity.feetArmorItem.nbt != null) {
			if (repair_or_damage == true && entity.feetArmorItem.nbt.Damage >= 1) {
					entity.feetArmorItem.nbt.Damage = entity.feetArmorItem.nbt.Damage - 2
						if (entity.feetArmorItem.nbt.Damage < 0) {
						entity.feetArmorItem.nbt.Damage = 0
				}
			}
			if (repair_or_damage == false && entity.feetArmorItem.nbt.Damage < entity.feetArmorItem.maxDamage) {
					entity.feetArmorItem.nbt.Damage = entity.feetArmorItem.nbt.Damage + 2
						if (entity.feetArmorItem.nbt.Damage > entity.feetArmorItem.maxDamage) {
						entity.feetArmorItem.nbt.Damage = entity.feetArmorItem.maxDamage
				}
			}
		}
		if (entity.mainHandItem.nbt != null) {
			if (repair_or_damage == true && entity.mainHandItem.nbt.Damage >= 1) {
					entity.mainHandItem.nbt.Damage = entity.mainHandItem.nbt.Damage - 2
						if (entity.mainHandItem.nbt.Damage < 0) {
						entity.mainHandItem.nbt.Damage = 0
				}
			}
			if (repair_or_damage == false && entity.mainHandItem.nbt.Damage < entity.mainHandItem.maxDamage) {
					entity.mainHandItem.nbt.Damage = entity.mainHandItem.nbt.Damage + 2
						if (entity.mainHandItem.nbt.Damage > entity.mainHandItem.maxDamage) {
						entity.mainHandItem.nbt.Damage = entity.mainHandItem.maxDamage
				}
			}
		}
		if (entity.offHandItem.nbt != null) {
			if (repair_or_damage == true && entity.offHandItem.nbt.Damage >= 1) {
					entity.offHandItem.nbt.Damage = entity.offHandItem.nbt.Damage - 2
						if (entity.offHandItem.nbt.Damage < 0) {
						entity.offHandItem.nbt.Damage = 0
				}
			}
			if (repair_or_damage == false && entity.offHandItem.nbt.Damage < entity.offHandItem.maxDamage) {
					entity.offHandItem.nbt.Damage = entity.offHandItem.nbt.Damage + 2
						if (entity.offHandItem.nbt.Damage > entity.offHandItem.maxDamage) {
						entity.offHandItem.nbt.Damage = entity.offHandItem.maxDamage
				}
			}
		}
	}
					}
            });
    });
	
	
	
	
    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:item_auto_repair')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))
			.addProperty("mainhand", "boolean", true, "true = main false = offhand")
			.addProperty("repair", "boolean", true, "true = repair false = damage")
			.addProperty("command_1", "string", " ", "Command to play when item breaks")
			.addProperty("command_2", "string", " ", "Command to play when item breaks")
            .tick((entity, entry, holder, enabled) => {
                if (enabled) {
					const mainhand = entry.getPropertyByName('mainhand');
					const repair = entry.getPropertyByName('repair');
					const command_1 = entry.getPropertyByName('command_1');
					const command_2 = entry.getPropertyByName('command_2');
					
					
				if (repair == false) {	
					if (entity.mainHandItem.nbt != null) {
			if (mainhand == true && entity.mainHandItem.nbt.Damage <= entity.mainHandItem.maxDamage) {
					entity.mainHandItem.nbt.Damage = entity.mainHandItem.nbt.Damage + 1
						if (entity.mainHandItem.nbt.Damage > entity.mainHandItem.maxDamage) {
						entity.mainHandItem = "minecraft:air"
						entity.server.runCommandSilent(`execute as ${entity.uuid} at @s run ${command_1}`)
						entity.server.runCommandSilent(`execute as ${entity.uuid} at @s run ${command_2}`)
						}
					}
				}
				if (entity.offHandItem.nbt != null) {
			if (mainhand == false && entity.offHandItem.nbt.Damage <= entity.offHandItem.maxDamage) {
					entity.offHandItem.nbt.Damage = entity.offHandItem.nbt.Damage + 1
						if (entity.offHandItem.nbt.Damage > entity.offHandItem.maxDamage) {
						entity.offHandItem = "minecraft:air"
						entity.server.runCommandSilent(`execute as ${entity.uuid} at @s run ${command_1}`)
						entity.server.runCommandSilent(`execute as ${entity.uuid} at @s run ${command_2}`)
							}
						}
					}
				} else {
				
		if (entity.mainHandItem.nbt != null) {
			if (mainhand == true && entity.mainHandItem.nbt.Damage >= 1) {
					entity.mainHandItem.nbt.Damage = entity.mainHandItem.nbt.Damage - 1
						if (entity.mainHandItem.nbt.Damage < 0) {
						entity.mainHandItem.nbt.Damage = 0
						}
					}
				}
		if (entity.offHandItem.nbt != null) {
			if (mainhand == false && entity.offHandItem.nbt.Damage >= 1) {
					entity.offHandItem.nbt.Damage = entity.offHandItem.nbt.Damage - 1
						if (entity.offHandItem.nbt.Damage < 0) {
						entity.offHandItem.nbt.Damage = 0
							}
						}
					}
				}
			}
            });
    });