forked from deadfacerip/GlobalBan
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CommandKick.cs
56 lines (48 loc) · 1.79 KB
/
CommandKick.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
using System;
using Rocket.API.Commands;
using Rocket.API.Plugins;
using Rocket.API.User;
using Rocket.Core.Commands;
using Rocket.Core.I18N;
namespace fr34kyn01535.GlobalBan
{
public class CommandKick : ICommand
{
private readonly GlobalBan _globalBanPlugin;
public CommandKick(IPlugin plugin)
{
_globalBanPlugin = (GlobalBan)plugin;
}
public string Name => "kick";
public string[] Aliases => null;
public string Summary => "Kicks a player.";
public string Description => null;
public string Permission => null;
public string Syntax => "<player> [reason]";
public IChildCommand[] ChildCommands => null;
public bool SupportsUser(Type user)
{
return true;
}
public void Execute(ICommandContext context)
{
if (context.Parameters.Length == 0 || context.Parameters.Length > 2)
{
throw new CommandWrongUsageException();
}
var globalUserManager = context.Container.Resolve<IUserManager>();
IUser userToKick = context.Parameters.Get<IUser>(0);
string reason = _globalBanPlugin.Translations.Get("command_kick_private_default_reason");
if (context.Parameters.Length >= 2)
{
reason = context.Parameters.GetArgumentLine(1);
globalUserManager.BroadcastLocalized(_globalBanPlugin.Translations, "command_kick_public_reason", userToKick.Name, reason);
}
else
{
globalUserManager.BroadcastLocalized(_globalBanPlugin.Translations, "command_kick_public", userToKick.Name);
}
userToKick.UserManager.Kick(userToKick, context.User, reason);
}
}
}