From 1772910a5223071bcf96709220ccef610f142c81 Mon Sep 17 00:00:00 2001 From: Jerry Wang Date: Sat, 23 Feb 2019 23:17:11 +1000 Subject: [PATCH] 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 --- sql/db_database.sql | 1 + src/client/MapleClient.java | 6 +-- src/client/command/CommandsExecutor.java | 2 +- .../commands/gm0/ReadPointsCommand.java | 38 +++++++++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 src/client/command/commands/gm0/ReadPointsCommand.java diff --git a/sql/db_database.sql b/sql/db_database.sql index ca9b171565..645d8bada3 100644 --- a/sql/db_database.sql +++ b/sql/db_database.sql @@ -40,6 +40,7 @@ CREATE TABLE IF NOT EXISTS `accounts` ( `email` varchar(45) DEFAULT NULL, `ip` text, `rewardpoints` int(11) NOT NULL DEFAULT '0', + `votepoints` int(11) NOT NULL DEFAULT '0', `hwid` varchar(12) NOT NULL DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`), diff --git a/src/client/MapleClient.java b/src/client/MapleClient.java index 9fdf031b53..55089dd751 100644 --- a/src/client/MapleClient.java +++ b/src/client/MapleClient.java @@ -1160,12 +1160,12 @@ public class MapleClient { int points = 0; try { 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); ResultSet rs = ps.executeQuery(); if (rs.next()) { - points = rs.getInt("votes"); + points = rs.getInt("votepoints"); } ps.close(); rs.close(); @@ -1196,7 +1196,7 @@ public class MapleClient { private void saveVotePoints() { try { 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(2, accId); ps.executeUpdate(); diff --git a/src/client/command/CommandsExecutor.java b/src/client/command/CommandsExecutor.java index edd7fcd061..012a784ef0 100644 --- a/src/client/command/CommandsExecutor.java +++ b/src/client/command/CommandsExecutor.java @@ -184,7 +184,7 @@ public class CommandsExecutor { addCommand("online", OnlineCommand.class); addCommand("gm", GmCommand.class); addCommand("reportbug", ReportBugCommand.class); - //addCommand("points", ""); + addCommand("points", ReadPointsCommand.class); addCommand("joinevent", JoinEventCommand.class); addCommand("leaveevent", LeaveEventCommand.class); addCommand("ranks", RanksCommand.class); diff --git a/src/client/command/commands/gm0/ReadPointsCommand.java b/src/client/command/commands/gm0/ReadPointsCommand.java new file mode 100644 index 0000000000..3194519786 --- /dev/null +++ b/src/client/command/commands/gm0/ReadPointsCommand.java @@ -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; + } + } +} \ No newline at end of file