AllianceOperationHandler.java
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:4k
源码类别:

游戏

开发平台:

Java

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package net.sf.odinms.net.channel.handler;
  6. import java.rmi.RemoteException;
  7. import net.sf.odinms.client.MapleCharacter;
  8. import net.sf.odinms.client.MapleClient;
  9. import net.sf.odinms.net.AbstractMaplePacketHandler;
  10. import net.sf.odinms.net.channel.ChannelServer;
  11. import net.sf.odinms.net.world.guild.MapleAlliance;
  12. import net.sf.odinms.tools.MaplePacketCreator;
  13. import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
  14. /**
  15.  *
  16.  * @author XoticStory
  17.  */
  18. public class AllianceOperationHandler extends AbstractMaplePacketHandler {
  19.     @Override
  20.     public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
  21.         System.out.println(slea.toString());
  22.         MapleAlliance alliance = null;
  23.         if (c.getPlayer().getGuild() != null && c.getPlayer().getGuild().getAllianceId() > 0) {
  24.             try {
  25.                 alliance = c.getChannelServer().getWorldInterface().getAlliance(c.getPlayer().getGuild().getAllianceId());
  26.             } catch (RemoteException rawr) {
  27.                 c.getChannelServer().reconnectWorld();
  28.             }
  29.         }
  30.         if (alliance == null) {
  31.             c.getPlayer().dropMessage("System error !");
  32.             c.getSession().write(MaplePacketCreator.enableActions());
  33.             return;
  34.         } else if (c.getPlayer().getMGC().getAllianceRank() > 2 || !alliance.getGuilds().contains(c.getPlayer().getGuildId())) {
  35.             c.getSession().write(MaplePacketCreator.enableActions());
  36.             return;
  37.         }
  38.         try {
  39.             switch (slea.readByte()) {
  40.                 case 0x0A:
  41.                     String notice = slea.readMapleAsciiString();
  42.                     c.getChannelServer().getWorldInterface().setAllianceNotice(alliance.getId(), notice);
  43.                     c.getChannelServer().getWorldInterface().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), notice), -1, -1);
  44.                     break;
  45.                 case 0x08:
  46.                     String ranks[] = new String[5];
  47.                     for (int i = 0; i < 5; i++) {
  48.                         ranks[i] = slea.readMapleAsciiString();
  49.                     }
  50.                     c.getChannelServer().getWorldInterface().setAllianceRanks(alliance.getId(), ranks);
  51.                     c.getChannelServer().getWorldInterface().allianceMessage(alliance.getId(), MaplePacketCreator.changeAllianceRankTitle(alliance.getId(), ranks), -1, -1);
  52.                     break;
  53.                 case 0x03: // fall through to default.
  54.                 /*
  55.                 String charName = slea.readMapleAsciiString();
  56.                 int channel = c.getChannelServer().getWorldInterface().find(charName);
  57.                 if (channel == -1) {
  58.                 c.getPlayer().dropMessage("The c.getPlayer() is not online");
  59.                 } else {
  60.                 MapleCharacter victim = ChannelServer.getInstance(channel).getPlayerStorage().getCharacterByName(charName);
  61.                 if (victim.getGuildId() == 0) {
  62.                 c.getPlayer().dropMessage("c.getPlayer() does not have a guild");
  63.                 } else if (victim.getGuildRank() != 1) {
  64.                 c.getPlayer().dropMessage("c.getPlayer() is not the leader of his/her guild.");
  65.                 }
  66.                 // UGH T___T No alliance packet.
  67.                 }*/
  68.                 default:
  69.                     c.getPlayer().dropMessage("Feature not available");
  70.             }
  71.             alliance.saveToDB();
  72.         } catch (RemoteException rawr) {
  73.             c.getChannelServer().reconnectWorld();
  74.         }
  75.     }
  76. }