44import com .cssbham .cssminecraft .common .command .CommandHandler ;
55import com .cssbham .cssminecraft .common .command .CommandSender ;
66import com .cssbham .cssminecraft .common .discord .DiscordClientService ;
7+ import com .cssbham .cssminecraft .common .permission .PermissionPluginService ;
78import net .kyori .adventure .text .Component ;
89import net .kyori .adventure .text .event .ClickEvent ;
910import net .kyori .adventure .text .format .NamedTextColor ;
1011import net .kyori .adventure .text .format .TextDecoration ;
1112
13+ import java .util .concurrent .ExecutionException ;
14+
1215public class MakeGreenCommandHandler implements CommandHandler {
1316
1417 private final DiscordClientService discordClientService ;
18+ private final PermissionPluginService permissionPluginService ;
1519
16- public MakeGreenCommandHandler (DiscordClientService discordClientService ) {
20+ public MakeGreenCommandHandler (DiscordClientService discordClientService , PermissionPluginService permissionPluginService ) {
1721 this .discordClientService = discordClientService ;
22+ this .permissionPluginService = permissionPluginService ;
1823 }
1924
2025 @ Override
2126 public void handle (CommandSender sender , CommandContext context ) {
27+ if (!permissionPluginService .isAvailable ()) {
28+ sender .sendMessage (Component .text ("There is no permissions plugin available." ).color (NamedTextColor .RED ));
29+ return ;
30+ }
31+
2232 if (sender .isConsole ()) {
2333 sender .sendMessage (Component .text ("Only players may use this command." ).color (NamedTextColor .RED ));
2434 return ;
@@ -31,7 +41,14 @@ public void handle(CommandSender sender, CommandContext context) {
3141 }
3242
3343 if (discordClientService .getDiscordClient ().isMember (arg )) {
34- //TODO the luckperms stuff
44+ sender .sendMessage (Component .text ("Making you green..." ).color (NamedTextColor .GRAY ));
45+ try {
46+ permissionPluginService .grantMemberRole (sender .getUuid ()).get ();
47+ } catch (InterruptedException | ExecutionException e ) {
48+ sender .sendMessage (Component .text ("There was a problem making you green. Try again later." )
49+ .color (NamedTextColor .RED ));
50+ throw new RuntimeException (e );
51+ }
3552 sender .sendMessage (Component .text ("Congratulations, you are now green!" ).color (NamedTextColor .GREEN ));
3653 } else {
3754 sender .sendMessage (Component .text ("You don't appear to be a " ).color (NamedTextColor .RED ).append (
0 commit comments