MagicBot
8 months ago
1 changed files with 96 additions and 0 deletions
@ -0,0 +1,96 @@
@@ -0,0 +1,96 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
package engine.net.client.handlers; |
||||
|
||||
import engine.exception.MsgSendException; |
||||
import engine.gameManager.SessionManager; |
||||
import engine.net.client.ClientConnection; |
||||
import engine.net.client.msg.ClientNetMsg; |
||||
import engine.net.client.msg.login.DeleteCharacterMsg; |
||||
import engine.objects.GuildStatusController; |
||||
import engine.objects.PlayerCharacter; |
||||
import engine.server.MBServerStatics; |
||||
import engine.server.login.LoginServer; |
||||
import engine.server.login.LoginServerMsgHandler; |
||||
import engine.session.Session; |
||||
import org.pmw.tinylog.Logger; |
||||
|
||||
public class DeleteCharacterMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public DeleteCharacterMsgHandler() { |
||||
super(DeleteCharacterMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
// Member variable declaration
|
||||
|
||||
DeleteCharacterMsg msg; |
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (DeleteCharacterMsg) baseMsg; |
||||
|
||||
try { |
||||
PlayerCharacter playerCharacter; |
||||
Session session; |
||||
|
||||
session = SessionManager.getSession(origin); |
||||
playerCharacter = PlayerCharacter.getPlayerCharacter(msg.getCharacterUUID()); |
||||
|
||||
if (playerCharacter == null) { |
||||
Logger.error("Delete Error: PlayerID=" + msg.getCharacterUUID() + " not found."); |
||||
LoginServerMsgHandler.sendCharacterSelectScreen(session); |
||||
return true; |
||||
} |
||||
|
||||
if (session.getAccount() == null) { |
||||
Logger.error("Delete Error: Account not found."); |
||||
LoginServerMsgHandler.sendCharacterSelectScreen(session); |
||||
return true; |
||||
} |
||||
|
||||
if (playerCharacter.getAccount().equals(session.getAccount()) == false) { |
||||
Logger.error("Delete Error: Character " + playerCharacter.getName() + " does not belong to account " + origin.getAccount().getUname()); |
||||
LoginServerMsgHandler.sendCharacterSelectScreen(session); |
||||
return true; |
||||
} |
||||
|
||||
//Can't delete as Guild Leader
|
||||
//TODO either find an error or just gdisband.
|
||||
|
||||
if (GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus())) { |
||||
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Cannot delete a guild leader.", origin); |
||||
return true; |
||||
} |
||||
|
||||
// check for active banes
|
||||
|
||||
if (LoginServer.getActiveBaneQuery(playerCharacter)) { |
||||
Logger.info("Character " + playerCharacter.getName() + " has unresolved bane"); |
||||
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Player has unresolved bane.", origin); |
||||
return true; |
||||
} |
||||
|
||||
playerCharacter.getAccount().characterMap.remove(playerCharacter.getObjectUUID()); |
||||
playerCharacter.deactivateCharacter(); |
||||
|
||||
// TODO Delete Equipment
|
||||
// Resend Character Select Screen.
|
||||
LoginServerMsgHandler.sendCharacterSelectScreen(session); |
||||
|
||||
} catch (Exception e) { |
||||
Logger.error(e); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue