Skip to content

Commit a6da005

Browse files
committed
Fixes
1 parent 7761e85 commit a6da005

File tree

3 files changed

+42
-45
lines changed

3 files changed

+42
-45
lines changed

UsefulHints/Config.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public class Config : IConfig
3434
public string DamageTakenWarning { get; set; } = "<size=27><color=red>{0}</color> <color=yellow>(teammate) hit you</color></size>";
3535
public bool ClassDAreTeammates { get; set; } = true;
3636
public bool EnableCuffedWarning { get; set; } = true;
37-
public string CuffedPlayerWarning { get; set; } = "<size=27><color=yellow>\u26A0 Player is cuffed</color></size>";
37+
public string CuffedAttackerWarning { get; set; } = "<size=27><color=yellow>\u26A0 Player is cuffed</color></size>";
38+
public string CuffedPlayerWarning { get; set; } = "<size=27><color=red>{0}</color> <color=yellow>hit you when you were cuffed</color></size>";
3839
[Description("Kill Counter:")]
3940
public bool EnableKillCounter { get; set; } = true;
4041
public string KillCountMessage { get; set; } = "{0} kills";

UsefulHints/EventHandlers/Items/Hints.cs

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Exiled.Events.EventArgs.Player;
1010
using InventorySystem.Items.ThrowableProjectiles;
1111
using InventorySystem.Items.Jailbird;
12+
using InventorySystem.Items.MicroHID;
1213
using MEC;
1314

1415
namespace UsefulHints.EventHandlers.Items
@@ -49,47 +50,42 @@ public static void UnregisterEvents()
4950
}
5051
private static void OnPickingUpMicroHid(PickingUpItemEventArgs ev)
5152
{
52-
if (ev.Pickup.Type == ItemType.MicroHID)
53+
if (ev.Pickup.Base is MicroHIDPickup microHidPickup)
5354
{
54-
var microHidPickup = ev.Pickup.Base as InventorySystem.Items.MicroHID.MicroHIDPickup;
55+
float energyPercentage = microHidPickup.Energy * 100;
56+
float roundedEnergyPercentage = (float)Math.Round(energyPercentage, 1);
5557

56-
if (microHidPickup != null)
58+
if (roundedEnergyPercentage < 5)
5759
{
58-
float energyPercentage = microHidPickup.Energy * 100;
59-
float roundedEnergyPercentage = (float)Math.Round(energyPercentage, 1);
60-
61-
if (roundedEnergyPercentage < 5)
62-
{
63-
ev.Player.ShowHint($"<color=red>{string.Format(UsefulHints.Instance.Config.MicroLowEnergyMessage)}</color>", 4);
64-
}
65-
else
66-
{
67-
ev.Player.ShowHint($"<color=#4169E1>{string.Format(UsefulHints.Instance.Config.MicroEnergyMessage, roundedEnergyPercentage)}</color>", 4);
68-
}
60+
ev.Player.ShowHint($"<color=red>{string.Format(UsefulHints.Instance.Config.MicroLowEnergyMessage)}</color>", 4);
61+
}
62+
else
63+
{
64+
ev.Player.ShowHint($"<color=#4169E1>{string.Format(UsefulHints.Instance.Config.MicroEnergyMessage, roundedEnergyPercentage)}</color>", 4);
6965
}
7066
}
7167
}
7268
public static void OnEquipMicroHid(ChangingItemEventArgs ev)
7369
{
7470
if (UsefulHints.Instance.Config.ShowHintOnEquip)
7571
{
76-
if (ev.Item.Type == ItemType.MicroHID)
72+
if (ev.Item == null)
73+
{
74+
return;
75+
}
76+
if (ev.Item.Base is MicroHIDItem microHidItem)
7777
{
78-
var microHidItem = ev.Item.Base as InventorySystem.Items.MicroHID.MicroHIDItem;
7978

80-
if (microHidItem != null)
81-
{
82-
float energyPercentage = microHidItem.RemainingEnergy * 100;
83-
float roundedEnergyPercentage = (float)Math.Round(energyPercentage, 1);
79+
float energyPercentage = microHidItem.RemainingEnergy * 100;
80+
float roundedEnergyPercentage = (float)Math.Round(energyPercentage, 1);
8481

85-
if (roundedEnergyPercentage < 5)
86-
{
87-
ev.Player.ShowHint($"<color=red>{string.Format(UsefulHints.Instance.Config.MicroLowEnergyMessage)}</color>", 4);
88-
}
89-
else
90-
{
91-
ev.Player.ShowHint($"<color=#4169E1>{string.Format(UsefulHints.Instance.Config.MicroEnergyMessage, roundedEnergyPercentage)}</color>", 4);
92-
}
82+
if (roundedEnergyPercentage < 5)
83+
{
84+
ev.Player.ShowHint($"<color=red>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroLowEnergyMessage)}</color>", 4);
85+
}
86+
else
87+
{
88+
ev.Player.ShowHint($"<color=#4169E1>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroEnergyMessage, roundedEnergyPercentage)}</color>", 4);
9389
}
9490
}
9591
}
@@ -259,27 +255,26 @@ private static void OnPickingUpJailbird(PickingUpItemEventArgs ev)
259255
}
260256
}
261257
}
262-
private static void OnEquipJailbird(ChangingItemEventArgs ev)
258+
public static void OnEquipJailbird(ChangingItemEventArgs ev)
263259
{
264260
if (UsefulHints.Instance.Config.ShowHintOnEquip)
265261
{
266-
if (ev.Item.Type == ItemType.Jailbird)
262+
if (ev.Item == null)
267263
{
268-
var jailbirdItem = ev.Item.Base as JailbirdItem;
264+
return;
265+
}
266+
if (ev.Item.Base is JailbirdItem jailbirdItem)
267+
{
268+
int maxCharges = 5;
269+
int remainingCharges = maxCharges - jailbirdItem.TotalChargesPerformed;
269270

270-
if (jailbirdItem != null)
271+
if (remainingCharges > 1)
271272
{
272-
int maxCharges = 5;
273-
int remainingCharges = maxCharges - jailbirdItem.TotalChargesPerformed;
274-
275-
if (remainingCharges > 1)
276-
{
277-
ev.Player.ShowHint($"<color=#00B7EB>{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4);
278-
}
279-
else
280-
{
281-
ev.Player.ShowHint($"<color=#C73804>{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4);
282-
}
273+
ev.Player.ShowHint($"<color=#00B7EB>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4);
274+
}
275+
else
276+
{
277+
ev.Player.ShowHint($"<color=#C73804>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4);
283278
}
284279
}
285280
}

UsefulHints/EventHandlers/Modules/FFWarning.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ private static void OnHurting(HurtingEventArgs ev)
3535
}
3636
if (UsefulHints.Instance.Config.EnableCuffedWarning && ev.Player.IsCuffed && ev.Attacker != ev.Player)
3737
{
38-
ev.Player.ShowHint(string.Format(UsefulHints.Instance.Config.CuffedPlayerWarning), 1);
38+
ev.Attacker.ShowHint(string.Format(UsefulHints.Instance.Config.CuffedAttackerWarning), 2);
39+
ev.Player.ShowHint(string.Format(UsefulHints.Instance.Config.CuffedPlayerWarning, ev.Attacker.Nickname), 2);
3940
}
4041
}
4142
}

0 commit comments

Comments
 (0)