-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFriendManager.cs
76 lines (58 loc) · 1.98 KB
/
FriendManager.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using BrokeProtocol.Collections;
using BrokeProtocol.Entities;
using BrokeProtocolClient.settings;
using BrokeProtocolClient.utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BrokeProtocolClient.modules.misc
{
class FriendManager : Module
{
InputSetting friendInput = new InputSetting("Friends username/ID", 16, "");
ActionSetting addFriendButton;
FileSetting friendsFile = new FileSetting("Friends file", FileManager.MainFolderPath + FileManager.FriendsFile);
static List<string> friendlyPlayers = new List<string>();
public FriendManager() : base(Categories.Misc, "Friend Manager", "Allows to manage friends")
{
addSetting(friendInput);
addFriendButton = new ActionSetting("Add friend", addFriendFunc);
addSetting(addFriendButton);
addSetting(friendsFile);
friendlyPlayers = friendsFile.readLines();
}
public override void onActivate()
{
}
public override void onDeactivate()
{
}
public override void onRender()
{
}
public override void onUpdate()
{
}
public static List<string> getFriends()
{
return friendlyPlayers;
}
private void addFriendFunc()
{
addFriend(friendInput.getValue());
}
private void addFriend(string usernameOrId)
{
ShPlayer target;
if (!EntityCollections.TryGetPlayerByNameOrID(usernameOrId, out target))
{
ConsoleBase.WriteLine($"{usernameOrId} not found!");
return;
}
friendlyPlayers.Add(target.username);
friendsFile.writeLine(target.username);
}
}
}