Skip to content

Commit d99ef6f

Browse files
committed
Merge pull request #374 from PseudoKnight/fixes
Fixes
2 parents 3d03eb8 + b990ac3 commit d99ef6f

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

src/main/java/com/laytonsmith/core/AliasCore.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,11 @@ public final void reload(MCPlayer player, String[] settings) {
253253
try {
254254
results = reloadOptions.match(settings);
255255
} catch (ArgumentParser.ValidationException ex) {
256-
Logger.getLogger(AliasCore.class.getName()).log(Level.SEVERE, null, ex);
256+
if (player != null) {
257+
player.sendMessage(ex.getMessage());
258+
} else {
259+
StreamUtils.GetSystemOut().println(ex.getMessage());
260+
}
257261
return;
258262
}
259263
if (results.isFlagSet('h')) {

src/main/java/com/laytonsmith/core/Static.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ public static void checkPlugin(String name, Target t) throws ConfigRuntimeExcept
395395
private static final Pattern INVALID_BINARY = Pattern.compile("\"0b[0-1]*[^0-1]+[0-1]*\"");
396396
private static final Pattern VALID_BINARY = Pattern.compile("0b[0-1]+");
397397
private static final Pattern INVALID_OCTAL = Pattern.compile("0o[0-7]*[^0-7]+[0-7]*");
398-
private static final Pattern VALID_OCTAL = Pattern.compile("0b[0-1]+");
398+
private static final Pattern VALID_OCTAL = Pattern.compile("0o[0-7]+");
399399

400400
/**
401401
* Given a string input, creates and returns a Construct of the appropriate

src/main/java/com/laytonsmith/core/functions/InventoryManagement.java

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

src/main/java/com/laytonsmith/core/functions/Scoreboards.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ public Construct exec(Target t, Environment environment,
483483
throw new Exceptions.LengthException("Objective names should be no more than 16 characters", t);
484484
}
485485
MCCriteria criteria = MCCriteria.DUMMY;
486-
if (args.length == 2) {
486+
if (args.length > 1) {
487487
try {
488488
criteria = MCCriteria.valueOf(args[1].val().toUpperCase());
489489
} catch (IllegalArgumentException iae) {

0 commit comments

Comments
 (0)