mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-23 01:08:47 +00:00
[ci skip] Add VpSharp.Commands example to samples
This commit is contained in:
parent
4c31eb58a9
commit
434dc204d9
@ -1,4 +1,5 @@
|
|||||||
using VpSharp.EventData;
|
using VpSharp.Commands;
|
||||||
|
using VpSharp.EventData;
|
||||||
|
|
||||||
namespace VpSharp.CSharp_Sample;
|
namespace VpSharp.CSharp_Sample;
|
||||||
|
|
||||||
@ -17,6 +18,8 @@ internal static class Program
|
|||||||
};
|
};
|
||||||
|
|
||||||
s_client = new VirtualParadiseClient(configuration);
|
s_client = new VirtualParadiseClient(configuration);
|
||||||
|
var commands = s_client.UseCommands(new CommandsExtensionConfiguration {Prefixes = {"/"}});
|
||||||
|
commands.RegisterCommands<SayCommand>();
|
||||||
|
|
||||||
s_client.AvatarJoined += ClientOnAvatarJoined;
|
s_client.AvatarJoined += ClientOnAvatarJoined;
|
||||||
|
|
||||||
|
13
Samples/VpSharp.CSharp_Sample/SayCommand.cs
Normal file
13
Samples/VpSharp.CSharp_Sample/SayCommand.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using VpSharp.Commands;
|
||||||
|
using VpSharp.Commands.Attributes;
|
||||||
|
|
||||||
|
namespace VpSharp.CSharp_Sample;
|
||||||
|
|
||||||
|
public class SayCommand : CommandModule
|
||||||
|
{
|
||||||
|
[Command("say")]
|
||||||
|
public async Task SayAsync(CommandContext context, [Remainder] string message)
|
||||||
|
{
|
||||||
|
await context.RespondAsync(message);
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\VpSharp.Commands\VpSharp.Commands.csproj" />
|
||||||
<ProjectReference Include="..\..\VpSharp\VpSharp.csproj" />
|
<ProjectReference Include="..\..\VpSharp\VpSharp.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
Imports VpSharp.Commands
|
||||||
Imports VpSharp.EventData
|
Imports VpSharp.EventData
|
||||||
|
|
||||||
Module Program
|
Module Program
|
||||||
@ -18,15 +19,26 @@ Module Program
|
|||||||
|
|
||||||
_client = New VirtualParadiseClient(configuration)
|
_client = New VirtualParadiseClient(configuration)
|
||||||
|
|
||||||
|
Dim commands = _client.UseCommands(New CommandsExtensionConfiguration With { .Prefixes = {"/"} })
|
||||||
|
commands.RegisterCommands(GetType(SayCommand))
|
||||||
|
|
||||||
Await _client.ConnectAsync()
|
Await _client.ConnectAsync()
|
||||||
Await _client.LoginAsync()
|
Await _client.LoginAsync()
|
||||||
Await _client.EnterAsync("WORLD_NAME")
|
Await _client.EnterAsync("WORLD_NAME")
|
||||||
Await _client.CurrentAvatar.TeleportAsync(Vector3d.Zero)
|
Await _client.CurrentAvatar.TeleportAsync(Vector3d.Zero)
|
||||||
|
|
||||||
Await Task.Delay(-1)
|
Await Task.Delay(- 1)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Async Sub ClientOnAvatarJoined(sender As Object, args As AvatarJoinedEventArgs) Handles _client.AvatarJoined
|
Private Async Sub ClientOnAvatarJoined(sender As Object, args As AvatarJoinedEventArgs) Handles _client.AvatarJoined
|
||||||
Await _client.SendMessageAsync("Hello, " & args.Avatar.Name)
|
Await _client.SendMessageAsync("Hello, " & args.Avatar.Name)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Async Sub OnChatMessage(sender As Object, args As MessageReceivedEventArgs) Handles _client.MessageReceived
|
||||||
|
Dim message As String = args.Message.Content
|
||||||
|
|
||||||
|
If message.StartsWith("/say ") Then
|
||||||
|
Await _client.SendMessageAsync(message.Substring(5))
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
End Module
|
End Module
|
||||||
|
12
Samples/VpSharp.VB_Sample/SayCommand.vb
Normal file
12
Samples/VpSharp.VB_Sample/SayCommand.vb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
Imports VpSharp.Commands
|
||||||
|
Imports VpSharp.Commands.Attributes
|
||||||
|
|
||||||
|
Public Class SayCommand
|
||||||
|
Inherits CommandModule
|
||||||
|
|
||||||
|
<Command("say")>
|
||||||
|
Public Async Function SayAsync(context as CommandContext, <Remainder> message As String) As Task
|
||||||
|
Await context.RespondAsync(message)
|
||||||
|
End Function
|
||||||
|
|
||||||
|
End Class
|
@ -7,6 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\VpSharp.Commands\VpSharp.Commands.csproj" />
|
||||||
<ProjectReference Include="..\..\VpSharp\VpSharp.csproj" />
|
<ProjectReference Include="..\..\VpSharp\VpSharp.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user