Error in console?

Discussion in 'Spigot Plugin Development' started by ShishKaBobz, Apr 21, 2017.

  1. line 35, in your onJoin class, has a null value.

    debug to see what is null
     
  2. Thanks But How do i debug? I did /debug left and came back and stopped it and got this

    ---- Minecraft Profiler Results ----
    // *cracks redstone whip*

    Time span: 30964 ms
    Tick span: 619 ticks
    // This is approximately 19.99 ticks per second. It should be 20 ticks per second

    --- BEGIN PROFILE DUMP ---

    --- END PROFILE DUMP ---
     
  3. is this even how you read from the Config a UUID?

    Code (Text):
            if(nick.equals(p.getUniqueId().toString())){
                p.setDisplayName("§b§lBEAST " + nick);
            }
     
  4. BTW This is my config if i do /Nick <Nickname> Ingame This is what i get in my config

    Code (Text):
    1293f9f3-5908-4534-897b-2881158e6831: Test
    4651a4de-09bd-4644-9804-36b6a1489e91: TestA
     
     
  5. debugging means you output values for you to see and check their actual contents. ex:
    Code (Java):

    int x = plugin.getConfig().getInt("example.path");

    //hm my code doesn't seem to be running, let me see the output of x!
    System.out.println(x); //output: '2'
    //That's why its not running!
    if (x == 3) {
         Bukkit.shutdown();
    }
     
  6. You're looking for "Admin" in the config. Do you have a name
    assigned to the field "Admin" in your config.

    If not, that would be your null, because
    p.getName() contains a value.

    Also, I honestly have no clue how you would
    run the debugger on a Spigot server.

    It's not like Tomcat, where you can run an
    instance right from Eclipse. :/
     
  7. Thank you both! I never though of Debugging from Eclipse, I instantly though to go to My Minecraft server and do /debug lol

    But @VirusBrandon thank makes sense! Admin is not assigned to the config until i do the command /name admin <1010bob> along with the other args[0]'s So do you have an idea how i can fix that? Thank you!
     
  8. What's your question? maybe a small description instead of posting a small sentence in the post above would be better
     
  9. I would first change the NameA, NameB, NameC to a Map<String, Runnable>
    Code (Text):

    HashMap<String, Runnable> ranks = new HashMap<>();

    ranks.put("Admin", new Command() {
      public void setName(Player p) { p.setDisplayName("§e§lADMIN§4§l " + p.getName()+ "§c")  };
    });
     
    Then I would read the config with this and check if it's in
    Code (Text):

    String rank = plugin.getConfig().getString(p.getUniqueId().toString());
    Player p = event.getPlayer();
    if (ranks.containsKey(rank)) {
      ranks.get(rank).setName(p);
    }
    EDIT: The reason for your error is because you are asking Owner like
    Code (Text):

    owner: 'Name here'
     
    And since that doesn't exist in the config it can't check if it equals something since it's null.
     
  10. store bukkittasks instead
     
  11. What is that?? :D
     
  12. OP, do you know Java properly enough to make plugins? You don't seem like you know what you're doing. If you can't find a method use the javadocs.
     
  13. Since you assign information to your config at certain times.
    I would simply suggest adding function that takes as a parameter, the
    path in the config that you wish to access and then perform a null check
    within the function, then return the value if it exists, or some other non-null
    value when the item you request from config does not exist.