Ejemplo n.º 1
0
  public static final void DeleteChar(final LittleEndianAccessor slea, final MapleClient c) {
    String Secondpw_Client = GameConstants.GMS ? slea.readMapleAsciiString() : null;
    if (Secondpw_Client == null) {
      if (slea.readByte() > 0) { // Specific if user have second password or not
        Secondpw_Client = slea.readMapleAsciiString();
      }
      slea.readMapleAsciiString();
    }

    final int Character_ID = slea.readInt();

    if (!c.login_Auth(Character_ID) || !c.isLoggedIn() || loginFailCount(c)) {
      c.getSession().close();
      return; // Attempting to delete other character
    }
    byte state = 0;

    if (c.getSecondPassword() != null) { // On the server, there's a second password
      if (Secondpw_Client == null) { // Client's hacking
        c.getSession().close();
        return;
      } else {
        if (!c.CheckSecondPassword(Secondpw_Client)) { // Wrong Password
          state = 20;
        }
      }
    }

    if (state == 0) {
      state = (byte) c.deleteCharacter(Character_ID);
    }
    c.getSession().write(LoginPacket.deleteCharResponse(Character_ID, state));
  }
Ejemplo n.º 2
0
  public static final void DeleteChar(LittleEndianAccessor slea, MapleClient c) {
    String Secondpw_Client = GameConstants.GMS ? slea.readMapleAsciiString() : null;
    if (Secondpw_Client == null) {
      if (slea.readByte() > 0) {
        Secondpw_Client = slea.readMapleAsciiString();
      }
      slea.readMapleAsciiString();
    }

    int Character_ID = slea.readInt();

    if ((!c.login_Auth(Character_ID)) || (!c.isLoggedIn()) || (loginFailCount(c))) {
      c.getSession().close(true);
      return;
    }
    byte state = 0;

    if (c.getSecondPassword() != null) {
      if (Secondpw_Client == null) {
        c.getSession().close(true);
        return;
      }
      if (!c.CheckSecondPassword(Secondpw_Client)) {
        state = 20;
      }
    }

    if (state == 0) {
      state = (byte) c.deleteCharacter(Character_ID);
    }
    c.getSession().write(LoginPacket.deleteCharResponse(Character_ID, state));
  }
Ejemplo n.º 3
0
  public static final void CharlistRequest(LittleEndianAccessor slea, MapleClient c) {
    if (!c.isLoggedIn()) {
      c.getSession().close(true);
      return;
    }
    if (GameConstants.GMS) {
      slea.readByte();
    }
    int server = slea.readByte();
    int channel = slea.readByte() + 1;
    if ((!World.isChannelAvailable(channel)) || (server != 0)) {
      c.getSession().write(LoginPacket.getLoginFailed(10));
      return;
    }

    List chars = c.loadCharacters(server);
    if ((chars != null) && (ChannelServer.getInstance(channel) != null)) {
      c.setWorld(server);
      c.setChannel(channel);

      c.getSession()
          .write(LoginPacket.getCharList(c.getSecondPassword(), chars, c.getCharacterSlots()));
    } else {
      c.getSession().close(true);
    }
  }
Ejemplo n.º 4
0
 public static final void CurePot(final LittleEndianAccessor slea, final MapleClient c) {
   final int itemid = slea.readInt();
   final Item slot =
       c.getPlayer().getInventory(MapleInventoryType.ETC).getItem((short) slea.readInt());
   if (slot == null
       || slot.getQuantity() <= 0
       || slot.getItemId() != itemid
       || itemid / 10000 != 434) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   final int index = slea.readInt() - 1;
   if (index < 0
       || index >= c.getPlayer().getImps().length
       || c.getPlayer().getImps()[index] == null
       || c.getPlayer().getImps()[index].getState() != 4) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   c.getPlayer().getImps()[index].setState(1);
   c.getSession()
       .write(
           CWvsContext.updateImp(
               c.getPlayer().getImps()[index], ImpFlag.STATE.getValue(), index, false));
   MapleInventoryManipulator.removeFromSlot(
       c, MapleInventoryType.ETC, slot.getPosition(), (short) 1, false, false);
 }
Ejemplo n.º 5
0
 public static final void UsePot(final LittleEndianAccessor slea, final MapleClient c) {
   final int itemid = slea.readInt();
   final Item slot = c.getPlayer().getInventory(MapleInventoryType.USE).getItem(slea.readShort());
   if (slot == null
       || slot.getQuantity() <= 0
       || slot.getItemId() != itemid
       || itemid / 10000 != 244
       || MapleItemInformationProvider.getInstance().getPot(itemid) == null) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   c.getSession().write(CWvsContext.enableActions());
   for (int i = 0; i < c.getPlayer().getImps().length; i++) {
     if (c.getPlayer().getImps()[i] == null) {
       c.getPlayer().getImps()[i] = new MapleImp(itemid);
       c.getSession()
           .write(
               CWvsContext.updateImp(
                   c.getPlayer().getImps()[i], ImpFlag.SUMMONED.getValue(), i, false));
       MapleInventoryManipulator.removeFromSlot(
           c, MapleInventoryType.USE, slot.getPosition(), (short) 1, false, false);
       return;
     }
   }
 }
Ejemplo n.º 6
0
  public static final void login(String username, MapleClient c, String pwd) {
    String login = username;
    int loginok = 0;
    boolean isBanned = c.hasBannedIP() || c.hasBannedMac() || c.hasProxyBan();
    loginok = c.login(login, pwd, isBanned);
    Calendar tempbannedTill = c.getTempBanCalendar();

    if ((loginok == 0) && (isBanned)) {
      loginok = 3;
    }
    if (loginok != 0) {
      if (!loginFailCount(c)) {
        c.clearInformation();
        c.getSession().write(LoginPacket.getLoginFailed(loginok));
      } else {
        c.getSession().close(true);
      }
    } else if (tempbannedTill.getTimeInMillis() != 0L) {
      if (!loginFailCount(c)) {
        c.clearInformation();
        c.getSession()
            .write(
                LoginPacket.getTempBan(
                    PacketHelper.getTime(tempbannedTill.getTimeInMillis()), c.getBanReason()));
      } else {
        c.getSession().close(true);
      }
    } else {
      c.loginAttempt = 0;
      LoginWorker.registerClient(c);
    }
  }
  public static final boolean UseHiredMerchant(MapleClient c, boolean packet) {
    if ((c.getPlayer().getMap() != null) && (c.getPlayer().getMap().allowPersonalShop())) {
      byte state = checkExistance(c.getPlayer().getAccountID(), c.getPlayer().getId());

      switch (state) {
        case 1:
          c.getPlayer().dropMessage(1, "Please claim your items from Fredrick first.");
          break;
        case 0:
          boolean merch = World.hasMerchant(c.getPlayer().getAccountID(), c.getPlayer().getId());
          if (!merch) {
            if (c.getChannelServer().isShutdown()) {
              c.getPlayer().dropMessage(1, "The server is about to shut down.");
              return false;
            }
            if (packet) {
              c.getSession().write(PlayerShopPacket.sendTitleBox());
            }
            return true;
          }
          c.getPlayer().dropMessage(1, "Please close the existing store and try again.");

          break;
        default:
          c.getPlayer().dropMessage(1, "An unknown error occured.");
      }
    } else {
      c.getSession().close(true);
    }
    return false;
  }
Ejemplo n.º 8
0
  public static final void CharlistRequest(final LittleEndianAccessor slea, final MapleClient c) {
    if (!c.isLoggedIn()) {
      c.getSession().close();
      return;
    }
    if (GameConstants.GMS) {
      slea.readByte(); // 2?
    }
    final int server = slea.readByte();
    final int channel = slea.readByte() + 1;
    if (!World.isChannelAvailable(channel) || server != 0) { // TODOO: MULTI WORLDS
      c.getSession().write(LoginPacket.getLoginFailed(10)); // cannot process so many
      return;
    }

    // System.out.println("Client " + c.getSession().getRemoteAddress().toString().split(":")[0] + "
    // is connecting to server " + server + " channel " + channel + "");

    final List<MapleCharacter> chars = c.loadCharacters(server);
    if (chars != null && ChannelServer.getInstance(channel) != null) {
      c.setWorld(server);
      c.setChannel(channel);
      c.getSession().write(LoginPacket.getSecondAuthSuccess(c));
      c.getSession()
          .write(LoginPacket.getCharList(c.getSecondPassword(), chars, c.getCharacterSlots()));
    } else {
      c.getSession().close();
    }
  }
Ejemplo n.º 9
0
 public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   if (!c.getPlayer().isAlive()) {
     c.getSession().write(MaplePacketCreator.enableActions());
     return;
   }
   MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
   slea.readInt();
   byte slot = (byte) slea.readShort();
   int itemId = slea.readInt();
   IItem toUse = c.getPlayer().getInventory(MapleInventoryType.USE).getItem(slot);
   if (toUse != null && toUse.getQuantity() > 0 && toUse.getItemId() == itemId) {
     if (itemId == 2022178 || itemId == 2022433 || itemId == 2050004) {
       c.getPlayer().dispelDebuffs();
       remove(c, slot);
       return;
     } else if (itemId == 2050003) {
       c.getPlayer().dispelSeal();
       remove(c, slot);
       return;
     }
     if (isTownScroll(itemId)) {
       if (ii.getItemEffect(toUse.getItemId()).applyTo(c.getPlayer())) {
         remove(c, slot);
       }
       c.getSession().write(MaplePacketCreator.enableActions());
       return;
     }
     remove(c, slot);
     ii.getItemEffect(toUse.getItemId()).applyTo(c.getPlayer());
     c.getPlayer().checkBerserk();
   }
 }
Ejemplo n.º 10
0
  public static void CreateChar(LittleEndianAccessor slea, MapleClient c) {
    String name = slea.readMapleAsciiString();
    slea.skip(4);
    final JobType jobType =
        JobType.getByType(
            slea
                .readInt()); // BIGBANG: 0 = Resistance, 1 = Adventurer, 2 = Cygnus, 3 = Aran, 4 =
                             // Evan, 5 = Mercedes
    final short subCategory = slea.readShort(); // whether dual blade = 1 or adventurer = 0
    final byte gender = slea.readByte();
    byte skinColor = slea.readByte(); // 01
    int hairColor = 0;
    slea.skip(1);
    boolean mercedes = (jobType == JobType.Mercedes);
    boolean demon = (jobType == JobType.Demon);
    boolean adventurer = (jobType == JobType.Adventurer);
    int face = slea.readInt();
    int hair = slea.readInt();

    final int demonMark = demon ? slea.readInt() : 0;
    int top = slea.readInt();
    int bottom = (mercedes || demon || adventurer) ? 0 : slea.readInt();
    int shoes = slea.readInt();
    int weapon = slea.readInt();
    int shield = demon ? slea.readInt() : (mercedes ? 1352000 : 0);

    MapleCharacter newchar = MapleCharacter.getDefault(c);
    newchar.setWorld((byte) c.getWorld());
    newchar.setFace(face);
    newchar.setHair(hair + hairColor);
    newchar.setGender(gender);
    newchar.setName(name);
    newchar.setSkinColor(skinColor);
    newchar.setDemonMarking(demonMark);
    newchar.setSubcategory(subCategory);

    MapleInventory equip = newchar.getInventory(MapleInventoryType.EQUIPPED);
    Item eq_top = MapleItemInformationProvider.getInstance().getEquipById(top);
    eq_top.setPosition((byte) -5);
    equip.addFromDB(eq_top);
    Item eq_bottom = MapleItemInformationProvider.getInstance().getEquipById(bottom);
    eq_bottom.setPosition((byte) -6);
    Item eq_shoes = MapleItemInformationProvider.getInstance().getEquipById(shoes);
    eq_shoes.setPosition((byte) -7);
    equip.addFromDB(eq_shoes);
    Item eq_weapon = MapleItemInformationProvider.getInstance().getEquipById(weapon);
    eq_weapon.setPosition((byte) -11);
    equip.addFromDB(eq_weapon);

    if (MapleCharacterUtil.canCreateChar(name, false)
        && !LoginInformationProvider.getInstance().isForbiddenName(name)) {
      MapleCharacter.saveNewCharToDB(newchar, (short) 0);
      c.getSession().write(LoginPacket.addNewCharEntry(newchar, true));
      c.createdChar(newchar.getId());
    } else {
      c.getSession().write(LoginPacket.addNewCharEntry(newchar, false));
    }
    newchar = null;
  }
Ejemplo n.º 11
0
 private static void sendMTSPackets(
     final MTSCart cart, final MapleClient c, final boolean changed) {
   c.getSession().write(MTSStorage.getInstance().getCurrentMTS(cart));
   c.getSession().write(MTSStorage.getInstance().getCurrentNotYetSold(cart));
   c.getSession().write(MTSStorage.getInstance().getCurrentTransfer(cart, changed));
   c.getSession().write(MTSCSPacket.showMTSCash(c.getPlayer()));
   c.getSession().write(MTSCSPacket.enableCSUse());
   MTSStorage.getInstance().checkExpirations();
 }
Ejemplo n.º 12
0
 public static final void ServerStatusRequest(MapleClient c) {
   int numPlayer = LoginServer.getUsersOn();
   int userLimit = LoginServer.getUserLimit();
   if (numPlayer >= userLimit) {
     c.getSession().write(LoginPacket.getServerStatus(2));
   } else if (numPlayer * 2 >= userLimit) {
     c.getSession().write(LoginPacket.getServerStatus(1));
   } else {
     c.getSession().write(LoginPacket.getServerStatus(0));
   }
 }
  public static void displayMerch(MapleClient c) {
    int conv = c.getPlayer().getConversation();
    boolean merch = World.hasMerchant(c.getPlayer().getAccountID(), c.getPlayer().getId());
    MerchItemPackage pack;
    if (merch) {
      c.getPlayer().dropMessage(1, "Please close the existing store and try again.");
      c.getPlayer().setConversation(0);
    } else if (c.getChannelServer().isShutdown()) {
      c.getPlayer().dropMessage(1, "The world is going to shut down.");
      c.getPlayer().setConversation(0);
    } else if (conv == 3) {
      pack = loadItemFrom_Database(c.getPlayer().getAccountID());

      if (pack == null) {
        c.getPlayer().dropMessage(1, "You do not have any item(s) with Fredrick.");
        c.getPlayer().setConversation(0);
      } else if (pack.getItems().size() <= 0) {
        if (!check(c.getPlayer(), pack)) {
          c.getSession().write(PlayerShopPacket.merchItem_Message(33));
          return;
        }
        if (deletePackage(
            c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId())) {
          c.getPlayer().fakeRelog();
          c.getPlayer().gainMeso(pack.getMesos(), false);
          c.getSession().write(PlayerShopPacket.merchItem_Message(29));
          c.getPlayer().dropMessage(1, "You have retrieved your mesos.");
        } else {
          c.getPlayer().dropMessage(1, "An unknown error occured.");
        }
        c.getPlayer().setConversation(0);
      } else {
        c.getSession().write(PlayerShopPacket.merchItemStore_ItemData(pack));
        MapleInventoryManipulator.checkSpace(c, conv, conv, null);
        for (Item item : pack.getItems()) {
          if (c.getPlayer()
              .getInventory(GameConstants.getInventoryType(item.getItemId()))
              .isFull()) {
            c.removeClickedNPC();
            c.getPlayer().dropMessage(1, "Your inventory is full (Please relog)");
            break;
          }
          MapleInventoryManipulator.addFromDrop(c, item, true);
          deletePackage(c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId());

          c.removeClickedNPC();
        }
        c.getPlayer().dropMessage(1, "Items have been returned to you, please relog.");
      }
    }

    c.getSession().write(CWvsContext.enableActions());
  }
 private static void requestItems(MapleClient c, boolean request) {
   if (c.getPlayer().getConversation() != 3) {
     return;
   }
   boolean merch = World.hasMerchant(c.getPlayer().getAccountID(), c.getPlayer().getId());
   if (merch) {
     c.getPlayer().dropMessage(1, "Please close the existing store and try again.");
     c.getPlayer().setConversation(0);
     return;
   }
   MerchItemPackage pack = loadItemFrom_Database(c.getPlayer().getAccountID());
   if (pack == null) {
     c.getPlayer().dropMessage(1, "An unknown error occured.");
     return;
   }
   if (c.getChannelServer().isShutdown()) {
     c.getPlayer().dropMessage(1, "The world is going to shut down.");
     c.getPlayer().setConversation(0);
     return;
   }
   int days = StringUtil.getDaysAmount(pack.getSavedTime(), System.currentTimeMillis());
   double percentage = days / 100.0D;
   int fee = (int) Math.ceil(percentage * pack.getMesos());
   if ((request) && (days > 0) && (percentage > 0.0D) && (pack.getMesos() > 0) && (fee > 0)) {
     c.getSession().write(PlayerShopPacket.merchItemStore((byte) 38, days, fee));
     return;
   }
   if (fee < 0) {
     c.getSession().write(PlayerShopPacket.merchItem_Message(33));
     return;
   }
   if (c.getPlayer().getMeso() < fee) {
     c.getSession().write(PlayerShopPacket.merchItem_Message(35));
     return;
   }
   if (!check(c.getPlayer(), pack)) {
     c.getSession().write(PlayerShopPacket.merchItem_Message(36));
     return;
   }
   if (deletePackage(c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId())) {
     if (fee > 0) {
       c.getPlayer().gainMeso(-fee, true);
     }
     c.getPlayer().gainMeso(pack.getMesos(), false);
     for (Item item : pack.getItems()) {
       MapleInventoryManipulator.addFromDrop(c, item, false);
     }
     c.getSession().write(PlayerShopPacket.merchItem_Message(32));
   } else {
     c.getPlayer().dropMessage(1, "An unknown error occured.");
   }
 }
Ejemplo n.º 15
0
 public static final void ServerListRequest(final MapleClient c) {
   // c.getSession().write(LoginPacket.getLoginWelcome());
   c.getSession().write(LoginPacket.getServerList(0, LoginServer.getLoad()));
   // c.getSession().write(CField.getServerList(1, "Scania",
   // LoginServer.getInstance().getChannels(), 1200));
   // c.getSession().write(CField.getServerList(2, "Scania",
   // LoginServer.getInstance().getChannels(), 1200));
   // c.getSession().write(CField.getServerList(3, "Scania",
   // LoginServer.getInstance().getChannels(), 1200));
   c.getSession().write(LoginPacket.getEndOfServerList());
   c.getSession().write(LoginPacket.enableRecommended());
   c.getSession().write(LoginPacket.sendRecommended(0, LoginServer.getEventMessage()));
 }
Ejemplo n.º 16
0
  public static final void Character_WithoutSecondPassword(
      final LittleEndianAccessor slea,
      final MapleClient c,
      final boolean haspic,
      final boolean view) {
    slea.readByte(); // 1?
    slea.readByte(); // 1?
    final int charId = slea.readInt();
    if (view) {
      c.setChannel(1);
      c.setWorld(slea.readInt());
    }
    final String currentpw = c.getSecondPassword();
    if (!c.isLoggedIn()
        || loginFailCount(c)
        || (currentpw != null && (!currentpw.equals("") || haspic))
        || !c.login_Auth(charId)
        || ChannelServer.getInstance(c.getChannel()) == null
        || c.getWorld() != 0) { // TODOO: MULTI WORLDS
      c.getSession().close();
      return;
    }
    c.updateMacs(slea.readMapleAsciiString());
    slea.readMapleAsciiString();
    if (slea.available() != 0) {
      final String setpassword = slea.readMapleAsciiString();

      if (setpassword.length() >= 6 && setpassword.length() <= 16) {
        c.setSecondPassword(setpassword);
        c.updateSecondPassword();
      } else {
        c.getSession().write(LoginPacket.secondPwError((byte) 0x14));
        return;
      }
    } else if (GameConstants.GMS && haspic) {
      return;
    }
    if (c.getIdleTask() != null) {
      c.getIdleTask().cancel(true);
    }
    final String s = c.getSessionIPAddress();
    LoginServer.putLoginAuth(
        charId, s.substring(s.indexOf('/') + 1, s.length()), c.getTempIP(), c.getChannel());
    c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION, s);
    c.getSession()
        .write(
            CField.getServerIP(
                c,
                Integer.parseInt(ChannelServer.getInstance(c.getChannel()).getIP().split(":")[1]),
                charId));
  }
Ejemplo n.º 17
0
 public static final void ServerStatusRequest(final MapleClient c) {
   // 0 = Select world normally
   // 1 = "Since there are many users, you may encounter some..."
   // 2 = "The concurrent users in this world have reached the max"
   final int numPlayer = LoginServer.getUsersOn();
   final int userLimit = LoginServer.getUserLimit();
   if (numPlayer >= userLimit) {
     c.getSession().write(LoginPacket.getServerStatus(2));
   } else if (numPlayer * 2 >= userLimit) {
     c.getSession().write(LoginPacket.getServerStatus(1));
   } else {
     c.getSession().write(LoginPacket.getServerStatus(0));
   }
 }
Ejemplo n.º 18
0
 public static final void ClearPot(final LittleEndianAccessor slea, final MapleClient c) {
   final int index = slea.readInt() - 1;
   if (index < 0
       || index >= c.getPlayer().getImps().length
       || c.getPlayer().getImps()[index] == null) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   c.getSession()
       .write(
           CWvsContext.updateImp(
               c.getPlayer().getImps()[index], ImpFlag.REMOVED.getValue(), index, false));
   c.getPlayer().getImps()[index] = null;
 }
  @Override
  public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {

    String pic = slea.readMapleAsciiString();
    int charId = slea.readInt();
    byte world = (byte) slea.readInt(); // world
    c.setWorld(world);
    byte channel =
        (byte) Randomizer.rand(0, Server.getInstance().getWorld(world).getChannels().size());
    c.setChannel(channel);
    String macs = slea.readMapleAsciiString();
    c.updateMacs(macs);

    if (c.hasBannedMac()) {
      c.getSession().close(true);
      return;
    }
    if (c.checkPic(pic)) {
      try {
        if (c.getIdleTask() != null) {
          c.getIdleTask().cancel(true);
        }
        c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION);

        String channelServerIP =
            MapleClient.getChannelServerIPFromSubnet(
                c.getSession().getRemoteAddress().toString().replace("/", "").split(":")[0],
                channel);
        if (channelServerIP.equals("0.0.0.0")) {
          String[] socket = Server.getInstance().getIP(world, channel).split(":");

          c.announce(
              MaplePacketCreator.getServerIP(
                  InetAddress.getByName(socket[0]), Integer.parseInt(socket[1]), charId));
        } else {
          String[] socket = Server.getInstance().getIP(world, channel).split(":");
          c.announce(
              MaplePacketCreator.getServerIP(
                  InetAddress.getByName(channelServerIP), Integer.parseInt(socket[1]), charId));
        }
      } catch (UnknownHostException e) {
        log.error("Host not found", e);
      }

    } else {

      c.announce(MaplePacketCreator.wrongPic());
    }
  }
Ejemplo n.º 20
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   c.removeClickedNPC();
   NPCScriptManager.getInstance().dispose(c);
   c.getSession().write(CWvsContext.enableActions());
   return 1;
 }
Ejemplo n.º 21
0
 @Override
 public void execute(MapleClient c, MessageCallback mc, String[] splitted)
     throws Exception, IllegalCommandSyntaxException {
   if (splitted[0].equals("!whosthere")) {
     MessageCallback callback = new ServernoticeMapleClientMessageCallback(c);
     StringBuilder builder = new StringBuilder("Players on Map: ");
     for (MapleCharacter chr : c.getPlayer().getMap().getCharacters()) {
       if (builder.length() > 150) { // wild guess :o
         builder.setLength(builder.length() - 2);
         callback.dropMessage(builder.toString());
         builder = new StringBuilder();
       }
       builder.append(MapleCharacter.makeMapleReadable(chr.getName()));
       builder.append(", ");
     }
     builder.setLength(builder.length() - 2);
     c.getSession().write(MaplePacketCreator.serverNotice(6, builder.toString()));
   } else if (splitted[0].equals("!cheaters")) {
     try {
       List<CheaterData> cheaters =
           c.getChannelServer().getWorldInterface().getCheaters(c.getWorld());
       for (int x = cheaters.size() - 1; x >= 0; x--) {
         CheaterData cheater = cheaters.get(x);
         mc.dropMessage(cheater.getInfo());
       }
     } catch (RemoteException e) {
       c.getChannelServer().reconnectWorld();
     }
   }
 }
Ejemplo n.º 22
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   if (splitted.length < 2) {
     c.getPlayer().dropMessage(6, splitted[0] + " <搜索信息>");
     return 0;
   }
   String search = StringUtil.joinStringFrom(splitted, 1);
   String result = "";
   MapleData data = null;
   MapleDataProvider dataProvider =
       MapleDataProviderFactory.getDataProvider(
           new File(System.getProperty("wzpath", "wz") + "/String.wz"));
   List<String> retItems = new ArrayList<>();
   int selection = 0;
   for (ItemInformation itemPair : MapleItemInformationProvider.getInstance().getAllItems()) {
     if (itemPair != null
         && itemPair.name != null
         && itemPair.name.toLowerCase().contains(search.toLowerCase())) {
       retItems.add(
           "\r\n#L"
               + selection
               + "##b"
               + itemPair.itemId
               + " "
               + " #k- "
               + " #r#z"
               + itemPair.itemId
               + "##k");
       selection++;
     }
   }
   if (retItems != null && retItems.size() > 0) {
     for (String singleRetItem : retItems) {
       if (result.length() < 10000) {
         result += singleRetItem;
       } else {
         result += "\r\n#b无法载入所有物品, 因为搜索出来的数量太多了#k";
         c.getSession().write(NPCPacket.sendNPCSay(9010000, result));
         return 1;
       }
     }
   } else {
     result = "找不到物品";
   }
   c.getSession().write(NPCPacket.sendNPCSay(9010000, result));
   return 1;
 }
Ejemplo n.º 23
0
 public static final void updateCCards(LittleEndianAccessor slea, MapleClient c) {
   if ((slea.available() != 36) || (!c.isLoggedIn())) {
     c.getSession().close(true);
     return;
   }
   Map<Integer, Integer> cids = new LinkedHashMap();
   for (int i = 1; i <= 9; i++) {
     int charId = slea.readInt();
     if (((!c.login_Auth(charId)) && (charId != 0))
         || (ChannelServer.getInstance(c.getChannel()) == null)
         || (c.getWorld() != 0)) {
       c.getSession().close(true);
       return;
     }
     cids.put(Integer.valueOf(i), Integer.valueOf(charId));
   }
   c.updateCharacterCards(cids);
 }
Ejemplo n.º 24
0
 public static final void CheckCharName(String name, MapleClient c) {
   c.getSession()
       .write(
           LoginPacket.charNameResponse(
               name,
               (!MapleCharacterUtil.canCreateChar(name, c.isGm()))
                   || ((LoginInformationProvider.getInstance().isForbiddenName(name))
                       && (!c.isGm()))));
 }
Ejemplo n.º 25
0
 public static final void updateCCards(final LittleEndianAccessor slea, final MapleClient c) {
   if (slea.available() != 24 || !c.isLoggedIn()) {
     c.getSession().close();
     return;
   }
   final Map<Integer, Integer> cids = new LinkedHashMap<>();
   for (int i = 1; i <= 6; i++) { // 6 chars
     final int charId = slea.readInt();
     if ((!c.login_Auth(charId) && charId != 0)
         || ChannelServer.getInstance(c.getChannel()) == null
         || c.getWorld() != 0) {
       c.getSession().close();
       return;
     }
     cids.put(i, charId);
   }
   c.updateCharacterCards(cids);
 }
Ejemplo n.º 26
0
  public static final void login(final LittleEndianAccessor slea, final MapleClient c) {
    String pwd = slea.readMapleAsciiString();
    String login = slea.readMapleAsciiString().replace("NP12:auth06:5:0:", "");

    final boolean ipBan = c.hasBannedIP();
    final boolean macBan = c.hasBannedMac();

    int loginok = c.login(login, pwd, ipBan || macBan);
    final Calendar tempbannedTill = c.getTempBanCalendar();

    if (loginok == 0 && (ipBan || macBan) && !c.isGm()) {
      loginok = 3;
      if (macBan) {
        // this is only an ipban o.O" - maybe we should refactor this a bit so it's more readable
        MapleCharacter.ban(
            c.getSession().getRemoteAddress().toString().split(":")[0],
            "Enforcing account ban, account " + login,
            false,
            4,
            false);
      }
    }
    if (loginok != 0) {
      if (!loginFailCount(c)) {
        c.clearInformation();
        c.getSession().write(LoginPacket.getLoginFailed(loginok));
      } else {
        c.getSession().close();
      }
    } else if (tempbannedTill.getTimeInMillis() != 0) {
      if (!loginFailCount(c)) {
        c.clearInformation();
        c.getSession()
            .write(
                LoginPacket.getTempBan(
                    PacketHelper.getTime(tempbannedTill.getTimeInMillis()), c.getBanReason()));
      } else {
        c.getSession().close();
      }
    } else {
      c.loginAttempt = 0;
      LoginWorker.registerClient(c);
    }
  }
Ejemplo n.º 27
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   c.removeClickedNPC();
   NPCScriptManager.getInstance().dispose(c);
   ItemScriptManager.getInstance().dispose(c);
   QuestScriptManager.getInstance().dispose(c);
   c.getSession().write(MaplePacketCreator.enableActions());
   c.getPlayer().dropMessage(6, "解卡成功。");
   return 1;
 }
Ejemplo n.º 28
0
  public void addPoints(MapleClient c, int points, long expiration, String reason) {
    this.lock.lock();
    try {
      int acc = c.getPlayer().getAccountID();

      if (this.points.containsKey(acc)) {
        int SavedPoints = (this.points.get(Integer.valueOf(acc)));
        if (SavedPoints >= AUTOBAN_POINTS) {
          return;
        }
        this.points.put(acc, SavedPoints + points);
        List reasonList = (List) this.reasons.get(Integer.valueOf(acc));
        reasonList.add(reason);
      } else {
        this.points.put(acc, points);
        List reasonList = new LinkedList();
        reasonList.add(reason);
        this.reasons.put(acc, reasonList);
      }

      if ((this.points.get(acc)) >= AUTOBAN_POINTS) {
        System.out.println(
            new StringBuilder()
                .append("[作弊] 玩家 ")
                .append(c.getPlayer().getName())
                .append(" A/b 触发 ")
                .append(reason)
                .toString());
        if (c.getPlayer().isGM()) {
          c.getPlayer()
              .dropMessage(
                  5, new StringBuilder().append("[警告] A/b 触发 : ").append(reason).toString());
          return;
        }
        StringBuilder sb = new StringBuilder("A/b ");
        sb.append(c.getPlayer().getName());
        sb.append(" (IP ");
        sb.append(c.getSession().getRemoteAddress().toString());
        sb.append("): ");
        for (String s : reasons.get(acc)) {
          sb.append(s);
          sb.append(", ");
        }
        //
        // WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0,
        // new StringBuilder().append(" <").append(c.getPlayer().getName()).append("> 被系统封号 (原因:
        // ").append(reason).append(")").toString()));
      } else if (expiration > 0L) {
        this.expirations.add(
            new ExpirationEntry(System.currentTimeMillis() + expiration, acc, points));
      }
    } finally {
      this.lock.unlock();
    }
  }
Ejemplo n.º 29
0
 public static void LeaveFarm(
     final LittleEndianAccessor slea, final MapleClient c, final MapleCharacter chr) {
   FarmServer.getPlayerStorage().deregisterPlayer(chr);
   c.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION, c.getSessionIPAddress());
   try {
     World.ChannelChange_Data(new CharacterTransfer(chr), chr.getId(), c.getChannel());
     c.getSession()
         .write(
             CField.getChannelChange(
                 c,
                 Integer.parseInt(
                     ChannelServer.getInstance(c.getChannel()).getIP().split(":")[1])));
   } finally {
     final String s = c.getSessionIPAddress();
     LoginServer.addIPAuth(s.substring(s.indexOf('/') + 1, s.length()));
     chr.saveToDB(false, true);
     c.setPlayer(null);
     c.setReceiving(false);
     c.getSession().close(true);
   }
 }
Ejemplo n.º 30
0
 public static void ViewChar(LittleEndianAccessor slea, MapleClient c) {
   Map<Byte, ArrayList<MapleCharacter>> worlds = new HashMap<Byte, ArrayList<MapleCharacter>>();
   List<MapleCharacter> chars = c.loadCharacters(0); // TODO multi world
   c.getSession().write(LoginPacket.showAllCharacter(chars.size()));
   for (MapleCharacter chr : chars) {
     if (chr != null) {
       ArrayList<MapleCharacter> chrr;
       if (!worlds.containsKey(chr.getWorld())) {
         chrr = new ArrayList<MapleCharacter>();
         worlds.put(chr.getWorld(), chrr);
       } else {
         chrr = worlds.get(chr.getWorld());
       }
       chrr.add(chr);
     }
   }
   for (Entry<Byte, ArrayList<MapleCharacter>> w : worlds.entrySet()) {
     c.getSession()
         .write(LoginPacket.showAllCharacterInfo(w.getKey(), w.getValue(), c.getSecondPassword()));
   }
 }