From 3398c29735170a568c19eb0d15954e5db45c900a Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Fri, 2 Jan 2015 11:50:44 -0500 Subject: [PATCH] Correction d'un bug de la calculatrice : quand un joueur fait un smiley qui commence par = --- .../pandacraftutils/calculator/CalculatorManager.java | 6 +++++- src/net/mc_pandacraft/java/util/JArithmeticInterpreter.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/calculator/CalculatorManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/calculator/CalculatorManager.java index 1403336..b39cb26 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/calculator/CalculatorManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/calculator/CalculatorManager.java @@ -55,6 +55,10 @@ public class CalculatorManager implements Listener { event.getPlayer().sendMessage(ChatColor.GRAY+"res"+i+ChatColor.RESET+" : "+ChatColor.GRAY+el.expression+ChatColor.RESET+"="+ChatColor.GRAY+el.value); i--; } + if (history.get(event.getPlayer()).size() == 0) + { + event.getPlayer().sendMessage(ChatColor.RED+"Utilisez le symbole "+ChatColor.GRAY+"="+ChatColor.RED+" dans le chat pour faire un calcul mathématique"); + } } else { @@ -80,7 +84,7 @@ public class CalculatorManager implements Listener { } catch (IllegalArgumentException e) { event.getPlayer().sendMessage(ChatColor.RED+e.getMessage()); - + event.getPlayer().sendMessage(ChatColor.RED+"Utilisez le symbole "+ChatColor.GRAY+"="+ChatColor.RED+" dans le chat pour faire un calcul mathématique"); } } diff --git a/src/net/mc_pandacraft/java/util/JArithmeticInterpreter.java b/src/net/mc_pandacraft/java/util/JArithmeticInterpreter.java index ff8e6f9..2230f6f 100644 --- a/src/net/mc_pandacraft/java/util/JArithmeticInterpreter.java +++ b/src/net/mc_pandacraft/java/util/JArithmeticInterpreter.java @@ -735,7 +735,11 @@ public class JArithmeticInterpreter { { StringBuffer input = new StringBuffer(expr); - JArithmeticInterpreter jai = JArithmeticInterpreter.constructTree(input,input.length(),0); + JArithmeticInterpreter jai = null; + + try { + jai = JArithmeticInterpreter.constructTree(input,input.length(),0); + } catch (Exception e) { } if (jai==null) throw new IllegalArgumentException("Le calcul passé en paramètre est invalide");