Added votepoints into db_database.sql (#411)
* Added GM lv0 command to read votepoints and rewardpoints * Added missing votepoints in sql and tweaked MapleClient * Fix read from votes * Fix votepoints sql
This commit is contained in:
@@ -40,6 +40,7 @@ CREATE TABLE IF NOT EXISTS `accounts` (
|
|||||||
`email` varchar(45) DEFAULT NULL,
|
`email` varchar(45) DEFAULT NULL,
|
||||||
`ip` text,
|
`ip` text,
|
||||||
`rewardpoints` int(11) NOT NULL DEFAULT '0',
|
`rewardpoints` int(11) NOT NULL DEFAULT '0',
|
||||||
|
`votepoints` int(11) NOT NULL DEFAULT '0',
|
||||||
`hwid` varchar(12) NOT NULL DEFAULT '',
|
`hwid` varchar(12) NOT NULL DEFAULT '',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `name` (`name`),
|
UNIQUE KEY `name` (`name`),
|
||||||
|
|||||||
@@ -1160,12 +1160,12 @@ public class MapleClient {
|
|||||||
int points = 0;
|
int points = 0;
|
||||||
try {
|
try {
|
||||||
Connection con = DatabaseConnection.getConnection();
|
Connection con = DatabaseConnection.getConnection();
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT `votes` FROM accounts WHERE id = ?");
|
PreparedStatement ps = con.prepareStatement("SELECT `votepoints` FROM accounts WHERE id = ?");
|
||||||
ps.setInt(1, accId);
|
ps.setInt(1, accId);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
points = rs.getInt("votes");
|
points = rs.getInt("votepoints");
|
||||||
}
|
}
|
||||||
ps.close();
|
ps.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
@@ -1196,7 +1196,7 @@ public class MapleClient {
|
|||||||
private void saveVotePoints() {
|
private void saveVotePoints() {
|
||||||
try {
|
try {
|
||||||
Connection con = DatabaseConnection.getConnection();
|
Connection con = DatabaseConnection.getConnection();
|
||||||
try (PreparedStatement ps = con.prepareStatement("UPDATE accounts SET votes = ? WHERE id = ?")) {
|
try (PreparedStatement ps = con.prepareStatement("UPDATE accounts SET votepoints = ? WHERE id = ?")) {
|
||||||
ps.setInt(1, votePoints);
|
ps.setInt(1, votePoints);
|
||||||
ps.setInt(2, accId);
|
ps.setInt(2, accId);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ public class CommandsExecutor {
|
|||||||
addCommand("online", OnlineCommand.class);
|
addCommand("online", OnlineCommand.class);
|
||||||
addCommand("gm", GmCommand.class);
|
addCommand("gm", GmCommand.class);
|
||||||
addCommand("reportbug", ReportBugCommand.class);
|
addCommand("reportbug", ReportBugCommand.class);
|
||||||
//addCommand("points", "");
|
addCommand("points", ReadPointsCommand.class);
|
||||||
addCommand("joinevent", JoinEventCommand.class);
|
addCommand("joinevent", JoinEventCommand.class);
|
||||||
addCommand("leaveevent", LeaveEventCommand.class);
|
addCommand("leaveevent", LeaveEventCommand.class);
|
||||||
addCommand("ranks", RanksCommand.class);
|
addCommand("ranks", RanksCommand.class);
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package client.command.commands.gm0;
|
||||||
|
|
||||||
|
import client.MapleCharacter;
|
||||||
|
import client.MapleClient;
|
||||||
|
import client.command.Command;
|
||||||
|
|
||||||
|
public class ReadPointsCommand extends Command {
|
||||||
|
{
|
||||||
|
setDescription("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(MapleClient client, String[] params) {
|
||||||
|
|
||||||
|
MapleCharacter player = client.getPlayer();
|
||||||
|
if (params.length > 2) {
|
||||||
|
player.yellowMessage("Syntax: @points (rp|vp|all)");
|
||||||
|
return;
|
||||||
|
} else if (params.length == 0) {
|
||||||
|
player.yellowMessage("RewardPoints: " + player.getRewardPoints() + " | "
|
||||||
|
+ "VotePoints: " + player.getClient().getVotePoints());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (params[0]) {
|
||||||
|
case "rp":
|
||||||
|
player.yellowMessage("RewardPoints: " + player.getRewardPoints());
|
||||||
|
break;
|
||||||
|
case "vp":
|
||||||
|
player.yellowMessage("VotePoints: " + player.getClient().getVotePoints());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
player.yellowMessage("RewardPoints: " + player.getRewardPoints() + " | "
|
||||||
|
+ "VotePoints: " + player.getClient().getVotePoints());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user