Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CustomItem Spawn Command #411

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions EXILED/Exiled.CustomItems/Commands/Spawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,38 +64,34 @@ public bool Execute(ArraySegment<string> 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);
Expand Down
Loading