@@ -715,10 +715,11 @@ public String docs() {
715715 }
716716
717717 @ Override
718- public Exceptions .ExceptionType [] thrown () {
719- return new Exceptions .ExceptionType []{Exceptions .ExceptionType .CastException , Exceptions .ExceptionType .FormatException ,
720- Exceptions .ExceptionType .PlayerOfflineException , ExceptionType .NotFoundException };
721- }
718+ public ExceptionType [] thrown () {
719+ return new ExceptionType []{ExceptionType .CastException , ExceptionType .FormatException ,
720+ ExceptionType .PlayerOfflineException , ExceptionType .NotFoundException ,
721+ ExceptionType .IllegalArgumentException };
722+ }
722723
723724 @ Override
724725 public boolean isRestricted () {
@@ -759,7 +760,12 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
759760 meta = ObjectGenerator .GetGenerator ().itemMeta (CNull .NULL , is .getType (), t );
760761 }
761762 is .setItemMeta (meta );
762- Map <Integer , MCItemStack > h = p .getInventory ().addItem (is );
763+ Map <Integer , MCItemStack > h ;
764+ try {
765+ h = p .getInventory ().addItem (is );
766+ } catch (IllegalArgumentException e ) {
767+ throw new ConfigRuntimeException ("Item value is invalid" , ExceptionType .IllegalArgumentException , t );
768+ }
763769
764770 p .updateInventory ();
765771
@@ -895,9 +901,10 @@ public String docs() {
895901 }
896902
897903 @ Override
898- public Exceptions .ExceptionType [] thrown () {
899- return new Exceptions .ExceptionType []{Exceptions .ExceptionType .CastException , Exceptions .ExceptionType .FormatException ,
900- Exceptions .ExceptionType .PlayerOfflineException , ExceptionType .NotFoundException };
904+ public ExceptionType [] thrown () {
905+ return new ExceptionType []{ExceptionType .CastException , ExceptionType .FormatException ,
906+ ExceptionType .PlayerOfflineException , ExceptionType .NotFoundException ,
907+ ExceptionType .IllegalArgumentException };
901908 }
902909
903910 @ Override
@@ -940,7 +947,12 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
940947 meta = ObjectGenerator .GetGenerator ().itemMeta (CNull .NULL , is .getType (), t );
941948 }
942949 is .setItemMeta (meta );
943- Map <Integer , MCItemStack > h = p .getEnderChest ().addItem (is );
950+ Map <Integer , MCItemStack > h ;
951+ try {
952+ h = p .getEnderChest ().addItem (is );
953+ } catch (IllegalArgumentException e ) {
954+ throw new ConfigRuntimeException ("Item value is invalid" , ExceptionType .IllegalArgumentException , t );
955+ }
944956
945957 if (h .isEmpty ()) {
946958 return new CInt (0 , t );
@@ -1734,7 +1746,7 @@ public String docs() {
17341746 @ Override
17351747 public ExceptionType [] thrown () {
17361748 return new ExceptionType []{ExceptionType .CastException , ExceptionType .FormatException ,
1737- ExceptionType .LengthException };
1749+ ExceptionType .LengthException , ExceptionType . IllegalArgumentException };
17381750 }
17391751
17401752 @ Override
@@ -1766,7 +1778,12 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
17661778 meta = ObjectGenerator .GetGenerator ().itemMeta (CNull .NULL , is .getType (), t );
17671779 }
17681780 is .setItemMeta (meta );
1769- Map <Integer , MCItemStack > h = inventory .addItem (is );
1781+ Map <Integer , MCItemStack > h ;
1782+ try {
1783+ h = inventory .addItem (is );
1784+ } catch (IllegalArgumentException e ){
1785+ throw new ConfigRuntimeException ("Item value is invalid" , ExceptionType .IllegalArgumentException , t );
1786+ }
17701787
17711788 if (h .isEmpty ()) {
17721789 return new CInt (0 , t );
0 commit comments