-
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.
- Loading branch information
Showing
28 changed files
with
288 additions
and
75 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using GangsAPI.Extensions; | ||
|
||
namespace Commands; | ||
|
||
public static class CommandCollection { | ||
public static void RegisterCommands(this IServiceCollection provider) { | ||
provider.AddPluginBehavior<GangCommand>(); | ||
} | ||
} |
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,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\GangsAPI\GangsAPI.csproj" /> | ||
<ProjectReference Include="..\GangsImpl\Mock\Mock.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,34 @@ | ||
using GangsAPI.Data; | ||
using GangsAPI.Data.Command; | ||
using GangsAPI.Services.Commands; | ||
using Mock; | ||
|
||
namespace Commands; | ||
|
||
public class GangCommand : ICommand { | ||
public string Name => "css_gang"; | ||
public string? Description => "Master command for gangs"; | ||
|
||
private Dictionary<string, ICommand> sub = new() { | ||
// ["create"] = new CreateGangCommand(), | ||
// ["delete"] = new DeleteGangCommand(), | ||
// ["invite"] = new InviteGangCommand(), | ||
// ["kick"] = new KickGangCommand(), | ||
// ["leave"] = new LeaveGangCommand(), | ||
// ["list"] = new ListGangCommand(), | ||
// ["promote"] = new PromoteGangCommand(), | ||
// ["demote"] = new DemoteGangCommand(), | ||
// ["info"] = new InfoGangCommand() | ||
}; | ||
|
||
public CommandResult | ||
Execute(PlayerWrapper? executor, CommandInfoWrapper info) { | ||
if (info.ArgCount == 0) return CommandResult.FAILURE; | ||
if (!sub.TryGetValue(info[0], out var command)) { | ||
// print usage | ||
return CommandResult.INVALID_ARGS; | ||
} | ||
|
||
return CommandResult.SUCCESS; | ||
} | ||
} |
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,15 @@ | ||
using GangsAPI.Data; | ||
using GangsAPI.Data.Command; | ||
using GangsAPI.Services.Commands; | ||
|
||
namespace Commands.gang; | ||
|
||
public class CreateCommand : ICommand { | ||
public string Name => "create"; | ||
public string? Description => "Creates a new gang"; | ||
|
||
public CommandResult | ||
Execute(PlayerWrapper? executor, CommandInfoWrapper info) { | ||
throw new NotImplementedException(); | ||
} | ||
} |
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
7 changes: 5 additions & 2 deletions
7
GangsPlugin/GangServiceCollection.cs → Core/GangServiceCollection.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using Commands; | ||
using CounterStrikeSharp.API.Core; | ||
using GangsAPI; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace GangsImpl; | ||
|
||
public class GangServiceCollection : IPluginServiceCollection<IGangPlugin> { | ||
public void ConfigureServices(IServiceCollection serviceCollection) { } | ||
public void ConfigureServices(IServiceCollection serviceCollection) { | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace GangsAPI.Data.Command; | ||
|
||
public enum CommandResult { | ||
SUCCESS, FAILURE, UNKNOWN_COMMAND, INVALID_ARGS, NO_PERMISSION | ||
} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace GangsAPI.Data.Stat; | ||
|
||
public interface IGangPerk : IPerk { | ||
void ApplyTo(int id); | ||
void RevokedFrom(int id); | ||
} |
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,5 @@ | ||
namespace GangsAPI.Data.Stat; | ||
|
||
public interface IPerk : IStat, IPluginBehavior { | ||
|
||
} |
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,6 @@ | ||
namespace GangsAPI.Data.Stat; | ||
|
||
public interface IPlayerPerk : IPerk { | ||
void ApplyTo(ulong steam); | ||
void RevokedFrom(ulong steam); | ||
} |
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,11 +1,21 @@ | ||
using GangsAPI.Data; | ||
using GangsAPI.Data.Command; | ||
|
||
namespace GangsAPI.Services.Commands; | ||
|
||
public interface ICommand { | ||
public interface ICommand : IPluginBehavior { | ||
string Name { get; } | ||
string? Description { get; } | ||
string[] RequiredFlags { get; } | ||
string[] RequiredGroups { get; } | ||
bool Execute(PlayerWrapper? executor, CommandInfoWrapper info); | ||
string[] RequiredFlags => []; | ||
string[] RequiredGroups => []; | ||
|
||
bool CanExecute(PlayerWrapper? executor) { | ||
if (executor == null) return true; | ||
if (RequiredFlags.Any(flag => !executor.HasFlags(flag))) return false; | ||
if (RequiredGroups.Length == 0) return true; | ||
return executor.Data != null | ||
&& RequiredGroups.All(group => executor.Data.Groups.Contains(group)); | ||
} | ||
|
||
CommandResult Execute(PlayerWrapper? executor, CommandInfoWrapper info); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
GangsTest/GangBankTests/MockBankStat.cs → GangsImpl/Mock/MockBankStat.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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace GangsTest.API; | ||
|
||
public class CommandWrapperTests { | ||
|
||
} |
Oops, something went wrong.