Skip to content

Commit

Permalink
Prevent giant stacktraces from bad math tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 17, 2013
1 parent 843fe06 commit ed8023c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/net/aufdemrand/denizen/tags/core/UtilTags.java
Expand Up @@ -13,6 +13,7 @@
import net.aufdemrand.denizen.utilities.Utilities;


import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizen.utilities.javaluator.DoubleEvaluator;
import net.citizensnpcs.Citizens;
import net.citizensnpcs.api.CitizensAPI;
Expand All @@ -33,8 +34,14 @@ public UtilTags(Denizen denizen) {
@EventHandler
public void mathTags(ReplaceableTagEvent event) {
if (!event.matches("math, m")) return;
Double evaluation = new DoubleEvaluator().evaluate(event.getValue());
event.setReplaced(String.valueOf(evaluation));
try {
Double evaluation = new DoubleEvaluator().evaluate(event.getValue());
event.setReplaced(String.valueOf(evaluation));
}
catch (Exception e) {
dB.echoError("Invalid math tag!");
event.setReplaced("0.0");
}
}

@EventHandler
Expand Down

0 comments on commit ed8023c

Please sign in to comment.