File tree Expand file tree Collapse file tree
java/com/nextplugins/sorteios Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ plugins {
77}
88
99group = ' com.nextplugins'
10- version = ' 1.0.0 '
10+ version = ' 1.0.1 '
1111
1212tasks. build. dependsOn(' shadowJar' )
1313
Original file line number Diff line number Diff line change 1515public class Prize {
1616
1717 private final String coloredName ;
18+ private final String sortBanPermission ;
1819 private final List <String > commands ;
1920
2021}
Original file line number Diff line number Diff line change 99import org .bukkit .entity .Player ;
1010import org .bukkit .plugin .PluginManager ;
1111
12+ import java .util .List ;
1213import java .util .Random ;
14+ import java .util .stream .Collectors ;
1315
1416/**
1517 * @author Yuhtin
@@ -25,12 +27,18 @@ public final class SelectWinnerExecutor implements Runnable {
2527 public void run () {
2628 PrizeManager prizeManager = NextSorteios .getInstance ().getPrizeManager ();
2729
28- int randomNumberPlayer = RANDOM .nextInt (Bukkit .getOnlinePlayers ().size ());
2930 int randomNumberPrizes = RANDOM .nextInt (prizeManager .getPrizes ().size ());
3031
31- Player player = (Player ) Bukkit .getOnlinePlayers ().toArray ()[randomNumberPlayer ];
3232 Prize prize = prizeManager .getPrizes ().get (randomNumberPrizes );
3333
34+ final List <Player > onlinePlayers = Bukkit .getOnlinePlayers ()
35+ .stream ()
36+ .filter (value -> !value .hasPermission (prize .getSortBanPermission ()))
37+ .collect (Collectors .toList ());
38+
39+ int randomNumberPlayer = RANDOM .nextInt (onlinePlayers .size ());
40+ Player player = (Player ) onlinePlayers .toArray ()[randomNumberPlayer ];
41+
3442 if (player == null || prize == null ) return ;
3543
3644 PluginManager pluginManager = Bukkit .getPluginManager ();
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ public final class PrizeParser {
1818
1919 public List <Prize > parseListSection (ConfigurationSection section ) {
2020
21- if (section == null ) NextSorteios . getInstance (). getLogger (). info ( "foda " );
21+ if (section == null ) throw new IllegalArgumentException ( "Section inexistente! " );
2222
2323 return section .getKeys (false )
2424 .stream ()
@@ -34,6 +34,7 @@ public Prize parseSection(ConfigurationSection section) {
3434 return Prize .builder ()
3535 .coloredName (ColorUtils .colored (section .getString ("coloredName" )))
3636 .commands (section .getStringList ("commands" ))
37+ .sortBanPermission (section .getString ("cantSortPermission" , "nextsorteios.sort" ))
3738 .build ();
3839
3940 }
Original file line number Diff line number Diff line change 11premios :
22 premio1 :
33 coloredName : ' &95x Key NextPlugins'
4+ cantSortPermission : sort.ban.premio1
45 commands :
56 - ' givekey @player nextplugins 5'
67 - ' give @player diamond_pickaxe'
You can’t perform that action at this time.
0 commit comments