Ban/Unban command fix
Bug detected by vcoc. Solution requires update at SQL tables "macbans" and "ipbans".
This commit is contained in:
@@ -615,7 +615,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
if (ps != null && !ps.isClosed()) {
|
||||
ps.close();
|
||||
}
|
||||
if (rs != null && !rs.isClosed()) {
|
||||
if (rs != null && !rs.isClosed()) {
|
||||
rs.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
@@ -2030,6 +2030,27 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
||||
return id;
|
||||
}
|
||||
|
||||
public static int getAccountIdByName(String name) {
|
||||
try {
|
||||
int id;
|
||||
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT accountid FROM characters WHERE name = ?")) {
|
||||
ps.setString(1, name);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
if (!rs.next()) {
|
||||
rs.close();
|
||||
ps.close();
|
||||
return -1;
|
||||
}
|
||||
id = rs.getInt("accountid");
|
||||
}
|
||||
}
|
||||
return id;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getIdByName(String name) {
|
||||
try {
|
||||
int id;
|
||||
|
||||
@@ -366,7 +366,7 @@ public class MapleClient {
|
||||
filtered.add(rs.getString("filter"));
|
||||
}
|
||||
}
|
||||
try (PreparedStatement ps = con.prepareStatement("INSERT INTO macbans (mac) VALUES (?)")) {
|
||||
try (PreparedStatement ps = con.prepareStatement("INSERT INTO macbans (mac, aid) VALUES (?, ?)")) {
|
||||
for (String mac : macs) {
|
||||
boolean matched = false;
|
||||
for (String filter : filtered) {
|
||||
@@ -377,6 +377,7 @@ public class MapleClient {
|
||||
}
|
||||
if (!matched) {
|
||||
ps.setString(1, mac);
|
||||
ps.setString(2, String.valueOf(getAccID()));
|
||||
ps.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1266,9 +1266,17 @@ public class Commands {
|
||||
player.updateSingleStat(MapleStat.LUK, x);
|
||||
} else if (sub[0].equals("unban")) {
|
||||
try {
|
||||
try (PreparedStatement p = DatabaseConnection.getConnection().prepareStatement("UPDATE accounts SET banned = -1 WHERE id = " + MapleCharacter.getIdByName(sub[1]))) {
|
||||
p.executeUpdate();
|
||||
}
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
int aid = MapleCharacter.getAccountIdByName(sub[1]);
|
||||
|
||||
PreparedStatement p = con.prepareStatement("UPDATE accounts SET banned = -1 WHERE id = " + aid);
|
||||
p.executeUpdate();
|
||||
|
||||
p = con.prepareStatement("DELETE FROM ipbans WHERE aid = " + aid);
|
||||
p.executeUpdate();
|
||||
|
||||
p = con.prepareStatement("DELETE FROM macbans WHERE aid = " + aid);
|
||||
p.executeUpdate();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
player.message("Failed to unban " + sub[1]);
|
||||
@@ -1291,8 +1299,10 @@ public class Commands {
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
if (ip.matches("/[0-9]{1,3}\\..*")) {
|
||||
ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)");
|
||||
ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?, ?)");
|
||||
ps.setString(1, ip);
|
||||
ps.setString(2, String.valueOf(target.getClient().getAccID()));
|
||||
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ServerConstants {
|
||||
//public static final boolean USE_ULTRA_THREE_SNAILS = true;
|
||||
public static final boolean USE_ADD_SLOTS_BY_LEVEL = true; //slots are added each 20 levels.
|
||||
public static final boolean USE_ADD_RATES_BY_LEVEL = true; //rates are added each 20 levels.
|
||||
public static final int USE_EQUIPMNT_LVLUP = 7; //all equips lvlup at max level as N, set 0 to disable.
|
||||
public static final int USE_EQUIPMNT_LVLUP = 7; //Nope, not working yet. //all equips lvlup at max level as N, set 0 to disable.
|
||||
public static final int FAME_GAIN_BY_QUEST = 4; //fame gain each N quest completes, set 0 to disable.
|
||||
public static final int SCROLL_CHANCE_RATE = 10; //number of tries for success on a scroll, set 0 for default.
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package net.server.channel.handlers;
|
||||
|
||||
import net.server.channel.handlers.DueyHandler;
|
||||
import client.MapleClient;
|
||||
import constants.ServerConstants;
|
||||
import net.AbstractMaplePacketHandler;
|
||||
@@ -43,6 +42,8 @@ public final class NPCTalkHandler extends AbstractMaplePacketHandler {
|
||||
MapleMapObject obj = c.getPlayer().getMap().getMapObject(oid);
|
||||
if (obj instanceof MapleNPC) {
|
||||
MapleNPC npc = (MapleNPC) obj;
|
||||
if(ServerConstants.USE_DEBUG == true) c.getPlayer().dropMessage(5, "Talking to NPC " + npc.getId());
|
||||
|
||||
if (npc.getId() == 9010009) { //is duey
|
||||
if(System.currentTimeMillis() - c.getPlayer().getDuey() < ServerConstants.BLOCK_DUEY_RACE_COND)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user