Remove "vote points" feature

This commit is contained in:
P0nk
2023-08-06 16:03:35 +02:00
parent 2686b2b02d
commit 449ab01bc2
6 changed files with 3 additions and 368 deletions

View File

@@ -56,7 +56,6 @@ import scripting.npc.NPCConversationManager;
import scripting.npc.NPCScriptManager;
import scripting.quest.QuestActionManager;
import scripting.quest.QuestScriptManager;
import server.MapleLeafLogger;
import server.ThreadManager;
import server.TimerManager;
import server.life.Monster;
@@ -73,7 +72,6 @@ import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.*;
import java.util.Date;
import java.util.*;
import java.util.concurrent.Semaphore;
import java.util.concurrent.locks.Lock;
@@ -124,8 +122,6 @@ public class Client extends ChannelInboundHandlerAdapter {
private final Lock announcerLock = new ReentrantLock(true);
// thanks Masterrulax & try2hack for pointing out a bottleneck issue with shared locks, shavit for noticing an opportunity for improvement
private Calendar tempBanCalendar;
private int votePoints;
private int voteTime = -1;
private int visibleWorlds;
private long lastNpcClick;
private long lastPacket = System.currentTimeMillis();
@@ -372,38 +368,6 @@ public class Client extends ChannelInboundHandlerAdapter {
return ret;
}
public int getVoteTime() {
if (voteTime != -1) {
return voteTime;
}
try (Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT date FROM bit_votingrecords WHERE UPPER(account) = UPPER(?)")) {
ps.setString(1, accountName);
try (ResultSet rs = ps.executeQuery()) {
if (!rs.next()) {
return -1;
}
voteTime = rs.getInt("date");
}
} catch (SQLException e) {
log.error("Error getting voting time");
return -1;
}
return voteTime;
}
public void resetVoteTime() {
voteTime = -1;
}
public boolean hasVotedAlready() {
Date currentDate = new Date();
int timeNow = (int) (currentDate.getTime() / 1000);
int difference = (timeNow - getVoteTime());
return difference < 86400 && difference > 0;
}
public boolean hasBannedHWID() {
if (hwid == null) {
return false;
@@ -1235,50 +1199,6 @@ public class Client extends ChannelInboundHandlerAdapter {
}
}
public int getVotePoints() {
int points = 0;
try (Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT `votepoints` FROM accounts WHERE id = ?")) {
ps.setInt(1, accId);
try (ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
points = rs.getInt("votepoints");
}
}
} catch (SQLException e) {
e.printStackTrace();
}
votePoints = points;
return votePoints;
}
public void addVotePoints(int points) {
votePoints += points;
saveVotePoints();
}
public void useVotePoints(int points) {
if (points > votePoints) {
//Should not happen, should probably log this
return;
}
votePoints -= points;
saveVotePoints();
MapleLeafLogger.log(player, false, Integer.toString(points));
}
private void saveVotePoints() {
try (Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE accounts SET votepoints = ? WHERE id = ?")) {
ps.setInt(1, votePoints);
ps.setInt(2, accId);
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
public void lockClient() {
lock.lock();
}

View File

@@ -289,7 +289,6 @@ public class CommandsExecutor {
addCommand("togglewhitechat", 3, ChatCommand.class);
addCommand("fame", 3, FameCommand.class);
addCommand("givenx", 3, GiveNxCommand.class);
addCommand("givevp", 3, GiveVpCommand.class);
addCommand("givems", 3, GiveMesosCommand.class);
addCommand("giverp", 3, GiveRpCommand.class);
addCommand("expeds", 3, ExpedsCommand.class);

View File

@@ -15,11 +15,10 @@ public class ReadPointsCommand extends Command {
Character player = client.getPlayer();
if (params.length > 2) {
player.yellowMessage("Syntax: @points (rp|vp|all)");
player.yellowMessage("Syntax: @points (rp|all)");
return;
} else if (params.length == 0) {
player.yellowMessage("RewardPoints: " + player.getRewardPoints() + " | "
+ "VotePoints: " + player.getClient().getVotePoints());
player.yellowMessage("RewardPoints: " + player.getRewardPoints());
return;
}
@@ -27,12 +26,8 @@ public class ReadPointsCommand extends Command {
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());
player.yellowMessage("RewardPoints: " + player.getRewardPoints());
break;
}
}

View File

@@ -1,52 +0,0 @@
/*
This file is part of the HeavenMS MapleStory Server, commands OdinMS-based
Copyleft (L) 2016 - 2019 RonanLana
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
@Author: Arthur L - Refactored command content into modules
*/
package client.command.commands.gm3;
import client.Character;
import client.Client;
import client.command.Command;
import client.command.CommandContext;
public class GiveVpCommand extends Command {
{
setDescription("Give vote points to a player.");
}
@Override
public void execute(Client c, String[] params, CommandContext ctx) {
Character player = c.getPlayer();
if (params.length < 2) {
player.yellowMessage("Syntax: !givevp <playername> <gainvotepoint>");
return;
}
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
if (victim != null) {
victim.getClient().addVotePoints(Integer.parseInt(params[1]));
player.message("VP given.");
} else {
player.message("Player '" + params[0] + "' could not be found.");
}
}
}