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

74 lines
3.2 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.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.GuildControlMsg;
import engine.net.client.msg.guild.GuildListMsg;
import engine.objects.GuildStatusController;
import engine.objects.PlayerCharacter;
public class GuildControlHandler extends AbstractClientMsgHandler {
2023-07-15 09:23:48 -04:00
public GuildControlHandler() {
2024-05-12 11:55:12 -04:00
super();
2023-07-15 09:23:48 -04:00
}
// TODO Don't think this protocolMsg (0x3235E5EA) is actually player history. so
// take further look at it.
@Override
2024-05-12 13:42:11 -04:00
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) {
2023-07-15 09:23:48 -04:00
GuildControlMsg msg = (GuildControlMsg) baseMsg;
2022-04-30 09:41:17 -04:00
Dispatch dispatch;
2023-07-15 09:23:48 -04:00
// until we know what it's for, just echo it back.
msg.setUnknown05((byte) 1);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
//Send a GuildList msg
if (msg.getUnknown01() == 1) {
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
//TODO figure out why GL can't be changed and IC can't be banished
//Bounce back the rank options
msg.setGM((byte) (GuildStatusController.isGuildLeader(player.getGuildStatus()) ? 1 : 0));
2022-04-30 09:41:17 -04:00
dispatch = Dispatch.borrow(player, msg);
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
2022-04-30 09:41:17 -04:00
if (GuildStatusController.isInnerCouncil(player.getGuildStatus()) || GuildStatusController.isGuildLeader(player.getGuildStatus())) {
dispatch = Dispatch.borrow(player, new GuildListMsg(player.getGuild()));
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
2023-07-15 09:23:48 -04:00
} else
2022-04-30 09:41:17 -04:00
ErrorPopupMsg.sendErrorMsg(player, "Only guild leader and inner council have such authority!");
2023-07-15 09:23:48 -04:00
} else if (msg.getUnknown01() == 2) {
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
//If we don't get a valid PC for whatever reason.. just ignore it.
PlayerCharacter pc = PlayerCharacter.getFromCache(msg.getUnknown03());
if (pc != null) {
dispatch = Dispatch.borrow(player, new GuildListMsg(pc));
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY);
2023-07-15 09:23:48 -04:00
}
}
return true;
}
2022-04-30 09:41:17 -04:00
}