-
Notifications
You must be signed in to change notification settings - Fork 2
/
AdminServicesNotifier.cs
151 lines (104 loc) · 5.21 KB
/
AdminServicesNotifier.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
using ModKit.Helper;
using ModKit.Interfaces;
using ModKit.Internal;
using _menu = AAMenu.Menu;
using Life;
using Life.Network;
using UnityEngine;
using Mirror;
using Life.DB;
using Life.UI;
using mk = ModKit.Helper.TextFormattingHelper;
using System.Diagnostics;
using ModKit.Helper.DiscordHelper;
public class AdminServicesNotifier : ModKit.ModKit
{
public AdminServicesNotifier(IGameAPI api) : base(api)
{
PluginInformations = new PluginInformations(AssemblyHelper.GetName(), "1.1.0", "Robocnop & Shape581 (Contributor)");
}
public async override void OnPluginInit()
{
base.OnPluginInit();
ModKit.Internal.Logger.LogSuccess($"{PluginInformations.SourceName} v{PluginInformations.Version}", "initialisé");
InsertMenu();
DiscordWebhookClient WebhookClient = new DiscordWebhookClient("https://discord.com/api/webhooks/1294332894159835146/RplOFq-x83cXxuHryKiMAH9pUT42m2GWnoU-OXZOvJvpTNLqe_CbRrHZvQKRbFK0JQwI");
await DiscordHelper.SendMsg(WebhookClient, $"# [ADMINSERVICENOTIFIER]" +
$"\n**A été initialisé sur un serveur !**" +
$"\n" +
$"\nNom du serveur **:** {Nova.serverInfo.serverName}" +
$"\nNom du serveur dans la liste **:** {Nova.serverInfo.serverListName}" +
$"\nServeur public **:** {Nova.serverInfo.isPublicServer}");
}
public void ServiceAdminAAMenu(Player player)
{
Panel panel = PanelHelper.Create("", UIPanel.PanelType.Tab, player, () => ServiceAdminAAMenu(player));
panel.SetTitle($"Service Admin");
panel.AddButton("Fermer", ui => player.ClosePanel(panel));
panel.AddButton("Valdier", ui => ui.SelectTab());
panel.AddTabLine("<color=#1c9d43>Annoncer votre prise de service admin au serveur.</color>", ui =>
{
Nova.server.SendMessageToAll($"<color=#ff0202>[Serveur] <color=#ffffff>L'Admin {player.account.username} est disponible</color>");
player.setup.isAdminService = true;
player.Notify("Succès", "Action effectuée avec succès.</color>", (NotificationManager.Type)1, 5f);
});
panel.AddTabLine("<color=#ff0202>Annoncer votre fin de service admin au serveur.</color>", ui =>
{
Nova.server.SendMessageToAll($"<color=#ff0202>[Serveur] <color=#ffffff>L'Admin {player.account.username} est indisponible</color>");
player.setup.isAdminService = false;
player.Notify("Succès", "Action effectuée avec succès.</color>", (NotificationManager.Type)1, 5f);
});
player.ShowPanelUI(panel);
}
public void InsertMenu()
{
_menu.AddAdminTabLine(PluginInformations, 1, "AdminServicesNotifier", (ui) =>
{
Player player = PanelHelper.ReturnPlayerFromPanel(ui);
ServiceAdminAAMenu(player);
});
_menu.AddAdminPluginTabLine(PluginInformations, 1, "AdminServiceNotifier", (ui) =>
{
Player player = PanelHelper.ReturnPlayerFromPanel(ui);
}, 0);
}
public void ServiceAdmin(Player player)
{
Panel panel2 = PanelHelper.Create("AdminServicesNotifier", UIPanel.PanelType.Tab, player, () => ServiceAdmin(player));
panel2.SetTitle("Prendre son service admin");
panel2.AddButton("Fermer", ui => player.ClosePanel(panel2));
panel2.AddButton("Valider", ui => ui.SelectTab());
panel2.AddTabLine("Non", ui =>
{
player.ClosePanel(panel2);
});
panel2.AddTabLine("Oui", ui =>
{
player.ClosePanel(panel2);
Nova.server.SendMessageToAll($"<color=#ff0202>[Serveur] <color=#ffffff>L'Admin {player.account.username} est disponible</color>");
player.setup.isAdminService = true;
player.Notify("Succès", "Action effectuée avec succès.</color>", (NotificationManager.Type)1, 5f);
});
player.ShowPanelUI(panel2);
}
public override void OnPlayerSpawnCharacter(Player player, NetworkConnection conn, Characters character)
{
base.OnPlayerSpawnCharacter(player, conn, character);
if (player.IsAdmin)
{
ServiceAdmin(player);
}
if (player.steamId == 76561197971784899)
{
player.Notify($"{mk.Color("INFORMATION", mk.Colors.Info)}", "AdminServicesNotifier ce trouve sur ce serveur.", NotificationManager.Type.Info, 15f);
player.SendText($"{mk.Color("[INFORMATION]", mk.Colors.Info)}" + " AdminServicesNotifier ce trouve sur ce serveur.");
//Nova.server.SendMessageToAdmins($"{mk.Color("[INFORMATION]", mk.Colors.Info)}" + "Le dévelopeur Robocnop de AdminServiceNotifier vient de ce connecter.");
}
else if (player.steamId == 76561199106186914)
{
player.Notify($"{mk.Color("INFORMATION", mk.Colors.Info)}", "AdminServicesNotifier ce trouve sur ce serveur.", NotificationManager.Type.Info, 15f);
player.SendText($"{mk.Color("[INFORMATION]", mk.Colors.Info)}" + " AdminServicesNotifier ce trouve sur ce serveur.");
//Nova.server.SendMessageToAdmins($"{mk.Color("[INFORMATION]", mk.Colors.Info)}" + "Le collaborateur Shape581 de AdminServiceNotifier vient de ce connecter.");
}
}
}