JoinListener doesn´t work need help!

Discussion in 'Spigot Plugin Development' started by JustBrainless, Sep 11, 2019.

Thread Status:
Not open for further replies.
  1. Hello,
    i have a problem with my JoinListener because the if question that should trigger the WelcomeBack message do not give me a String back, even though i am sure that the path and String is getable. Pls help me.


  2. Hey,

    Is your listener registered? Up until what point does code get executed? To test it, just put some debug output between the lines and after every if.
  3. What does your CreateFiles class look like?
  4. Ok, @petomka yes and it`s the if at pastebin line 20., @alyphen it works i am sure about it.
  5. Try to compare Strings not with ==, but rather with equals. If you want to ignore casing, use equalsIgnoreCase.
  6. @petomka equal throws nullpointerexceptions
  7. Then you have your problem. CreateFiles.getUsers().getString("UsersData.Users." + p.getUniqueId().toString().trim() + ".Name") returns null. What are you trying to accomplish with this whole line, anyways? It seems that you are checking if a player with a certain UUID still has the same name (which they can obviously change). Is this data even updated or set in the first place somewhere?
  8. Your getString call is returning null. Please show us what it's doing if you want help debugging it.
  9. public static void setupUsers() {

    userFile = new File(dataDir.getPath() + File.separator + "userData.yml");

    if(!userFile.exists()) {

    try {



    catch(IOException e) {

    Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.RED + "Could not create user data file!");
    //do something...



    customUserFile = YamlConfiguration.loadConfiguration(userFile);


    public static FileConfiguration getUsers() {

    return customUserFile;

  10. In that case, "UsersData.Users." + p.getUniqueId().toString().trim() + ".Name" isn't set in userData.yml.
  11. @alyphen check out line 59 of my pastebin.
  12. You're setting it after trying to use it. At the point you're trying to retrieve it from the config it hasn't been set.
  13. :rolleyes:I think you do not understand the sense.... If there is a user entry print welcomeback if not ok print welcome of course the second part try to create an entry for an unknown player
  14. Use p.getName().equals(CreateFiles.getUsers().getString("UsersData.Users." + p.getUniqueId().toString().trim() + ".Name")).

    Here are some things to remember:

    Use == only to compare primitives and enums. Otherwise you have to use Object#equals(Object).
    Method names should be written in lowerCamelCase.

    Getting an instance of your main class by doing Bukkit.getServer().getPluginManager().getPlugin("SimplePlots") is like the worst way. Use dependency injection.
  15. What you probably want in that case is this:
    Code (Java):
    if (CreateFiles.getUsers().getConfigurationSection("UsersData.Users").contains(p.getUniqueId().toString()) {
  16. Solved it.
    • Like Like x 1
Thread Status:
Not open for further replies.