Skip to content

Commit dd84fc0

Browse files
committed
fix: add checks
1 parent 3d6e5a2 commit dd84fc0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

GamingAPIPlugins/plugins/GamingAPI.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ object OnItemPickup(Item item, BasePlayer player)
208208
object OnLootItem(PlayerLoot playerLoot, Item item)
209209
{
210210
BasePlayer player = playerLoot.GetComponent<BasePlayer>();
211+
if (player == null)
212+
{
213+
Puts("On item loot player null");
214+
return null;
215+
}
211216
ServerPlayerItemLoot i = new ServerPlayerItemLoot
212217
{
213218
ItemId = item.info.itemid,
@@ -245,6 +250,11 @@ void OnItemCraftFinished(ItemCraftTask task, Item item)
245250
void OnPlayerBanned(string name, ulong id, string address, string reason)
246251
{
247252
BasePlayer player = BasePlayer.Find(id + "");
253+
if (player == null)
254+
{
255+
Puts("On player banned not found");
256+
return;
257+
}
248258
TimeSpan banTimeRemaining = player.IPlayer.BanTimeRemaining;
249259
ServerPlayerBanned i = new ServerPlayerBanned
250260
{
@@ -278,6 +288,11 @@ void OnPlayerReported(BasePlayer reporter, string targetName, string targetId, s
278288

279289
object OnServerCommand(ConsoleSystem.Arg arg)
280290
{
291+
if(arg.Args == null)
292+
{
293+
Puts("On server command args null");
294+
return null;
295+
}
281296
ServerCommand i = new ServerCommand
282297
{
283298
Timestamp = System.DateTime.Now.ToString(),
@@ -351,6 +366,9 @@ object OnPlayerAttack(BasePlayer player, HitInfo info)
351366
DefaultPluginInformation.GetInstance().NatsClient.JetStreamPublishToV0RustServersServerIdPlayersSteamIdEventsCombatHit(pophWrapper, DefaultPluginInformation.GetServerId(), player.IPlayer.Id);
352367
});
353368
});
369+
} else
370+
{
371+
Puts("Attack skipped");
354372
}
355373

356374
return null;

0 commit comments

Comments
 (0)