@@ -1057,7 +1057,28 @@ public String getWaitUntilDelaySiteFromService(String service) {
10571057 return "" ;
10581058 }
10591059
1060- private long getLastVotesTime (ArrayList <Column > cols , String site ) {
1060+ private long getLastVotesTime (String uuid , ArrayList <Column > cols , String site , String service ) {
1061+ long mostRecentTime = 0 ;
1062+
1063+ // Check cached online votes
1064+ if (cachedOnlineVotes .containsKey (uuid )) {
1065+ ArrayList <OfflineBungeeVote > onlineVotes = cachedOnlineVotes .get (uuid );
1066+ for (OfflineBungeeVote vote : onlineVotes ) {
1067+ if (vote .getService ().equalsIgnoreCase (service )) {
1068+ mostRecentTime = Math .max (mostRecentTime , vote .getTime ());
1069+ }
1070+ }
1071+ }
1072+
1073+ // Check cached votes
1074+ for (ArrayList <OfflineBungeeVote > votes : cachedVotes .values ()) {
1075+ for (OfflineBungeeVote vote : votes ) {
1076+ if (vote .getUuid ().equals (uuid ) && vote .getService ().equalsIgnoreCase (service )) {
1077+ mostRecentTime = Math .max (mostRecentTime , vote .getTime ());
1078+ }
1079+ }
1080+ }
1081+
10611082 for (Column d : cols ) {
10621083 if (d .getName ().equalsIgnoreCase ("LastVotes" )) {
10631084
@@ -1066,26 +1087,28 @@ private long getLastVotesTime(ArrayList<Column> cols, String site) {
10661087 for (String str : list ) {
10671088 String [] data = str .split ("//" );
10681089 if (data [0 ].equalsIgnoreCase (site )) {
1069- return Long .valueOf (data [1 ]);
1090+ mostRecentTime = Math . max ( mostRecentTime , Long .valueOf (data [1 ]) );
10701091 }
10711092 }
10721093
10731094 }
10741095 }
1075- return 0 ;
1096+ return mostRecentTime ;
10761097 }
10771098
10781099 public boolean checkVoteDelay (String uuid , String service , ArrayList <Column > data ) {
10791100 String site = getWaitUntilDelaySiteFromService (service );
10801101 if (site .isEmpty ()) {
1102+ debug ("No service site set for " + service + ", skipping vote delay check" );
10811103 return true ;
10821104 }
10831105
10841106 int voteDelay = getConfig ().getWaitUntilVoteDelayVoteDelay (site );
10851107 int voteDelayMin = getConfig ().getWaitUntilVoteDelayVoteDelayMin (site );
10861108
1087- long lastVote = getLastVotesTime (data , site );
1109+ long lastVote = getLastVotesTime (uuid , data , site , service );
10881110 if (lastVote == 0 ) {
1111+ debug ("No last vote time found for " + uuid + "/" + service + ", skipping vote delay check" );
10891112 return true ;
10901113 }
10911114
@@ -1096,6 +1119,7 @@ public boolean checkVoteDelay(String uuid, String service, ArrayList<Column> dat
10961119
10971120 if (!getConfig ().getWaitUntilVoteDelayVoteDelayDaily (site )) {
10981121 if (voteDelay == 0 && voteDelayMin == 0 ) {
1122+ debug ("Vote delay is 0 for " + site + ", skipping vote delay check" );
10991123 return true ;
11001124 }
11011125
@@ -1109,17 +1133,20 @@ public boolean checkVoteDelay(String uuid, String service, ArrayList<Column> dat
11091133
11101134 if (lastVoteTime .isBefore (resetTime )) {
11111135 if (now .isAfter (resetTime )) {
1136+ debug ("Vote delay is met for " + uuid + "/" + service + ", vote can be processed" );
11121137 return true ;
11131138 }
11141139 } else {
11151140 if (now .isAfter (resetTimeTomorrow )) {
1141+ debug ("Vote delay is met for " + uuid + "/" + service + ", vote can be processed" );
11161142 return true ;
11171143 }
11181144 }
11191145 } catch (Exception e ) {
11201146 e .printStackTrace ();
11211147 }
11221148
1149+ debug ("Vote delay is not met for " + uuid + "/" + service + ", skipping vote" );
11231150 return false ;
11241151 }
11251152
0 commit comments