hyperzxmezu-dot
📎 1 file 55,328 chars
📄
pasted-code-1787040887815.txt
txt 1118 lines
▶
can you create this skript into plugin and name the plugin into DistrictX-BattleRoyale then the author name is DistrictX Developers Official then the main file name is BattleRoyale heres the skript:

import:
	java.lang.Math
	java.util.Arrays 
	java.util.ArrayList	 	
	org.bukkit.Sound
	org.bukkit.Bukkit
	org.bukkit.Location	
	org.bukkit.util.Vector
	org.bukkit.util.EulerAngle	
	com.leaf.nbt.nbtapi.NBTItem
	com.leaf.nbt.nbtapi.NBTEntity	
	com.leaf.nbt.nbtapi.NBTContainer	
	fr.mrmicky.fastparticle.FastParticle
	fr.mrmicky.fastparticle.ParticleType	
	org.bukkit.event.player.PlayerInteractEvent	
	org.bukkit.event.player.PlayerArmorStandManipulateEvent
	
options:

	#do not touch this -_-
	plugin-version: 0.2.3
			
local effect create scoreboard for %player%:	
	trigger:
		if {-bg::TitleManager}.hasScoreboard(expr-1) is true:
			{-bg::TitleManager}.removeScoreboard(expr-1)
		{-bg::TitleManager}.giveScoreboard(expr-1)

local effect delete scoreboard of %player%:	
	trigger:
		{-bg::TitleManager}.removeScoreboard(expr-1)	

local effect set scoreboard title of %player% to %string%:	
	trigger:
		{-bg::TitleManager}.setScoreboardTitle(expr-1 and expr-2)

local effect set scoreboard line %number% of %player% to %string%:	
	trigger:
		{-bg::TitleManager}.setScoreboardValue(expr-2, expr-1 and expr-3)

expression %item% with [leaf] lore %texts%:
	return type: item
	get:
		set {_r} to expr-1
		loop expressions 2:
			set {_lore} to loop-value-1
			add 1 to {_line}			
			set line {_line} of lore of {_r} to colored {_lore}		
		return {_r}		

function check_yaml(dir: text, value: text, set: text, type: text = "TEXT"):
	yaml value {_value} from "leaf.bg.%{_dir}%" is not set:
		if {_type} is "text":
			set yaml value {_value} from "leaf.bg.%{_dir}%" to {_set}
		if {_type} is "number":
			set yaml value {_value} from "leaf.bg.%{_dir}%" to {_set} parsed as number
		if {_type} is "boolean":
			set yaml value {_value} from "leaf.bg.%{_dir}%" to {_set} parsed as boolean
	if {_type} is "list":
		yaml list {_value} from "leaf.bg.%{_dir}%" is not set
		loop {_set} split at "||":
			add loop-value to yaml list {_value} from "leaf.bg.%{_dir}%"

local effect add %string% to nbt of %entity%:
	trigger:
		set {_nbtent} to new NBTEntity(expr-2)
		{_nbtent}.mergeCompound(new NBTContainer(expr-1))	

function bg_play_sound(p: player, soundLegacy: string, soundNew: string):
	if minecraft version contains "1.8":
		{_p}.playSound(location of {_p}, Sound..{_soundLegacy}, 1 and 1)	
	else:	
		{_p}.playSound(location of {_p}, Sound..{_soundNew}, 1 and 1)

#From https://forums.skunity.com/resources/mirrorutils.706/ by EWS
local expression replacer %texts% with %texts% in %text%:
	return type: text
	get:
		set {_result} to expr-3
		loop exprs-1:
			add 1 to {_n}
			replace all "%loop-value-1%" with ({_n}th element of exprs-2 ? "") in {_result}
		return {_result}			

on load:
	delete {-bg::*}
	loop currently loaded yaml files:
		loop-value contains "leaf.bg.config" or "leaf.bg.data" or "leaf.bg.arenas" or "leaf.bg.playerdata"
		unload yaml loop-value-1
	loop "config", "arenas", "data" and "playerdata":
		load yaml "plugins/BattleRoyale/%loop-value-1%.yml" as "leaf.bg.%loop-value-1%"		
	check_yaml("config", "Settings.Chat-Format", "&3{player} &8» &7{message}")			
	check_yaml("config", "Settings.Chest.Enabled", "true", "boolean")
	check_yaml("config", "Settings.Chest.Min", "3", "number")		
	check_yaml("config", "Settings.Chest.Max", "6", "number")			
	check_yaml("config", "Settings.Chest.Normal.Loot", "1 stone sword||1 diamond||1 golden carrot||1 golden apple||1 flint and steel:61||1 bread||1 baked potato||1 cooked beef||1 cooked porkchop||1 cooked chicken||1 iron helmet||1 iron chestplate||1 iron leggings||1 iron boots||1 chainmail helmet||1 chainmail chestplate||1 chainmail leggings||1 chainmail boots||1 golden helmet||1 golden chestplate||1 golden leggings||1 golden boots||1 bow||5 arrows||1 carrot plant||1 pumpkin pie||1 raw porkchop||1 raw chicken||1 cookie||1 cooked fish||1 stone sword||1 wooden sword||1 stone axe||1 wooden axe||1 fishing rod||1 bow||5 arrows||1 iron ingot||1 gold ingot||1 flint||1 stick||1 feather||1 leather helmet||1 leather chestplate||1 leather leggings||1 leather boots", "list")		
	check_yaml("config", "Settings.Death-Chest.Enabled", "true", "boolean")	
	check_yaml("config", "Settings.Death-Chest.Extra-Items", "golden apple", "list")	
	check_yaml("config", "Settings.Blocks.Allowed-To-Place", "normal wood plank", "list")		
	check_yaml("config", "Settings.blocks.Allowed-To-Break", "normal wood plank", "list")			
	check_yaml("config", "Settings.Items.Leave.Item", "magma cream")		
	check_yaml("config", "Settings.Items.Leave.Name", "&cLeave the game")	
	check_yaml("config", "Settings.Items.Leave.Slot", "8", "number")	
	check_yaml("config", "Settings.Items.Bandage.Name", "&eBandage")					
	check_yaml("config", "Settings.Timers.In-Lobby", "30", "number")		
	check_yaml("config", "Settings.Misc.Dragon-Name", "&eEnder Dragon")	
	check_yaml("config", "Settings.Misc.Allow-Jump-After", "20", "number")		
	check_yaml("config", "Settings.Scoreboard.Waiting.Name", "&eBATTLE ROYALE")	
	check_yaml("config", "Settings.Scoreboard.Waiting.Lines", "&7{now}||||&8▪ &fStarting in &a{timer}||||&8▪ &fPlayers &a{players}||||&8▪ &fArena &a{arena}||||&eplay.my-cool-server.net", "list")
	check_yaml("config", "Settings.Scoreboard.Game.Name", "&eBATTLE ROYALE")
	check_yaml("config", "Settings.Scoreboard.Game.Lines", "&7{now}||||&8▪ &fNext Border: &a{next-border}||&8▪ &fPlayers left &a{players-left}/100||&8▪ &fKills &a{kills}||||    {up}|| {left}  {right} &fPlay zone||    {back}    {status}||||&c❤ &e{health} &f{player} &7(You)||||&8▪ &fSize {size}x{size}m||||&eplay.my-cool-server.net", "list")
	check_yaml("config", "Menus.Arena-Browser.Menu", "&8&l» &7Battle Royale Arenas")	
	check_yaml("config", "Menus.Arena-Browser.Name", "&8» &7Arena: &e{arena}")	
	check_yaml("config", "Menus.Arena-Browser.Lore", "&8▪ &7Status: &e{status}||&8▪ &7Playing: &e{playing}", "list")
	check_yaml("config", "Menus.Arena-Browser.AutoJoin.Name", "&8▪ &eAutoJoin &8▪")	
	check_yaml("config", "Menus.Arena-Browser.AutoJoin.Item", "beacon")		
	check_yaml("config", "Messages.Join", "&a{player} &ehas joined to the game.")	
	check_yaml("config", "Messages.Leave", "&a{player} &eleft the game.")
	check_yaml("config", "Messages.Kill.Msg", "&9➜ &a{victim} &7was killed by &a{attacker} &7using &a{tool}")
	check_yaml("config", "Messages.Kill.Action-Bar", "&7You killed &c{victim} &7with &e{tool} &7- {players-left} &7left &c{kills} &cKILLS")	
	check_yaml("config", "Messages.Death", "&9➜ &a{victim} &7died")	
	check_yaml("config", "Messages.Starting", "&eThe battle starts in &a{seconds} &eseconds")	
	check_yaml("config", "Messages.Stats", "&e&l✦&7&l&m--------------------------------------&e&l✦||||&8&l»          &6&lBattleRoyale STATS        &8&l«||||&6» &7Wins &c{Wins}||&6» &7Kills &c{Kills}||&6» &7PlayedGames &c{PlayedGames}||&6» &7Chests &c{Chests}||&6» &7Deaths &c{deaths}||||&e&l✦&7&l&m--------------------------------------&e&l✦", "list")		
	check_yaml("config", "Messages.Summary", "||||||&e✦ &7Battle Royale &e✦||||&aWinner &7- &e{player}||&aKills &7- &e{kills}||||||", "list")
	check_yaml("config", "Titles.Win.Title", "&e&l##1 &a&lYOU WON")	
	check_yaml("config", "Titles.Win.SubTitle", "&eBATTLE ROYALE")				
	#Fixing old arenas
	if {bg::arenas::*} is set:
		broadcast "&cOld version found, converting arenas.."
		loop {bg::arenas::*}:
			set yaml value "%loop-value-1%.State" from "leaf.bg.arenas" to {bg::arena::%loop-value-1%::state}
			set yaml value "%loop-value-1%.Lobby" from "leaf.bg.arenas" to {bg::arena::%loop-value-1%::lobby}
			set yaml value "%loop-value-1%.Center" from "leaf.bg.arenas" to {bg::arena::%loop-value-1%::center}		
			set yaml value "%loop-value-1%.Id" from "leaf.bg.arenas" to {bg::arena::%loop-value-1%::route::id}		
			set yaml value "%loop-value-1%.MaxPlayers" from "leaf.bg.arenas" to 100		
			set yaml value "%loop-value-1%.MinPlayers" from "leaf.bg.arenas" to 2
			set yaml value "%loop-value-1%.Border-First" from "leaf.bg.arenas" to {bg::arena::%loop-value-1%::border::first}
			loop {bg::arena::%loop-value-1%::borders::*}:
				add loop-value-2 to yaml list "%loop-value-1%.Borders" from "leaf.bg.arenas"
			set {_id} to 1
			loop {bg::arena::%loop-value-1%::route::id} times:
				set yaml value "%loop-value-1%.Start.%{_id}%" from "leaf.bg.arenas" to {bg::arena::%loop-value-1%::start::%{_id}%}
				set yaml value "%loop-value-1%.End.%{_id}%" from "leaf.bg.arenas" to {bg::arena::%loop-value-1%::end::%{_id}%}
				add 1 to {_id}
			broadcast "&cArena &a%loop-value% &cdone..."	
		delete {bg::arenas::*}
	loop "config", "arenas" and "data" and "playerdata":	
		save yaml "leaf.bg.%loop-value-1%"
	minecraft version contains "1.8":
		set {-bg::banner} to "banner" parsed as material
	else:
		set {-bg::banner} to "black banner" parsed as material		
	bg_getArenas()		
	loop "Place" and "Break":
		loop yaml list "Settings.Blocks.Allowed-To-%loop-value-1%" from "leaf.bg.config":
			if "%loop-value-2%" parsed as material is set:
				add "%loop-value-2%" parsed as material to {-bg::arena::blocks-to-%loop-value-1%::*}
			else:
				broadcast "BG: item %loop-value-2% from Blocks To %loop-value-1% is invalid."
		wait a tick
	loop yaml list "Settings.Chest.Normal.Loot" from "leaf.bg.config":
		if loop-value-1 != "bandage":
			add "%loop-value-1%" parsed as material to {-bg::chestItems::*}
		if loop-value-1 = "bandage":	
			add paper named yaml value "Settings.Items.Bandage.Name" from "leaf.bg.config" to {-bg::chestItems::*}
	add yaml list "Settings.Chest.Custom-Loot" from "leaf.bg.config" to {-bg::chestItems::*} 			
	send "&7&l--------------------------------------------" to console
	send " " to console
	send "&aLoading &ev.{@plugin-version}&a..." to console
	broadcast "&aBattle Royale loaded!"
	send " " to console
	send "&7&l--------------------------------------------" to console
	set {-bg::TitleManager} to Bukkit.getServer().getPluginManager().getPlugin("TitleManager")	
	set {-bg::Items::Leave} to yaml value "Settings.Items.Leave.Item" from "leaf.bg.config" parsed as material named yaml value "Settings.Items.Leave.Name" from "leaf.bg.config"	
	loop {-bg::arenas::*}:		
		delete {-bg::arena::%loop-value-1%::ninjas::*} and {-bg::arena::%loop-value-1%::bad-ninjas::*}
		bg_resetarena(loop-value-1)			
				
function bg_getArenas():
	delete {-bg::arenas::*}
	loop yaml nodes with keys "" from "leaf.bg.arenas":
		if yaml value "%loop-value-1%.State" from "leaf.bg.arenas" is "ready":
			add loop-value-1 to {-bg::arenas::*}

#Easy setup pls.
function bg_send_arena_status(p: player):
	if {-bg::player::setup} is set:
		set {_arena} to {-bg::player::setup}
		send centered "&7☁☁☁☁☁☁☁☁☁☁ &a%{_arena}% &7☁☁☁☁☁☁☁☁☁☁" to {_p}
		if yaml value "%{_arena}%.Lobby" from "leaf.bg.arenas" is not set:
			send "&c&l✘ &fLobby is not set, use /bg setArenaLobby &e%{_arena}%" to {_p}
		if yaml value "%{_arena}%.Lobby" from "leaf.bg.arenas" is set:		
			send "&a&l✔ &fLobby set." to {_p}
		if yaml value "%{_arena}%.Center" from "leaf.bg.arenas" is not set:
			send "&c&l✘ &fArena center is not set, use /bg setCenter &e%{_arena}%" to {_p}
		if yaml value "%{_arena}%.Center" from "leaf.bg.arenas" is set:		
			send "&a&l✔ &fArena center set." to {_p}
		if yaml value "%{_arena}%.Border-First" from "leaf.bg.arenas" is not set:
			send "&c&l✘ &fArena First border size is not set, use /bg setbodersize &e%{_arena}% &c{size}" to {_p}
		if yaml value "%{_arena}%.Border-First" from "leaf.bg.arenas" is set:		
			send "&a&l✔ &fArena First border size is set." to {_p}		
		if size of yaml list "%{_arena}%.Borders" from "leaf.bg.arenas" = 0:
			send "&c&l✘ &fArena has no border locations add some using /bg addBorder &e%{_arena}%" to {_p}
		else:	
			set {_size} to size of yaml list "%{_arena}%.Borders" from "leaf.bg.arenas"
			send "&a&l✔ &fArena has border location(s). &a(%{_size}%)" to {_p}
		if yaml value "%{_arena}%.Start.1" from "leaf.bg.arenas" and yaml value "%{_arena}%.End.1" from "leaf.bg.arenas" is not set:
			send "&c&l✘ &fArena has no plane route use /bg setRouteStart &e%{_arena}%" to {_p}
			send "&f/bg setRouteEnd &e%{_arena}% &fand /bg saveRoute &e%{_arena}%" to {_p}
		if yaml value "%{_arena}%.Start.1" from "leaf.bg.arenas" and yaml value "%{_arena}%.End.1" from "leaf.bg.arenas" is set:
			set {_size} to size of yaml nodes with keys "%{_arena}%.Start.1" from "leaf.bg.arenas"
			send "&a&l✔ &fArena route(s) set. &a(%{_size}%&a)" to {_p}
		if yaml value "%{_arena}%.MinPlayers" from "leaf.bg.arenas" is set:		
			send "&a&l✔ &fArena min players set." to {_p}
		if yaml value "%{_arena}%.MinPlayers" from "leaf.bg.arenas" is not set:		
			send "&c&l✘ &fArena min players is not set, use /bg setMinPlayers &e%{_arena}% (number)" to {_p}	
		if yaml value "%{_arena}%.MaxPlayers" from "leaf.bg.arenas" is set:		
			send "&a&l✔ &fArena max players set." to {_p}
		if yaml value "%{_arena}%.MaxPlayers" from "leaf.bg.arenas" is not set:		
			send "&c&l✘ &fArena max players is not set, use /bg setMaxPlayers &e%{_arena}% (number)" to {_p}							
		send "&fTo save arena use &a/bg saveArena &e%{_arena}%" to {_p}
		send centered "&7☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁" to {_p}		


function bg_set_banner(p: player, side: text):
	open chest inventory with 2 rows named "&3Banner for &e%{_side}% &3side" to {_p}	
	set {_slot} to 0				
	wait a tick
	loop "Black", "Red", "Dark Green", "Brown", "Blue", "Purple", "Cyan", "Gray", "Pink", "Light Green", "Yellow", "Light Blue", "Magenta", "Orange" and "White":
		minecraft version contains "1.8" or "1.9" or "1.10" or "1.11" or "1.12":
			set {_banner} to "%loop-value% banner item" parsed as material
		else:
			set {_banner} to "%loop-value% banner" parsed as material
		make a INVENTORY GUI slot {_slot} of {_p} with {_banner} named "&8&l» <%loop-value%>%loop-value% Banner" to run:
			set {bg::stats::banner::%{_side}%::%{_p}%} to {_banner}
			send "&aBanner set for &e%{_side}% &aside"
			close {_p}'s inventory
		make a INVENTORY GUI slot 17 of {_p} with {-bg::banner} named "&8&l» &eRandom" to run:			
			delete {bg::stats::banner::%{_side}%::%{_p}%}
			send "&aBanner set for &e%{_side}% &aside"
			close {_p}'s inventory	
		add 1 to {_slot}	

command battlegrouns [] [] [] []:
	aliases: bg
	executable by: players
	trigger:
		if arg 1 is "help":
			if player has permission "bg.player":
				send "&8&l[&7&l----------&8[ &6&lBattleRoyale &8]&7&l----------&8&l]"
				send "&a/bg list"
				send "&a/bg join &8(&7arena_name&8)"
				send "&a/bg parachute"				
				send "&a/bg autojoin"
				send "&a/bg leave"
				send centered "&7☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁" to player
			if player has permission "bg.admin":
				send centered "&7☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁" to player			
				send "&7/bg &astart"	
				send "&7/bg &csetlobby"										
				send "&7/bg &ccreateArena &8(&7arena_name&8)"			
				send "&7/bg &csetArenaLobby &8(&7arena_name&8)"
				send "&7/bg &csetMinPlayers &8(&7arena_name&8) &8(&7number&8)"
				send "&7/bg &csetMaxPlayers &8(&7arena_name&8) &8(&7number&8)"
				send "&7/bg &cdeleteRoute &8(&7arena_name&8)"												
				send "&7/bg &csaveArena &8(&7arena_name&8)"							
				send "&7/bg &cdeleteArena &8(&7arena_name&8)"						
				send "&7/bg &esetCenter &8(&7arena_name&8)"	
				send "&7/bg &eaddBorder &8(&7arena_name&8)"			
				send "&7/bg &esetBorderSize &8(&7arena_name&8)"									
				send "&7/bg &esetRouteStart &8(&7arena_name&8)"							
				send "&7/bg &esetRouteEnd &8(&7arena_name&8)"	
				send "&7/bg &esaveRoute &8(&7arena_name&8)"								
				send "&7/bg &bchest add &8(&7hold the item)"	
				send "&7/bg &bchest remove &8(&7hold the item)"		
				send "&7/bg &bchest rename &8(&7hold the item)"															
				send centered "&7☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁" to player
				stop
		if arg-1 is "join" or "list" or "chest" or "parachute" or "leave" or "autojoin" or "stats":
			if player has permission "bg.player":
				if arg 1 is "join":		
					bg_join(player, arg-2)
				if arg 1 is "list":		
					if {-bg::player::%player%::state} is not set:	
						open chest inventory with 6 rows named yaml value "Menus.Arena-Browser.Menu" from "leaf.bg.config" to player
						wait a tick	
						set {_slot} to 10
						loop {-bg::arenas::*}:
							set {_item} to green clay named replacer "{arena}" with loop-value-1 in yaml value "Menus.Arena-Browser.Name" from "leaf.bg.config"
							set {_lore::*} to yaml list "Menus.Arena-Browser.Lore" from "leaf.bg.config"
							replace all "{status}" with "%{-bg::arena::%loop-value%::status}%" in {_lore::*}
							replace all "{playing}" with "%size of {-bg::arena::%loop-value%::ninjas::*}%" in {_lore::*}																	
							make a INVENTORY GUI slot {_slot} of player with {_item} with leaf lore {_lore::*} to run function bg_join(player, loop-value-1)
							add 1 to {_slot}
							if {_slot} is 17 or 26 or 35:
								add 2 to {_slot}
					make a INVENTORY GUI slot 49 of player with yaml value "Menus.Arena-Browser.AutoJoin.Item" from "leaf.bg.config" parsed as material named yaml value "Menus.Arena-Browser.AutoJoin.Name" from "leaf.bg.config" to run:
						make player execute command "bg autojoin"								
				if arg 1 is "chest":
					if player has permission "bg.admin":	
						if arg-2 is "add":
							if player's tool is not air:
								add player's tool to yaml list "Settings.Chest.Custom-Loot" from "leaf.bg.config"
								send "&aItem added."
								save yaml "leaf.bg.config" 	
						if arg-2 is "remove":
							if player's tool is not air:
								remove player's tool from yaml list "Settings.Chest.Custom-Loot" from "leaf.bg.config"
								send "&aItem removed."
								save yaml "leaf.bg.config" 	
						if arg-2 is "rename":
							if player's tool is not air:
								set name of player's tool to colored arg-3									
				if arg 1 is "parachute":
					open chest inventory with 1 row named "&8&l» &7Select Side" to player	
					wait a tick
					if {-bg::stats::banner::left::%uuid of player%} is set:
						make a INVENTORY GUI slot 0 of player with {-bg::stats::banner::left::%uuid of player%} named "&8&l» &7Left Side" to run function bg_set_banner(player, "left")
					if {-bg::stats::banner::left::%uuid of player%} is not set:
						make a INVENTORY GUI slot 0 of player with {-bg::banner} named "&8&l» &7Left Side" to run function bg_set_banner(player, "left")
					make a INVENTORY GUI slot 2 of player with fence gate named "&7¯\_(ツ)_/¯" to do nothing
					if {-bg::stats::banner::right::%uuid of player%} is set:
						make a INVENTORY GUI slot 4 of player with {-bg::stats::banner::right::%uuid of player%} named "&8&l» &7Left Side" to run function bg_set_banner(player, "right")
					if {-bg::stats::banner::right::%uuid of player%} is not set:
						make a INVENTORY GUI slot 4 of player with {-bg::banner} named "&8&l» &7Right Side" to run function bg_set_banner(player, "right")				
				if arg 1 is "leave":	
					bg_leave(player)
				if arg 1 is "autojoin":		
					if {-bg::player::%player%::state} is not set:
						loop {-bg::arenas::*}:
							if {-bg::arena::%loop-value%::status} is "WAITING" or "STARTING":
								bg_join(player, loop-value)
								stop
				if arg-1 is "stats":
					loop yaml list "Messages.Stats" from "leaf.bg.config":
						set {_msg} to loop-value-1
						loop "Kills", "Wins", "Deaths", "PlayedGames" and "Chests":
							set {_int} to yaml value "%uuid of player%.%loop-value-2%" from "leaf.bg.playerdata"
							replace all "{%loop-value-2%}" with "%{_int}%" in {_msg}
						send colored {_msg} to player
		if arg 1 is "createArena" or "setArenaLobby" or "setMaxPlayers" or "setMinPlayers" or "setlobby" or "setRouteStart" or "setRouteEnd" or "saveRoute" or "deleteRoute" or "addBorder" or "remove-border" or "setCenter" or "start" or "saveArena" or "reload" or "setBorderSize":
			if player has permission "bg.admin":
				if arg 1 is "createArena":		
					if arg-2 is set:
						if yaml value "%arg-2%.State" from "leaf.bg.arenas" is not set:
							set yaml value "%arg-2%.State" from "leaf.bg.arenas" to "setup"
							set {-bg::player::setup} to arg-2
							bg_send_arena_status(player)
							send "&aArena &c%arg-2% &ahas been created!"
						else:
							send "&aThis arena already exists!"	
					else:
						send "&aSpecify Arena!"				
				if arg 1 is "setArenaLobby":
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:
						set yaml value "%arg-2%.Lobby" from "leaf.bg.arenas" to location of player
						bg_send_arena_status(player)
						send "&aLobby for Arena &3%arg-2% &ahas been set!"						
					else:
						send "&aThis arena not exists"		
				if arg 1 is "setMaxPlayers":	
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:
						set yaml value "%arg-2%.MaxPlayers" from "leaf.bg.arenas" to arg-3 parsed as number
						bg_send_arena_status(player)
						send "&aMax Players for Arena &3%arg-2% &ahas been set!"						
					else:
						send "&aThis arena not exists"	
				if arg 1 is "setMinPlayers":	
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:
						set yaml value "%arg-2%.MinPlayers" from "leaf.bg.arenas" to arg-3 parsed as number
						bg_send_arena_status(player)
						send "&aMin Players for Arena &3%arg-2% &ahas been set!"						
					else:
						send "&aThis arena not exists"																				
				if arg 1 is "setlobby":	
					if player has permission "bg.admin":
						set yaml value "Locations.Lobby" from "leaf.bg.data" to location of player
						save "leaf.bg.data"
						send "&aLobby set."	
				if arg 1 is "setRouteStart":	
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:
						if yaml value "%arg-2%.Id" from "leaf.bg.arenas" is not set:
							set yaml value "%arg-2%.Id" from "leaf.bg.arenas" to 1
						set {_id} to yaml value "%arg-2%.Id" from "leaf.bg.arenas"
						set yaml value "%arg-2%.Start.%{_id}%" from "leaf.bg.arenas" to location of player
						send "&aStart with id &e&n%{_id}%&r &aset."
				if arg 1 is "setRouteEnd":	
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:			
						if yaml value "%arg-2%.Id" from "leaf.bg.arenas" is not set:
							set yaml value "%arg-2%.Id" from "leaf.bg.arenas" to 1
						set {_id} to yaml value "%arg-2%.Id" from "leaf.bg.arenas"
						set yaml value "%arg-2%.End.%{_id}%" from "leaf.bg.arenas" to location of player
						send "&aEnd with id &e&n%{_id}%&r &aset."	
				if arg 1 is "saveRoute":	
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:		
						set {_id} to yaml value "%arg-2%.Id" from "leaf.bg.arenas"
						if yaml value "%arg-2%.Start.%{_id}%" from "leaf.bg.arenas" and yaml value "%arg-2%.End.%{_id}%" from "leaf.bg.arenas" is set:
							set yaml value "%arg-2%.Id" from "leaf.bg.arenas" to yaml value "%arg-2%.Id" from "leaf.bg.arenas" +1
							bg_send_arena_status(player)
							send "&aRoute with id &e&n%{_id}%&r&a saved."
				if arg 1 is "deleteRoute":	
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:
						set {_id} to yaml value "%arg-2%.Id" from "leaf.bg.arenas"
						delete yaml value "%arg-2%.Start.%{_id}%" from "leaf.bg.arenas"
						delete yaml value "%arg-2%.End.%{_id}%" from "leaf.bg.arenas"
						bg_send_arena_status(player)
						send "&aDeleted route with id &e&n%{_id}%&r&a."
						set yaml value "%arg-2%.Id" from "leaf.bg.arenas" to yaml value "%arg-2%.Id" from "leaf.bg.arenas" -1
				if arg 1 is "addBorder":	
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:				
						add location of player to yaml list "%arg-2%.Borders" from "leaf.bg.arenas"
						bg_send_arena_status(player)
						send "&aAdded border location&r&a to arena &e&n%arg-2%&r&a."					
				if arg 1 is "setCenter":	
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:			
						set yaml value "%arg-2%.Center" from "leaf.bg.arenas" to location of player
						bg_send_arena_status(player)
						send "&aCenter for Arena &b%arg-2% &ahas been set!"		
				if arg 1 is "setBorderSize":	
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:
						arg-3 parsed as number is set
						set yaml value "%arg-2%.Border-First" from "leaf.bg.arenas" to arg-3 parsed as number
						bg_send_arena_status(player)
						send "&aFirst Border for Arena &b%arg-2% &ahas been set to &b%arg-3%!"															
				if arg 1 is "start":
					if {-bg::arena::%{-bg::player::%player%::arena}%::status} is "WAITING" or "STARTING":
						bg_start({-bg::player::%player%::arena})
				if arg 1 is "reload":		
					broadcast "&aReloading..."
					wait a tick
					make console execute command "sk reload %script%"
				if arg 1 is "saveArena":	
					if yaml value "%arg-2%.State" from "leaf.bg.arenas" is set:			
						if yaml value "%arg-2%.Lobby" from "leaf.bg.arenas" is set:
							if yaml value "%arg-2%.Start.1" from "leaf.bg.arenas" is set:
								if yaml value "%arg-2%.End.1" from "leaf.bg.arenas" is set:						
									if yaml value "%arg-2%.Center" from "leaf.bg.arenas" is set:
										if yaml value "%arg-2%.MaxPlayers" from "leaf.bg.arenas" is set:
											if yaml value "%arg-2%.MinPlayers" from "leaf.bg.arenas" is set:
												if size of yaml list "%arg-2%.Borders" from "leaf.bg.arenas" > 0:
													set yaml value "%arg-2%.State" from "leaf.bg.arenas" to "ready"
													add arg-2 to {-bg::arenas::*}
													send "&aArena &c%arg-2% &ahas been saved."
													save yaml "leaf.bg.arenas"
													bg_resetarena(arg-2)	
												else:
													send "&aNo borders added."
											else:
												send "&aMin players not set!"												
										else:
											send "&aMax players not set!"									
									else:
										send "&aCenter is not set!"										
								else:
									send "&aEnd point is not set"											
							else:
								send "&aStart point is not set"																			
						else:
							send "&aLobby is not set!"						
					else:
						send "&aThis arena not exists"	
				if arg 1 is "deleteArena":		
					if {-bg::arena::%arg-2%::state} is set:
						bg_resetarena(arg-2)
						delete {-bg::arena::%arg-2%::*}							
						remove arg-2 from {-bg::arenas::*}
						delete yaml value arg-2 from "leaf.bg.arenas"
						send "&aArena &c%arg-2% &ahas been deleted."
						save yaml "leaf.bg.arenas"
					else:
						send "&aThis arena not exists"
	
on PlayerArmorStandManipulateEvent:
	if {-bg::player::%event.getPlayer()%::state} is set:	
		cancel event

on PlayerInteractEvent:
	if {-bg::player::%event.getPlayer()%::state} is set:	
		if "%event.getAction()%" is "PHYSICAL":
			cancel event
	
on chat:
	if {-bg::player::%player%::state} is set:
		cancel event
		send replacer "{player}" and "{message}" with "%player%" and message in yaml value "Settings.Chat-Format" from "leaf.bg.config" to {-bg::arena::%{-bg::player::%player%::arena}%::ninjas::*}

on drop:
	if {-bg::arena::%{-bg::player::%player%::arena}%::status} is "STARTING" or "WAITING":
		cancel event

on dismount:
	if {-bg::player::%player%::state} is set:
		if distance between yaml value "%{-bg::player::%player%::arena}%.Start.%{-bg::arena::%{-bg::player::%player%::arena}%::route}%" from "leaf.bg.arenas" and player > yaml value "Settings.Misc.Allow-Jump-After" from "leaf.bg.config":
			metadata value "BG-FLYING" of player is set
			bg_parachute(player)	
			stop
		wait a tick
		if player is riding:
			stop
		metadata value "BG-PARACHUTE" of player is set:
			wait a tick
			loop chickens in radius 5 of player:
				metadata value "BG-OWNER" of loop-entity is "%player%"
				make player ride loop-entity
				stop
		loop chickens in radius 5 of player:
			metadata value "BG-PLANE" of loop-entity is "%player%"
			make player ride loop-entity

on packet PacketPlayInSteerVehicle:
	if {-bg::player::%player%::state} is set:
		metadata value "BG-PARACHUTE" of player is set:
			event.setCancelled(true)
		metadata value "BG-FLYING" of player is set:
			if distance between yaml value "%{-bg::player::%player%::arena}%.Start.%{-bg::arena::%{-bg::player::%player%::arena}%::route}%" from "leaf.bg.arenas" and player < yaml value "Settings.Misc.Allow-Jump-After" from "leaf.bg.config":
				event.setCancelled(true)		

on right click on chest or trapped chest:	
	if {-bg::arena::%{-bg::player::%player%::arena}%::status} is "IN-GAME" or "FLYING":	
		if yaml value "Settings.Chest.Enabled" from "leaf.bg.config" is true:	
			if {-bg::arena::%{-bg::player::%player%::arena}%::chests::%location of event-block%} is not set:
				clear inventory of block at event-block
				set {_items} to random number between yaml value "Settings.Chest.Min" from "leaf.bg.config" and yaml value "Settings.Chest.Max" from "leaf.bg.config"
				set {_loot::*} to {-bg::chestItems::*}	
				loop rounded {_items} times:
					set {_slot} to rounded random number between 0 and 26
					set {_item} to random element out of {_loot::*}
					remove {_item} from {_loot::*}
					add {_item} to slot {_slot} of event-block
				add 1 to {-bg::stats::chests::%uuid of player%}
				bg_stats("add", player, "Chests")
				set {-bg::arena::%{-bg::player::%player%::arena}%::chests::%location of event-block%} to location of event-block
					
on hunger bar change:	
	if {-bg::player::%player%::state} is "IN-GAME":
		if {-bg::arena::%{-bg::player::%player%::arena}%::status} is "STARTING" or "WAITING":
			set player's hunger to 20
		
function bg_death_chest(p: player, arena: text):
	if yaml value "Settings.Death-Chest.Enabled" from "leaf.bg.config" is true:
		set {_helmet} to {_p}'s helmet		
		set {_chestplate} to {_p}'s chestplate
		set {_leggings} to {_p}'s leggings
		set {_boots} to {_p}'s boots	
		loop blocks in radius 1 of {_p}:
			loop-block is air
			set loop-block to chest
			set {-bg::arena::%{_arena}%::chests::%location of loop-block%} to location of loop-block
			add {_helmet}, {_chestplate}, {_leggings} and {_boots} to loop-block
			loop items in {_p}'s inventory:
				add loop-item to loop-block
			loop yaml list "Settings.Death-Chest.Extra-Items" from "leaf.bg.config":
				add "%loop-value-2%" parsed as material to loop-block
			add location of loop-block to {-bg::arena::%{_arena}%::KILL-ME-PLS::*}
			stop
		loop items in {_p}'s inventory:
			drop loop-item at {_p}
	if yaml value "Settings.Death-Chest.Enabled" from "leaf.bg.config" is false:
		loop items in {_p}'s inventory:
			drop loop-item at {_p}	

function bg_player_death(p: player, killer: text = "null"):
	set {_arena} to {-bg::player::%{_p}%::arena}
	set {_players-left} to size of {-bg::arena::%{_arena}%::ninjas::*}
	bg_death_chest({_p}, {_arena})
	bg_remove({_p}, {_arena})
	create lightning effect at {_p}
	add {_p} to {-bg::arena::%{_arena}%::bad-ninjas::*}
	bg_stats("add", {_p}, "Deaths")
	set {_p}'s gamemode to spectator
	send title "&e&l##%size of {-bg::arena::%{_arena}%::ninjas::*}+1% &c&lGAME OVER" with subtitle "&eBATTLE ROYALE" to {_p} with 10 fadein and 10 fadeout for 70
	if {_killer} != "null":
		set {_killer} to {_killer} parsed as player
		if {_killer} is not {_p}:
			bg_stats("add", {_killer}, "Kills")
			add 1 to {-bg::player::%{_killer}%::kills}
			if {_killer}'s tool is set:
				set {_display} to name of {_killer}'s tool
				set {_display} to first element of {_display} split at " of " 
				replace all "_" with " " in {_display}
			else:
				set {_display} to "Unknown"
			set {_bar} to replacer "{victim}", "{players-left}", "{kills}", "{tool}" and "{attacker}" with {_p}'s display name, "%{_players-left}%", "%{-bg::player::%{_killer}%::kills}%", "%{_display}%" and {_killer}'s display name in yaml value "Messages.Kill.Action-Bar" from "leaf.bg.config"
			set {_msg} to replacer "{victim}", "{players-left}", "{kills}", "{tool}" and "{attacker}" with {_p}'s display name, "%{_players-left}%", "%{-bg::player::%{_killer}%::kills}%", "%{_display}%" and {_killer}'s display name in yaml value "Messages.Kill.Msg" from "leaf.bg.config"
			send {_msg} to {-bg::arena::%{_arena}%::ninjas::*}
			send action bar "%{_bar}%" to {_killer} 
		else:
			send replacer "{victim}" with {_p}'s display name in yaml value "Messages.Death" from "leaf.bg.config" to {-bg::arena::%{_arena}%::ninjas::*}			
	else:
		send replacer "{victim}" with {_p}'s display name in yaml value "Messages.Death" from "leaf.bg.config" to {-bg::arena::%{_arena}%::ninjas::*}

on death of player:
	if {-bg::arena::%{-bg::player::%victim%::arena}%::status} is "IN-GAME" or "FLYING":
		wait a tick
		force victim to respawn
		if attacker is set:
			bg_player_death(victim, "%attacker%")
		else:
			bg_player_death(victim)	

on damage of player:
	if {-bg::player::%victim%::state} is "IN-GAME":
		if {-bg::arena::%{-bg::player::%victim%::arena}%::status} is "STARTING" or "WAITING":
			cancel event
			damage cause is void
			teleport victim to yaml value "%{-bg::player::%victim%::arena}%.Lobby" from "leaf.bg.arenas"				
		if {-bg::arena::%{-bg::player::%victim%::arena}%::status} is "RESTARTING":				
			cancel event	
						
function bg_remove(p: player, arena: text):
	remove {_p} from {-bg::arena::%{_arena}%::ninjas::*}
	if {-bg::arena::%{_arena}%::status} is "IN-GAME" or "FLYING":	
		size of {-bg::arena::%{_arena}%::ninjas::*} = 1
		set {-bg::arena::%{_arena}%::status} to "RESTARTING"
		bg_delete_arena_entities({_arena})
		loop {-bg::arena::%{_arena}%::ninjas::*}:
			set {_p} to loop-value-1
		send title yaml value "Titles.Win.Title" from "leaf.bg.config" with subtitle yaml value "Titles.Win.SubTitle" from "leaf.bg.config" to {_p} with 10 fadein and 10 fadeout for 80
		loop yaml list "Messages.Summary" from "leaf.bg.config":
			set {_msg} to loop-value-1
			replace all "{player}" with "%{_p}%" in {_msg}
			replace all "{kills}" with "%{-bg::player::%{_p}%::kills}%" in {_msg}
			send message centered colored {_msg} to {-bg::arena::%{_arena}%::ninjas::*} and {-bg::arena::%{_arena}%::bad-ninjas::*}
		bg_stats("add", {_p}, "Wins")
		loop 10 times:
			minecraft version contains "1.8" or "1.9" or "1.10" or "1.11" or "1.12"
			if {-bg::player::%{_p}%::state} is "IN-GAME":
				wait a second	
		bg_resetarena({_arena})

on unload:
	send "&7&l--------------------------------------------" to console
	send " " to console
	send "&aDisabling &ev.{@plugin-version}&a..." to console
	send "&ev.{@plugin-version} &adisabled!" to console
	send " " to console
	send "&7&l--------------------------------------------" to console

function bg_stats(do: text, p: player, type: text = "", int: number = 1):
	{_do} is "check":
		loop "Kills", "Wins", "Deaths", "PlayedGames" and "Chests":
			yaml value "%uuid of {_p}%.%loop-value-1%" from "leaf.bg.playerdata" is not set
			set yaml value "%uuid of {_p}%.%loop-value-1%" from "leaf.bg.playerdata" to 0
	{_do} is "add":
		set yaml value "%uuid of {_p}%.%{_type}%" from "leaf.bg.playerdata" to yaml value "%uuid of {_p}%.%{_type}%" from "leaf.bg.playerdata" + {_int}		
	save yaml "leaf.bg.playerdata" with no extra lines between nodes
	
function bg_leave(p: player):
	if {-bg::player::%{_p}%::state} is set:
		if {-bg::player::%{_p}%::state} is "IN-GAME":
			bg_remove({_p}, {-bg::player::%{_p}%::arena})
			send replacer "{player}" with {_p}'s display name in yaml value "Messages.Leave" from "leaf.bg.config" to {-bg::arena::%{-bg::player::%{_p}%::arena}%::ninjas::*}		
		delete {-bg::player::%{_p}%::*}	
		bg_clear_player({_p})
		delete scoreboard of {_p}
		teleport {_p} to yaml value "Locations.Lobby" from "leaf.bg.data"
		
function bg_join(p: player, arena: text):	
	if {-bg::player::%{_p}%::state} is not set:
		if yaml value "%{_arena}%.State" from "leaf.bg.arenas" is "ready":
			if {-bg::arena::%{_arena}%::status} is "WAITING" or "STARTING":
				if size of {-bg::arena::%{_arena}%::ninjas::*} < yaml value "%{_arena}%.MaxPlayers" from "leaf.bg.arenas":
					bg_clear_player({_p})
					set {-bg::player::%{_p}%::state} to "IN-GAME"
					set {-bg::player::%{_p}%::arena} to {_arena}
					set {-bg::player::%{_p}%::kills} to 0
					set slot yaml value "Settings.Items.Leave.Slot" from "leaf.bg.config" of {_p} to {-bg::Items::Leave}
					add {_p} to {-bg::arena::%{_arena}%::ninjas::*}		
					if size of {-bg::arena::%{_arena}%::ninjas::*} = yaml value "%{_arena}%.MinPlayers" from "leaf.bg.arenas":
						bg_start_countdown({_arena})											
					send replacer "{player}" and "{players-count}" with {_p}'s display name and "%size of {-bg::arena::%{_arena}%::ninjas::*}%" in yaml value "Messages.Join" from "leaf.bg.config" to {-bg::arena::%{_arena}%::ninjas::*}
					teleport {_p} to yaml value "%{_arena}%.Lobby" from "leaf.bg.arenas"
					bg_createBoard({_p}, "BG-WAITING", 9)
				else:
					send "&7This arena is full" to {_p}
			else:
				send "&7This game is running" to {_p}
		else:
			send "&7This arena not exists" to {_p}
	else:
		send "&7You are already playing." to {_p}
					
on join:
	bg_stats("check", player)
		
on right click:
	if {-bg::player::%player%::state} is set:
		name of event-item is yaml value "Settings.Items.Leave.Name" from "leaf.bg.config":
			cancel event
			bg_leave(player)
		if event-item = paper named yaml value "Settings.Items.Bandage.Name" from "leaf.bg.config":
			if {-bg::player::%player%::bandaging} is not set:
				set {-bg::player::%player%::bandaging} to true
				set {_bandage} to event-item
				send "&7Bandaging... do not move"
				set {_loc} to location of player
				while player's tool is {_bandage}:
					if distance between {_loc} and player > 0.5:
						delete {-bg::player::%player%::bandaging}
						send "&c&7Bandaging canceled"
						stop
					add 5 to {_timer}	
					send action bar "&7Bandaging... &e%{_timer}%/100" to player
					if {_timer} = 1*{_timer}:
						bg_play_sound(player, "DRINK", "ENTITY_GENERIC_DRINK")
					if {_timer} = 100:
						delete {-bg::player::%player%::bandaging}
						remove 1 of {_bandage} from player
						heal player
						send "&aBandage used"
					wait 8 ticks

on quit:
	if {-bg::player::%player%::state} is set:
		bg_leave(player)
	delete scoreboard of player	

on entity target:
	metadata value "BG-PLANE" of event-entity is set:
		cancel event

on damage of entity:
	loop "PLANE", "OWNER", "FLYING" and "PARACHUTE":
		metadata value "BG-%loop-value-1%" of victim is set:
			cancel event
			stop

function bg_delete_arena_entities(arena: text):
	set {_w} to world of yaml value "%{_arena}%.Center" from "leaf.bg.arenas"
	loop ...{_w}.getEntities():
		loop-value != player
		loop-value.remove()		

function bg_load_chunks(loc: location):
	set {_pos} to {_loc}
	set z-coordinate of {_pos} to z-coordinate of {_loc} - 16 * 4
	loop 2 * 4 + 1 times:
		set x-coordinate of {_pos} to x-coordinate of {_loc} - 16 * 4
		loop 2 * 4 + 1 times:
			{_pos}.getChunk().load()
			add 16 to x-coordinate of {_pos}
		add 16 to z-coordinate of {_pos}
		
function bg_player_track_plane2(p: player, arena: text, base: entity, plane: entity):
	wait a tick	
	while {-bg::arena::%{_arena}%::status} is "FLYING":
		set {_loc} to location of {_plane}
		add 10 to y-coords of {_loc}
		set velocity of {_base} to vector between {_base} and {_loc}		
		wait a tick	

function bg_player_track_plane(p: player, arena: text, start: location, plane: entity):
	add 180 to yaw of {_start}
	teleport {_p} to {_start}
	wait a tick
	loop 10 times:
		set {_loc} to location of {_plane}
		add 5 to y-coords of {_loc}
		set pitch of {_loc} to pitch of {_p}
		set yaw of {_loc} to yaw of {_p}
		teleport {_p} to {_loc}
		wait a tick			
	set {_p}'s gamemode to survival
	spawn 1 chicken at {_plane}
	set {_base} to spawned chicken
	add "{Silent:1,NoGravity:1b}" to nbt of {_base}
	apply invisibility without any particles to {_base} for 7 days
	set metadata value "BG-FLYING" of {_p} to true
	set metadata value "BG-PLANE" of {_base} to {_p}
	bg_player_track_plane2({_p}, {_arena}, {_base}, {_plane})
	loop 10 times:
		if {_p}'s vehicle is not set:
			make {_p} ride {_base}
		wait a tick

function bw_border_closing(arena: text, time: number):
	set {-bg::arena::%{_arena}%::next-border} to "&cBORDER CLOSING"
	set {_w} to world of yaml value "%{_arena}%.Center" from "leaf.bg.arenas"
	{_w}.getWorldBorder().setSize({-bg::arena::%{_arena}%::border::current-size} and {_time})
	loop {_time} times:
		if {-bg::arena::%{_arena}%::status} is "FLYING" or "IN-GAME":
			wait a second
		else:
			stop
	bg_start_border({_arena})

on explode:
	metadata value "BG-PLANE" of event-entity is set:
		cancel event

function bg_start_border(arena: text):
	set {_time_machine} to 1
	set {_time_machine2} to 60
	while {-bg::arena::%{_arena}%::status} is "FLYING" or "IN-GAME":
		remove 1 from {_time_machine2}
		if {_time_machine2} = 0:
			if {_time_machine} = 0:
				set {-bg::arena::%{_arena}%::border::current-size} to {-bg::arena::%{_arena}%::border::current-size}/2
				bw_border_closing({_arena}, 120)
				stop
			set {_time_machine2} to 60
			remove 1 from {_time_machine}
		if {_time_machine2} < 10:
			set {_mark2} to 0
		else:
			set {_mark2} to ""					
		if {_time_machine} < 10:
			set {_mark1} to 0
		else:
			set {_mark1} to ""			
		set {-bg::arena::%{_arena}%::next-border} to "%{_mark1}%%{_time_machine}%:%{_mark2}%%{_time_machine2}%"
		wait a second

function plane_start_route(arena: text, plane: entity, start: location, end: location):
	set {_oldY} to y-coords of {_start}
	set {_dir} to {_end}.getDirection()
	while {-bg::arena::%{_arena}%::status} is "FLYING":
		{_start}.getChunk().load()
		{_dir}.multiply(1)
		{_start}.add({_dir})
		{_dir}.normalize()	
		set {_vector} to vector from {_end} to {_plane}
		set yaw of {_start} to vector yaw of {_vector}-11
		set pitch of {_start} to vector pitch of {_vector}
		teleport {_plane} to {_start}
		if y-coords of {_start} < {_oldY}:
			set {_calc} to {_oldY} - y-coords of {_start}
			add {_calc} to y-coords of {_start}
		if distance between yaml value "%{_arena}%.Start.%{-bg::arena::%{_arena}%::route}%" from "leaf.bg.arenas" and {_plane} > yaml value "Settings.Misc.Allow-Jump-After" from "leaf.bg.config":
			loop {-bg::arena::%{_arena}%::ninjas::*}:
				metadata value "BG-FLYING" of loop-value is set:	
					send title "&e" with subtitle "&ePRESS &bSNEAK &eTO OPEN PARACHUTE" to loop-value-1 with 0 fadein and 0 fadeout for 20		
		if distance between {_plane} and {-bg::arena::%{_arena}%::end::%{-bg::arena::%{_arena}%::route}%} < 50:
			bg_load_chunks({_start})
			wait a tick
			loop {-bg::arena::%{_arena}%::ninjas::*}:
				metadata value "BG-FLYING" of loop-value is set:
					bg_parachute(loop-value)	
			loop entities in radius 100 of {-bg::arena::%{_arena}%::end::%{-bg::arena::%{_arena}%::route}%}:
				metadata value "BG-PLANE" of loop-entity is "DRAGON":
					clear loop-entity	
			set {-bg::arena::%{_arena}%::status} to "IN-GAME"
			stop					
		wait a tick	

function bg_start(arena: text):
	set {-bg::arena::%{_arena}%::status} to "FLYING"
	set {-bg::arena::%{_arena}%::route} to rounded random number between 1 and yaml value "%{_arena}%.Id" from "leaf.bg.arenas" -1
	set {_start} to yaml value "%{_arena}%.Start.%{-bg::arena::%{_arena}%::route}%" from "leaf.bg.arenas"
	set {_end} to yaml value "%{_arena}%.End.%{-bg::arena::%{_arena}%::route}%" from "leaf.bg.arenas"
	{_start}.getChunk().load()
	bg_delete_arena_entities({_arena})	
	spawn an ender dragon at {_start}
	set {_plane} to spawned ender dragon
	if minecraft version contains "1.8":
		add "{Silent:1,NoGravity:1b,CustomName:""%yaml value ""Settings.Misc.Dragon-Name"" from ""leaf.bg.config""%"",DragonPhase:10}" to nbt of {_plane} 
	else:
		add "{Silent:1b,NoGravity:1b,Name:""%yaml value ""Settings.Misc.Dragon-Name"" from ""leaf.bg.config""%"",DragonPhase:0}" to nbt of {_plane} 
	set metadata value "BG-PLANE" of {_plane} to "DRAGON"		
	set {_w} to world of yaml value "%{_arena}%.Center" from "leaf.bg.arenas"
	set {-bg::arena::%{_arena}%::border::current-size} to rounded yaml value "%{_arena}%.Border-First" from "leaf.bg.arenas"
	set {-bg::arena::%{_arena}%::game-border} to random element out of yaml list "%{_arena}%.Borders" from "leaf.bg.arenas"
	{_w}.getWorldBorder().setSize({-bg::arena::%{_arena}%::border::current-size})	
	{_w}.getWorldBorder().setCenter({-bg::arena::%{_arena}%::game-border})
	bg_start_border({_arena})	
	loop {-bg::arena::%{_arena}%::ninjas::*}:	
		bg_clear_player(loop-value)
		set loop-value's gamemode to spectator
	plane_start_route({_arena}, {_plane}, {_start}, {_end})			
	loop {-bg::arena::%{_arena}%::ninjas::*}:
		apply blindness without any particles to loop-value-1 for 3 seconds
		bg_createBoard(loop-value, "BG-GAME", 15)	
		apply invisibility without any particles to loop-value for 7 days
		loop-value-1.setAllowFlight(true)
		loop-value-1.setFlying(true)
		bg_stats("add", loop-value-1, "PlayedGames")
		bg_player_track_plane(loop-value, {_arena}, {_start}, {_plane})				

function bg_clear_parachute(p: player):
	{_p}.setFlying(false)
	{_p}.setAllowFlight(false)
	teleport {_p} to block 1.5 above {_p}
	set {_w} to world of {_p}	
	set {_loc} to location of {_p}
	FastParticle.spawnParticle({_w}, ParticleType.EXPLOSION_HUGE, {_loc} and 1)
	delete metadata value "BG-PARACHUTE" of {_p}
	loop entities in radius 3 of {_p}:
		metadata value "BG-OWNER" of loop-entity is {_p}:
			clear loop-entity	

function bg_parachute(p: player):
	wait a tick
	delete metadata value "BG-FLYING" of {_p}
	set metadata value "BG-PARACHUTE" of {_p} to "SET"
	spawn an chicken at {_p}
	set {_base} to spawned chicken
	add "{Silent:1,NoGravity:1b,Invisible:1b}" to nbt of {_base}
	set metadata value "BG-OWNER" of {_base} to "%{_p}%"	
	spawn an armor stand at {_p}
	set {_left} to spawned armor stand	
	if {bg::stats::banner::left::%{_p}%} is set:	
		set {_left}'s helmet to {bg::stats::banner::left::%{_p}%}
	else:
		set {_left}'s helmet to {-bg::banner}
	add "{Pose:{Head:[265f,94f,0f]},NoGravity:1b,Invisible:1b}" to nbt of {_left}
	spawn an armor stand at {_p}
	set {_right} to spawned armor stand
	if {bg::stats::banner::right::%{_p}%} is set:	
		set {_right}'s helmet to {bg::stats::banner::right::%{_p}%}
	else:
		set {_right}'s helmet to {-bg::banner}
	add "{Pose:{Head:[265f,270f,0f]},NoGravity:1b,Invisible:1b}" to nbt of {_right}
	spawn an armor stand at {_p}		
	set {_center} to spawned armor stand	
	set {_center}'s helmet to fence gate
	add "{NoGravity:1b,Invisible:1b}" to nbt of {_center}
	make {_p} ride {_base}	
	set metadata value "BG-OWNER" of {_center} to "%{_p}%"
	set metadata value "BG-OWNER" of {_left} to "%{_p}%"
	set metadata value "BG-OWNER" of {_right} to "%{_p}%"		
	remove invisibility from {_p}
	set {_w} to world of {_p}
	while metadata value "BG-PARACHUTE" of {_p} is set:
		if {_base} is alive:
			{_base} is not on ground:
				teleport {_left} to {_p}
				teleport {_right} to {_p}
				teleport {_center} to {_p}
				add "{Rotation:[%{_p}'s yaw%f, %{_p}'s pitch%f]}" to nbt of {_base} 
				{_p}'s pitch < 70		
				{_p}'s pitch > -30
				push {_base} vector between {_p} and block in front of {_p} at speed 0.06
			push {_base} downwards at speed 0.06
			if block at {_p} != air:
				bg_clear_parachute({_p})
				stop	
			FastParticle.spawnParticle({_w}, ParticleType.FLAME, location of {_p} and 1)	
			FastParticle.spawnParticle({_w}, ParticleType.VILLAGER_HAPPY, location of {_p} and 1)	
		else:
			stop
		wait a tick

on break:
	if {-bg::player::%player%::state} is "IN-GAME":
		if {-bg::arena::%{-bg::player::%player%::arena}%::status} is "IN-GAME" or "FLYING":
			loop {-bg::arena::blocks-to-break::*}:
				loop-value is event-block 	
				if {-bg::arena::%{-bg::player::%player%::arena}%::PLACED-BLOCKS::%location of event-block%} is set:
					delete {-bg::arena::%{-bg::player::%player%::arena}%::PLACED-BLOCKS::%location of event-block%}
					stop
				if {-bg::arena::%{-bg::player::%player%::arena}%::PLACED-BLOCKS::%location of event-block%} is not set:	
					set {-bg::arena::%{-bg::player::%player%::arena}%::BROKEN-BLOCKS::%location of event-block%} to location of event-block
					set {-bg::arena::%{-bg::player::%player%::arena}%::BROKEN-BLOCKS-TYPE::%location of event-block%} to type of event-block
				stop
			cancel event										
		else:
			cancel event
	
on place:
	if {-bg::player::%player%::state} is "IN-GAME":
		if {-bg::arena::%{-bg::player::%player%::arena}%::status} is "IN-GAME" or "FLYING":
			loop {-bg::arena::blocks-to-place::*}:
				loop-value is event-block 
				if {-bg::arena::%{-bg::player::%player%::arena}%::PLACED-BLOCKS::%location of event-block%} is not set:
					set {-bg::arena::%{-bg::player::%player%::arena}%::PLACED-BLOCKS::%location of event-block%} to location of event-block
				stop
			cancel event
		else:
			cancel event

function bg_start_countdown(arena: text):
	set {-bg::arena::%{_arena}%::status} to "STARTING"
	loop {-bg::arena::%{_arena}%::seconds} times:
		if {-bg::arena::%{_arena}%::status} is "STARTING" or "WAITING":
			size of {-bg::arena::%{_arena}%::ninjas::*} >= 2
			remove 1 from {-bg::arena::%{_arena}%::seconds}	
			if {-bg::arena::%{_arena}%::seconds} = 1 or 2 or 3 or 4 or 5 or 10:
				send replacer "{seconds}" with "%{-bg::arena::%{_arena}%::seconds}%" in yaml value "Messages.Starting" from "leaf.bg.config" to {-bg::arena::%{_arena}%::ninjas::*}	
			if {-bg::arena::%{_arena}%::seconds} = 1:
				size of {-bg::arena::%{_arena}%::ninjas::*} >= 2:
					bg_start({_arena})
				else:
					set {-bg::arena::%{_arena}%::status} to "WAITING"
					set {-bg::arena::%{_arena}%::seconds} to yaml value "Settings.Timers.In-Lobby" from "leaf.bg.config"
			wait a second			
		else:
			stop
		
function bg_resetarena(arena: text):
	set {_w} to world of yaml value "%{_arena}%.Center" from "leaf.bg.arenas"
	{_w}.getWorldBorder().reset()
	{_w}.getWorldBorder().setSize(10000)
	loop {-bg::arena::%{_arena}%::ninjas::*} and {-bg::arena::%{_arena}%::bad-ninjas::*}:
		delete {-bg::player::%loop-value-1%::*}		
		bg_clear_player(loop-value-1)
		delete scoreboard of loop-value-1
		teleport loop-value-1 to yaml value "Locations.Lobby" from "leaf.bg.data"
	loop {-bg::arena::%{_arena}%::chests::*}:
		clear inventory of block at loop-value-1
	loop {-bg::arena::%{_arena}%::KILL-ME-PLS::*}:
		set block at loop-value to air
		remove loop-value from {-bg::arena::%{_arena}%::KILL-ME-PLS::*}
	delete {-bg::arena::%{_arena}%::*}	
	bg_delete_arena_entities({_arena})
	loop {-bg::arena::%{_arena}%::PLACED-BLOCKS::*}:
		set block at location of {-bg::arena::%{_arena}%::PLACED-BLOCKS::%loop-index%} to air
		wait a tick
	loop {-bg::arena::%{_arena}%::BROKEN-BLOCKS::*}:
		set block at location of {-bg::arena::%{_arena}%::BROKEN-BLOCKS::%loop-index%} to {-bg::arena::%{_arena}%::BROKEN-BLOCKS-TYPE::%loop-index%}
		wait a tick		
	delete {-bg::arena::%{_arena}%::BROKEN-BLOCKS::*}
	delete {-bg::arena::%{_arena}%::PLACED-BLOCKS::*}	
	set {-bg::arena::%{_arena}%::seconds} to yaml value "Settings.Timers.In-Lobby" from "leaf.bg.config"
	set {-bg::arena::%{_arena}%::status} to "WAITING"
							
function bg_clear_player(p: player):						
	heal {_p}
	extinguish {_p}
	set {_p}'s food to 20	
	clear {_p}'s level
	clear {_p}'s inventory
	{_p}.setFlying(false)
	{_p}.setAllowFlight(false)	
	set {_p}'s gamemode to survival
	loop ...{_p}.getActivePotionEffects():
		{_p}.removePotionEffect(loop-value.getType())	
	set velocity of {_p} to new vector 0, 0, 0	
	loop "BG-FLYING" and "BG-PARACHUTE":
		delete metadata value "%loop-value-1%" of {_p}

function bg_get_direction(p: player, target: location) :: text:
	set {_vector} to {_target}.toVector().subtract({_p}.getLocation().toVector())
	set {_direction} to {_p}.getEyeLocation().getDirection()
	set {_angle} to {_vector}.angle({_direction})
	set {_r} to {_angle} * 180 / 3.14159265359
	set {_directions::*} to "⬆", "⬅", "⬇" and "➡"
	set {_values::*} to 45, 135, 225 and 315	
	loop {_values::*}:
		{_r} < loop-value
		if {_r} > 45:
			if {_r} <= 135:
				if {_vector}.crossProduct({_direction}).getY() > 0.0:
					return "➡"
				else:
					return "⬅"
		return {_directions::%loop-index%}	

function bg_setSlot(p: player, slot: integer, t: text):
	add "&a", "&b", "&c", "&d", "&e", "&1", "&2", "&3", "&4", "&5", "&6", "&7", "&8", "&9" and "&f" to {_d::*}
	if {_slot} is between 1 and 15: 
		set scoreboard line {_slot} of {_p} to "%{_d::%{_slot}%}%%{_t}%"		
	
function bg_createBoard(p: player, t: text, size: integer = 15):
	set {_arena} to {-bg::player::%{_p}%::arena}
	create scoreboard for {_p}
	add "&a", "&b", "&c", "&d", "&e", "&1", "&2", "&3", "&4", "&5", "&6", "&7", "&8", "&9" and "&f" to {_d::*}
	if {_t} is "BG-GAME":
		set scoreboard title of {_p} to yaml value "Settings.Scoreboard.Game.Name" from "leaf.bg.config"
		while {-bg::player::%{_p}%::arena} = {_arena}:	
			if {-bg::arena::%{-bg::player::%{_p}%::arena}%::status} is set:	
				set {_target} to {-bg::arena::%{_arena}%::game-border}
				if {-bg::arena::%{_arena}%::next-border} is "&cBORDER CLOSING":
					set {_distance-check} to {-bg::arena::%{_arena}%::border::current-size}/2
				else:
					set {_distance-check} to {-bg::arena::%{_arena}%::border::current-size}
				if distance between {_p} and {_target} < {_distance-check}:
					set {_status} to "&aSAFE"
					set {_color} to "&a"
				else:
					set {_status} to "&cNOT STAFE"
					set {_color} to "&7"
				set {_dir} to bg_get_direction({_p}, {-bg::arena::%{_arena}%::game-border})
				loop "⬆", "⬅", "⬇" and "➡":
					if loop-value-1 is {_dir}:
						set {_pointer.%loop-value-1%} to "&a%loop-value-1%"
					else:
						set {_pointer.%loop-value-1%} to "%{_color}%%loop-value-1%"
				set {_slot} to 1 
				loop yaml list "Settings.Scoreboard.Game.Lines" from "leaf.bg.config":
					set {_value} to loop-value-1
					replace all "{now}" with "%now%" in {_value}
					replace all "{next-border}" with "%{-bg::arena::%{_arena}%::next-border}%" in {_value}
					replace all "{players-left}" with "%size of {-bg::arena::%{_arena}%::ninjas::*}%" in {_value}
					replace all "{kills}" with "%{-bg::player::%{_p}%::kills}%" in {_value}
					replace all "{up}" with "%{_pointer.⬆}%" in {_value}
					replace all "{left}" with "%{_pointer.⬅}% " in {_value}
					replace all "{right}" with "%{_pointer.➡}%" in {_value}
					replace all "{back}" with "%{_pointer.⬇}%" in {_value}
					replace all "{status}" with "%{_status}%" in {_value}
					replace all "{health}" with "%{_p}'s health%" in {_value}
					replace all "{player}" with {_p}'s displayname in {_value}
					replace all "{size}" with "%{-bg::arena::%{_arena}%::border::current-size}%" in {_value}
					bg_setSlot({_p}, {_slot}, colored {_value})
					add 1 to {_slot}
			else:
				stop							
			wait a second
	if {_t} is "BG-WAITING":
		set scoreboard title of {_p} to yaml value "Settings.Scoreboard.Waiting.Name" from "leaf.bg.config"
		while {-bg::player::%{_p}%::arena} = {_arena}:	
			if {-bg::arena::%{-bg::player::%{_p}%::arena}%::status} = "STARTING" or "WAITING":
				set {_slot} to 1
				loop yaml list "Settings.Scoreboard.Waiting.Lines" from "leaf.bg.config":
					set {_value} to loop-value-1
					replace all "{now}" with "%now%" in {_value}
					replace all "{player}" with {_p}'s displayname in {_value}
					replace all "{timer}" with "%{-bg::arena::%{_arena}%::seconds}%" in {_value}
					replace all "{players}" with "%size of {-bg::arena::%{_arena}%::ninjas::*}%" in {_value}
					replace all "{arena}" with "%{-bg::player::%{_p}%::arena}%" in {_value}
					bg_setSlot({_p}, {_slot}, colored {_value})
					add 1 to {_slot}
			else:
				stop				
			wait a second		
				
Kodari AI
KodariAug 18 at 8:18 am 2
DistrictXBattleRoyale
DistrictXBattleRoyale is a comprehensive Minecraft plugin that transforms servers into a full Battle Royale experience. It features multi-arena support with configurable lobbies, borders, and flight routes. Players join arenas, ride ender dragons as planes, deploy parachutes with customizable banners, and battle until one survivor remains. The plugin includes loot chests, death chests, bandages, world border shrinking mechanics, scoreboards with directional indicators, stats tracking, and a complete admin setup system with GUI arena browser. It supports configurable messages, titles, timers, and block placement rules, delivering an immersive last-player-standing gameplay mode.
  1. Create the Gradle project and plugin metadata for DistrictX-BattleRoyale.

  2. Implement arena setup, persistence, countdowns, drops, borders, deaths, winners, loot, restoration, and stats.

  3. Add /bg commands, event listeners, scoreboards, and configurable messages/items.

  4. Replace Skript-only NBT/particle behavior with native Bukkit-compatible mechanics and XSeries material parsing.

Created DistrictX-BattleRoyale with:

  • Gradle project configuration and plugin.yml

  • BattleRoyale main class by DistrictX Developers Official

  • Arena creation, setup, routes, borders, countdowns, joining, leaving, and auto-join

  • Battle Royale gameplay with drop phase, chest loot, death chests, block tracking/restoration, deaths, kills, winners, and stats

  • /bg command system with admin setup commands

  • Configurable messages, scoreboards, loot, materials, permissions, and lobby settings

  • Native Bukkit replacements for Skript YAML, NBT, particles, and scoreboard behavior

  • XSeries material compatibility for cross-version support

hyperzxmezu-dot

this plugin should run in 1.21.8 server

Kodari AI
KodariAug 18 at 8:23 am 2
  1. Update the build target to Java 21 and the 1.21.8 server API.

  2. Update plugin metadata to advertise the 1.21 API.

  3. Ensure the existing XSeries dependency is packaged or otherwise available at runtime.

  1. Updated build.gradle to compile against Spigot API 1.21.8 using Java 21.

  2. Updated plugin.yml to api-version: '1.21'.

  3. Configured the Gradle JAR task to package XSeries at runtime, preventing missing-class errors on the server.

  4. Confirmed the plugin uses Bukkit APIs rather than version-specific NMS, so no additional 1.21.8 migration is required.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
13 1,135
src/main/java/com/districtx/battleroyale/BattleRoyale.java
package com.districtx.battleroyale;

import lombok.Getter;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;

public class BattleRoyale extends JavaPlugin {
    @Getter
    private ArenaManager arenaManager;
    @Getter
    private StatsManager statsManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        statsManager = new StatsManager(this);
        arenaManager = new ArenaManager(this);
        getServer().getPluginManager().registerEvents(new BattleRoyaleListener(this), this);
        BattleRoyaleCommand command = new BattleRoyaleCommand(this);
        getCommand("battleroyale").setExecutor(command);
        getCommand("battleroyale").setTabCompleter(command);
        getServer().getScheduler().runTaskTimer(this, () -> {
            arenaManager.tick();
            arenaManager.updateScoreboards();
        }, 20L, 20L);
        getLogger().info("DistrictX-BattleRoyale v0.2.3 enabled.");
    }

    @Override
    public void onDisable() {
        if (arenaManager != null) arenaManager.shutdown();
        if (statsManager != null) statsManager.save();
    }

    public String color(String text) {
        return ChatColor.translateAlternateColorCodes('&', text == null ? "" : text);
    }
}