Skip to content

Commit 7913281

Browse files
committed
sort command bug fix
1 parent a60b538 commit 7913281

3 files changed

Lines changed: 19 additions & 18 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
}
88

99
group = 'com.nextplugins'
10-
version = '1.0.4'
10+
version = '1.0.5'
1111

1212
tasks.build.dependsOn('shadowJar')
1313

src/main/java/com/nextplugins/sorteios/NextSorteios.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ public void onEnable() {
2929
this.prizeManager.init();
3030

3131
PluginCommand sortCommand = this.getCommand("sortear");
32-
if (sortCommand != null) sortCommand.setExecutor(new SortCommand());
32+
if (sortCommand != null) sortCommand.setExecutor(new SortCommand(this));
3333

3434
PluginManager pluginManager = Bukkit.getPluginManager();
3535
pluginManager.registerEvents(new PlayerWinSortListener(), this);
3636

3737
this.getLogger().info("Plugin started successfully");
38-
3938
}
4039

4140
}
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.nextplugins.sorteios.command;
22

3+
import static com.nextplugins.sorteios.utils.ColorUtils.colored;
4+
35
import com.nextplugins.sorteios.NextSorteios;
46
import com.nextplugins.sorteios.configuration.values.ConfigValue;
57
import com.nextplugins.sorteios.executor.SortPlayerExecutor;
6-
import com.nextplugins.sorteios.utils.ColorUtils;
8+
import lombok.Data;
79
import org.bukkit.Bukkit;
810
import org.bukkit.command.Command;
911
import org.bukkit.command.CommandExecutor;
@@ -15,49 +17,49 @@
1517
* @author Yuhtin
1618
* Github: https://github.com/Yuhtin
1719
*/
20+
@Data
1821
public class SortCommand implements CommandExecutor {
1922

23+
private final NextSorteios plugin;
24+
2025
@Override
2126
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
2227

2328
if (!sender.hasPermission("nextsorteios.sort")) {
2429

25-
sender.sendMessage(ColorUtils.colored("&cSem permissão para fazer isto."));
26-
return false;
30+
sender.sendMessage(colored("&cSem permissão para fazer isto."));
2731

32+
return false;
2833
}
2934

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)) {
3338

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."));
3640

41+
return false;
3742
}
3843

39-
40-
Logger logger = NextSorteios.getInstance().getLogger();
44+
Logger logger = plugin.getLogger();
4145

4246
try {
4347

4448
SortPlayerExecutor.createDefault(
45-
NextSorteios.getInstance(),
49+
plugin,
4650
ConfigValue.get(ConfigValue::executes)
4751
);
4852

4953
} catch (IllegalStateException exception) {
50-
5154
logger.info(exception.getMessage());
52-
return false;
5355

56+
return false;
5457
}
5558

56-
sender.sendMessage(ColorUtils.colored("&aSorteio iniciado com sucesso."));
59+
sender.sendMessage(colored("&aSorteio iniciado com sucesso."));
5760
logger.info("O jogador " + sender.getName() + " forçou o inicio de um sorteio.");
5861

5962
return true;
60-
6163
}
6264

6365
}

0 commit comments

Comments
 (0)