@@ -1204,6 +1204,28 @@ public void onValidate(Reward reward, RewardInject inject, ConfigurationSection
12041204 }
12051205 }));
12061206
1207+ injectedRewards .add (new RewardInjectConfigurationSection ("NumberCommand" ) {
1208+
1209+ @ Override
1210+ public String onRewardRequested (Reward reward , AdvancedCoreUser user , ConfigurationSection section ,
1211+ HashMap <String , String > placeholders ) {
1212+ int min = section .getInt ("Min" , 0 );
1213+ int max = section .getInt ("Max" , 100 );
1214+ int number = ThreadLocalRandom .current ().nextInt (min , max + 1 );
1215+ String command = section .getString ("Command" , "" ).replace ("%number%" , String .valueOf (number ));
1216+ MiscUtils .getInstance ().executeConsoleCommands (user .getPlayerName (), command , placeholders );
1217+ return String .valueOf (number );
1218+ }
1219+ }.asPlaceholder ("Number" ).priority (100 ).validator (new RewardInjectValidator () {
1220+
1221+ @ Override
1222+ public void onValidate (Reward reward , RewardInject inject , ConfigurationSection data ) {
1223+ if (!data .isInt ("Min" ) || !data .isInt ("Max" ) || !data .isString ("Command" )) {
1224+ warning (reward , inject , "NumberCommand requires Min, Max, and Command to be set" );
1225+ }
1226+ }
1227+ }));
1228+
12071229 injectedRewards .add (new RewardInjectInt ("EXP" , 0 ) {
12081230
12091231 @ Override
@@ -1442,7 +1464,7 @@ public void onValidate(Reward reward, RewardInject inject, ConfigurationSection
14421464 @ Override
14431465 public String onRewardRequest (Reward reward , AdvancedCoreUser user , String value ,
14441466 HashMap <String , String > placeholders ) {
1445- MiscUtils .getInstance ().executeConsoleCommands (user .getPlayer (), value , placeholders );
1467+ MiscUtils .getInstance ().executeConsoleCommands (user .getPlayerName (), value , placeholders );
14461468 return null ;
14471469 }
14481470 }.addEditButton (new EditGUIButton (new ItemBuilder ("COMMAND_BLOCK" ), new EditGUIValueString ("Command" , null ) {
@@ -1833,7 +1855,7 @@ public void openInventory(ClickEvent clickEvent) {
18331855 public String onRewardRequest (Reward r , AdvancedCoreUser user , ArrayList <String > list ,
18341856 HashMap <String , String > placeholders ) {
18351857 if (list .size () > 0 ) {
1836- MiscUtils .getInstance ().executeConsoleCommands (user .getPlayer (),
1858+ MiscUtils .getInstance ().executeConsoleCommands (user .getPlayerName (),
18371859 list .get (ThreadLocalRandom .current ().nextInt (list .size ())), placeholders );
18381860 }
18391861 return null ;
0 commit comments