Improved Delete Character
Improved the Delete Character feature, now aiming to clean all leftovers of the character from the DB. Only works with the ENABLE_PIC flag activated.
This commit is contained in:
@@ -484,6 +484,10 @@ public class Server implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public MapleGuild getGuild(int id, int world) {
|
||||
return getGuild(id, world, null);
|
||||
}
|
||||
|
||||
public MapleGuild getGuild(int id, int world, MapleCharacter mc) {
|
||||
synchronized (guilds) {
|
||||
if (guilds.get(id) != null) {
|
||||
|
||||
@@ -62,16 +62,8 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
|
||||
if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuildId() < 1 || c.getPlayer().getGuildRank() != 1) {
|
||||
return;
|
||||
}
|
||||
int guildid = c.getPlayer().getGuildId();
|
||||
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildid, c), -1, -1);
|
||||
Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildid);
|
||||
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c), -1, -1);
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1);
|
||||
Server.getInstance().guildMessage(guildid, MaplePacketCreator.disbandAlliance(alliance.getId()));
|
||||
|
||||
alliance.dropMessage("[" + c.getPlayer().getGuild().getName() + "] guild has left the union.");
|
||||
MapleAlliance.removeGuildFromAlliance(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getGuildId(), c.getPlayer().getWorld());
|
||||
break;
|
||||
}
|
||||
case 0x03: // send alliance invite... or at least it would be this way if i could find the right way to call it!
|
||||
@@ -129,10 +121,10 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildid, c), -1, -1);
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildid, c.getWorld()), -1, -1);
|
||||
Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildid);
|
||||
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c), -1, -1);
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c.getWorld()), -1, -1);
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1);
|
||||
Server.getInstance().guildMessage(guildid, MaplePacketCreator.disbandAlliance(allianceid));
|
||||
|
||||
@@ -189,7 +181,7 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
|
||||
newLeader.getMGC().setAllianceRank(1);
|
||||
newLeader.saveGuildStatus();
|
||||
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, newLeader.getClient()), -1, -1);
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, newLeader.getWorld()), -1, -1);
|
||||
alliance.dropMessage("'" + newLeader.getName() + "' has been appointed as the new head of this Alliance.");
|
||||
}
|
||||
|
||||
@@ -200,7 +192,7 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
|
||||
chr.getMGC().setAllianceRank(newRank);
|
||||
chr.saveGuildStatus();
|
||||
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, chr.getClient()), -1, -1);
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, chr.getWorld()), -1, -1);
|
||||
alliance.dropMessage("'" + chr.getName() + "' has been reassigned as '" + alliance.getRankTitle(newRank) + "' in this Alliance.");
|
||||
}
|
||||
|
||||
|
||||
@@ -192,12 +192,7 @@ public class BuddylistModifyHandler extends AbstractMaplePacketHandler {
|
||||
nextPendingRequest(c);
|
||||
} else if (mode == 3) { // delete
|
||||
int otherCid = slea.readInt();
|
||||
if (buddylist.containsVisible(otherCid)) {
|
||||
notifyRemoteChannel(c, c.getWorldServer().find(otherCid), otherCid, BuddyOperation.DELETED);
|
||||
}
|
||||
buddylist.remove(otherCid);
|
||||
c.announce(MaplePacketCreator.updateBuddylist(player.getBuddylist().getBuddies()));
|
||||
nextPendingRequest(c);
|
||||
player.deleteBuddy(otherCid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -294,6 +294,19 @@ public class MapleAlliance {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeGuildFromAlliance(int allianceId, int guildId, int worldId) {
|
||||
MapleAlliance alliance = Server.getInstance().getAlliance(allianceId);
|
||||
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildId, worldId), -1, -1);
|
||||
Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildId);
|
||||
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, worldId), -1, -1);
|
||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1);
|
||||
Server.getInstance().guildMessage(guildId, MaplePacketCreator.disbandAlliance(alliance.getId()));
|
||||
|
||||
alliance.dropMessage("[" + Server.getInstance().getGuild(guildId, worldId) + "] guild has left the union.");
|
||||
}
|
||||
|
||||
public void updateAlliancePackets(MapleCharacter chr) {
|
||||
if (allianceId > 0) {
|
||||
this.broadcastMessage(MaplePacketCreator.updateAllianceInfo(this, chr.getClient()));
|
||||
|
||||
@@ -136,6 +136,7 @@ public class MapleGuild {
|
||||
public void writeToDB(boolean bDisband) {
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
|
||||
if (!bDisband) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("UPDATE guilds SET GP = ?, logo = ?, logoColor = ?, logoBG = ?, logoBGColor = ?, ");
|
||||
@@ -496,6 +497,13 @@ public class MapleGuild {
|
||||
}
|
||||
|
||||
public void disbandGuild() {
|
||||
if(allianceId > 0) {
|
||||
MapleAlliance alliance = Server.getInstance().getAlliance(allianceId);
|
||||
|
||||
if(alliance.getLeader().getGuildId() != id) MapleAlliance.removeGuildFromAlliance(allianceId, id, world);
|
||||
else MapleAlliance.disbandAlliance(allianceId);
|
||||
}
|
||||
|
||||
this.writeToDB(true);
|
||||
this.broadcast(null, -1, BCOp.DISBAND);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public final class CreateCharHandler extends AbstractMaplePacketHandler {
|
||||
for (int i = 0; i < items.length; i++){
|
||||
if (!isLegal(items[i])) {
|
||||
AutobanFactory.PACKET_EDIT.alert(newchar, name + " tried to packet edit in character creation.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + newchar + ".txt", "Tried to packet edit in char creation.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + newchar + ".txt", "Tried to packet edit in char creation.");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class DeleteCharHandler extends AbstractMaplePacketHandler {
|
||||
String pic = slea.readMapleAsciiString();
|
||||
int cid = slea.readInt();
|
||||
if (c.checkPic(pic)) {
|
||||
FilePrinter.printError(FilePrinter.DELETED_CHARACTERS + c.getAccountName() + ".txt", c.getAccountName() + " deleted CID: " + cid + "\r\n");
|
||||
FilePrinter.printError(FilePrinter.DELETED_CHARACTERS + c.getAccountName() + ".txt", c.getAccountName() + " deleted CID: " + cid + "\r\n");
|
||||
c.announce(MaplePacketCreator.deleteCharResponse(cid, 0));
|
||||
c.deleteCharacter(cid);
|
||||
} else {
|
||||
|
||||
@@ -16,10 +16,10 @@ public final class RegisterPicHandler extends AbstractMaplePacketHandler {
|
||||
slea.readByte();
|
||||
int charId = slea.readInt();
|
||||
String macs = slea.readMapleAsciiString();
|
||||
String hwid = slea.readMapleAsciiString();
|
||||
String hwid = slea.readMapleAsciiString();
|
||||
|
||||
c.updateMacs(macs);
|
||||
c.updateHWID(hwid);
|
||||
c.updateHWID(hwid);
|
||||
|
||||
if (c.hasBannedMac() || c.hasBannedHWID()) {
|
||||
c.getSession().close(true);
|
||||
|
||||
Reference in New Issue
Block a user