For some reason, I disabled the server and the server has 1 UUID on the HashMap, it saves 3, then when I reload the server, it saves double that, then double that???? What is happening? Here is my Saving. Code (Text): for(Entry<UUID, Boolean> Speed : DM.SpeedMap().entrySet()) { userData.set(Speed.getKey().toString() + ".speed", Speed.getValue()); }
What do you mean? I don't understand what you meant by 1 then 3 then double that. The HashMap gets more values?
@Bolt On my file, at the start, I only have my own UUID, but then, if I reload, It just adds a lot of fake UUIDs that don't exist in Minecraft. Why?
Agreed. It would be helpful to both you and us if you posted your whole code here. Quite frankly, I haven't understood what you were trying to accomplish here.
@MarinD99 @xXVevzZXx What code? I have a lot of code. This is my loading: Code (Text): for(String UUIDs : userData.getKeys(true)) { UUID id = DM.StoID(UUIDs); boolean speed = userData.getBoolean(UUIDs + ".speed"); DM.putSpeed(id, speed); }
Ok let me ask you a few things here, does this help us? (Thats shoild be a no...) What is DM What is putSpeed What is userData What is stoID This is why we need to see the whole class, we cant magically see what all of your code is with a snippet, please supply the class (es) that relate to this and then we can help you Plus supplying the whole class means that we are more likely to find you problem (most people post a snippet... and the problem isnt even in the snippet of code they have supplied, which makes the thread pointless)
@LeePMC DM(this is my class) = DataManger, Code inside it: putSpeed: Code (Text): public static void putSpeed(UUID id, boolean value) { if(String.valueOf(value).equals("true")) { Speed.put(id, value); return; } else if(String.valueOf(value).equals("false")) { Speed.put(id, value); return; } else return; } stoID: Code (Text): @SuppressWarnings("deprecation") public static UUID StoID(String s) { return Bukkit.getOfflinePlayer(s).getUniqueId(); } ------------------------------------ On my SLAPI userData: Code (Text): userData = YamlConfiguration.loadConfiguration(ursFile);
all i can say about this is 1. why the hell are you using String.valueOf(value).equals("true") when you could just go if (value) since its adding more and more every time you reload... its probably because you are using .put which means that if Speed has changed since the reload, it will at it into the hash map and not remove the others, check if the UUID is already in the hash map, and if it is set that value instead of putting a new one in (i think put is supposed to replace it but some say it doesn't so just check to be sure)
@LeePMC Okay, I changed the SString.valueOf(value).equals("true") Part, but I don't understand what you wrote other than that, I made a command which allows me to see the UUIDs in the HashMap, but somehow it keeps on adding more non-existing UUIDs into the HashMap... Why is it doing that?
@LeePMC Erm... Actaully, It is adding non existent UUIDs, I checked the UUIDs to see who they are and why its happening, and they are non-existent. They are all different UUIDs and only mine which exists.
This method is functionally the same as: PHP: public static void putSpeed(UUID id, boolean value) { Speed.put(id, value); }
@St3venAU OMG I FNA OF YOUR VIDEOS!!! And I changed that, I didn't know why I did that I hope you make more Over-Engineering Episodes I have been watching since the your first episode!
Bukkit.getOfflinePlayer(String) returns a player by their name, not by their UUID, therefor it will give you a completely random UUID on reload :/. Do what @MajorSkillage said and it should solve your issue.
@megamichiel Oh Thanks!!! But I do not know how to convert a string which is a UUID to a actually UUID.
An offline player's UUID is the exact same as if they were a player. EDIT: Sorry was tried when I typed this I really meant An offline player's UUID is the exact same as that same offline player except as a player's UUID.