Hello! I was just wondering how i can pull a UUID (Thats a string) from the config? I got this code from the Bukkit Wiki idk if it works yet but i think it will fit my needs Code (Text): List<String> listOfStrings = Arrays.asList("Hello World", "Welcome to Bukkit", "Have a Good Day!"); this.getConfig().set("path.to.list", listOfStrings); Thanks in advance! This has been driving me crazy!!!
Once you have a String, you can call UUID.fromString, this will either return the UUID or it will throw an exception if the string doesnt represent a UUID
Deconstruct what you're doing. Player#getUniqueId returns a UUID, UUID.fromString takes in a String. A UUID isn't a String. This call to fromString is redundant, as getUniqueId already returns a UUID
Save a UUID: FileConfiguration#set(String, UUID#toString) Load a UUID: UUID.fromString(FileConfiguration#getString(String))
Would this work?? if(UUID.fromString(p.getUniqueId().toString()) != null){ p.setDisplayName("§b§lBEAST " + nick); }
... Why would you need to take a player's uuid and turn it into a string then turn it back into a uuid to check if it's null? It's not even possible for that to be null.
And if i use UUID.fromString(FileConfiguration#getString(String)) my string would be player.getUUID or whatever
Before you get a UUID from config, you need to save it in the config. And then, you need to do UUID.fromString(config.getString("uuid")) to get the UUID back. But if you just need to check if it's null, don't bother turning it into a UUID. Just do if (!config.contains("uuid")) { }
ok so, What i am doing is saving a UUID to the config 5749w8650ejldh gfd hg (What ever): and then giving it a value 5749w8650ejldh gfd hg: <Nickname> Then when they join i get there UUID and the string and apply the Name
Save the players UUID to your file: Code (Text): yourConfig.set(player.getUniqueId().toString(); Check if the player exists in the file: Code (Text): if(yourConfig.getString(player.getUniqueId().toString()) != null) { UUID id = UUID.fromString(yourConfig.getString(player.getUniqueId().toString()); Not too hard, and I suggest learning a bit more about java and files.
This is completely redundant and incorrect... If the value in the config is stored by UUID then you would not be returning the UUID from the config.