Files
Server/src/engine/net/client/handlers/SwearInHandler.java
T

78 lines
3.0 KiB
Java
Raw Normal View History

2022-04-30 09:41:17 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.gameManager.ChatManager;
import engine.gameManager.DispatchManager;
2022-04-30 09:41:17 -04:00
import engine.gameManager.SessionManager;
2024-05-12 11:55:12 -04:00
import engine.mbEnums;
2022-04-30 09:41:17 -04:00
import engine.net.Dispatch;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.guild.GuildInfoMsg;
import engine.net.client.msg.guild.GuildListMsg;
import engine.net.client.msg.guild.SwearInMsg;
import engine.objects.GuildStatusController;
import engine.objects.PlayerCharacter;
public class SwearInHandler extends AbstractClientMsgHandler {
2023-07-15 09:23:48 -04:00
public SwearInHandler() {
2024-05-12 11:55:12 -04:00
super();
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
@Override
2024-05-12 13:42:11 -04:00
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) {
2023-07-15 09:23:48 -04:00
SwearInMsg msg = (SwearInMsg) baseMsg;
2022-04-30 09:41:17 -04:00
Dispatch dispatch;
2023-07-15 09:23:48 -04:00
// get source player
PlayerCharacter source = SessionManager.getPlayerCharacter(origin);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (source == null)
return true;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
// get target player
PlayerCharacter target = SessionManager.getPlayerCharacterByID(msg.getTargetID());
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (target == null) {
ChatManager.chatGuildError(source,
"No such character found!");
return true;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (source.getGuild() != target.getGuild()) {
ChatManager.chatGuildError(source,
"That player is not a member of " + source.getGuild().getName());
return true;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
// Verify source has authority to swear in
if (GuildStatusController.isInnerCouncil(source.getGuildStatus()) == false) {
ErrorPopupMsg.sendErrorMsg(source, "Your do not have such authority!");
return true;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
// Swear target in and send message to guild
target.setFullMember(true);
target.incVer();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
ChatManager.chatGuildInfo(source, target.getFirstName() + " has been sworn in as a full member!");
2022-04-30 09:41:17 -04:00
dispatch = Dispatch.borrow(source, new GuildListMsg(source.getGuild()));
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
DispatchManager.sendToAllInRange(target, new GuildInfoMsg(target, target.getGuild(), 2));
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
return true;
}
2022-04-30 09:41:17 -04:00
}