Discussion in 'Spigot Plugin Development' started by sistem21, May 15, 2015.

    #1 sistem21, May 15, 2015
    Last edited: May 31, 2015
  2. remove e.printStackTrace();
    you are printing unnecessary stacktraces
  3. It is not unnecessary if you want to debug to figure out what is going wrong — the parseInt method throws a NumberFormatException if the string does not contain a parsable integer.
  4. @sistem21 you should be doing your own work. What's wrong with the current snippet you posted? Post the error if there is any.
    • Agree Agree x 1
  5. Code (Text):
        public boolean isInt(String str)
            }catch(NumberFormatException e){
              return false;
        return false;
    Shouldn't it return true since it is a int. Currently it will always return false.
  6. Code (Text):
    public static boolean isInteger(String s) {
        try {
        } catch(NumberFormatException e) {
            return false;
        } catch(NullPointerException e) {
            return false;
        // only got here if we didn't return false
        return true;
  7. Surely he would be checking the arguments of the commands so it couldn't be null surely?
  8. It is about the return statements — his method always returns false, regardless whether the integer successfully parses or not.
  9. I pointed that out in my first post I just didn't change I just pointed him/her in the correct direction.
  10. Yes, and that would be significantly better than catching a null pointer.
  11. thanks to all but in game the command doesn't work..
  12. What does it do, what should it be doing, any errors that you can post?
  13. in console there aren't errors but in game it doesn't works
    For example i made that if the player(that i want to give a banknote) isn't online it send a message to the sender that explain that the layer isn't online..and it doesn't work..and also if i make the command /bn give sistem21 50 in game it doesn't give the banknote
  14. Debug your code.
  15. Log messages to the console, see what code is being executed and what not.
  16. Also show what you're currently using.