1+ using System ;
2+ using System . Collections . Generic ;
3+ using Rocket . API . Commands ;
4+ using Rocket . API . Permissions ;
5+ using Rocket . API . Plugin ;
6+
7+ namespace Rocket . Core . Commands . RocketCommands
8+ {
9+ public class CommandRocket : ICommand
10+ {
11+ public List < ICommand > ChildCommands => null ;
12+ public string GetSyntax ( ICommandContext context )
13+ {
14+ return context . Parameters . Length == 0 ? "<reload>" : "" ;
15+ }
16+
17+ public string Description => "Manage Rocket" ;
18+ public List < string > Aliases => null ;
19+
20+ public string GetHelpText ( ICommandContext context )
21+ {
22+ if ( context . Parameters . Length == 0 )
23+ return Description ;
24+
25+ string cmd = context . Parameters . Get < string > ( 1 ) . ToLower ( ) ;
26+ if ( cmd == "reload" )
27+ return "Reloads all configs." ;
28+
29+ return "Unknown sub command." ;
30+ }
31+
32+ public string Name => "Rocket" ;
33+ public string Permission => "Rocket.ManageRocket" ;
34+
35+ public void Execute ( ICommandContext context )
36+ {
37+ if ( context . Parameters . Length == 0 )
38+ throw new CommandParameterMismatchException ( ) ;
39+
40+ string cmd = context . Parameters . Get < string > ( 1 ) . ToLower ( ) ;
41+ switch ( cmd )
42+ {
43+ case "reload" :
44+ {
45+ var permissions = context . Container . Get < IPermissionProvider > ( ) ;
46+ permissions . Reload ( ) ;
47+
48+ foreach ( var plugin in context . Container . Get < IPluginManager > ( ) )
49+ {
50+ plugin . Reload ( ) ;
51+ }
52+
53+ context . Caller . SendMessage ( "Reload completed." , ConsoleColor . DarkGreen ) ;
54+ return ;
55+ }
56+ }
57+
58+ throw new CommandWrongUsageException ( ) ;
59+ }
60+
61+ public bool SupportsCaller ( ICommandCaller caller )
62+ {
63+ return true ;
64+ }
65+ }
66+ }
0 commit comments