本文整理汇总了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
}
}
}
示例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) {
}
}
}
示例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;
}
}
}
示例4: readFirstByte
import tools.data.input.ByteArrayByteStream; //导入依赖的package包/类
private int readFirstByte(byte[] arr) {
return new GenericLittleEndianAccessor(new ByteArrayByteStream(arr)).readByte();
}
示例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) {
}
}
}