execute @a[scores={secondarymagic=0,secondarylevel=4}] ~ ~ ~ scoreboard players add @s jump_boosteffect 1
execute @a[scores={secondarymagic=1,secondarylevel=4}] ~ ~ ~ scoreboard players add @s resistanceeffect 1
execute @a[scores={secondarymagic=2,secondarylevel=4}] ~ ~ ~ scoreboard players add @s strengtheffect 1
execute @a[scores={secondarymagic=3,secondarylevel=4}] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[scores={secondarymagic=4,secondarylevel=4}] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[scores={secondarymagic=5,secondarylevel=4}] ~ ~ ~ scoreboard players add @s speedeffect 1
execute @a[scores={secondarymagic=6,secondarylevel=4}] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[scores={secondarymagic=7,secondarylevel=4}] ~ ~ ~ scoreboard players add @s strengtheffect 1
execute @a[scores={secondarymagic=7,secondarylevel=4}] ~ ~ ~ effect @s fire_resistance 10 0 true
execute @a[scores={secondarymagic=8,secondarylevel=4}] ~ ~ ~ scoreboard players add @s speedeffect 1
execute @a[scores={secondarymagic=9,secondarylevel=4}] ~ ~ ~ scoreboard players add @s speedeffect 1

execute @a[scores={primarymagic=0,primarylevel=4}] ~ ~ ~ scoreboard players add @s jump_boosteffect 1
execute @a[scores={primarymagic=1,primarylevel=4}] ~ ~ ~ scoreboard players add @s resistanceeffect 1
execute @a[scores={primarymagic=2,primarylevel=4}] ~ ~ ~ scoreboard players add @s strengtheffect 1
execute @a[scores={primarymagic=3,primarylevel=4}] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[scores={primarymagic=4,primarylevel=4}] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[scores={primarymagic=5,primarylevel=4}] ~ ~ ~ scoreboard players add @s speedeffect 1
execute @a[scores={primarymagic=6,primarylevel=4}] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[scores={primarymagic=7,primarylevel=4}] ~ ~ ~ scoreboard players add @s strengtheffect 1
execute @a[scores={primarymagic=7,primarylevel=4}] ~ ~ ~ effect @s fire_resistance 10 0 true
execute @a[scores={primarymagic=8,primarylevel=4}] ~ ~ ~ scoreboard players add @s speedeffect 1
execute @a[scores={primarymagic=9,primarylevel=4}] ~ ~ ~ scoreboard players add @s speedeffect 1

scoreboard objectives add magiceffecttick dummy magiceffecttick
execute @a[tag=electric1] ~ ~ ~ scoreboard players add @s speedeffect 1
execute @a[tag=electric1] ~ ~ ~ scoreboard players add @s jump_boosteffect 1
scoreboard players add @a[tag=electric1] magiceffecttick 1
execute @a[tag=electric2] ~ ~ ~ scoreboard players add @s speedeffect 2
execute @a[tag=electric2] ~ ~ ~ scoreboard players add @s jump_boosteffect 2
execute @a[tag=electric2] ~ ~ ~ scoreboard players add @s hasteeffect 1
scoreboard players add @a[tag=electric2] magiceffecttick 1
execute @a[tag=electric3] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[tag=electric3] ~ ~ ~ scoreboard players add @s speedeffect 3
execute @a[tag=electric3] ~ ~ ~ scoreboard players add @s jump_boosteffect 3
execute @a[tag=electric3] ~ ~ ~ scoreboard players add @s hasteeffect 2
scoreboard players add @a[tag=electric3] magiceffecttick 1
execute @a[tag=fire1] ~ ~ ~ scoreboard players add @s strengtheffect 1
scoreboard players add @a[tag=fire1] magiceffecttick 1
execute @a[tag=fire2] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[tag=fire2] ~ ~ ~ scoreboard players add @s strengtheffect 2
scoreboard players add @a[tag=fire2] magiceffecttick 1
execute @a[tag=grass1] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[tag=grass1] ~ ~ ~ scoreboard players add @s speedeffect 1
scoreboard players add @a[tag=grass1] magiceffecttick 1
execute @a[tag=grass2] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[tag=grass2] ~ ~ ~ scoreboard players add @s speedeffect 2
execute @a[tag=grass2] ~ ~ ~ scoreboard players add @s resistanceeffect 1
scoreboard players add @a[tag=grass2] magiceffecttick 1
execute @a[tag=grass3] ~ ~ ~ scoreboard players add @s regeneffect 2
execute @a[tag=grass3] ~ ~ ~ scoreboard players add @s speedeffect 3
execute @a[tag=grass3] ~ ~ ~ scoreboard players add @s resistanceeffect 2
scoreboard players add @a[tag=grass3] magiceffecttick 1
execute @a[tag=water1] ~ ~ ~ scoreboard players add @s resistanceeffect 1
execute @a[tag=water1] ~ ~ ~ scoreboard players add @s speedeffect 1
execute @a[tag=water1] ~ ~ ~ scoreboard players add @s strengtheffect 1
scoreboard players add @a[tag=water1] magiceffecttick 1
execute @a[tag=water2] ~ ~ ~ scoreboard players add @s resistanceeffect 1
execute @a[tag=water2] ~ ~ ~ scoreboard players add @s speedeffect 2
execute @a[tag=water2] ~ ~ ~ scoreboard players add @s strengtheffect 2
scoreboard players add @a[tag=water2] magiceffecttick 1
execute @a[tag=wind1] ~ ~ ~ scoreboard players add @s regeneffect 1
execute @a[tag=wind1] ~ ~ ~ scoreboard players add @s jump_boosteffect 2
scoreboard players add @a[tag=wind1] magiceffecttick 1

execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove electric1
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove electric2
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove electric3
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove fire1
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove fire2
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove grass1
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove grass2
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove grass3
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove water1
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove water2
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ tag @s remove wind1
execute @a[scores={magiceffecttick=2000..}] ~ ~ ~ scoreboard players set @s magiceffecttick 0

scoreboard objectives add primarylevel dummy primarylevel
scoreboard objectives add secondarylevel dummy secondarylevel
scoreboard objectives add primaryexp dummy primaryexp
scoreboard objectives add secondaryexp dummy secondaryexp
scoreboard objectives add primarymagic dummy primarymagic
scoreboard objectives add secondarymagic dummy secondarymagic
scoreboard players add @a primarylevel 0
scoreboard players add @a secondarylevel 0

execute @a[tag=!magicnew] ~ ~ ~ give @s vatonage:primary_magic_orb
execute @a[tag=!magicnew] ~ ~ ~ give @s vatonage:empty_wand
execute @a[tag=!magicnew] ~ ~ ~ tag @s add magicnew

scoreboard objectives add magictick dummy magictick
scoreboard players add @a magictick 1
execute @a[scores={magictick=3..}] ~ ~ ~ scoreboard players set @s magictick 0
scoreboard players add @a[scores={magictick=1,primarymagic=0..}] primaryexp 1
scoreboard players add @a[scores={magictick=1,secondarymagic=0..}] secondaryexp 1

execute @a[tag=magicpvp,scores={magictick=1}] ~ ~ ~ tag @a[tag=!magicpvp] add magicpvp
execute @a[tag=magicpvp,scores={magictick=1}] ~ ~ ~ tag @e[type=allyzombie,type=allyfish] add magicpvp

execute @a[scores={primaryexp=25000..,primarylevel=0}] ~ ~ ~ playsound random.levelup @s ~ ~ ~
execute @a[scores={primaryexp=25000..,primarylevel=0}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§7[§9Primary Magic§7]"}]}
execute @a[scores={primaryexp=25000..,primarylevel=0}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§aLevel Up: Unlocked Tier 2 Wand"}]}
execute @a[scores={primaryexp=25000..,primarylevel=0}] ~ ~ ~ scoreboard players add @s primarylevel 1

execute @a[scores={primaryexp=75000..,primarylevel=1}] ~ ~ ~ playsound random.levelup @s ~ ~ ~
execute @a[scores={primaryexp=75000..,primarylevel=1}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§7[§9Primary Magic§7]"}]}
execute @a[scores={primaryexp=75000..,primarylevel=1}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§aLevel Up: Unlocked Tier 3 Wand"}]}
execute @a[scores={primaryexp=75000..,primarylevel=1}] ~ ~ ~ scoreboard players add @s primarylevel 1

execute @a[scores={primaryexp=150000..,primarylevel=2}] ~ ~ ~ playsound random.levelup @s ~ ~ ~
execute @a[scores={primaryexp=150000..,primarylevel=2}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§7[§9Primary Magic§7]"}]}
execute @a[scores={primaryexp=150000..,primarylevel=2}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§aLevel Up: Unlocked Tier 4 Wand"}]}
execute @a[scores={primaryexp=150000..,primarylevel=2}] ~ ~ ~ scoreboard players add @s primarylevel 1

execute @a[scores={primaryexp=250000..,primarylevel=3}] ~ ~ ~ playsound random.levelup @s ~ ~ ~
execute @a[scores={primaryexp=250000..,primarylevel=3}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§7[§9Primary Magic§7]"}]}
execute @a[scores={primaryexp=250000..,primarylevel=3}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§aLevel Up: Unlocked Passive Effect"}]}
execute @a[scores={primaryexp=250000..,primarylevel=3}] ~ ~ ~ scoreboard players add @s primarylevel 1

execute @a[scores={secondaryexp=25000..,secondarylevel=0}] ~ ~ ~ playsound random.levelup @s
execute @a[scores={secondaryexp=25000..,secondarylevel=0}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§7[§2Secondary Magic§7]"}]}
execute @a[scores={secondaryexp=25000..,secondarylevel=0}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§aLevel Up: Unlocked Tier 2 Wand"}]}
execute @a[scores={secondaryexp=25000..,secondarylevel=0}] ~ ~ ~ scoreboard players add @s secondarylevel 1

execute @a[scores={secondaryexp=75000..,secondarylevel=1}] ~ ~ ~ playsound random.levelup @s
execute @a[scores={secondaryexp=75000..,secondarylevel=1}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§7[§2Secondary Magic§7]"}]}
execute @a[scores={secondaryexp=75000..,secondarylevel=1}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§aLevel Up: Unlocked Tier 3 Wand"}]}
execute @a[scores={secondaryexp=75000..,secondarylevel=1}] ~ ~ ~ scoreboard players add @s secondarylevel 1

execute @a[scores={secondaryexp=150000..,secondarylevel=2}] ~ ~ ~ playsound random.levelup @s
execute @a[scores={secondaryexp=150000..,secondarylevel=2}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§7[§2Secondary Magic§7]"}]}
execute @a[scores={secondaryexp=150000..,secondarylevel=2}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§aLevel Up: Unlocked Tier 4 Wand"}]}
execute @a[scores={secondaryexp=150000..,secondarylevel=2}] ~ ~ ~ scoreboard players add @s secondarylevel 1

execute @a[scores={secondaryexp=250000..,secondarylevel=3}] ~ ~ ~ playsound random.levelup @s
execute @a[scores={secondaryexp=250000..,secondarylevel=3}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§7[§2Secondary Magic§7]"}]}
execute @a[scores={secondaryexp=250000..,secondarylevel=3}] ~ ~ ~ tellraw @s {"rawtext":[{"text":"§aLevel Up: Unlocked Passive Effect"}]}
execute @a[scores={secondaryexp=250000..,secondarylevel=3}] ~ ~ ~ scoreboard players add @s secondarylevel 1

execute @a[scores={primarymagic=0,magictick=2}] ~ ~ ~ /particle minecraft:falling_dust_top_snow_particle ~ ~0.1 ~
execute @a[scores={primarymagic=1,magictick=2}] ~ ~ ~ /particle minecraft:water_wake_particle ~ ~0.1 ~
execute @a[scores={primarymagic=2,magictick=2}] ~ ~ ~ /particle minecraft:dragon_breath_trail ~ ~0.1 ~
execute @a[scores={primarymagic=3,magictick=2}] ~ ~ ~ /particle minecraft:falling_dust ~ ~0.1 ~
execute @a[scores={primarymagic=4,magictick=2}] ~ ~ ~ /particle minecraft:shulker_bullet ~ ~0.1 ~
execute @a[scores={primarymagic=5,magictick=2}] ~ ~ ~ /particle minecraft:blue_flame_particle ~ ~0.1 ~
execute @a[scores={primarymagic=6,magictick=2}] ~ ~ ~ /particle minecraft:villager_happy ~ ~0.1 ~
execute @a[scores={primarymagic=7,magictick=2}] ~ ~ ~ /particle minecraft:basic_flame_particle ~ ~0.1 ~
execute @a[scores={primarymagic=8,magictick=2}] ~ ~ ~ /particle minecraft:conduit_particle ~ ~0.1 ~
execute @a[scores={primarymagic=9,magictick=2}] ~ ~ ~ /particle minecraft:sparkler_emitter ~ ~0.1 ~

execute @a[scores={secondarymagic=0,magictick=0}] ~ ~ ~ /particle minecraft:falling_dust_top_snow_particle ~ ~0.1 ~
execute @a[scores={secondarymagic=1,magictick=0}] ~ ~ ~ /particle minecraft:water_wake_particle ~ ~0.1 ~
execute @a[scores={secondarymagic=2,magictick=0}] ~ ~ ~ /particle minecraft:dragon_breath_trail ~ ~0.1 ~
execute @a[scores={secondarymagic=3,magictick=0}] ~ ~ ~ /particle minecraft:falling_dust ~ ~0.1 ~
execute @a[scores={secondarymagic=4,magictick=0}] ~ ~ ~ /particle minecraft:shulker_bullet ~ ~0.1 ~
execute @a[scores={secondarymagic=5,magictick=0}] ~ ~ ~ /particle minecraft:blue_flame_particle ~ ~0.1 ~
execute @a[scores={secondarymagic=6,magictick=0}] ~ ~ ~ /particle minecraft:villager_happy ~ ~0.1 ~
execute @a[scores={secondarymagic=7,magictick=0}] ~ ~ ~ /particle minecraft:basic_flame_particle ~ ~0.1 ~
execute @a[scores={secondarymagic=8,magictick=0}] ~ ~ ~ /particle minecraft:conduit_particle ~ ~0.1 ~
execute @a[scores={secondarymagic=9,magictick=0}] ~ ~ ~ /particle minecraft:sparkler_emitter ~ ~0.1 ~