-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix offline votes not saving and fix expired vote
- Loading branch information
Showing
4 changed files
with
92 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ hs_err_pid* | |
target | ||
.idea | ||
*.iml | ||
/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.pocketvote.data; | ||
|
||
import java.util.HashMap; | ||
|
||
import cn.nukkit.utils.ConfigSection; | ||
|
||
public class Vote { | ||
private final String player, site, ip; | ||
private final long expires; | ||
|
||
public Vote(String player, String site, String ip, long expires) { | ||
this.player = player; | ||
this.site = site; | ||
this.ip = ip; | ||
this.expires = expires; | ||
} | ||
|
||
public Vote(ConfigSection selection) { | ||
this.player = selection.getString("player"); | ||
this.site = selection.getString("site"); | ||
this.ip = selection.getString("ip"); | ||
this.expires = Long.parseLong(selection.getString("expires")); | ||
} | ||
|
||
public String getPlayer() { | ||
return player; | ||
} | ||
|
||
public String getSite() { | ||
return site; | ||
} | ||
|
||
public String getIp() { | ||
return ip; | ||
} | ||
|
||
public long getExpires() { | ||
return expires; | ||
} | ||
|
||
public HashMap<String, String> saveVote() { | ||
HashMap<String, String> voteData = new HashMap<>(); | ||
voteData.put("site", getSite()); | ||
voteData.put("ip", getIp()); | ||
voteData.put("player", getPlayer()); | ||
voteData.put("expires", Long.toString(getExpires())); | ||
return voteData; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters