Skip to content

Commit 3285ec1

Browse files
committed
Added ConfigRuntimeException.BuildException.
This is a intermediate change that allows a proper Exception extension system to be put in place in the future, without causing old code to break. Ultimately, ideally one would use new CREIOException, but in the meantime, until that system is in place, this will suffice. Extensions should switch to this method as soon as possible.
1 parent aa8ed4c commit 3285ec1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+976
-905
lines changed

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCPotionMeta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public BukkitMCPotionMeta(PotionMeta pomet) {
2424
public boolean addCustomEffect(int potionID, int strength, int seconds, boolean ambient, boolean overwrite, Target t) {
2525
int maxID = PotionEffectType.values().length;
2626
if (potionID < 1 || potionID > maxID) {
27-
throw new ConfigRuntimeException("Invalid effect ID, must be from 1-" + maxID, ExceptionType.RangeException, t);
27+
throw ConfigRuntimeException.BuildException("Invalid effect ID, must be from 1-" + maxID, ExceptionType.RangeException, t);
2828
}
2929
PotionEffect pe = new PotionEffect(PotionEffectType.getById(potionID),
3030
(int) Static.msToTicks(seconds * 1000), strength, ambient);

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCWorld.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
465465

466466
}
467467
} catch (IllegalArgumentException e) {
468-
throw new ConfigRuntimeException("No mob of type " + name + " exists",
468+
throw ConfigRuntimeException.BuildException("No mob of type " + name + " exists",
469469
ExceptionType.FormatException, t);
470470
}
471471
for (int i = 0; i < qty; i++) {
@@ -483,7 +483,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
483483
color = MCDyeColor.valueOf(type);
484484
s.setColor(BukkitMCDyeColor.getConvertor().getConcreteEnum(color));
485485
} catch (IllegalArgumentException ex) {
486-
throw new ConfigRuntimeException(type + " is not a valid color",
486+
throw ConfigRuntimeException.BuildException(type + " is not a valid color",
487487
ExceptionType.FormatException, t);
488488
}
489489
}
@@ -496,7 +496,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
496496
otype = MCOcelotType.valueOf(type);
497497
o.setCatType(BukkitMCOcelotType.getConvertor().getConcreteEnum(otype));
498498
} catch (IllegalArgumentException ex){
499-
throw new ConfigRuntimeException(type + " is not an ocelot type",
499+
throw ConfigRuntimeException.BuildException(type + " is not an ocelot type",
500500
ExceptionType.FormatException, t);
501501
}
502502
}
@@ -514,7 +514,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
514514
break;
515515
}
516516
} catch (IllegalArgumentException ex){
517-
throw new ConfigRuntimeException(type + " is not a creeper state",
517+
throw ConfigRuntimeException.BuildException(type + " is not a creeper state",
518518
ExceptionType.FormatException, t);
519519
}
520520
}
@@ -535,7 +535,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
535535
break;
536536
}
537537
} catch (IllegalArgumentException ex){
538-
throw new ConfigRuntimeException(type + " is not a wolf state",
538+
throw ConfigRuntimeException.BuildException(type + " is not a wolf state",
539539
ExceptionType.FormatException, t);
540540
}
541541
}
@@ -548,7 +548,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
548548
job = MCProfession.valueOf(type);
549549
v.setProfession(BukkitMCProfession.getConvertor().getConcreteEnum(job));
550550
} catch (IllegalArgumentException ex) {
551-
throw new ConfigRuntimeException(type + " is not a valid profession",
551+
throw ConfigRuntimeException.BuildException(type + " is not a valid profession",
552552
ExceptionType.FormatException, t);
553553
}
554554
}
@@ -560,7 +560,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
560560
MaterialData held = new MaterialData(Material.valueOf(type));
561561
en.setCarriedMaterial(held);
562562
} catch (IllegalArgumentException ex) {
563-
throw new ConfigRuntimeException(type + " is not a valid material",
563+
throw ConfigRuntimeException.BuildException(type + " is not a valid material",
564564
ExceptionType.FormatException, t);
565565
}
566566
}
@@ -572,7 +572,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
572572
try{
573573
sl.setSize(Integer.parseInt(type));
574574
} catch (IllegalArgumentException ex){
575-
throw new ConfigRuntimeException(type + " is not a valid size",
575+
throw ConfigRuntimeException.BuildException(type + " is not a valid size",
576576
ExceptionType.FormatException, t);
577577
}
578578
}
@@ -586,7 +586,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
586586
stype = MCSkeletonType.valueOf(type);
587587
sk.setSkeletonType(BukkitMCSkeletonType.getConvertor().getConcreteEnum(stype));
588588
} catch (IllegalArgumentException ex){
589-
throw new ConfigRuntimeException(type + " is not a skeleton type",
589+
throw ConfigRuntimeException.BuildException(type + " is not a skeleton type",
590590
ExceptionType.FormatException, t);
591591
}
592592
}
@@ -609,11 +609,11 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
609609
try {
610610
((PigZombie) z).setAnger(Integer.valueOf(type));
611611
} catch (IllegalArgumentException iae) {
612-
throw new ConfigRuntimeException(type + " was neither a zombie state nor a number.",
612+
throw ConfigRuntimeException.BuildException(type + " was neither a zombie state nor a number.",
613613
ExceptionType.FormatException, t);
614614
}
615615
} else {
616-
throw new ConfigRuntimeException(type + " is not a zombie state",
616+
throw ConfigRuntimeException.BuildException(type + " is not a zombie state",
617617
ExceptionType.FormatException, t);
618618
}
619619
}
@@ -632,7 +632,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
632632
break;
633633
}
634634
} catch (IllegalArgumentException ex){
635-
throw new ConfigRuntimeException(type + " is not a pig state",
635+
throw ConfigRuntimeException.BuildException(type + " is not a pig state",
636636
ExceptionType.FormatException, t);
637637
}
638638
}
@@ -652,7 +652,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
652652
MCHorse.MCHorsePattern hpattern = MCHorse.MCHorsePattern.valueOf(type);
653653
h.setStyle(BukkitMCHorse.BukkitMCHorsePattern.getConvertor().getConcreteEnum(hpattern));
654654
} catch (IllegalArgumentException notAnything) {
655-
throw new ConfigRuntimeException("Type " + type + " did not match any horse variants,"
655+
throw ConfigRuntimeException.BuildException("Type " + type + " did not match any horse variants,"
656656
+ " colors, or patterns.", ExceptionType.FormatException, t);
657657
}
658658
}

src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCLivingEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public void setRemoveWhenFarAway(boolean remove) {
337337
@Override
338338
public MCLivingEntity getTarget(Target t) {
339339
if (!(le instanceof Creature)) {
340-
throw new ConfigRuntimeException("This type of mob does not have a target API",
340+
throw ConfigRuntimeException.BuildException("This type of mob does not have a target API",
341341
ExceptionType.BadEntityException, t);
342342
}
343343
LivingEntity target = ((Creature) le).getTarget();
@@ -347,7 +347,7 @@ public MCLivingEntity getTarget(Target t) {
347347
@Override
348348
public void setTarget(MCLivingEntity target, Target t) {
349349
if (!(le instanceof Creature)) {
350-
throw new ConfigRuntimeException("This type of mob does not have a target API",
350+
throw ConfigRuntimeException.BuildException("This type of mob does not have a target API",
351351
ExceptionType.BadEntityException, t);
352352
}
353353
((Creature) le).setTarget(target == null ? null : ((BukkitMCLivingEntity) target).asLivingEntity());

src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitBlockEvents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public MCItemStack getItem() {
376376
@Override
377377
public void setItem(MCItemStack item) {
378378
if (item == null || item.getType().getName() == "AIR") {
379-
throw new ConfigRuntimeException("Due to Bukkit's handling of this event, the item cannot be set to null."
379+
throw ConfigRuntimeException.BuildException("Due to Bukkit's handling of this event, the item cannot be set to null."
380380
+ " Until they change this, workaround by cancelling the event and manipulating the block"
381381
+ " using inventory functions.", ExceptionType.IllegalArgumentException, Target.UNKNOWN);
382382
} else {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static Construct getItemFromArray(CArray object, String key, Target t, Co
4040
if (object.containsKey(key)) {
4141
return object.get(key, t);
4242
} else if (defaultItem == null) {
43-
throw new ConfigRuntimeException("Expected the key \"" + key + "\" to be present, but it was not found.", Exceptions.ExceptionType.FormatException, t);
43+
throw ConfigRuntimeException.BuildException("Expected the key \"" + key + "\" to be present, but it was not found.", Exceptions.ExceptionType.FormatException, t);
4444
} else {
4545
return defaultItem;
4646
}
@@ -58,7 +58,7 @@ public static CArray getArray(Construct construct, Target t) {
5858
if (construct instanceof CArray) {
5959
return ((CArray) construct);
6060
} else {
61-
throw new ConfigRuntimeException("Expecting array, but received " + construct.val(), Exceptions.ExceptionType.CastException, t);
61+
throw ConfigRuntimeException.BuildException("Expecting array, but received " + construct.val(), Exceptions.ExceptionType.CastException, t);
6262
}
6363
}
6464

@@ -82,7 +82,7 @@ public static <T extends Construct> T getObject(Construct construct, Target t, S
8282
if (clazz.isAssignableFrom(construct.getClass())) {
8383
return (T) construct;
8484
} else {
85-
throw new ConfigRuntimeException("Expecting " + expectedClassName + " but receieved " + construct.val() + " instead.", Exceptions.ExceptionType.CastException, t);
85+
throw ConfigRuntimeException.BuildException("Expecting " + expectedClassName + " but receieved " + construct.val() + " instead.", Exceptions.ExceptionType.CastException, t);
8686
}
8787
}
8888

@@ -104,7 +104,7 @@ public static <T extends Construct> T getObject(Construct construct, Target t, C
104104
} else {
105105
String expectedClassName = clazz.getAnnotation(typeof.class).value();
106106
String actualClassName = construct.getClass().getAnnotation(typeof.class).value();
107-
throw new ConfigRuntimeException("Expecting " + expectedClassName + " but receieved " + construct.val()
107+
throw ConfigRuntimeException.BuildException("Expecting " + expectedClassName + " but receieved " + construct.val()
108108
+ " (" + actualClassName + ") instead.", Exceptions.ExceptionType.CastException, t);
109109
}
110110
}
@@ -135,7 +135,7 @@ public static double getNumber(Construct c, Target t) {
135135
try {
136136
d = Double.parseDouble(c.val());
137137
} catch (NumberFormatException e) {
138-
throw new ConfigRuntimeException("Expecting a number, but received \"" + c.val() + "\" instead",
138+
throw ConfigRuntimeException.BuildException("Expecting a number, but received \"" + c.val() + "\" instead",
139139
Exceptions.ExceptionType.CastException, t);
140140
}
141141
} else if (c instanceof CBoolean) {
@@ -145,7 +145,7 @@ public static double getNumber(Construct c, Target t) {
145145
d = 0;
146146
}
147147
} else {
148-
throw new ConfigRuntimeException("Expecting a number, but received \"" + c.val() + "\" instead",
148+
throw ConfigRuntimeException.BuildException("Expecting a number, but received \"" + c.val() + "\" instead",
149149
Exceptions.ExceptionType.CastException, t);
150150
}
151151
return d;
@@ -195,7 +195,7 @@ public static double getDouble(Construct c, Target t) {
195195
try {
196196
return getNumber(c, t);
197197
} catch (ConfigRuntimeException e) {
198-
throw new ConfigRuntimeException("Expecting a double, but received " + c.val() + " instead",
198+
throw ConfigRuntimeException.BuildException("Expecting a double, but received " + c.val() + " instead",
199199
Exceptions.ExceptionType.CastException, t);
200200
}
201201
}
@@ -251,7 +251,7 @@ public static long getInt(Construct c, Target t) {
251251
try {
252252
i = Long.parseLong(c.val());
253253
} catch (NumberFormatException e) {
254-
throw new ConfigRuntimeException("Expecting an integer, but received \"" + c.val() + "\" instead",
254+
throw ConfigRuntimeException.BuildException("Expecting an integer, but received \"" + c.val() + "\" instead",
255255
Exceptions.ExceptionType.CastException, t);
256256
}
257257
}

0 commit comments

Comments
 (0)