-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redo logging & formatting (again) (#25)
* Redo `SimpleView` semantics to be more in line with how they're actually used (use collection-constructor pattern rather than delegate pattern) * Fragment `LogManager` into `ILogService`, `IPlayerTag`, and rich variants in `Jailbreak.Formatting` * Add barebones english translations for logging (will need to go over again)
- Loading branch information
Showing
35 changed files
with
1,097 additions
and
697 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
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 CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
|
||
using Jailbreak.Formatting.Base; | ||
using Jailbreak.Formatting.Core; | ||
using Jailbreak.Formatting.Logistics; | ||
using Jailbreak.Formatting.Objects; | ||
using Jailbreak.Formatting.Views; | ||
using Jailbreak.Public.Extensions; | ||
|
||
namespace Jailbreak.English.Logs; | ||
|
||
public class LogMessages : ILogMessages, ILanguage<Formatting.Languages.English> | ||
{ | ||
|
||
|
||
|
||
public IView BEGIN_JAILBREAK_LOGS => new SimpleView() | ||
{ | ||
{ "********************************" }, SimpleView.NEWLINE, | ||
{ "***** BEGIN JAILBREAK LOGS *****" }, SimpleView.NEWLINE, | ||
{ "********************************" } | ||
}; | ||
|
||
public IView END_JAILBREAK_LOGS => new SimpleView() | ||
{ | ||
{ "********************************" }, SimpleView.NEWLINE, | ||
{ "****** END JAILBREAK LOGS ******" }, SimpleView.NEWLINE, | ||
{ "********************************" } | ||
}; | ||
|
||
|
||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Core.Attributes.Registration; | ||
|
||
using Jailbreak.Formatting.Views; | ||
using Jailbreak.Public.Behaviors; | ||
using Jailbreak.Public.Extensions; | ||
|
||
namespace Jailbreak.Logs.Listeners; | ||
|
||
public class LogDamageListeners : IPluginBehavior | ||
{ | ||
private readonly IRichLogService _logs; | ||
|
||
public LogDamageListeners(IRichLogService logs) | ||
{ | ||
_logs = logs; | ||
} | ||
|
||
|
||
|
||
[GameEventHandler] | ||
public HookResult OnGrenadeThrown(EventGrenadeThrown @event, GameEventInfo info) | ||
{ | ||
var player = @event.Userid; | ||
if (!player.IsReal()) | ||
return HookResult.Continue; | ||
var grenade = @event.Weapon; | ||
|
||
_logs.Append(_logs.Player(player), $"threw a {grenade}"); | ||
|
||
return HookResult.Continue; | ||
} | ||
|
||
[GameEventHandler] | ||
public HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info) | ||
{ | ||
var player = @event.Userid; | ||
if (!player.IsReal()) | ||
return HookResult.Continue; | ||
var attacker = @event.Attacker; | ||
|
||
bool isWorld = attacker == null || !attacker.IsReal(); | ||
int health = @event.DmgHealth; | ||
|
||
if (isWorld) | ||
{ | ||
if (health > 0) | ||
{ | ||
_logs.Append($"The world hurt", _logs.Player(player), $"for {health} damage"); | ||
} | ||
else | ||
{ | ||
_logs.Append("The world killed", _logs.Player(player)); | ||
} | ||
} | ||
else | ||
{ | ||
if (health > 0) | ||
{ | ||
_logs.Append( _logs.Player(attacker), "hurt", _logs.Player(player), $"for {health} damage"); | ||
Check warning on line 60 in mod/Jailbreak.Logs/Listeners/LogDamageListeners.cs GitHub Actions / build
|
||
} | ||
else | ||
{ | ||
_logs.Append(_logs.Player(attacker!), "killed", _logs.Player(player)); | ||
} | ||
} | ||
|
||
return HookResult.Continue; | ||
} | ||
} |
Oops, something went wrong.