Search in sources :

Example 1 with MaplePacketHandler

use of net.MaplePacketHandler in project HeavenMS by ronancpl.

the class Commands method executeHeavenMsCommandLv3.

public static boolean executeHeavenMsCommandLv3(Channel cserv, Server srv, MapleClient c, String[] sub) {
    // GM
    MapleCharacter player = c.getPlayer();
    MapleCharacter victim;
    switch(sub[0]) {
        case "fly":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !fly <on/off>");
                break;
            }
            Integer accid = c.getAccID();
            String sendStr = "";
            if (sub[1].equalsIgnoreCase("on")) {
                sendStr += "Enabled Fly feature (F1). With fly active, you cannot attack.";
                if (!srv.canFly(accid))
                    sendStr += " Re-login to take effect.";
                srv.changeFly(c.getAccID(), true);
            } else {
                sendStr += "Disabled Fly feature. You can now attack.";
                if (srv.canFly(accid))
                    sendStr += " Re-login to take effect.";
                srv.changeFly(c.getAccID(), false);
            }
            player.dropMessage(6, sendStr);
            break;
        case "spawn":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !spawn <mobid>");
                break;
            }
            MapleMonster monster = MapleLifeFactory.getMonster(Integer.parseInt(sub[1]));
            if (monster == null) {
                break;
            }
            if (sub.length > 2) {
                for (int i = 0; i < Integer.parseInt(sub[2]); i++) {
                    player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(Integer.parseInt(sub[1])), player.getPosition());
                }
            } else {
                player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(Integer.parseInt(sub[1])), player.getPosition());
            }
            break;
        case "mutemap":
            if (player.getMap().isMuted()) {
                player.getMap().setMuted(false);
                player.dropMessage(5, "The map you are in has been un-muted.");
            } else {
                player.getMap().setMuted(true);
                player.dropMessage(5, "The map you are in has been muted.");
            }
            break;
        case "checkdmg":
            victim = c.getWorldServer().getPlayerStorage().getCharacterByName(sub[1]);
            if (victim != null) {
                int maxBase = victim.calculateMaxBaseDamage(victim.getTotalWatk());
                Integer watkBuff = victim.getBuffedValue(MapleBuffStat.WATK);
                Integer matkBuff = victim.getBuffedValue(MapleBuffStat.MATK);
                Integer blessing = victim.getSkillLevel(10000000 * player.getJobType() + 12);
                if (watkBuff == null)
                    watkBuff = 0;
                if (matkBuff == null)
                    matkBuff = 0;
                player.dropMessage(5, "Cur Str: " + victim.getTotalStr() + " Cur Dex: " + victim.getTotalDex() + " Cur Int: " + victim.getTotalInt() + " Cur Luk: " + victim.getTotalLuk());
                player.dropMessage(5, "Cur WATK: " + victim.getTotalWatk() + " Cur MATK: " + victim.getTotalMagic());
                player.dropMessage(5, "Cur WATK Buff: " + watkBuff + " Cur MATK Buff: " + matkBuff + " Cur Blessing Level: " + blessing);
                player.dropMessage(5, victim.getName() + "'s maximum base damage (before skills) is " + maxBase);
            } else {
                player.message("Player '" + sub[1] + "' could not be found on this world.");
            }
            break;
        case "inmap":
            String st = "";
            for (MapleCharacter chr : player.getMap().getCharacters()) {
                st += chr.getName() + " ";
            }
            player.message(st);
            break;
        case "reloadevents":
            for (Channel ch : Server.getInstance().getAllChannels()) {
                ch.reloadEventScriptManager();
            }
            player.dropMessage(5, "Reloaded Events");
            break;
        case "reloaddrops":
            MapleMonsterInformationProvider.getInstance().clearDrops();
            player.dropMessage(5, "Reloaded Drops");
            break;
        case "reloadportals":
            PortalScriptManager.getInstance().reloadPortalScripts();
            player.dropMessage(5, "Reloaded Portals");
            break;
        case "reloadmap":
            MapleMap oldMap = c.getPlayer().getMap();
            MapleMap newMap = c.getChannelServer().getMapFactory().resetMap(player.getMapId());
            int callerid = c.getPlayer().getId();
            for (MapleCharacter chr : oldMap.getCharacters()) {
                chr.changeMap(newMap);
                if (chr.getId() != callerid)
                    chr.dropMessage("You have been relocated due to map reloading. Sorry for the inconvenience.");
            }
            newMap.respawn();
            break;
        case "hpmp":
            victim = player;
            int statUpdate = 1;
            if (sub.length >= 3) {
                victim = c.getWorldServer().getPlayerStorage().getCharacterByName(sub[1]);
                statUpdate = Integer.valueOf(sub[2]);
            } else if (sub.length == 2) {
                statUpdate = Integer.valueOf(sub[1]);
            } else {
                player.yellowMessage("Syntax: !sethpmp [<playername>] <value>");
            }
            if (victim != null) {
                victim.setHp(statUpdate);
                victim.setMp(statUpdate);
                victim.updateSingleStat(MapleStat.HP, statUpdate);
                victim.updateSingleStat(MapleStat.MP, statUpdate);
                victim.checkBerserk(victim.isHidden());
            } else {
                player.message("Player '" + sub[1] + "' could not be found on this world.");
            }
            break;
        case "music":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !music <song>");
                for (String s : songs) {
                    player.yellowMessage(s);
                }
                break;
            }
            String song = joinStringFrom(sub, 1);
            for (String s : songs) {
                if (s.equals(song)) {
                    player.getMap().broadcastMessage(MaplePacketCreator.musicChange(s));
                    player.yellowMessage("Now playing song " + song + ".");
                    break;
                }
            }
            player.yellowMessage("Song not found, please enter a song below.");
            for (String s : songs) {
                player.yellowMessage(s);
            }
            break;
        case "monitor":
            if (sub.length < 1) {
                player.yellowMessage("Syntax: !monitor <ign>");
                break;
            }
            victim = c.getWorldServer().getPlayerStorage().getCharacterByName(sub[1]);
            if (victim == null) {
                player.message("Player '" + sub[1] + "' could not be found on this world.");
                break;
            }
            boolean monitored = MapleLogger.monitored.contains(victim.getName());
            if (monitored) {
                MapleLogger.monitored.remove(victim.getName());
            } else {
                MapleLogger.monitored.add(victim.getName());
            }
            player.yellowMessage(victim.getName() + " is " + (!monitored ? "now being monitored." : "no longer being monitored."));
            String message = player.getName() + (!monitored ? " has started monitoring " : " has stopped monitoring ") + victim.getName() + ".";
            Server.getInstance().broadcastGMMessage(c.getWorld(), MaplePacketCreator.serverNotice(5, message));
            break;
        case "monitors":
            for (String ign : MapleLogger.monitored) {
                player.yellowMessage(ign + " is being monitored.");
            }
            break;
        case "ignore":
            if (sub.length < 1) {
                player.yellowMessage("Syntax: !ignore <ign>");
                break;
            }
            victim = c.getWorldServer().getPlayerStorage().getCharacterByName(sub[1]);
            if (victim == null) {
                player.message("Player '" + sub[1] + "' could not be found on this world.");
                break;
            }
            boolean monitored_ = MapleLogger.ignored.contains(victim.getName());
            if (monitored_) {
                MapleLogger.ignored.remove(victim.getName());
            } else {
                MapleLogger.ignored.add(victim.getName());
            }
            player.yellowMessage(victim.getName() + " is " + (!monitored_ ? "now being ignored." : "no longer being ignored."));
            String message_ = player.getName() + (!monitored_ ? " has started ignoring " : " has stopped ignoring ") + victim.getName() + ".";
            Server.getInstance().broadcastGMMessage(c.getWorld(), MaplePacketCreator.serverNotice(5, message_));
            break;
        case "ignored":
            for (String ign : MapleLogger.ignored) {
                player.yellowMessage(ign + " is being ignored.");
            }
            break;
        case "pos":
            float xpos = player.getPosition().x;
            float ypos = player.getPosition().y;
            float fh = player.getMap().getFootholds().findBelow(player.getPosition()).getId();
            player.dropMessage(6, "Position: (" + xpos + ", " + ypos + ")");
            player.dropMessage(6, "Foothold ID: " + fh);
            break;
        case "togglecoupon":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !togglecoupon <itemid>");
                break;
            }
            Server.getInstance().toggleCoupon(Integer.parseInt(sub[1]));
            break;
        case "chat":
            player.toggleWhiteChat();
            player.message("Your chat is now " + (player.getWhiteChat() ? " white" : "normal") + ".");
            break;
        case "fame":
            if (sub.length < 3) {
                player.yellowMessage("Syntax: !fame <playername> <gainfame>");
                break;
            }
            victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
            if (victim != null) {
                victim.setFame(Integer.parseInt(sub[2]));
                victim.updateSingleStat(MapleStat.FAME, victim.getFame());
                player.message("FAME given.");
            } else {
                player.message("Player '" + sub[1] + "' could not be found on this channel.");
            }
            break;
        case "givenx":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !givenx [<playername>] <gainnx>");
                break;
            }
            String recv;
            int value;
            if (sub.length > 2) {
                recv = sub[1];
                value = Integer.parseInt(sub[2]);
            } else {
                recv = c.getPlayer().getName();
                value = Integer.parseInt(sub[1]);
            }
            victim = cserv.getPlayerStorage().getCharacterByName(recv);
            if (victim != null) {
                victim.getCashShop().gainCash(1, value);
                player.message("NX given.");
            } else {
                player.message("Player '" + recv + "' could not be found on this channel.");
            }
            break;
        case "givevp":
            if (sub.length < 3) {
                player.yellowMessage("Syntax: !givevp <playername> <gainvotepoint>");
                break;
            }
            victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
            if (victim != null) {
                victim.getClient().addVotePoints(Integer.parseInt(sub[2]));
                player.message("VP given.");
            } else {
                player.message("Player '" + sub[1] + "' could not be found on this channel.");
            }
            break;
        case "givems":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !givems [<playername>] <gainmeso>");
                break;
            }
            String recv_;
            int value_;
            if (sub.length > 2) {
                recv_ = sub[1];
                value_ = Integer.parseInt(sub[2]);
            } else {
                recv_ = c.getPlayer().getName();
                value_ = Integer.parseInt(sub[1]);
            }
            victim = cserv.getPlayerStorage().getCharacterByName(recv_);
            if (victim != null) {
                victim.gainMeso(value_, true);
                player.message("MESO given.");
            } else {
                player.message("Player '" + recv_ + "' could not be found on this channel.");
            }
            break;
        case "id":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !id <id>");
                break;
            }
            try {
                try (BufferedReader dis = new BufferedReader(new InputStreamReader(new URL("http://www.mapletip.com/search_java.php?search_value=" + sub[1] + "&check=true").openConnection().getInputStream()))) {
                    String s;
                    while ((s = dis.readLine()) != null) {
                        player.dropMessage(s);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
        case "expeds":
            for (Channel ch : Server.getInstance().getChannelsFromWorld(c.getWorld())) {
                if (ch.getExpeditions().size() == 0) {
                    player.yellowMessage("No Expeditions in Channel " + ch.getId());
                    continue;
                }
                player.yellowMessage("Expeditions in Channel " + ch.getId());
                int id = 0;
                for (MapleExpedition exped : ch.getExpeditions()) {
                    id++;
                    player.yellowMessage("> Expedition " + id);
                    player.yellowMessage(">> Type: " + exped.getType().toString());
                    player.yellowMessage(">> Status: " + (exped.isRegistering() ? "REGISTERING" : "UNDERWAY"));
                    player.yellowMessage(">> Size: " + exped.getMembers().size());
                    player.yellowMessage(">> Leader: " + exped.getLeader().getName());
                    int memId = 2;
                    for (MapleCharacter member : exped.getMembers()) {
                        if (exped.isLeader(member)) {
                            continue;
                        }
                        player.yellowMessage(">>> Member " + memId + ": " + member.getName());
                        memId++;
                    }
                }
            }
            break;
        case "kill":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !kill <playername>");
                break;
            }
            victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
            if (victim != null) {
                victim.setHpMp(0);
                Server.getInstance().broadcastGMMessage(c.getWorld(), MaplePacketCreator.serverNotice(5, player.getName() + " used !kill on " + victim.getName()));
            } else {
                player.message("Player '" + sub[1] + "' could not be found on this channel.");
            }
            break;
        case "seed":
            if (player.getMapId() != 910010000) {
                player.yellowMessage("This command can only be used in HPQ.");
                break;
            }
            Point[] pos = { new Point(7, -207), new Point(179, -447), new Point(-3, -687), new Point(-357, -687), new Point(-538, -447), new Point(-359, -207) };
            int[] seed = { 4001097, 4001096, 4001095, 4001100, 4001099, 4001098 };
            for (int i = 0; i < pos.length; i++) {
                Item item = new Item(seed[i], (byte) 0, (short) 1);
                player.getMap().spawnItemDrop(player, player, item, pos[i], false, true);
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            break;
        case "energy":
            System.out.println(c.getPlayer().getDojoEnergy());
            break;
        case "maxenergy":
            c.getPlayer().setDojoEnergy(10000);
            c.announce(MaplePacketCreator.getEnergy("energy", 10000));
            break;
        case "killall":
            MapleMap map = player.getMap();
            List<MapleMapObject> monsters = map.getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.MONSTER));
            int count = 0;
            for (MapleMapObject monstermo : monsters) {
                monster = (MapleMonster) monstermo;
                if (!monster.getStats().isFriendly() && !(monster.getId() >= 8810010 && monster.getId() <= 8810018)) {
                    map.damageMonster(player, monster, Integer.MAX_VALUE);
                    count++;
                }
            }
            player.dropMessage(5, "Killed " + count + " monsters.");
            break;
        case "notice":
            Server.getInstance().broadcastMessage(c.getWorld(), MaplePacketCreator.serverNotice(6, "[Notice] " + joinStringFrom(sub, 1)));
            break;
        case "rip":
            Server.getInstance().broadcastMessage(c.getWorld(), MaplePacketCreator.serverNotice(6, "[RIP]: " + joinStringFrom(sub, 1)));
            break;
        case "openportal":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !openportal <portalid>");
                break;
            }
            player.getMap().getPortal(sub[1]).setPortalState(true);
            break;
        case "closeportal":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !closeportal <portalid>");
                break;
            }
            player.getMap().getPortal(sub[1]).setPortalState(false);
            break;
        case "pe":
            String packet = "";
            try {
                InputStreamReader is = new FileReader("pe.txt");
                Properties packetProps = new Properties();
                packetProps.load(is);
                is.close();
                packet = packetProps.getProperty("pe");
            } catch (IOException ex) {
                ex.printStackTrace();
                player.yellowMessage("Failed to load pe.txt");
                break;
            }
            MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
            mplew.write(HexTool.getByteArrayFromHexString(packet));
            SeekableLittleEndianAccessor slea = new GenericSeekableLittleEndianAccessor(new ByteArrayByteStream(mplew.getPacket()));
            short packetId = slea.readShort();
            final MaplePacketHandler packetHandler = PacketProcessor.getProcessor(0, c.getChannel()).getHandler(packetId);
            if (packetHandler != null && packetHandler.validateState(c)) {
                try {
                    player.yellowMessage("Receiving: " + packet);
                    packetHandler.handlePacket(slea, c);
                } catch (final Throwable t) {
                    FilePrinter.printError(FilePrinter.PACKET_HANDLER + packetHandler.getClass().getName() + ".txt", t, "Error for " + (c.getPlayer() == null ? "" : "player ; " + c.getPlayer() + " on map ; " + c.getPlayer().getMapId() + " - ") + "account ; " + c.getAccountName() + "\r\n" + slea.toString());
                    break;
                }
            }
            break;
        case "startevent":
            int players = 50;
            if (sub.length > 1)
                players = Integer.parseInt(sub[1]);
            c.getChannelServer().setEvent(new MapleEvent(player.getMapId(), players));
            player.dropMessage(5, "The event has been set on " + player.getMap().getMapName() + " and will allow " + players + " players to join.");
            break;
        case "endevent":
            c.getChannelServer().setEvent(null);
            player.dropMessage(5, "You have ended the event. No more players may join.");
            break;
        case "online2":
            int total = 0;
            for (Channel ch : srv.getChannelsFromWorld(player.getWorld())) {
                int size = ch.getPlayerStorage().getAllCharacters().size();
                total += size;
                String s = "(Channel " + ch.getId() + " Online: " + size + ") : ";
                if (ch.getPlayerStorage().getAllCharacters().size() < 50) {
                    for (MapleCharacter chr : ch.getPlayerStorage().getAllCharacters()) {
                        s += MapleCharacter.makeMapleReadable(chr.getName()) + ", ";
                    }
                    player.dropMessage(6, s.substring(0, s.length() - 2));
                }
            }
            // player.dropMessage(6, "There are a total of " + total + " players online.");
            player.showHint("Players online: #e#r" + total + "#k#n.", 300);
            break;
        case "warpsnowball":
            List<MapleCharacter> chars = new ArrayList<>(player.getMap().getCharacters());
            for (MapleCharacter chr : chars) {
                chr.changeMap(109060000, chr.getTeam());
            }
            break;
        case "ban":
            if (sub.length < 3) {
                player.yellowMessage("Syntax: !ban <IGN> <Reason> (Please be descriptive)");
                break;
            }
            String ign = sub[1];
            String reason = joinStringFrom(sub, 2);
            MapleCharacter target = c.getChannelServer().getPlayerStorage().getCharacterByName(ign);
            if (target != null) {
                String readableTargetName = MapleCharacter.makeMapleReadable(target.getName());
                String ip = target.getClient().getSession().getRemoteAddress().toString().split(":")[0];
                // Ban ip
                PreparedStatement ps = null;
                try {
                    Connection con = DatabaseConnection.getConnection();
                    if (ip.matches("/[0-9]{1,3}\\..*")) {
                        ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?, ?)");
                        ps.setString(1, ip);
                        ps.setString(2, String.valueOf(target.getClient().getAccID()));
                        ps.executeUpdate();
                        ps.close();
                    }
                    con.close();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                    c.getPlayer().message("Error occured while banning IP address");
                    c.getPlayer().message(target.getName() + "'s IP was not banned: " + ip);
                }
                target.getClient().banMacs();
                reason = c.getPlayer().getName() + " banned " + readableTargetName + " for " + reason + " (IP: " + ip + ") " + "(MAC: " + c.getMacs() + ")";
                target.ban(reason);
                target.yellowMessage("You have been banned by #b" + c.getPlayer().getName() + " #k.");
                target.yellowMessage("Reason: " + reason);
                c.announce(MaplePacketCreator.getGMEffect(4, (byte) 0));
                final MapleCharacter rip = target;
                TimerManager.getInstance().schedule(new Runnable() {

                    @Override
                    public void run() {
                        rip.getClient().disconnect(false, false);
                    }
                }, // 5 Seconds
                5000);
                Server.getInstance().broadcastMessage(c.getWorld(), MaplePacketCreator.serverNotice(6, "[RIP]: " + ign + " has been banned."));
            } else if (MapleCharacter.ban(ign, reason, false)) {
                c.announce(MaplePacketCreator.getGMEffect(4, (byte) 0));
                Server.getInstance().broadcastMessage(c.getWorld(), MaplePacketCreator.serverNotice(6, "[RIP]: " + ign + " has been banned."));
            } else {
                c.announce(MaplePacketCreator.getGMEffect(6, (byte) 1));
            }
            break;
        case "unban":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !unban <playername>");
                break;
            }
            try {
                Connection con = DatabaseConnection.getConnection();
                int aid = MapleCharacter.getAccountIdByName(sub[1]);
                PreparedStatement p = con.prepareStatement("UPDATE accounts SET banned = -1 WHERE id = " + aid);
                p.executeUpdate();
                p = con.prepareStatement("DELETE FROM ipbans WHERE aid = " + aid);
                p.executeUpdate();
                p = con.prepareStatement("DELETE FROM macbans WHERE aid = " + aid);
                p.executeUpdate();
                con.close();
            } catch (Exception e) {
                e.printStackTrace();
                player.message("Failed to unban " + sub[1]);
                return true;
            }
            player.message("Unbanned " + sub[1]);
            break;
        case "healmap":
            for (MapleCharacter mch : player.getMap().getCharacters()) {
                if (mch != null) {
                    mch.setHp(mch.getMaxHp());
                    mch.updateSingleStat(MapleStat.HP, mch.getMaxHp());
                    mch.setMp(mch.getMaxMp());
                    mch.updateSingleStat(MapleStat.MP, mch.getMaxMp());
                }
            }
            break;
        case "healperson":
            victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
            if (victim != null) {
                victim.setHp(victim.getMaxHp());
                victim.updateSingleStat(MapleStat.HP, victim.getMaxHp());
                victim.setMp(victim.getMaxMp());
                victim.updateSingleStat(MapleStat.MP, victim.getMaxMp());
            } else {
                player.message("Player '" + sub[1] + "' could not be found on this channel.");
            }
            break;
        case "hurt":
            victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
            if (victim != null) {
                victim.setHp(1);
                victim.updateSingleStat(MapleStat.HP, 1);
            } else {
                player.message("Player '" + sub[1] + "' could not be found on this channel.");
            }
            break;
        case "killmap":
            for (MapleCharacter mch : player.getMap().getCharacters()) {
                mch.setHp(0);
                mch.updateSingleStat(MapleStat.HP, 0);
            }
            break;
        case "night":
            player.getMap().broadcastNightEffect();
            player.yellowMessage("Done.");
            break;
        case "npc":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !npc <npcid>");
                break;
            }
            MapleNPC npc = MapleLifeFactory.getNPC(Integer.parseInt(sub[1]));
            if (npc != null) {
                npc.setPosition(player.getPosition());
                npc.setCy(player.getPosition().y);
                npc.setRx0(player.getPosition().x + 50);
                npc.setRx1(player.getPosition().x - 50);
                npc.setFh(player.getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId());
                player.getMap().addMapObject(npc);
                player.getMap().broadcastMessage(MaplePacketCreator.spawnNPC(npc));
            }
            break;
        case "face":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !face [<playername>] <faceid>");
                break;
            }
            try {
                if (sub.length == 2) {
                    int itemId = Integer.parseInt(sub[1]);
                    if (!(itemId >= 20000 && itemId < 22000) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
                        player.yellowMessage("Face id '" + sub[1] + "' does not exist.");
                        break;
                    }
                    player.setFace(itemId);
                    player.updateSingleStat(MapleStat.FACE, itemId);
                    player.equipChanged();
                } else {
                    int itemId = Integer.parseInt(sub[2]);
                    if (!(itemId >= 20000 && itemId < 22000) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
                        player.yellowMessage("Face id '" + sub[2] + "' does not exist.");
                        break;
                    }
                    victim = c.getChannelServer().getPlayerStorage().getCharacterByName(sub[1]);
                    if (victim == null) {
                        victim.setFace(itemId);
                        victim.updateSingleStat(MapleStat.FACE, itemId);
                        victim.equipChanged();
                    } else {
                        player.yellowMessage("Player '" + sub[1] + "' has not been found on this channel.");
                    }
                }
            } catch (Exception e) {
            }
            break;
        case "hair":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !hair [<playername>] <hairid>");
                break;
            }
            try {
                if (sub.length == 2) {
                    int itemId = Integer.parseInt(sub[1]);
                    if (!(itemId >= 30000 && itemId < 35000) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
                        player.yellowMessage("Hair id '" + sub[1] + "' does not exist.");
                        break;
                    }
                    player.setHair(itemId);
                    player.updateSingleStat(MapleStat.HAIR, itemId);
                    player.equipChanged();
                } else {
                    int itemId = Integer.parseInt(sub[2]);
                    if (!(itemId >= 30000 && itemId < 35000) || MapleItemInformationProvider.getInstance().getName(itemId) == null) {
                        player.yellowMessage("Hair id '" + sub[2] + "' does not exist.");
                        break;
                    }
                    victim = c.getChannelServer().getPlayerStorage().getCharacterByName(sub[1]);
                    if (victim != null) {
                        victim.setHair(itemId);
                        victim.updateSingleStat(MapleStat.HAIR, itemId);
                        victim.equipChanged();
                    } else {
                        player.yellowMessage("Player '" + sub[1] + "' has not been found on this channel.");
                    }
                }
            } catch (Exception e) {
            }
            break;
        default:
            return false;
    }
    return true;
}
Also used : MapleCharacter(client.MapleCharacter) MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) MapleMapObject(server.maps.MapleMapObject) Properties(java.util.Properties) URL(java.net.URL) MapleMap(server.maps.MapleMap) MapleMapItem(server.maps.MapleMapItem) Item(client.inventory.Item) ByteArrayByteStream(tools.data.input.ByteArrayByteStream) FileReader(java.io.FileReader) MapleNPC(server.life.MapleNPC) MapleEvent(server.events.gm.MapleEvent) InputStreamReader(java.io.InputStreamReader) Channel(net.server.channel.Channel) SeekableLittleEndianAccessor(tools.data.input.SeekableLittleEndianAccessor) GenericSeekableLittleEndianAccessor(tools.data.input.GenericSeekableLittleEndianAccessor) Connection(java.sql.Connection) DatabaseConnection(tools.DatabaseConnection) PreparedStatement(java.sql.PreparedStatement) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) IOException(java.io.IOException) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) SQLException(java.sql.SQLException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) GenericSeekableLittleEndianAccessor(tools.data.input.GenericSeekableLittleEndianAccessor) MapleExpedition(server.expeditions.MapleExpedition) BufferedReader(java.io.BufferedReader) MaplePacketHandler(net.MaplePacketHandler) MapleMonster(server.life.MapleMonster)

Aggregations

MapleCharacter (client.MapleCharacter)1 Item (client.inventory.Item)1 Point (java.awt.Point)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 MaplePacketHandler (net.MaplePacketHandler)1 Channel (net.server.channel.Channel)1 MapleEvent (server.events.gm.MapleEvent)1 MapleExpedition (server.expeditions.MapleExpedition)1 MapleMonster (server.life.MapleMonster)1 MapleNPC (server.life.MapleNPC)1