forked from RocketModPlugins/GlobalBan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandUnban.cs
55 lines (45 loc) · 1.62 KB
/
CommandUnban.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
using System;
using Rocket.API.Commands;
using Rocket.API.Plugins;
using Rocket.API.User;
using Rocket.Core.Commands;
using Rocket.Core.I18N;
using Rocket.Core.User;
namespace fr34kyn01535.GlobalBan
{
public class CommandUnban : ICommand
{
private readonly GlobalBan _globalBanPlugin;
public CommandUnban(IPlugin plugin)
{
_globalBanPlugin = (GlobalBan)plugin;
}
public string Name => "unban";
public string[] Aliases => null;
public string Permission => null;
public string Syntax => "<player>";
public IChildCommand[] ChildCommands => null;
public string Summary => "Unbans a player.";
public string Description => null;
public bool SupportsUser(Type user)
{
return true;
}
public void Execute(ICommandContext context)
{
if (context.Parameters.Length != 1)
{
throw new CommandWrongUsageException();
}
IUserManager globalUserManager = context.Container.Resolve<IUserManager>();
IUserInfo target = context.Parameters.Get<IUserInfo>(0);
DatabaseManager.UnbanResult name = _globalBanPlugin.Database.UnbanPlayer(target);
if (!target.UserManager.Unban(target, context.User) && String.IsNullOrEmpty(name.Name))
{
context.User.SendLocalizedMessage(_globalBanPlugin.Translations, "command_generic_player_not_found");
return;
}
globalUserManager.Broadcast(null, "The player " + name.Name + " was unbanned");
}
}
}