@@ -48,45 +48,56 @@ public override void LoadGeneratedCommands()
4848
4949 protected override bool ExecuteParent ( ArraySegment < string > arguments , ICommandSender sender , out string response )
5050 {
51- if ( arguments . Count == 0 )
51+ try
5252 {
53- response = $ "UncomplicatedCustomItems v{ Plugin . Instance . Version } by FoxWorn3365, SpGerg & Mr. Baguetter\n \n <size=35>Available commands:</size>";
54- foreach ( ISubcommand command in Subcommands )
55- response += $ "\n - uci { command . Name } { ( command . VisibleArgs != string . Empty ? $ " { command . VisibleArgs } " : "" ) } - { command . Description } ";
53+ if ( arguments . Count == 0 )
54+ {
55+ response = $ "UncomplicatedCustomItems v{ Plugin . Instance . Version } by FoxWorn3365, SpGerg & Mr. Baguetter\n \n <size=35>Available commands:</size>";
56+ foreach ( ISubcommand command in Subcommands )
57+ response += $ "\n - uci { command . Name } { ( command . VisibleArgs != string . Empty ? $ " { command . VisibleArgs } " : "" ) } - { command . Description } ";
5658
57- return true ;
58- }
59+ return true ;
60+ }
5961
60- ISubcommand cmd = Subcommands . FirstOrDefault ( cmd => cmd . Name == arguments . At ( 0 ) ) ;
62+ ISubcommand cmd = Subcommands . FirstOrDefault ( cmd => cmd . Name == arguments . At ( 0 ) ) ;
6163
62- cmd ??= Subcommands . FirstOrDefault ( cmd => cmd . Aliases . Contains ( arguments . At ( 0 ) ) ) ;
64+ cmd ??= Subcommands . FirstOrDefault ( cmd => cmd . Aliases . Contains ( arguments . At ( 0 ) ) ) ;
6365
64- if ( cmd is null )
65- {
66- response = "Command not found!" ;
67- return false ;
68- }
66+ if ( cmd is null )
67+ {
68+ response = "Command not found!" ;
69+ return false ;
70+ }
6971#if EXILED
70- if ( ! sender . CheckPermission ( cmd . RequiredPermission ) )
72+ if ( ! sender . CheckPermission ( cmd . RequiredPermission ) )
7173#else
72- if ( ! sender . HasPermissions ( cmd . RequiredPermission ) )
74+ if ( ! sender . HasPermissions ( cmd . RequiredPermission ) )
7375#endif
76+ {
77+ response = "You don't have permission to access that command! \n Required permission: {cmd.RequiredPermission}" ;
78+ return false ;
79+ }
7480
75- {
76- response = "You don't have permission to access that command! \n Required permission: {cmd.RequiredPermission}" ;
77- return false ;
78- }
81+ if ( arguments . Count < cmd . RequiredArgsCount )
82+ {
83+ response = $ "Wrong usage!\n Correct usage: uci { cmd . Name } { cmd . VisibleArgs } ";
84+ return false ;
85+ }
86+
87+ List < string > args = [ .. arguments ] ;
88+ args . RemoveAt ( 0 ) ;
7989
80- if ( arguments . Count < cmd . RequiredArgsCount )
90+ return cmd . Execute ( args , sender , out response ) ;
91+ }
92+ catch ( Exception ex )
8193 {
82- response = $ "Wrong usage!\n Correct usage: uci { cmd . Name } { cmd . VisibleArgs } ";
94+ ISubcommand cmd = Subcommands . FirstOrDefault ( cmd => cmd . Name == arguments . At ( 0 ) ) ;
95+ cmd ??= Subcommands . FirstOrDefault ( cmd => cmd . Aliases . Contains ( arguments . At ( 0 ) ) ) ;
96+
97+ LogManager . Error ( $ "Error when running command { cmd . Name } \n \n { ex . Message } \n \n { ex . StackTrace } ") ;
98+ response = $ "Error when running command { cmd . Name } \n \n { ex . Message } \n \n { ex . StackTrace } ";
8399 return false ;
84100 }
85-
86- List < string > args = [ .. arguments ] ;
87- args . RemoveAt ( 0 ) ;
88-
89- return cmd . Execute ( args , sender , out response ) ;
90101 }
91102 }
92103}
0 commit comments