|
1 | 1 | package com.nextplugins.sorteios.command; |
2 | 2 |
|
| 3 | +import static com.nextplugins.sorteios.utils.ColorUtils.colored; |
| 4 | + |
3 | 5 | import com.nextplugins.sorteios.NextSorteios; |
4 | 6 | import com.nextplugins.sorteios.configuration.values.ConfigValue; |
5 | 7 | import com.nextplugins.sorteios.executor.SortPlayerExecutor; |
6 | | -import com.nextplugins.sorteios.utils.ColorUtils; |
| 8 | +import lombok.Data; |
7 | 9 | import org.bukkit.Bukkit; |
8 | 10 | import org.bukkit.command.Command; |
9 | 11 | import org.bukkit.command.CommandExecutor; |
|
15 | 17 | * @author Yuhtin |
16 | 18 | * Github: https://github.com/Yuhtin |
17 | 19 | */ |
| 20 | +@Data |
18 | 21 | public class SortCommand implements CommandExecutor { |
19 | 22 |
|
| 23 | + private final NextSorteios plugin; |
| 24 | + |
20 | 25 | @Override |
21 | 26 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { |
22 | 27 |
|
23 | 28 | if (!sender.hasPermission("nextsorteios.sort")) { |
24 | 29 |
|
25 | | - sender.sendMessage(ColorUtils.colored("&cSem permissão para fazer isto.")); |
26 | | - return false; |
| 30 | + sender.sendMessage(colored("&cSem permissão para fazer isto.")); |
27 | 31 |
|
| 32 | + return false; |
28 | 33 | } |
29 | 34 |
|
30 | | - if (args.length < 1 |
31 | | - || !args[0].contains("force") |
32 | | - && Bukkit.getOnlinePlayers().size() < ConfigValue.get(ConfigValue::minPlayers)) { |
| 35 | + if ((args.length < 1 |
| 36 | + || !args[0].contains("force")) |
| 37 | + && Bukkit.getOnlinePlayers().size() < ConfigValue.get(ConfigValue::minPlayers)) { |
33 | 38 |
|
34 | | - sender.sendMessage(ColorUtils.colored("&cO sorteio não foi iniciado por falta de jogadores.")); |
35 | | - return false; |
| 39 | + sender.sendMessage(colored("&cO sorteio não foi iniciado por falta de jogadores.")); |
36 | 40 |
|
| 41 | + return false; |
37 | 42 | } |
38 | 43 |
|
39 | | - |
40 | | - Logger logger = NextSorteios.getInstance().getLogger(); |
| 44 | + Logger logger = plugin.getLogger(); |
41 | 45 |
|
42 | 46 | try { |
43 | 47 |
|
44 | 48 | SortPlayerExecutor.createDefault( |
45 | | - NextSorteios.getInstance(), |
| 49 | + plugin, |
46 | 50 | ConfigValue.get(ConfigValue::executes) |
47 | 51 | ); |
48 | 52 |
|
49 | 53 | } catch (IllegalStateException exception) { |
50 | | - |
51 | 54 | logger.info(exception.getMessage()); |
52 | | - return false; |
53 | 55 |
|
| 56 | + return false; |
54 | 57 | } |
55 | 58 |
|
56 | | - sender.sendMessage(ColorUtils.colored("&aSorteio iniciado com sucesso.")); |
| 59 | + sender.sendMessage(colored("&aSorteio iniciado com sucesso.")); |
57 | 60 | logger.info("O jogador " + sender.getName() + " forçou o inicio de um sorteio."); |
58 | 61 |
|
59 | 62 | return true; |
60 | | - |
61 | 63 | } |
62 | 64 |
|
63 | 65 | } |
0 commit comments