1- using Rocket . API . Chat ;
2- using Rocket . API . Commands ;
1+ using Rocket . API . Commands ;
32using Rocket . API . Entities ;
43using Rocket . API . I18N ;
54using Rocket . API . Player ;
5+ using Rocket . API . User ;
66using Rocket . Core . Commands ;
7- using Rocket . Core . I18N ;
7+ using Rocket . Core . User ;
88
99namespace Rocket . Examples . CommandsPlugin
1010{
1111 public class CommandsCollection
1212 {
13- private readonly IChatManager chatManager ;
14- private readonly ITranslationLocator translations ;
13+ private readonly IUserManager userManager ;
14+ private readonly ITranslationCollection translations ;
1515
16- public CommandsCollection ( IChatManager chatManager , ITranslationLocator translations )
16+ public CommandsCollection ( IUserManager userManager , ITranslationCollection translations )
1717 {
18- this . chatManager = chatManager ;
18+ this . userManager = userManager ;
1919 this . translations = translations ;
2020 }
2121
2222 [ Command ( Summary = "Kills a player." ) ] //By default, name is the same as the method name, and it will support all command callers
23- public void KillPlayer ( ICommandCaller sender , IOnlinePlayer target )
23+ public void KillPlayer ( IUser sender , IPlayer target )
2424 {
25- if ( target is ILivingEntity entity )
25+ if ( target . IsOnline && target . Entity is ILivingEntity entity )
2626 entity . Kill ( sender ) ;
2727 else // the game likely does not support killing players (e.g. Eco)
2828 sender . SendMessage ( "Target could not be killed :(" ) ;
2929 }
3030
3131 [ Command ( Name = "Broadcast" , Summary = "Broadcasts a message." ) ]
3232 [ CommandAlias ( "bc" ) ]
33- [ CommandCaller ( typeof ( IConsoleCommandCaller ) ) ] // only console can call it
34- public void Broadcast ( ICommandCaller sender , string [ ] args )
33+ [ CommandUser ( typeof ( IConsole ) ) ] // only console can call it
34+ public void Broadcast ( IUser sender , string [ ] args )
3535 {
36- string message = string . Join ( " " , args ) ;
37- chatManager . BroadcastLocalized ( translations , message , sender , message ) ;
36+ userManager . Broadcast ( sender , translations . Get ( "broadcast" , sender , string . Join ( " " , args ) ) ) ;
3837 }
3938 }
4039}
0 commit comments