11package pro .cloudnode .smp .enchantbookplus ;
22
3- import net .kyori .adventure .text .minimessage .MiniMessage ;
4- import net .kyori .adventure .text .minimessage .tag .resolver .Placeholder ;
53import org .bukkit .command .Command ;
64import org .bukkit .command .CommandExecutor ;
75import org .bukkit .command .CommandSender ;
86import org .bukkit .command .TabCompleter ;
7+ import org .bukkit .plugin .PluginDescriptionFile ;
98import org .jetbrains .annotations .NotNull ;
109
1110import java .util .List ;
12- import java .util .Optional ;
1311
1412public final class MainCommand implements CommandExecutor , TabCompleter {
1513 private final @ NotNull EnchantBookPlus plugin ;
@@ -19,15 +17,25 @@ public MainCommand(final @NotNull EnchantBookPlus plugin) {
1917 }
2018
2119 @ Override
22- public boolean onCommand (@ NotNull CommandSender sender , @ NotNull Command command , @ NotNull String label , @ NotNull String @ NotNull [] args ) {
20+ public boolean onCommand (
21+ final @ NotNull CommandSender sender ,
22+ final @ NotNull Command command ,
23+ final @ NotNull String label ,
24+ final @ NotNull String @ NotNull [] args
25+ ) {
2326 if (args .length == 1 && args [0 ].equalsIgnoreCase ("reload" ))
2427 return reload (sender , command );
2528
2629 return overview (sender );
2730 }
2831
2932 @ Override
30- public @ NotNull List <String > onTabComplete (@ NotNull CommandSender sender , @ NotNull Command command , @ NotNull String label , @ NotNull String @ NotNull [] args ) {
33+ public @ NotNull List <String > onTabComplete (
34+ final @ NotNull CommandSender sender ,
35+ final @ NotNull Command command ,
36+ final @ NotNull String label ,
37+ final @ NotNull String @ NotNull [] args
38+ ) {
3139 if (sender .hasPermission (Permissions .RELOAD ))
3240 return List .of ("reload" );
3341
@@ -37,15 +45,11 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
3745 /**
3846 * Plugin overview
3947 */
40- @ SuppressWarnings ({ "UnstableApiUsage" , " SameReturnValue"} )
48+ @ SuppressWarnings (" SameReturnValue" )
4149 public boolean overview (final @ NotNull CommandSender sender ) {
42- sender .sendMessage (MiniMessage .miniMessage ()
43- .deserialize (
44- "<green><name></green> <white>v<version> by</white> <gray><author></gray>" ,
45- Placeholder .unparsed ("name" , plugin .getPluginMeta ().getName ()),
46- Placeholder .unparsed ("version" , plugin .getPluginMeta ().getVersion ()),
47- Placeholder .unparsed ("author" , String .join (", " , plugin .getPluginMeta ().getAuthors ()))
48- ));
50+ PluginDescriptionFile description = plugin .getDescription ();
51+ sender .sendMessage ("§а" + description .getName () + " §fv" + description .getVersion () + " by §7"
52+ + String .join (", " , description .getAuthors ()));
4953
5054 return true ;
5155 }
@@ -55,15 +59,12 @@ public boolean overview(final @NotNull CommandSender sender) {
5559 */
5660 @ SuppressWarnings ("SameReturnValue" )
5761 public boolean reload (final @ NotNull CommandSender sender , final @ NotNull Command command ) {
58- if (!sender .hasPermission (Permissions .RELOAD )) {
59- sender .sendMessage (Optional .ofNullable (command .permissionMessage ())
60- .orElse (sender .getServer ().permissionMessage ()));
61- return true ;
62- }
62+ if (!sender .hasPermission (Permissions .RELOAD ))
63+ return overview (sender );
6364
6465 plugin .reload ();
6566
66- sender .sendMessage (MiniMessage . miniMessage (). deserialize ( "<green> (!) Plugin configuration reloaded.") );
67+ sender .sendMessage ("§a (!) Plugin configuration reloaded." );
6768
6869 return true ;
6970 }
0 commit comments