Skip to content

Commit

Permalink
Bump Community API version
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooshua committed Aug 20, 2023
1 parent ef89de3 commit 60c30b8
Show file tree
Hide file tree
Showing 81 changed files with 1,002 additions and 146 deletions.
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "upstream/BattleBitAPI"]
path = upstream/BattleBitAPI
url = https://github.com/Mooshua/BattleBit-Community-Server-API/
branch = feat/gameserverstate
[submodule "upstream/DotNetCorePlugins"]
path = upstream/DotNetCorePlugins
url = https://github.com/Mooshua/DotNetCorePlugins
13 changes: 13 additions & 0 deletions .idea/.idea.BitMod.Builtin/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions BitMod.Builtin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitMod.Whitelist", "builtin
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "upstream", "upstream", "{034634E0-DADE-4CDD-BCA4-98FDD606D934}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BattleBitAPI", "upstream\BattleBitAPI\BattleBitAPI\BattleBitAPI.csproj", "{AFF43ED3-4F91-48DA-9C78-95DCEABC8228}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McMaster.NETCore.Plugins", "upstream\DotNetCorePlugins\src\Plugins\McMaster.NETCore.Plugins.csproj", "{52914215-CD2B-4E9A-9C56-773E80011320}"
EndProject
Global
Expand All @@ -30,7 +28,6 @@ Global
{977540BF-CC03-4F81-AA50-22E924469634} = {A5E7842B-999F-4AB3-B846-51C68DAA792B}
{1CD7B592-A453-4A8E-B556-14D52947C0F5} = {575C205C-A43D-45DF-A4E4-B689A8C7AC82}
{E4BA4F87-3089-49B2-AA73-46C1D2812A92} = {A5E7842B-999F-4AB3-B846-51C68DAA792B}
{AFF43ED3-4F91-48DA-9C78-95DCEABC8228} = {034634E0-DADE-4CDD-BCA4-98FDD606D934}
{52914215-CD2B-4E9A-9C56-773E80011320} = {034634E0-DADE-4CDD-BCA4-98FDD606D934}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
Expand Down Expand Up @@ -58,10 +55,6 @@ Global
{E4BA4F87-3089-49B2-AA73-46C1D2812A92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4BA4F87-3089-49B2-AA73-46C1D2812A92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4BA4F87-3089-49B2-AA73-46C1D2812A92}.Release|Any CPU.Build.0 = Release|Any CPU
{AFF43ED3-4F91-48DA-9C78-95DCEABC8228}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFF43ED3-4F91-48DA-9C78-95DCEABC8228}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFF43ED3-4F91-48DA-9C78-95DCEABC8228}.Release|Any CPU.Build.0 = Release|Any CPU
{AFF43ED3-4F91-48DA-9C78-95DCEABC8228}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52914215-CD2B-4E9A-9C56-773E80011320}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52914215-CD2B-4E9A-9C56-773E80011320}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52914215-CD2B-4E9A-9C56-773E80011320}.Release|Any CPU.Build.0 = Release|Any CPU
Expand Down
16 changes: 9 additions & 7 deletions BitMod.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{621F6C25-527
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "upstream", "upstream", "{382D2698-5A85-4BA7-85C7-CD58874F8169}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BattleBitAPI", "upstream\BattleBitAPI\BattleBitAPI\BattleBitAPI.csproj", "{63E2A804-E204-4919-98EC-F60CFC4777FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitMod.Plugins", "standalone\BitMod.Plugins\BitMod.Plugins.csproj", "{8D614C4F-22BE-461A-BD7D-80507EAA823F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{11BEBA9D-0E44-4A6D-A5EF-5A53B977EC06}"
Expand Down Expand Up @@ -42,6 +40,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitMod.Moderation", "builti
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitMod.Provision", "builtin\BitMod.Provision\BitMod.Provision.csproj", "{2FCD0D1B-C58A-406C-83F9-FD2EB3598F9F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plugins", "plugins", "{40317A0E-F34B-4367-BF2C-C2540A521B28}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitMod.Gamemode.GunGame", "plugins\BitMod.Gamemode.GunGame\BitMod.Gamemode.GunGame.csproj", "{93EE784F-49A4-4BF4-90CF-D1C605404458}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -52,10 +54,6 @@ Global
{20CD73A1-A74C-4205-AD74-9B48EEEFB3EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20CD73A1-A74C-4205-AD74-9B48EEEFB3EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20CD73A1-A74C-4205-AD74-9B48EEEFB3EC}.Release|Any CPU.Build.0 = Release|Any CPU
{63E2A804-E204-4919-98EC-F60CFC4777FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63E2A804-E204-4919-98EC-F60CFC4777FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63E2A804-E204-4919-98EC-F60CFC4777FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63E2A804-E204-4919-98EC-F60CFC4777FA}.Release|Any CPU.Build.0 = Release|Any CPU
{8D614C4F-22BE-461A-BD7D-80507EAA823F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D614C4F-22BE-461A-BD7D-80507EAA823F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D614C4F-22BE-461A-BD7D-80507EAA823F}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -108,10 +106,13 @@ Global
{2FCD0D1B-C58A-406C-83F9-FD2EB3598F9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FCD0D1B-C58A-406C-83F9-FD2EB3598F9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FCD0D1B-C58A-406C-83F9-FD2EB3598F9F}.Release|Any CPU.Build.0 = Release|Any CPU
{93EE784F-49A4-4BF4-90CF-D1C605404458}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{93EE784F-49A4-4BF4-90CF-D1C605404458}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93EE784F-49A4-4BF4-90CF-D1C605404458}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93EE784F-49A4-4BF4-90CF-D1C605404458}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{20CD73A1-A74C-4205-AD74-9B48EEEFB3EC} = {621F6C25-527F-4BA1-BF59-1D19021A9B88}
{63E2A804-E204-4919-98EC-F60CFC4777FA} = {382D2698-5A85-4BA7-85C7-CD58874F8169}
{A3BE58F5-FB17-4B97-8636-57062741EBFA} = {11BEBA9D-0E44-4A6D-A5EF-5A53B977EC06}
{BB262DE9-DD31-4DDB-A078-DAC6DD35AF88} = {11BEBA9D-0E44-4A6D-A5EF-5A53B977EC06}
{46F25EB1-C8E0-4703-A5CA-616433688BE7} = {2EF5B35B-16D2-49CE-82D5-37883FCF6EA7}
Expand All @@ -125,5 +126,6 @@ Global
{0DF78B4C-26A7-4FF7-BD07-036981815125} = {CCEA8B6B-5212-4C12-BB31-A70501DE31D0}
{3FB356E0-587B-42EA-A1A0-C10AE6ADA621} = {CCEA8B6B-5212-4C12-BB31-A70501DE31D0}
{2FCD0D1B-C58A-406C-83F9-FD2EB3598F9F} = {CCEA8B6B-5212-4C12-BB31-A70501DE31D0}
{93EE784F-49A4-4BF4-90CF-D1C605404458} = {40317A0E-F34B-4367-BF2C-C2540A521B28}
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<Project>

<PropertyGroup>
<!--Where the dev build should be by default-->
<BitModDev Condition=" '$(BitModDev)' == '' " >$(MSBuildThisFileDirectory)\dev</BitModDev>

<!--Ditto for publishes-->
<BitModBuild Condition=" '$(BitModDev)' == '' " >$(MSBuildThisFileDirectory)\dev</BitModBuild>
</PropertyGroup>

<PropertyGroup>
<!--Language version-->
<LangVersion>11</LangVersion>
Expand Down
11 changes: 11 additions & 0 deletions api/BitMod/Attributes/Injects/MetaAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Lilikoi.Attributes;
using Lilikoi.Attributes.Typed;
using Lilikoi.Context;

namespace BitMod.Attributes.Injects;

public class MetaAttribute : LkTypedInjectionAttribute<Mount>
{
public override Mount Inject(Mount context)
=> context;
}
45 changes: 45 additions & 0 deletions api/BitMod/Attributes/Targets/BitConfigUpdateAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using BitMod.Attributes.Internal;
using BitMod.Configuration.Model;
using BitMod.Events.Config;
using BitMod.Internal;
using BitMod.Internal.Assemblers;
using BitMod.Internal.Registries;
using BitMod.Router;
using BitMod.Router.Extensions;

using Lilikoi.Attributes;
using Lilikoi.Compiler.Public;

namespace BitMod.Attributes.Targets;

public class BitConfigUpdateAttribute : LkTargetAttribute
{
private string _configFile;

public BitConfigUpdateAttribute(string configFile)
{
_configFile = configFile;
}

public override bool IsTargetable<TUserContext>()
=> (typeof(RouterContext)).IsAssignableFrom(typeof(TUserContext));

public override void Target<TUserContext>(TUserContext context, LilikoiMutator mutator)
=> Target(context as RouterContext, mutator);

Check warning on line 28 in api/BitMod/Attributes/Targets/BitConfigUpdateAttribute.cs

View workflow job for this annotation

GitHub Actions / Tests

Possible null reference argument for parameter 'router' in 'void BitConfigUpdateAttribute.Target(RouterContext router, LilikoiMutator mutator)'.

public void Target(RouterContext router, LilikoiMutator mutator)
{
router.ConfigUpdated(mutator);

// Add wildcards for common parameters
mutator.Wildcard<IConfigObject>(new UnpackWildcardParameterAttribute(typeof(IConfigObject)));
mutator.Wildcard<ConfigUpdatedEventArgs>(new UnpackWildcardParameterAttribute(typeof(ConfigUpdatedEventArgs)));


// Proper async-await code handling
mutator.Implicit(new AsyncAttribute());

// Store metadata so the command assembler can tell what kind of command we are.
mutator.Store(new StringRouterDirectives(_configFile));
}
}
5 changes: 5 additions & 0 deletions api/BitMod/BitMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public IConfigObject Get(string name)
{
throw new NotImplementedException();
}

public IConfigSymbol Fake(string symbol)
{
throw new NotImplementedException();
}
}

public class MockInSystem : IPluginSystem
Expand Down
4 changes: 2 additions & 2 deletions api/BitMod/BitMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public BitMod(ILogger logger, IConfigurationSystem config, IPluginSystem plugins
var context = new PluginContext( this );
var invoker = new PluginInvoker( context );

_server = new ServerListener<BitPlayer, BitServer>(new RoutingHandlerFactory(invoker));
var listener = new RoutingHandler(_server, invoker);
_server = new ServerListener<BitPlayer, BitServer>();
var listener = new RoutingHandler(_server, invoker, logger);

Store(context);
Store(invoker);
Expand Down
7 changes: 2 additions & 5 deletions api/BitMod/BitMod.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>BitMod</RootNamespace>
Expand All @@ -14,10 +14,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\upstream\BattleBitAPI\BattleBitAPI\BattleBitAPI.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityServerAPI" Version="1.0.2.2" />
<PackageReference Include="Lilikoi" Version="0.1.0-prerelease.28" />
<PackageReference Include="Serilog" Version="3.0.2-dev-02044" />
</ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion api/BitMod/Compatibility/BitServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ public class BitServer : GameServer<BitPlayer>, IBitObject
{
public Mount Mount { get; }

public override string ToString()
=> $"{this.GameIP}:{this.GamePort}";


public static implicit operator string(BitServer value)
=> $"{value.GameIP}:{value.GamePort}";
=> value.ToString();
}
5 changes: 4 additions & 1 deletion api/BitMod/Config/Extensions/ConfigSymbolExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static long Int(this IConfigSymbol symbol, long fallback, long min = long
return symbol.AsInt.Value;
}

public static double Float(this IConfigSymbol symbol, float fallback, float min = float.MinValue, float max = float.MaxValue)
public static double Float(this IConfigSymbol symbol, double fallback, double min = double.MinValue, double max = double.MaxValue)
{
if (symbol == null)
return fallback;
Expand All @@ -32,6 +32,9 @@ public static double Float(this IConfigSymbol symbol, float fallback, float min
return symbol.AsFloat.Value;
}

public static TimeSpan AsSeconds(this IConfigSymbol symbol, double fallback, double min = double.MinValue, double max = double.MaxValue)
=> TimeSpan.FromSeconds(Float(symbol, fallback, min, max));

public static ushort AsPort(this IConfigSymbol symbol, ushort fallback)
=> (ushort)symbol.Int(fallback, 0, ushort.MaxValue);
}
24 changes: 24 additions & 0 deletions api/BitMod/Events/Config/ConfigUpdatedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using BitMod.Configuration.Model;
using BitMod.Events.Base;

namespace BitMod.Events.Config;

public class ConfigUpdatedEventArgs : IBaseArgs
{
public ConfigUpdatedEventArgs(string file, IConfigObject config)
{
File = file;
Config = config;
}

/// <summary>
/// The name of the file (relative to /configs) that updated.
/// </summary>
public string File { get; }

/// <summary>
/// The updated copy of the config object.
/// </summary>
public IConfigObject Config { get; }

}
1 change: 0 additions & 1 deletion api/BitMod/Events/Player/PlayerChangedRoleEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BattleBitAPI.Common;
using BattleBitAPI.Common.Enums;

using BitMod.Compatibility;
using BitMod.Events.Accessors;
Expand Down
1 change: 0 additions & 1 deletion api/BitMod/Events/Player/PlayerChangedTeamEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BattleBitAPI.Common;
using BattleBitAPI.Common.Enums;

using BitMod.Compatibility;
using BitMod.Events.Accessors;
Expand Down
25 changes: 25 additions & 0 deletions api/BitMod/Events/Player/PlayerChangingTeamEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using BattleBitAPI.Common;

using BitMod.Compatibility;
using BitMod.Events.Accessors;
using BitMod.Events.Base;

namespace BitMod.Events.Player;

public class PlayerChangingTeamEventArgs : IHookArgs, IResponsiblePlayerEvent
{
public PlayerChangingTeamEventArgs(BitServer server, BitPlayer player, Team team)
{
Server = server;
Player = player;
Team = team;
}

public BitPlayer Player { get; }

public Team Team { get; }

public BitServer Server { get; }

public BitPlayer? ResponsiblePlayer => Player;
}
20 changes: 20 additions & 0 deletions api/BitMod/Events/Player/PlayerGivenUpEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using BitMod.Compatibility;
using BitMod.Events.Accessors;
using BitMod.Events.Base;

namespace BitMod.Events.Player;

public class PlayerGivenUpEventArgs : IEventArgs, IResponsiblePlayerEvent
{
public PlayerGivenUpEventArgs(BitServer server, BitPlayer player)
{
Player = player;
Server = server;
}

public BitPlayer Player { get; }

public BitServer Server { get; }

public BitPlayer? ResponsiblePlayer => Player;
}
7 changes: 4 additions & 3 deletions api/BitMod/Events/Player/PlayerJoinedSquadEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BattleBitAPI.Common;
using BattleBitAPI.Common.Enums;
using BattleBitAPI.Common;

Check warning on line 2 in api/BitMod/Events/Player/PlayerJoinedSquadEventArgs.cs

View workflow job for this annotation

GitHub Actions / Tests

The using directive for 'BattleBitAPI.Common' appeared previously in this namespace
using BattleBitAPI.Server;

using BitMod.Compatibility;
using BitMod.Events.Accessors;
Expand All @@ -17,9 +18,9 @@ public class PlayerJoinedSquadEventArgs : IEventArgs, IResponsiblePlayerEvent
/// <summary>
/// The squad the player joined.
/// </summary>
public Squads Squads { get; }
public Squad<BitPlayer> Squads { get; }

public PlayerJoinedSquadEventArgs(BitServer server, BitPlayer player, Squads squad)
public PlayerJoinedSquadEventArgs(BitServer server, BitPlayer player, Squad<BitPlayer> squad)
{
Player = player;
Squads = squad;
Expand Down
1 change: 0 additions & 1 deletion api/BitMod/Events/Player/PlayerKilledPlayerEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Numerics;

using BattleBitAPI.Common;
using BattleBitAPI.Common.Enums;

using BitMod.Compatibility;
using BitMod.Events.Accessors;
Expand Down
6 changes: 3 additions & 3 deletions api/BitMod/Events/Player/PlayerLeftSquadEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using BattleBitAPI.Common;
using BattleBitAPI.Common.Enums;
using BattleBitAPI.Server;

using BitMod.Compatibility;
using BitMod.Events.Accessors;
Expand All @@ -17,9 +17,9 @@ public class PlayerLeftSquadEventArgs : IEventArgs, IResponsiblePlayerEvent
/// <summary>
/// The squad the player left.
/// </summary>
public Squads Squads { get; }
public Squad<BitPlayer> Squads { get; }

internal PlayerLeftSquadEventArgs(BitServer server, BitPlayer player, Squads squad)
internal PlayerLeftSquadEventArgs(BitServer server, BitPlayer player, Squad<BitPlayer> squad)
{
Player = player;
Squads = squad;
Expand Down
1 change: 0 additions & 1 deletion api/BitMod/Events/Player/PlayerReportedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BattleBitAPI.Common;
using BattleBitAPI.Common.Enums;

using BitMod.Compatibility;
using BitMod.Events.Accessors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BattleBitAPI.Common;
using BattleBitAPI.Common.Enums;

using BitMod.Compatibility;
using BitMod.Events.Accessors;
Expand Down
Loading

0 comments on commit 60c30b8

Please sign in to comment.