forked from RestoreMonarchyPlugins/HealingBall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtensions.cs
44 lines (39 loc) · 1.36 KB
/
Extensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using SDG.Unturned;
using Steamworks;
using System;
using Color = UnityEngine.Color;
using Logger = Rocket.Core.Logging.Logger;
using UP = Rocket.Unturned.Player.UnturnedPlayer;
namespace HealingBall
{
public static class Extensions
{
public static Configuration Config => Plugin.Instance.Configuration.Instance;
public static void SendChat(UP up, string text, Color color)
{
ChatManager.serverSendMessage($"<color=green>[HealingBall]</color> {text}", color, null,
up.SteamPlayer(), EChatMode.SAY, "", true);
}
public static void SendConsole(string text, ConsoleColor color)
{
Logger.Log(text, color);
}
public static bool TryFindPlayer(string parameter, out UP target)
{
target = ulong.TryParse(parameter, out var sid)
? UP.FromCSteamID(new CSteamID(sid))
: UP.FromName(parameter);
return target != null;
}
public static void Heal(this Player player)
{
player.life.askHeal(100, Config.HealBleeding, Config.HealBroken);
if (Config.FillHunger)
player.life.askEat(100);
if (Config.FillThirst)
player.life.askDrink(100);
if (Config.HealToxic)
player.life.askDisinfect(100);
}
}
}