##############################
##
##        WorldEdit
##    Made By M7mdTG ;)
##
##############################

#error check

tag @a[tag=we_host] add we_pos1_not_found
tag @a[tag=we_host] add we_pos2_not_found
execute @e[type=worldedit:pos1] ~~~ tag @a[tag=we_host] remove we_pos1_not_found
execute @e[type=worldedit:pos2] ~~~ tag @a[tag=we_host] remove we_pos2_not_found
tag @a[tag=we_host,tag=we_pos1_not_found,tag=we_pos2_not_found] add we_all_pos_not_found

# modes 1-4

execute @a[tag=we_host] ~~~ playsound random.click @s ~~~ 1 1
execute @s[tag=we_host,scores={we_build_mode=1,we_fill_mode=1}] ~~~ execute @e[type=worldedit:pos2] ~~~ tag @e[type=worldedit:pos1,tag=!we_fill,tag=!we_hollow,tag=!we_outline,tag=!we_wall,tag=!we_circle,tag=!we_sphere,tag=!we_clear] add we_fill
execute @s[tag=we_host,scores={we_build_mode=1,we_fill_mode=2}] ~~~ execute @e[type=worldedit:pos2] ~~~ tag @e[type=worldedit:pos1,tag=!we_fill,tag=!we_hollow,tag=!we_outline,tag=!we_wall,tag=!we_circle,tag=!we_sphere,tag=!we_clear] add we_hollow
execute @s[tag=we_host,scores={we_build_mode=1,we_fill_mode=3}] ~~~ execute @e[type=worldedit:pos2] ~~~ tag @e[type=worldedit:pos1,tag=!we_fill,tag=!we_hollow,tag=!we_outline,tag=!we_wall,tag=!we_circle,tag=!we_sphere,tag=!we_clear] add we_outline
execute @s[tag=we_host,scores={we_build_mode=2}] ~~~ execute @e[type=worldedit:pos2] ~~~ tag @e[type=worldedit:pos1,tag=!we_fill,tag=!we_hollow,tag=!we_outline,tag=!we_wall,tag=!we_circle,tag=!we_sphere,tag=!we_clear] add we_wall
execute @s[tag=we_host,scores={we_build_mode=3}] ~~~ tag @e[type=worldedit:pos1,tag=!we_fill,tag=!we_hollow,tag=!we_outline,tag=!we_wall,tag=!we_circle,tag=!we_sphere,tag=!we_clear] add we_circle
execute @s[tag=we_host,scores={we_build_mode=4}] ~~~ tag @e[type=worldedit:pos1,tag=!we_fill,tag=!we_hollow,tag=!we_outline,tag=!we_wall,tag=!we_circle,tag=!we_sphere,tag=!we_clear] add we_sphere
execute @s[tag=we_host,scores={we_build_mode=5}] ~~~ execute @e[type=worldedit:pos2] ~~~ tag @e[type=worldedit:pos1,tag=!we_fill,tag=!we_hollow,tag=!we_outline,tag=!we_wall,tag=!we_circle,tag=!we_sphere,tag=!we_clear] add we_clear
 
# mode 6

execute @s[tag=we_host,scores={we_build_mode=6}] ~~~ tag @e[type=worldedit:pos2] add we_useless
execute @s[tag=we_host,scores={we_build_mode=6}] ~~~ tag @e[type=worldedit:pos1,tag=!we_fill,tag=!we_hollow,tag=!we_outline,tag=!we_wall,tag=!we_circle,tag=!we_sphere,tag=!we_clear] add we_useless
execute @s[tag=we_host,scores={we_build_mode=6}] ~~~ execute @e[type=worldedit:pos1,tag=!we_useless] ~~~ tag @e[type=worldedit:pos2] remove we_useless

execute @e[tag=we_useless,c=1] ~~~ tellraw @a[tag=we_host] {"rawtext":[{"text":"<WorldEdit> §6"},{"selector":"@e[tag=we_useless]"},{"text":"§r Removed successfully"}]}
execute @e[tag=we_useless,c=1] ~~~ execute @a[tag=we_host] ~~~ playsound random.levelup @s ~~~ 0.5 1
execute @s[tag=we_host,scores={we_build_mode=6}] ~~~ kill @e[tag=we_useless]
execute @s[tag=we_host,scores={we_build_mode=6}] ~~~ structure delete we_selection


# errors

tellraw @a[tag=we_host,scores={we_build_mode=1..2},tag=we_pos1_not_found,tag=!we_all_pos_not_found] {"rawtext":[{"text":"<WorldEdit> "},{"text":"Operation failed, missing position selector: §6Pos1"}]}
execute @a[tag=we_host,scores={we_build_mode=1..2},tag=we_pos1_not_found,tag=!we_all_pos_not_found] ~~~ playsound item.trident.return @s ~~~ 0.5 0.8
execute @a[tag=we_host,scores={we_build_mode=1..2},tag=we_pos1_not_found,tag=!we_all_pos_not_found] ~~~ playsound random.hurt @s ~~~ 0.3 1
tellraw @a[tag=we_host,scores={we_build_mode=1..2},tag=we_pos2_not_found,tag=!we_all_pos_not_found] {"rawtext":[{"text":"<WorldEdit> "},{"text":"Operation failed, missing position selector: §6Pos2"}]}
execute @a[tag=we_host,scores={we_build_mode=1..2},tag=we_pos2_not_found,tag=!we_all_pos_not_found] ~~~ playsound item.trident.return @s ~~~ 0.5 0.8
execute @a[tag=we_host,scores={we_build_mode=1..2},tag=we_pos2_not_found,tag=!we_all_pos_not_found] ~~~ playsound random.hurt @s ~~~ 0.3 1
tellraw @a[tag=we_host,scores={we_build_mode=1..2},tag=we_all_pos_not_found] {"rawtext":[{"text":"<WorldEdit> "},{"text":"Operation failed, missing position selectors: §6Pos1§r, §6Pos2"}]}
execute @a[tag=we_host,scores={we_build_mode=1..2},tag=we_all_pos_not_found] ~~~ playsound item.trident.return @s ~~~ 0.5 0.8
execute @a[tag=we_host,scores={we_build_mode=1..2},tag=we_all_pos_not_found] ~~~ playsound random.hurt @s ~~~ 0.3 1
tellraw @a[tag=we_host,scores={we_build_mode=3},tag=we_pos1_not_found] {"rawtext":[{"text":"<WorldEdit> "},{"text":"Operation failed, missing center position selector: §6Pos1"}]}
execute @a[tag=we_host,scores={we_build_mode=3},tag=we_pos1_not_found] ~~~ playsound item.trident.return @s ~~~ 0.5 0.8
execute @a[tag=we_host,scores={we_build_mode=3},tag=we_pos1_not_found] ~~~ playsound random.hurt @s ~~~ 0.3 1
tellraw @a[tag=we_host,scores={we_build_mode=4},tag=we_pos1_not_found] {"rawtext":[{"text":"<WorldEdit> "},{"text":"Operation failed, missing center position selector: §6Pos1"}]}
execute @a[tag=we_host,scores={we_build_mode=4},tag=we_pos1_not_found] ~~~ playsound item.trident.return @s ~~~ 0.5 0.8
execute @a[tag=we_host,scores={we_build_mode=4},tag=we_pos1_not_found] ~~~ playsound random.hurt @s ~~~ 0.3 1
tellraw @a[tag=we_host,scores={we_build_mode=5},tag=we_pos1_not_found,tag=!we_all_pos_not_found] {"rawtext":[{"text":"<WorldEdit> "},{"text":"Operation failed, missing position selector: §6Pos1"}]}
execute @a[tag=we_host,scores={we_build_mode=5},tag=we_pos1_not_found,tag=!we_all_pos_not_found] ~~~ playsound item.trident.return @s ~~~ 0.5 0.8
execute @a[tag=we_host,scores={we_build_mode=5},tag=we_pos1_not_found,tag=!we_all_pos_not_found] ~~~ playsound random.hurt @s ~~~ 0.3 1
tellraw @a[tag=we_host,scores={we_build_mode=5},tag=we_pos2_not_found,tag=!we_all_pos_not_found] {"rawtext":[{"text":"<WorldEdit> "},{"text":"Operation failed, missing position selector: §6Pos2"}]}
execute @a[tag=we_host,scores={we_build_mode=5},tag=we_pos2_not_found,tag=!we_all_pos_not_found] ~~~ playsound item.trident.return @s ~~~ 0.5 0.8
execute @a[tag=we_host,scores={we_build_mode=5},tag=we_pos2_not_found,tag=!we_all_pos_not_found] ~~~ playsound random.hurt @s ~~~ 0.3 1
tellraw @a[tag=we_host,scores={we_build_mode=5},tag=we_all_pos_not_found] {"rawtext":[{"text":"<WorldEdit> "},{"text":"Operation failed, missing position selectors: §6Pos1§r, §6Pos2"}]}
execute @a[tag=we_host,scores={we_build_mode=5},tag=we_all_pos_not_found] ~~~ playsound item.trident.return @s ~~~ 0.5 0.8
execute @a[tag=we_host,scores={we_build_mode=5},tag=we_all_pos_not_found] ~~~ playsound random.hurt @s ~~~ 0.3 1
tellraw @a[tag=we_host,scores={we_build_mode=6},tag=we_all_pos_not_found] {"rawtext":[{"text":"<WorldEdit> "},{"text":"Couldn't remove any Position Selectors because there wasn't any."}]}
execute @a[tag=we_host,scores={we_build_mode=6},tag=we_all_pos_not_found] ~~~ playsound item.trident.return @s ~~~ 0.5 0.8
execute @a[tag=we_host,scores={we_build_mode=6},tag=we_all_pos_not_found] ~~~ playsound random.hurt @s ~~~ 0.3 1

# tag removing

tag @a[tag=we_host] remove we_pos1_not_found
tag @a[tag=we_host] remove we_pos2_not_found
tag @a[tag=we_host] remove we_all_pos_not_found