mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-22 19:38:47 +00:00
Validate non-null arguments for public API
This commit is contained in:
parent
cfc73cfb62
commit
cfd1e4c208
@ -134,6 +134,7 @@ public sealed class CommandsExtension : VirtualParadiseClientExtension
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override Task OnMessageReceived(MessageReceivedEventArgs args)
|
protected override Task OnMessageReceived(MessageReceivedEventArgs args)
|
||||||
{
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(args);
|
||||||
var message = args.Message;
|
var message = args.Message;
|
||||||
|
|
||||||
if (message.Type != MessageType.ChatMessage)
|
if (message.Type != MessageType.ChatMessage)
|
||||||
|
@ -11,8 +11,10 @@ public static class VirtualParadiseClientExtensions
|
|||||||
/// <param name="client">The <see cref="VirtualParadiseClient" />.</param>
|
/// <param name="client">The <see cref="VirtualParadiseClient" />.</param>
|
||||||
/// <param name="configuration">The configuration required for the extensions.</param>
|
/// <param name="configuration">The configuration required for the extensions.</param>
|
||||||
/// <returns>The commands extension instance.</returns>
|
/// <returns>The commands extension instance.</returns>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="client" /> is <see langword="null" />.</exception>
|
||||||
public static CommandsExtension UseCommands(this VirtualParadiseClient client, CommandsExtensionConfiguration configuration)
|
public static CommandsExtension UseCommands(this VirtualParadiseClient client, CommandsExtensionConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(client);
|
||||||
return client.AddExtension<CommandsExtension>(configuration);
|
return client.AddExtension<CommandsExtension>(configuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,8 +292,10 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="world">The name of the world to which this avatar should be teleported.</param>
|
/// <param name="world">The name of the world to which this avatar should be teleported.</param>
|
||||||
/// <param name="position">The position to which this avatar should be teleported.</param>
|
/// <param name="position">The position to which this avatar should be teleported.</param>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="world" /> is <see langword="null" />.</exception>
|
||||||
public Task TeleportAsync(VirtualParadiseWorld world, Vector3d position)
|
public Task TeleportAsync(VirtualParadiseWorld world, Vector3d position)
|
||||||
{
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(world);
|
||||||
return TeleportAsync(world.Name, position, Quaternion.Identity);
|
return TeleportAsync(world.Name, position, Quaternion.Identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,8 +305,10 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
|
|||||||
/// <param name="world">The name of the world to which this avatar should be teleported.</param>
|
/// <param name="world">The name of the world to which this avatar should be teleported.</param>
|
||||||
/// <param name="position">The position to which this avatar should be teleported.</param>
|
/// <param name="position">The position to which this avatar should be teleported.</param>
|
||||||
/// <param name="rotation">The rotation to which this avatar should be teleported.</param>
|
/// <param name="rotation">The rotation to which this avatar should be teleported.</param>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="world" /> is <see langword="null" />.</exception>
|
||||||
public Task TeleportAsync(VirtualParadiseWorld world, Vector3d position, Quaternion rotation)
|
public Task TeleportAsync(VirtualParadiseWorld world, Vector3d position, Quaternion rotation)
|
||||||
{
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(world);
|
||||||
return TeleportAsync(world.Name, position, rotation);
|
return TeleportAsync(world.Name, position, rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,6 +330,16 @@ public sealed class VirtualParadiseAvatar : IEquatable<VirtualParadiseAvatar>
|
|||||||
/// <param name="rotation">The rotation to which this avatar should be teleported.</param>
|
/// <param name="rotation">The rotation to which this avatar should be teleported.</param>
|
||||||
public async Task TeleportAsync(string world, Vector3d position, Quaternion rotation)
|
public async Task TeleportAsync(string world, Vector3d position, Quaternion rotation)
|
||||||
{
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(world);
|
||||||
|
#if NET7_0_OR_GREATER
|
||||||
|
ArgumentException.ThrowIfNullOrEmpty(world);
|
||||||
|
#else
|
||||||
|
if (string.IsNullOrEmpty(world))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("World cannot be empty");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// ReSharper disable InconsistentlySynchronizedField
|
// ReSharper disable InconsistentlySynchronizedField
|
||||||
bool isSelf = this == _client.CurrentAvatar;
|
bool isSelf = this == _client.CurrentAvatar;
|
||||||
bool isNewWorld = world != Location.World.Name;
|
bool isNewWorld = world != Location.World.Name;
|
||||||
|
Loading…
Reference in New Issue
Block a user