當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteArrayByteStream類代碼示例

本文整理匯總了Java中tools.data.input.ByteArrayByteStream的典型用法代碼示例。如果您正苦於以下問題:Java ByteArrayByteStream類的具體用法?Java ByteArrayByteStream怎麽用?Java ByteArrayByteStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ByteArrayByteStream類屬於tools.data.input包,在下文中一共展示了ByteArrayByteStream類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: messageReceived

import tools.data.input.ByteArrayByteStream; //導入依賴的package包/類
@Override
public void messageReceived(IoSession session, Object message) {
    byte[] content = (byte[]) message;
    SeekableLittleEndianAccessor slea = new GenericSeekableLittleEndianAccessor(new ByteArrayByteStream(content));
    short packetId = slea.readShort();
    MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
    
    final MaplePacketHandler packetHandler = processor.getHandler(packetId);
    if (packetHandler != null && packetHandler.validateState(client)) {
        try {
            packetHandler.handlePacket(slea, client);
        } catch (final Throwable t) {
            FilePrinter.printError(FilePrinter.PACKET_HANDLER + packetHandler.getClass().getName() + ".txt", t, "Error for " + (client.getPlayer() == null ? "" : "player ; " + client.getPlayer() + " on map ; " + client.getPlayer().getMapId() + " - ") + "account ; " + client.getAccountName() + "\r\n" + slea.toString());
            //client.announce(MaplePacketCreator.enableActions());//bugs sometimes
        }
    }
}
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:18,代碼來源:MapleServerHandler.java

示例2: messageReceived

import tools.data.input.ByteArrayByteStream; //導入依賴的package包/類
@Override
public void messageReceived(IoSession session, Object message) throws Exception {
    byte[] content = (byte[]) message;
    SeekableLittleEndianAccessor slea = new GenericSeekableLittleEndianAccessor(new ByteArrayByteStream(content));
    short opcode = slea.readShort();
    GMPacketHandler packetHandler = processor.getHandler(opcode);
    if (packetHandler != null) {
        try {
            packetHandler.handlePacket(slea, session);
        } catch (Throwable t) {
        }
    }
}
 
開發者ID:NovaStory,項目名稱:AeroStory,代碼行數:14,代碼來源:GMServerHandler.java

示例3: messageReceived

import tools.data.input.ByteArrayByteStream; //導入依賴的package包/類
@Override
public void messageReceived(IoSession session, Object message) {
    if (message == null || session == null) {
        return;
    }
    SeekableLittleEndianAccessor slea = new GenericSeekableLittleEndianAccessor(new ByteArrayByteStream((byte[]) message));
    if (slea.available() < 1) {
        FileoutputUtil.log("數據包長度異常:" + slea.toString());
        return;
    }
    MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
    if (client == null || !client.isReceiving()) {
        return;
    }
    short packetId = slea.readByte();
    for (RecvPacketOpcode recv : RecvPacketOpcode.values()) {
        if (recv.getValue() == packetId) {
            if (recv.NeedsChecking() && !client.isLoggedIn()) {
                FileoutputUtil.log("客戶端沒有登錄,丟棄包!");
                return;
            }
            try {
                handlePacket(recv, slea, client);
            } catch (InterruptedException e) {
                FileoutputUtil.log(FileoutputUtil.Packet_Ex, new StringBuilder().append("封包: ").append(lookupRecv(packetId)).append("\r\n").append(slea.toString(true)).toString());
                FileoutputUtil.outputFileError(FileoutputUtil.Packet_Ex, e);
            }
            return;
        }
    }
}
 
開發者ID:icelemon1314,項目名稱:mapleLemon,代碼行數:32,代碼來源:MapleServerHandler.java

示例4: readFirstByte

import tools.data.input.ByteArrayByteStream; //導入依賴的package包/類
private int readFirstByte(byte[] arr) {
    return new GenericLittleEndianAccessor(new ByteArrayByteStream(arr)).readByte();
}
 
開發者ID:icelemon1314,項目名稱:mapleLemon,代碼行數:4,代碼來源:MaplePacketEncoder.java

示例5: main

import tools.data.input.ByteArrayByteStream; //導入依賴的package包/類
public static void main(String[] args) {
    System.out.println("LOADING :: Please wait...");
    //String out = args[0];
    //String out = "CrusaderItemDump";
    //File dir = new File(out);
    File text = new File("Codex.txt");
    //dir.mkdir();

    BufferedReader b = null;
    MapleDataProvider data = MapleDataProviderFactory.getDataProvider(MapleDataProviderFactory.fileInWZPath("Item.wz"));
    try {
        String s;

        text.createNewFile();
        b = new BufferedReader(new FileReader("monsterbook.txt"));

        StringBuilder sb = new StringBuilder();
        try (PrintWriter writer = new PrintWriter(new FileOutputStream(text))) {
            while ((s = b.readLine()) != null) {
                byte[] bArray = HexTool.getByteArrayFromHexString(s);
                SeekableLittleEndianAccessor slea = new GenericSeekableLittleEndianAccessor(new ByteArrayByteStream(bArray));
                int card = slea.readInt();
                int size = slea.readShort();
                MapleData consume = data.getData("Consume/0238.img").getChildByPath("0" + String.valueOf(card));
                int monsterid = MapleDataTool.getIntConvert("info/mob", consume, 0);
                // Don't forget to insert the card, along with the rest of the drops.
                sb.append("INSERT INTO `drop_data` (`dropperid`, `itemid`, `questid`, `chance`) VALUES (").append(monsterid).append(", ").append(card).append(", 0, 400);\r\n");
                for (int i = 0; i < size; i++) {
                    int itemid = slea.readInt();
                    sb.append("INSERT INTO `drop_data` (`dropperid`, `itemid`, `questid`, `chance`) VALUES ");
                    sb.append("(").append(monsterid).append(", ").append(itemid).append(", 0, ").append(getChance(itemid) == -1 ? -1 : getChance(itemid) * 10).append(");\r\n");
                }
                writer.println(sb.toString());
                sb.delete(0, sb.length());
            }
            writer.flush();
        }
        System.out.println("Success! The task has been completed.");
    } catch (IOException e) {
    } finally {
        try {
            if (b != null) {
                b.close();
            }
        } catch (IOException ex) {
        }
    }
}
 
開發者ID:skorch37,項目名稱:Asteria,代碼行數:49,代碼來源:CrusaderCodex.java


注:本文中的tools.data.input.ByteArrayByteStream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。