Salut , je galere depuis pas mal de temps a stocker une HashMap<UUID,ArrayList<String>>
en gros une arrayList pour chaque joueur qui contient des string seulement j’arrive pas a stocer ca quand le serveur ferme voici mon code :
public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) {
NBTTagList contactNom = new NBTTagList();
for(Map.Entry<UUID,ArrayList<String>> mapentry : ServerSide.nomContact.entrySet()){
NBTTagCompound pointstag = new NBTTagCompound();
pointstag.setUniqueId("contactnomid", mapentry.getKey());
NBTTagList tagList = new NBTTagList();
ArrayList <String>list = mapentry.getValue();
for(String s:list){
tagList.appendTag(new NBTTagString(s));
}
pointstag.setTag("listnom",tagList);
contactNom.appendTag(pointstag);
}
nbtTagCompound.setTag("contactnom",contactNom);
return nbtTagCompound;
}
et dans le readFromNBT :
public void readFromNBT(NBTTagCompound nbtTagCompound) {
NBTTagList contactNom= (NBTTagList)nbtTagCompound.getTag("contactnom");
for(int i = 0; i < contactNom.tagCount(); i++) {
NBTTagCompound rankTag = contactNom.getCompoundTagAt(i);
ArrayList<String> listNom = new ArrayList<>();
NBTTagList tagList = rankTag.getTagList("listnom", Constants.NBT.TAG_STRING);
for(int t = 0; t < tagList.tagCount();t++){
String s = tagList.getStringTagAt(i);
listNom.add(s);
}
ServerSide.numeroContact.put(rankTag.getUniqueId("contactnomid"),listNom);
}
Oui , le WorldSavedData est bien appélé , car je l’use pour stocker d’autre chose qui marche bien