Skip to content

Commit 2fc391d

Browse files
committed
fix(sorter): error with no players to sort
1 parent 0a06385 commit 2fc391d

2 files changed

Lines changed: 15 additions & 1 deletion

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.2'
10+
version = '1.0.3'
1111

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

src/main/java/com/nextplugins/sorteios/executor/SelectWinnerExecutor.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import com.nextplugins.sorteios.api.events.sorted.AsyncSortedPlayerEvent;
55
import com.nextplugins.sorteios.api.prize.Prize;
66
import com.nextplugins.sorteios.manager.PrizeManager;
7+
import com.nextplugins.sorteios.utils.MessageUtils;
78
import lombok.NoArgsConstructor;
89
import org.bukkit.Bukkit;
10+
import org.bukkit.Sound;
911
import org.bukkit.entity.Player;
1012
import org.bukkit.plugin.PluginManager;
1113

@@ -36,6 +38,18 @@ public void run() {
3638
.filter(value -> !value.hasPermission(prize.getSortBanPermission()))
3739
.collect(Collectors.toList());
3840

41+
if (onlinePlayers.isEmpty()) {
42+
43+
MessageUtils.sendSoundAndTitle(
44+
"&c&LERRO{nl}&fNão tem nenhum jogador elegível para o prêmio",
45+
Sound.ENTITY_CREEPER_HURT,
46+
90
47+
);
48+
49+
return;
50+
51+
}
52+
3953
int randomNumberPlayer = RANDOM.nextInt(onlinePlayers.size());
4054
Player player = (Player) onlinePlayers.toArray()[randomNumberPlayer];
4155

0 commit comments

Comments
 (0)