diff --git a/BitMod.sln b/BitMod.sln index d78f08f..3d811fe 100644 --- a/BitMod.sln +++ b/BitMod.sln @@ -42,8 +42,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitMod.Provision", "builtin 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 @@ -106,10 +104,6 @@ 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} @@ -126,6 +120,5 @@ 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 diff --git a/api/BitMod/BitMod.cs b/api/BitMod/BitMod.cs index fc5dc25..f92a565 100644 --- a/api/BitMod/BitMod.cs +++ b/api/BitMod/BitMod.cs @@ -66,11 +66,6 @@ public void Start() Logger.Information("[BitMod] Starting server on {@IP}:{@Port}", ip.ToString(), port); _server.Start(ip, port); - - while (true) - { - - } } public void Stop() diff --git a/api/BitMod/Compatibility/BitServer.cs b/api/BitMod/Compatibility/BitServer.cs index 5cf8e53..8bdf1d3 100644 --- a/api/BitMod/Compatibility/BitServer.cs +++ b/api/BitMod/Compatibility/BitServer.cs @@ -11,7 +11,6 @@ public class BitServer : GameServer, IBitObject public override string ToString() => $"{this.GameIP}:{this.GamePort}"; - public static implicit operator string(BitServer value) => value.ToString(); } diff --git a/api/BitMod/Events/Core/StandardInputEventArgs.cs b/api/BitMod/Events/Core/StandardInputEventArgs.cs new file mode 100644 index 0000000..f65af82 --- /dev/null +++ b/api/BitMod/Events/Core/StandardInputEventArgs.cs @@ -0,0 +1,13 @@ +using BitMod.Events.Base; + +namespace BitMod.Events.Core; + +public class StandardInputEventArgs : IEventArgs +{ + public StandardInputEventArgs(string contents) + { + Contents = contents; + } + + public string Contents { get; } +} diff --git a/api/BitMod/Internal/Registries/SimpleEventRegistry.cs b/api/BitMod/Internal/Registries/SimpleEventRegistry.cs index 98b7728..6fb73b6 100644 --- a/api/BitMod/Internal/Registries/SimpleEventRegistry.cs +++ b/api/BitMod/Internal/Registries/SimpleEventRegistry.cs @@ -29,7 +29,7 @@ public void Invoke(EventInput input) } catch (Exception ex) { - _logger.Warning(ex, "Event handler failed during execution!"); + _logger.Warning(ex, "Event handler for {@Type} failed during execution!", input.Type?.FullName); if (Environment.DoNotCatchEventExceptions) throw; } diff --git a/builtin/BitMod.Commands/Builtin/HelloCommand.cs b/builtin/BitMod.Commands/Builtin/HelloCommand.cs new file mode 100644 index 0000000..e2d45a4 --- /dev/null +++ b/builtin/BitMod.Commands/Builtin/HelloCommand.cs @@ -0,0 +1,13 @@ +using BitMod.Commands.Attributes; +using BitMod.Commands.Sources; + +namespace BitMod.Commands.Builtin; + +public class HelloCommand +{ + + [BitCommand("hello", "Say Hello")] + public async Task OnHello(ICommandSource source) + => source.Reply("[BitMod] Hello, there!"); + +} diff --git a/builtin/BitMod.Commands/Handlers/CommandHandler.cs b/builtin/BitMod.Commands/Handlers/CommandHandler.cs index 2b2328a..928ad57 100644 --- a/builtin/BitMod.Commands/Handlers/CommandHandler.cs +++ b/builtin/BitMod.Commands/Handlers/CommandHandler.cs @@ -10,13 +10,13 @@ internal class CommandHandler public CommandHandler(LilikoiContainer container) { Container = container; - Compiled = container.Compile>(); + Compiled = container.Compile(); } public LilikoiContainer Container { get; } - public Func> Compiled { get; } + public Func Compiled { get; } - public Directive Invoke(EventInput input) - => Compiled(input).Result; + public void Invoke(EventInput input) + => Compiled(input); } diff --git a/builtin/BitMod.Commands/Hosts/StandardInputHost.cs b/builtin/BitMod.Commands/Hosts/StandardInputHost.cs new file mode 100644 index 0000000..37918e9 --- /dev/null +++ b/builtin/BitMod.Commands/Hosts/StandardInputHost.cs @@ -0,0 +1,32 @@ +using BitMod.Attributes.Targets; +using BitMod.Commands.Extensions; +using BitMod.Commands.Handlers; +using BitMod.Commands.Sources.Internal; +using BitMod.Events.Core; +using BitMod.Internal.Public; + +using Lilikoi.Standard; + +using Serilog; + +namespace BitMod.Commands.Hosts; + +public class StandardInputHost +{ + + [Singleton] + private ILogger _logger; + + [Singleton] + private PluginInvoker _invoker; + + [BitEvent] + public async Task OnStandardInput(StandardInputEventArgs ev) + { + var source = new StandardInputSource(_logger); + var input = CommandInput.FromString(source, ev.Contents); + + _invoker.Command(input); + } + +} diff --git a/builtin/BitMod.Commands/Sources/Internal/StandardInputSource.cs b/builtin/BitMod.Commands/Sources/Internal/StandardInputSource.cs new file mode 100644 index 0000000..812c54c --- /dev/null +++ b/builtin/BitMod.Commands/Sources/Internal/StandardInputSource.cs @@ -0,0 +1,32 @@ +using BitMod.Compatibility; + +using Serilog; + +namespace BitMod.Commands.Sources.Internal; + +public class StandardInputSource : ICommandSource +{ + private readonly ILogger _logger; + + public StandardInputSource(ILogger logger) + { + _logger = logger; + } + + public bool IsRemote => true; + + public bool IsAuthenticated => false; + + public bool IsAssociatedWithGameServer => false; + + public ulong Steam64 => ulong.MaxValue; + + public BitServer? GameServer => null; + + public BitPlayer? Player => null; + + public void Reply(string message) + { + _logger.Information("[BitMod Commands] {@Msg}", message); + } +} diff --git a/builtin/BitMod.Flags/Public/FlagExtension.cs b/builtin/BitMod.Flags/Public/FlagExtension.cs index b084bb0..4000d41 100644 --- a/builtin/BitMod.Flags/Public/FlagExtension.cs +++ b/builtin/BitMod.Flags/Public/FlagExtension.cs @@ -15,13 +15,19 @@ public class FlagExtension : IExtension public void Register(Mount mount) { var cfg = mount.Get(); + var logger = mount.Get(); var cfgObject = cfg.Get(FlagFile.NAME); - var flagFile = new FlagFile(cfgObject, mount.Get(), cfg); - mount.Store(flagFile); + var flagFile = new FlagFile(cfgObject, logger, cfg); + + logger.Information("Registering FlagFile"); + mount.Store(flagFile); } public void Unregister(Mount mount) { + var logger = mount.Get(); + logger.Information("Unregistering FlagFile"); + mount.Store(null); } } diff --git a/builtin/BitMod.Provision/Config/ProvisionConfigAdapter.cs b/builtin/BitMod.Provision/Config/ProvisionConfigAdapter.cs new file mode 100644 index 0000000..9334ff8 --- /dev/null +++ b/builtin/BitMod.Provision/Config/ProvisionConfigAdapter.cs @@ -0,0 +1,24 @@ +using BitMod.Compatibility; +using BitMod.Configuration.Model; + +namespace BitMod.Provision.Config; + +public class ProvisionConfigAdapter +{ + private IConfigObject _configObject; + + public ProvisionConfigAdapter(IConfigObject configObject) + { + _configObject = configObject; + } + + public ProvisionServerAdapter? GetServer(string server) + { + var child = _configObject.Get(server); + + if (child == null) + return null; + + return new ProvisionServerAdapter(child); + } +} diff --git a/builtin/BitMod.Provision/Config/ProvisionServer.cs b/builtin/BitMod.Provision/Config/ProvisionServer.cs deleted file mode 100644 index 767eb99..0000000 --- a/builtin/BitMod.Provision/Config/ProvisionServer.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace BitMod.Provision.Config; - -public class ProvisionServer -{ - public bool BleedingEnabled { get; set; } = true; - - public float DamageMultiplier { get; set; } = 1f; - - public bool SpectatorsEnabled { get; set; } = true; - - public bool HitMarkersEnabled { get; set; } = true; - - public bool StaminaEnabled { get; set; } = true; - - public bool FriendlyFireEnabled { get; set; } = true; - - public bool PointLogEnabled { get; set; } = true; - - public bool OnlyWinnersCanVote { get; set; } = false; - - - public List Gamemodes { get; set; } = new(); - - public List Maps { get; set; } = new(); -} diff --git a/builtin/BitMod.Provision/Config/ProvisionServerAdapter.cs b/builtin/BitMod.Provision/Config/ProvisionServerAdapter.cs new file mode 100644 index 0000000..24173e1 --- /dev/null +++ b/builtin/BitMod.Provision/Config/ProvisionServerAdapter.cs @@ -0,0 +1,37 @@ +using BitMod.Configuration.Model; + +namespace BitMod.Provision.Config; + +public class ProvisionServerAdapter +{ + private const string MAPCYCLE = "mapcycle"; + private const string GAMEMODES = "gamemodes"; + private IConfigObject _configObject; + + public ProvisionServerAdapter(IConfigObject configObject) + { + _configObject = configObject; + } + + public bool HasMapcycle() + => _configObject.Get(MAPCYCLE) != null; + + public bool HasGamemodes() + => _configObject.Get(GAMEMODES) != null; + + public string[]? GetMapcycle() + => _configObject.Get(MAPCYCLE)?.AsList() + ?.Select(model => model as IConfigSymbol) + ?.Where(symbol => symbol != null) + ?.Select(symbol => symbol.Symbol) + ?.ToArray(); + + public string[]? GetGamemodes() + => _configObject.Get(GAMEMODES)?.AsList() + ?.Select(model => model as IConfigSymbol) + ?.Where(symbol => symbol != null) + ?.Select(symbol => symbol.Symbol) + ?.ToArray(); + + +} diff --git a/builtin/BitMod.Provision/Host/ProvisionHost.cs b/builtin/BitMod.Provision/Host/ProvisionHost.cs index 2947d3b..b2ee646 100644 --- a/builtin/BitMod.Provision/Host/ProvisionHost.cs +++ b/builtin/BitMod.Provision/Host/ProvisionHost.cs @@ -1,6 +1,9 @@ +using BattleBitAPI.Common; + using BitMod.Attributes.Injects; using BitMod.Attributes.Targets; using BitMod.Compatibility; +using BitMod.Configuration.Model; using BitMod.Events.Meta; using BitMod.Events.Server; using BitMod.Provision.Config; @@ -14,70 +17,43 @@ namespace BitMod.Provision.Host; public class ProvisionHost { - - /*[Config("provisions")] - private Dictionary _servers; + [Config("provisions")] + private IConfigObject _config; [Singleton] private ILogger _logger; - [Singleton] - private IConfigurationSystem _config; [BitEvent] - public async Task OnPluginLoad(PluginLoadEvent ev) + public async Task OnServerConnected(GameServerConnectedEventArgs ev) { - + Provision(ev.Server); } [BitEvent] - public async Task OnGameServerConnected(GameServerConnectedEventArgs ev) - => Provision(ev.Server); - - [BitEvent] - public async Task OnRoundEnd(RoundEndedEventArgs ev) - => Provision(ev.Server); - - - private void Provision(BitServer server) + public async Task OnServerRoundEnd(RoundEndedEventArgs ev) { - if (_servers.TryGetValue($"{server.GameIP.ToString()}:{server.GamePort}", out var config)) - Provision(server, config); - else - Provision(server, new ProvisionServer()); + Provision(ev.Server); } - private void Provision(BitServer server, ProvisionServer provision) + private void Provision(BitServer server) { - _logger.Information("[BitMod Provision] Provisioning server {@Name} {@IP}:{@Port}", server.ServerName, server.GameIP, server.GamePort); - _logger.Information("[BitMod Provision] Current: {@Settings}; New: {@Settings}", server.ServerSettings, provision); - server.ServerSettings.BleedingEnabled = provision.BleedingEnabled; - server.ServerSettings.DamageMultiplier = provision.DamageMultiplier; - server.ServerSettings.SpectatorEnabled = provision.SpectatorsEnabled; - server.ServerSettings.HitMarkersEnabled = provision.HitMarkersEnabled; - server.ServerSettings.StamineEnabled = provision.StaminaEnabled; - server.ServerSettings.FriendlyFireEnabled = provision.FriendlyFireEnabled; - server.ServerSettings.PointLogEnabled = provision.PointLogEnabled; - server.ServerSettings.OnlyWinnerTeamCanVote = provision.OnlyWinnersCanVote; + var globalAdapter = new ProvisionConfigAdapter(_config); + var localAdapter = globalAdapter.GetServer(server); - if (provision.Gamemodes?.Count != 0 && provision.Gamemodes != null) - { - _logger.Information("[BitMod Provision] Gamemodes: {@Modes}", server.GamemodeRotation.GetGamemodeRotation().ToList()); - foreach (string gamemode in server.GamemodeRotation.GetGamemodeRotation().ToList()) - server.GamemodeRotation.RemoveFromRotation(gamemode); + if (localAdapter == null) + return; - foreach (string provisionGamemode in provision.Gamemodes) - server.GamemodeRotation.AddToRotation(provisionGamemode); + if (localAdapter.HasMapcycle()) + { + _logger.Verbose("Provisioning {@Server}'s mapcycle to {@Mapcycle}", server.ToString(), localAdapter.GetMapcycle()); + server.MapRotation.SetRotation(localAdapter.GetMapcycle()); } - if (provision.Maps?.Count != 0 && provision.Maps != null) + if (localAdapter.HasGamemodes()) { - _logger.Information("[BitMod Provision] Maps: {@Maps}", server.MapRotation.GetMapRotation().ToList()); - foreach (string gamemode in server.MapRotation.GetMapRotation().ToList()) - server.MapRotation.RemoveFromRotation(gamemode); - - foreach (string provisionGamemode in provision.Maps) - server.MapRotation.AddToRotation(provisionGamemode); + _logger.Verbose("Provisioning {@Server}'s gamemodes to {@Gamemodes}", server.ToString(), localAdapter.GetGamemodes()); + server.GamemodeRotation.SetRotation(localAdapter.GetGamemodes()); } - }*/ + } } diff --git a/builtin/Directory.Build.Targets b/builtin/Directory.Build.Targets new file mode 100644 index 0000000..3469f4c --- /dev/null +++ b/builtin/Directory.Build.Targets @@ -0,0 +1,5 @@ + + + false + + diff --git a/docs/Writerside/bd.tree b/docs/Writerside/bd.tree index 18ed187..cbeddd8 100644 --- a/docs/Writerside/bd.tree +++ b/docs/Writerside/bd.tree @@ -26,4 +26,6 @@ + + \ No newline at end of file diff --git a/docs/Writerside/cfg/buildprofiles.xml b/docs/Writerside/cfg/buildprofiles.xml index 4caf336..3bd4777 100644 --- a/docs/Writerside/cfg/buildprofiles.xml +++ b/docs/Writerside/cfg/buildprofiles.xml @@ -2,7 +2,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> vivid - halloween + metallic ../images/bitmod.svg @@ -12,5 +12,6 @@ Source License Issues + Discord \ No newline at end of file diff --git a/docs/Writerside/images/bitmod.svg b/docs/Writerside/images/bitmod.svg index cb43224..11f68e3 100644 --- a/docs/Writerside/images/bitmod.svg +++ b/docs/Writerside/images/bitmod.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/docs/Writerside/topics/Configuration-Core.topic b/docs/Writerside/topics/Configuration-Core.topic index 57e52ac..9ed4302 100644 --- a/docs/Writerside/topics/Configuration-Core.topic +++ b/docs/Writerside/topics/Configuration-Core.topic @@ -22,10 +22,10 @@ { // Configures the port and IP where BitMod will listen for requests. // If this is not present, BitMod will listen on all IPs at port 9000. - "Listener" + "listener" { - "PublicIP" "0.0.0.0" - "Port" "9000" + "public_ip" "0.0.0.0" + "port" "9000" } } diff --git a/docs/Writerside/topics/Configuration-Whitelists.topic b/docs/Writerside/topics/Configuration-Whitelists.topic index 49846e7..b4463ae 100644 --- a/docs/Writerside/topics/Configuration-Whitelists.topic +++ b/docs/Writerside/topics/Configuration-Whitelists.topic @@ -46,13 +46,10 @@ // default handler. Note that if you do not specify any here, // other plugins will still be able to accept connections. // Plugins can also override this list, and reject connections listed here. - "AllowedIPs" - { - // Format: "entryNumber" "ipAddress" - "0" "127.0.0.1" - } - } + // Format: "entryNumber" "ipAddress" + "0" "127.0.0.1" + } - \ No newline at end of file + diff --git a/docs/Writerside/topics/Embedding-BitMod.topic b/docs/Writerside/topics/Embedding-BitMod.topic new file mode 100644 index 0000000..73f64ee --- /dev/null +++ b/docs/Writerside/topics/Embedding-BitMod.topic @@ -0,0 +1,118 @@ + + + + +

+ BitMod has zero dependency on any kind of local filesystem. + As long as you are able to implement it's public interfaces, you can run + BitMod anywhere using any data source. + + Pure bitmod plugins are completely portable and do not depend on the underlying runtime or filesystem. +

+ +

+ (Individual plugins may use the filesystem, but that is something plugin authors + will have to go out of their way to use) +

+ + +

+ BitMod is designed to be used in a variety of simple and large-scale deployments + and is built with reflection on various modding frameworks released over the years. +

+

+ While BitMod encourages filesystem configuration (as is present in the standard implementation), + it is not required--enabling advanced users to (i.e) use object storage or relational databases + to manage their BitMod deployment. +

+

+ Configuration files could be stored in MongoDB, or logs could be funneled over + WebSockets to a gameserver panel. Plugins could be fetched from CI/CD workflows. + Plugins that do not use low-level .NET APIs (such as filesystem methods) + will be fully portable between BitMod runtimes. +

+
+ + +

+ Your BitMod runtime must provide a ILogger + object from SeriLog. The actual sinks here don't matter (you can even code your own) as long as + all of the methods in the Serilog ILogger interface are fully functional. +

+

+ Failing to provide a functional ILogger will prevent BitMod from booting. +

+
+ + +

+ Your BitMod runtime must provide a IPluginSystem object + that will load and monitor running plugins. +

+

+ This object does not need to be functional or have any of the hot-reloading + functionality of the built-in plugin system, but it should. What you do + with this interface is entirely up to you. +

+

+ If you choose to load a plugin, you should call PluginContext.Load(string, any) + with a name unique to the plugin and either a Type or Assembly + which is scanned for Lilikoi containers. +

+

+ If you choose to unload a plugin, you should call PluginContext.Unload(string) + with the unique name of the plugin you passed earlier. This will unregister all events, + but will do nothing to the underlying types or assemblies. +

+
+ + +

+ Your BitMod runtime must provide a fully functional IConfigurationSystem + object. Failing to do so will prevent BitMod from booting. +

+

+ All a config system does is return a tree of IConfigObject and IConfigSymbol objects. + These can be in any format--JSON, YAML, etc. as long as they comply with the object-symbol semantics. +

+ + The default implementation uses Valve KeyValues; unless you have a good reason to the contrary, + you should probably stick with that for ease of use. + +
+ + +

+ Your BitMod runtime should emit certain events at certain times. + All of these are optional; with the worst case scenario being bugs cropping up in plugins. +

+ +
  • + StandardInputEventArgs +

    + When a full line is entered into the standard input, + invoke this event with it's contents. + Used by the command system and other things. +

    +
  • +
  • + ConfigUpdatedEventArgs +

    + Used by built-in plugins to hot-reload + config files without having to do expensive polling + within hot loops. +

    +
  • +
  • + PluginLoad/UnloadEvent +

    + Can be used by plugins. Optional. +

    +
  • +
    +
    + +
    \ No newline at end of file diff --git a/docs/Writerside/topics/Plugins-Getting-Started.topic b/docs/Writerside/topics/Plugins-Getting-Started.topic index 4896415..20e345f 100644 --- a/docs/Writerside/topics/Plugins-Getting-Started.topic +++ b/docs/Writerside/topics/Plugins-Getting-Started.topic @@ -5,5 +5,40 @@ xsi:noNamespaceSchemaLocation="https://helpserver.labs.jb.gg/help/schemas/mvp/topic.v2.xsd" title="Getting Started" id="Plugins-Getting-Started"> -

    Start typing here...

    + + Page is still under development :^) + + + + +
  • + BitMod +

    + Contains the reference to the community server API + and all event types +

    +
  • +
  • + BitMod.Commands +

    + Contains code, types, and event handlers for the + built-in command system +

    +
  • +
  • + BitMod.Flags +

    + Contains code, types, and event handlers for + the built-in flag system (very similar to ConVars) +

    +
  • +
  • + BitMod.Moderation +

    + Contains event handlers and commands for common moderation + tasks. Currently only supports votekicking +

    +
  • +
    +
    \ No newline at end of file diff --git a/plugins/BitMod.Gamemode.GunGame/BitMod.Gamemode.GunGame.csproj b/plugins/BitMod.Gamemode.GunGame/BitMod.Gamemode.GunGame.csproj deleted file mode 100644 index 8090c94..0000000 --- a/plugins/BitMod.Gamemode.GunGame/BitMod.Gamemode.GunGame.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - net6.0 - enable - - $(BitModDev)/plugins/$(AssemblyName)/ - - - - - - - - - diff --git a/plugins/BitMod.Gamemode.GunGame/Controllers/GunGameController.cs b/plugins/BitMod.Gamemode.GunGame/Controllers/GunGameController.cs deleted file mode 100644 index ab1d5c7..0000000 --- a/plugins/BitMod.Gamemode.GunGame/Controllers/GunGameController.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Threading.Tasks; - -using BattleBitAPI.Common; - -using BitMod.Attributes.Targets; -using BitMod.Compatibility; -using BitMod.Events.Player; -using BitMod.Gamemode.GunGame.State; - -namespace BitMod.Gamemode.GunGame.Controllers; - -public class GunGameController -{ - [BitEvent] - public async Task OnPlayerKilled(PlayerKilledPlayerEventArgs ev) - { - var serverState = ev.Server.Mount.Get(); - var playerState = ev.Killer.Mount.Get(); - - // Upgrade the killer - } - - private void UpgradePlayer(BitPlayer player, GunGameState serverState, GunGamePlayerState playerState) - { - if (serverState.Progression.Count <= playerState.Progression) - { - } - } -} diff --git a/plugins/BitMod.Gamemode.GunGame/State/GunGamePlayerState.cs b/plugins/BitMod.Gamemode.GunGame/State/GunGamePlayerState.cs deleted file mode 100644 index dc02c70..0000000 --- a/plugins/BitMod.Gamemode.GunGame/State/GunGamePlayerState.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace BitMod.Gamemode.GunGame.State; - -public class GunGamePlayerState -{ - public GunGamePlayerState(int progression) - { - Progression = progression; - } - - public int Progression { get; set; } - -} diff --git a/plugins/BitMod.Gamemode.GunGame/State/GunGameState.cs b/plugins/BitMod.Gamemode.GunGame/State/GunGameState.cs deleted file mode 100644 index 2379750..0000000 --- a/plugins/BitMod.Gamemode.GunGame/State/GunGameState.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; - -using BattleBitAPI.Common; - -namespace BitMod.Gamemode.GunGame.State; - -public class GunGameState -{ - public List Progression { get; } - -} diff --git a/samples/SamplePlugin/SampleEvents/EventListener.cs b/samples/SamplePlugin/SampleEvents/EventListener.cs index cf2198a..a90e43c 100644 --- a/samples/SamplePlugin/SampleEvents/EventListener.cs +++ b/samples/SamplePlugin/SampleEvents/EventListener.cs @@ -1,7 +1,10 @@ using BitMod.Attributes.Injects; using BitMod.Attributes.Mutators; using BitMod.Attributes.Targets; +using BitMod.Configuration.Model; using BitMod.Events.Meta; +using BitMod.Events.Server; +using BitMod.Flags.Attribute; using Lilikoi.Standard; @@ -11,12 +14,18 @@ namespace SamplePlugin.SampleEvents; public class EventListener { + [BitEvent] [Log] - public Task OnEvent(PluginLoadEvent ev, ILogger logger) + public async Task OnEvent(PluginLoadEvent ev, ILogger logger) { logger.Information("hello there, {@Name}!", ev.Name); + } - return Task.CompletedTask; + [BitEvent] + [Log] + public async Task OnServerConnect(GameServerConnectedEventArgs ev, [Flag("sample_flag", "nothing!")] IConfigSymbol flag, ILogger logger) + { + logger.Information("Hello new gameserver! Your flag value is {@Value}.", flag.Symbol); } } diff --git a/samples/SamplePlugin/SamplePlugin.csproj b/samples/SamplePlugin/SamplePlugin.csproj index 307c021..873a75d 100644 --- a/samples/SamplePlugin/SamplePlugin.csproj +++ b/samples/SamplePlugin/SamplePlugin.csproj @@ -6,6 +6,7 @@ enable Debug;Release AnyCPU + sample_plugin ../../dev/plugins/$(AssemblyName)/ ../../build/plugins/$(AssemblyName) @@ -14,6 +15,7 @@ + diff --git a/standalone/BitMod.Launcher/Program.cs b/standalone/BitMod.Launcher/Program.cs index d99ff1a..c72c495 100644 --- a/standalone/BitMod.Launcher/Program.cs +++ b/standalone/BitMod.Launcher/Program.cs @@ -1,4 +1,5 @@ using BitMod.Config; +using BitMod.Events.Core; using BitMod.Logging; using BitMod.Plugins; @@ -17,5 +18,13 @@ public static void Main() var bitmod = new BitMod.BitMod(log, configSystem, pluginSystem); bitmod.Start(); + + while (true) + { + var command = Console.ReadLine(); + + if (command != null) + bitmod.Invoker.Event(new StandardInputEventArgs(command)); + } } }