Solved HashMaps

Discussion in 'Plugin Development' started by johnny boy, Jul 21, 2019.

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

    johnny boy

  2. Offline

    CraftCreeper6

    @johnny_boy
    Just out of interest, are you storing the time they have played as the key and their UUID as the value?

    Also, your problem is that HashMap#remove() takes a key, not a value.
     
  3. Offline

    johnny boy

    Yes i am. Should i reverse that.. ? OHHH it just hit me i should store UUID as key correct?

    edit: just tested what you said and it indeed is the case and now works as intended. Thank you :)
     
  4. Offline

    CraftCreeper6

  5. Offline

    johnny boy

    Works great thank you. As for how im doing it (code wise) is it good ?
     
  6. Offline

    CraftCreeper6

    @johnny_boy
    Only criticism is that you're using a capital letter for a HashMap. But that's it.
     
  7. Offline

    johnny boy

    Hahaha like the actual class! Okay thanks a lot ! (I'm surprised i got it right first time as i haven't coded with java or in general for ages, anyway tysm) :)
     
  8. Offline

    KarimAKL

    @johnny_boy Read this. It tells you about the Java naming conventions.
     
  9. Offline

    johnny boy

    i guess going by that then it should be Hashmap. (Eclipse > PlaytimeHashMap > Refractor > Rename) :p
     
  10. Offline

    CraftCreeper6

    @johnny_boy
    I meant your PlayerPlaytime hashmap, it should be called playerPlaytime
     
  11. Offline

    KarimAKL

    @johnny_boy No, going by that, you should change your variable map from 'PlayerPlaytime' to 'playerPlaytime'.
    EDIT: Ah, @CraftCreeper6 posted before me. :p
    I see you also have some variables in your 'Main' class called 'PlaytimeConfig' and 'Playtime', they should be renamed to 'playtimeConfig' and 'playtime'. Change all your variable names like that.
     
  12. Offline

    johnny boy

    o h i see now yes, thanks... (btw the plugin im making rn isn't going well haha).
     
Thread Status:
Not open for further replies.

Share This Page