java - How to get a HashMap value and compare it to a number -


i have list of entries in hashmap, string key, , long value. i'm trying check if value greater number, i'm not sure how can value , check it.

i know incorrect, may show mean better can explain:

long offlinetimelimit = (offlinetimelimitconfig*1000); long limit = (offlinetimelimit + system.currenttimemillis()); long playername = playertimecheck.get(p);  if (playertimecheck.containsvalue( > limit)) { } 

this gets amount of time player allowed offline, offlimetimelimitconfig, multiplies 1000 (so it's in milliseconds), adds current time. want check if of values in hashmap greater current time plus time limit, execute code.

i've been doing research, , i've found other ways store data (like treemap) , i'm not sure if may better way store data.

here's rest of code:

string p = event.getplayer().getname(); hashmap<string, long> playertimecheck = new hashmap<string, long>(); configurationsection section = getconfig().getconfigurationsection("playertime"); long currenttime = system.currenttimemillis(); string playercheck = getconfig().getstring("playertime");  (string key : section.getkeys(false)) {             playertimecheck.put(key, section.getlong(key));         } 

thanks help, colby

map<string,long> playertimechcek = new treemap<>(new valuecomparator()); ...  if(!playertimecheck.isempty() && playertimecheck.firstentry().getvalue() > limit) {     ... } 

then implement value comparator class seen how sort treemap based on values?


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -