Skip to content

Commit

Permalink
feat: Fix OnInternalSpawning & Added ChargingJailbird setter (by Blac…
Browse files Browse the repository at this point in the history
…kSerperior6) (#368)

BlackSerperior6

Co-authored-by: BlackSerperior6 <109168410+blackserperior6@users.noreply.github.com>
  • Loading branch information
louis1706 and BlackSerperior6 authored Jan 10, 2025
1 parent b33f211 commit 48720bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ private void OnInternalChangingNickname(ChangingNicknameEventArgs ev)

private void OnInternalSpawning(SpawningEventArgs ev)
{
if (!IgnoreSpawnSystem && SpawnChance > 0 && !Check(ev.Player) && ev.Player.Role.Type == Role && Loader.Random.NextDouble() * 100 <= SpawnChance)
if (!IgnoreSpawnSystem && SpawnChance > 0 && !Check(ev.Player) && ev.NewRole == Role && Loader.Random.NextDouble() * 100 <= SpawnChance)
AddRole(ev.Player);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public ChargingJailbirdEventArgs(ReferenceHub player, InventorySystem.Items.Item
{
Player = Player.Get(player);
Jailbird = (Jailbird)Item.Get(swingItem);
#pragma warning disable CS0618
IsAllowed = isAllowed;
#pragma warning restore CS0618
}

/// <summary>
Expand All @@ -47,8 +45,8 @@ public ChargingJailbirdEventArgs(ReferenceHub player, InventorySystem.Items.Item
public Item Item => Jailbird;

/// <summary>
/// Gets a value indicating whether the Jailbird can be charged.
/// Gets or sets a value indicating whether the Jailbird can be charged.
/// </summary>
public bool IsAllowed { get; }
public bool IsAllowed { get; set; }
}
}
7 changes: 6 additions & 1 deletion EXILED/Exiled.Events/Patches/Events/Item/JailbirdPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ private static bool HandleJailbird(JailbirdItem instance, JailbirdMessageType me
ChargingJailbirdEventArgs ev = new(instance.Owner, instance);

Item.OnChargingJailbird(ev);
return true;
if (ev.IsAllowed)
return true;

ev.Player.RemoveHeldItem(destroy: false);
ev.Player.AddItem(ev.Item);
return false;
}

default:
Expand Down

0 comments on commit 48720bd

Please sign in to comment.