-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start getting actual basic plugin working
- Loading branch information
Showing
10 changed files
with
63 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using GangsAPI.Extensions; | ||
using GangsAPI.Services; | ||
using GangsAPI.Services.Commands; | ||
|
||
namespace Commands; | ||
|
||
public static class CommandCollection { | ||
public static void RegisterCommands(this IServiceCollection provider) { | ||
provider.AddPluginBehavior<GangCommand>(); | ||
provider.AddPluginBehavior<ICommandManager, CommandManager>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Core; | ||
using GangsAPI; | ||
using GangsAPI.Data; | ||
using GangsAPI.Data.Command; | ||
using GangsAPI.Services; | ||
using GangsAPI.Services.Commands; | ||
using Mock; | ||
|
||
namespace Commands; | ||
|
||
public class CommandManager(IGangManager gangMgr) | ||
: MockCommandManager, IPluginBehavior { | ||
private BasePlugin plugin = null!; | ||
|
||
public void Start(BasePlugin? basePlugin, bool hotReload) { | ||
ArgumentNullException.ThrowIfNull(basePlugin, nameof(basePlugin)); | ||
plugin = basePlugin; | ||
|
||
RegisterCommand(new GangCommand(gangMgr)); | ||
} | ||
|
||
public override bool RegisterCommand(ICommand command) { | ||
base.RegisterCommand(command); | ||
plugin.AddCommand(command.Name, command.Description ?? string.Empty, | ||
(player, info) => { | ||
var wrapper = player == null ? null : new PlayerWrapper(player); | ||
var args = info.GetCommandString.Split(" "); | ||
Server.NextFrameAsync(async () => { | ||
await ProcessCommand(wrapper, args); | ||
}); | ||
}); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
using Commands; | ||
using CounterStrikeSharp.API.Core; | ||
using GangsAPI; | ||
using GangsAPI.Extensions; | ||
using GangsAPI.Services; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Mock; | ||
|
||
namespace GangsImpl; | ||
|
||
public class GangServiceCollection : IPluginServiceCollection<IGangPlugin> { | ||
public void ConfigureServices(IServiceCollection serviceCollection) { | ||
serviceCollection.AddPluginBehavior<IGangManager, MockGangManager>(); | ||
serviceCollection.AddPluginBehavior<IPlayerManager, MockPlayerManager>(); | ||
serviceCollection.AddPluginBehavior<IStatManager, MockStatManager>(); | ||
serviceCollection | ||
.AddPluginBehavior<IGangStatManager, MockInstanceStatManager>(); | ||
serviceCollection | ||
.AddPluginBehavior<IPlayerStatManager, MockInstanceStatManager>(); | ||
serviceCollection.RegisterCommands(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
GangsTest/Commands/GangCommandTestses.cs → GangsTest/Commands/GangCommandTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters