From b71ba423b541f886cfac8cc9f21f58b040ecf1d3 Mon Sep 17 00:00:00 2001 From: Yamato Date: Mon, 20 Jan 2025 18:55:04 +0100 Subject: [PATCH] CustomItem Spawn Command --- EXILED/Exiled.CustomItems/Commands/Spawn.cs | 46 ++++++++++----------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/EXILED/Exiled.CustomItems/Commands/Spawn.cs b/EXILED/Exiled.CustomItems/Commands/Spawn.cs index a66158403..2ba955dc7 100644 --- a/EXILED/Exiled.CustomItems/Commands/Spawn.cs +++ b/EXILED/Exiled.CustomItems/Commands/Spawn.cs @@ -64,38 +64,34 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s } Vector3 position; - - if (Enum.TryParse(arguments.At(1), out SpawnLocationType location)) - { - position = location.GetPosition(); - } - else + if (arguments.Count > 3) { - if (Player.Get(arguments.At(1)) is Player player) + if (!float.TryParse(arguments.At(1), out float x) || !float.TryParse(arguments.At(2), out float y) || !float.TryParse(arguments.At(3), out float z)) { - if (player.IsDead) - { - response = $"Cannot spawn custom items under dead players!"; - return false; - } - - position = player.Position; + response = "Invalid coordinates selected."; + return false; } - else if (arguments.Count > 3) - { - if (!float.TryParse(arguments.At(1), out float x) || !float.TryParse(arguments.At(2), out float y) || !float.TryParse(arguments.At(3), out float z)) - { - response = "Invalid coordinates selected."; - return false; - } - position = new Vector3(x, y, z); - } - else + position = new Vector3(x, y, z); + } + else if (Player.Get(arguments.At(1)) is Player player) + { + if (player.IsDead) { - response = $"Unable to find spawn location: {arguments.At(1)}."; + response = $"Cannot spawn custom items under dead players!"; return false; } + + position = player.Position; + } + else if (Enum.TryParse(arguments.At(1), out SpawnLocationType location)) + { + position = location.GetPosition(); + } + else + { + response = $"Unable to find spawn location: {arguments.At(1)}."; + return false; } item?.Spawn(position);