hashmap problem

Discussion in 'Plugin Development' started by paxi, Jun 30, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    paxi

    Hello everybody,

    i hope somebody can help me with my problem! I give into an Hashmap some objects so that the hashmap has a size of 4 as example.
    But when i try to get some information about the hashmap with an classmethode i can only get the first entry and the HashMap has the size of 1...

    The code:
    Code:java
    1. class
    2. [...]
    3.  
    4. private HashMap<String, Integer> attributes = new HashMap<String,Integer>();
    5.  
    6. [...]
    7.  
    8. private HashMap<String, String> loadRawData(List<String> data) {
    9. HashMap<String, String> map = new HashMap<String, String>();
    10. if(data != null && !data.isEmpty()) {
    11.  
    12. System.out.print("Länge der Liste:"+data.size());
    13. for(int i=0;i<data.size();i++){
    14. String dstring=data.get(i);
    15. dstring = ChatColor.stripColor(dstring);
    16.  
    17. try {
    18. String[] kv = dstring.split(": ");
    19.  
    20. map.put(kv[0], kv[1]);
    21. System.out.print(kv[0]+" "+ kv[1]);
    22. } catch (Exception e) {
    23. RPG.getPluginLogger().severe("Error.....");
    24. }
    25.  
    26. }
    27. }
    28. System.out.print("Mapsize:"+map.size());
    29.  
    30. [...]
    31. public boolean hasAttribute(String type) {
    32. System.out.print("leer?"+attributes.isEmpty());
    33. System.out.print("Test:"+attributes.get(type));
    34. System.out.print("Groesse der Map:"+attributes.size());
    35. return attributes.containsKey(type);
    36.  
    37. }
    38.  
    39. public int getAttribute(AttributeType type) {
    40. int back=0;
    41. if (hasAttribute(type.getName())) {
    42. back= attributes.get(type.getName());
    43.  
    44. }else{
    45. back=-1;
    46. }
    47. System.out.print("back:"+back);
    48. return back;
    49. }


    About LoadRawData i put the Informations into the HashMap, about getAttribute i want to get them back...

    someone an idea why i only can get the first entry back?

    Thanks,
    i hope you can understand my English an my code....
     
  2. Offline

    FabeGabeMC

    "RPG.getPluginLogger().severe("Error.....");"
    just do e.printStackTrace(); then check on what line the error happened.
    if you don't know how, here's a tutorial:
     
  3. Offline

    paxi

    There is no error...
    The only problem is that when i want to get the informations only the first entry is there...
     
Thread Status:
Not open for further replies.

Share This Page