当前位置: 首页>>代码示例>>Java>>正文


Java LittleEndianAccessor.available方法代码示例

本文整理汇总了Java中tools.data.LittleEndianAccessor.available方法的典型用法代码示例。如果您正苦于以下问题:Java LittleEndianAccessor.available方法的具体用法?Java LittleEndianAccessor.available怎么用?Java LittleEndianAccessor.available使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tools.data.LittleEndianAccessor的用法示例。


在下文中一共展示了LittleEndianAccessor.available方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateCCards

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
public static 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 || !WorldOption.isExists(c.getWorld())) {
            c.getSession().close();
            return;
        }
        cids.put(i, charId);
    }
    c.updateCharacterCards(cids);
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:17,代码来源:CharLoginHandler.java

示例2: absorbingDF

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
public static void absorbingDF(LittleEndianAccessor slea, final MapleClient c) {
	int size = slea.readInt();
	int room = 0;
	byte unk = 0;
	int sn;
	for (int i = 0; i < size; i++) {
		room = GameConstants.isDemonAvenger(c.getPlayer().getJob()) || c.getPlayer().getJob() == 212 ? 0
				: slea.readInt();
		unk = slea.readByte();
		sn = slea.readInt();
		if (GameConstants.isDemonSlayer(c.getPlayer().getJob())) {
			// c.getPlayer().addMP(c.getPlayer().getStat().getForce(room));
		}
		if (GameConstants.isAngelicBuster(c.getPlayer().getJob())) {
			boolean rand = Randomizer.isSuccess(80);
			if (sn > 0) {
				if (rand) {
					c.getSession().write(JobPacket.AngelicPacket.SoulSeekerRegen(c.getPlayer(), sn));
				}
			}
		}
		if ((GameConstants.isDemonAvenger(c.getPlayer().getJob())) && slea.available() >= 8) {
			// c.getPlayer().getMap().broadcastMessage(MainPacketCreator.ShieldChacingRe(c.getPlayer().getId(),
			// slea.readInt(), slea.readInt(), unk,
			// c.getPlayer().getKeyValue2("schacing")));
		}
		if (c.getPlayer().getJob() == 212) {
			// c.getPlayer().getMap().broadcastMessage(MainPacketCreator.MegidoFlameRe(c.getPlayer().getId(),
			// unk, slea.readInt()));
		}
	}
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:33,代码来源:PlayerHandler.java

示例3: QuickSlot

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
public static void QuickSlot(LittleEndianAccessor slea, MapleCharacter chr) {
	if ((slea.available() == 32L) && (chr != null)) {
		StringBuilder ret = new StringBuilder();
		for (int i = 0; i < 8; i++) {
			ret.append(slea.readInt()).append(",");
		}
		ret.deleteCharAt(ret.length() - 1);
		chr.getQuestNAdd(MapleQuest.getInstance(123000)).setCustomData(ret.toString());
	}
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:11,代码来源:PlayerHandler.java

示例4: Heal

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
public static void Heal(LittleEndianAccessor slea, MapleCharacter chr) {
	if (chr == null) {
		return;
	}
	slea.skip(4); // update tick
	if (slea.available() >= 8L) {
		slea.skip(slea.available() >= 12L ? 8 : 4);
	}
	int healHP = slea.readShort();
	int healMP = slea.readShort();

	PlayerStats stats = chr.getStat();

	if (stats.getHp() <= 0) {
		return;
	}
	long now = System.currentTimeMillis();
	if ((healHP != 0) && (chr.canHP(now + 1000L))) {
		if (healHP > stats.getHealHP()) {
			healHP = (int) stats.getHealHP();
		}
		chr.addHP(healHP);
	}
	if ((healMP != 0) && (!GameConstants.isDemonSlayer(chr.getJob())) && (chr.canMP(now + 1000L))) {
		if (healMP > stats.getHealMP()) {
			healMP = (int) stats.getHealMP();
		}
		chr.addMP(healMP);
	}
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:31,代码来源:PlayerHandler.java

示例5: NPCAnimation

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
public static void NPCAnimation(LittleEndianAccessor slea, MapleClient c) {
    PacketWriter mplew = new PacketWriter();
    mplew.writeShort(SendPacketOpcode.NPC_ACTION.getValue());
    int length = (int) slea.available();
    if (length == 10) {
        mplew.writeInt(slea.readInt());
        mplew.writeShort(slea.readShort());
        mplew.writeInt(slea.readInt());
    } else if (length > 10) {
        mplew.write(slea.read(length - 9));
    } else {
        return;
    }
    c.getSession().write(mplew.getPacket());
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:16,代码来源:NPCHandler.java

示例6: repair

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
public static final void repair(final LittleEndianAccessor slea, final MapleClient c) {
    if (slea.available() < 4) { //leafre for now
        return;
    }
    final int position = slea.readInt(); //who knows why this is a int
    final MapleInventoryType type = position < 0 ? MapleInventoryType.EQUIPPED : MapleInventoryType.EQUIP;
    final Item item = c.getPlayer().getInventory(type).getItem((byte) position);
    if (item == null) {
        return;
    }
    final Equip eq = (Equip) item;
    final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    final Map<String, Integer> eqStats = ii.getEquipStats(item.getItemId());
    if (eq.getDurability() < 0 || !eqStats.containsKey("durability") || eqStats.get("durability") <= 0 || eq.getDurability() >= eqStats.get("durability")) {
        return;
    }
    final double rPercentage = (100.0 - Math.ceil((eq.getDurability() * 1000.0) / (eqStats.get("durability") * 10.0)));
    //drpq level 105 weapons - ~420k per %; 2k per durability point
    //explorer level 30 weapons - ~10 mesos per %
    final int price = (int) Math.ceil(rPercentage * ii.getPrice(eq.getItemId()) / (ii.getReqLevel(eq.getItemId()) < 70 ? 100.0 : 1.0)); // / 100 for level 30?
    //TODO: need more data on calculating off client
    if (c.getPlayer().getMeso() < price) {
        return;
    }
    c.getPlayer().gainMeso(-price, false);
    eq.setDurability(eqStats.get("durability"));
    c.getPlayer().forceReAddItem(eq.copy(), type);
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:29,代码来源:NPCHandler.java

示例7: TouchReactor

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
public static void TouchReactor(final LittleEndianAccessor slea, final MapleClient c) {
    final int oid = slea.readInt();
    final boolean touched = slea.available() == 0 || slea.readByte() > 0; //the byte is probably the state to set it to
    final MapleReactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
    if (!touched || reactor == null || !reactor.isAlive() || reactor.getTouch() == 0) {
        return;
    }
    if (reactor.getTouch() == 2) {
        ReactorScriptManager.getInstance().act(c, reactor); //not sure how touched boolean comes into play
    } else if (reactor.getTouch() == 1 && !reactor.isTimerActive()) {
        if (reactor.getReactorType() == 100) {
            final int itemid = GameConstants.getCustomReactItem(reactor.getReactorId(), reactor.getReactItem().getLeft());
            if (c.getPlayer().haveItem(itemid, reactor.getReactItem().getRight())) {
                if (reactor.getArea().contains(c.getPlayer().getTruePosition())) {
                    MapleInventoryManipulator.removeById(c, GameConstants.getInventoryType(itemid), itemid, reactor.getReactItem().getRight(), true, false);
                    reactor.hitReactor(c);
                } else {
                    c.getPlayer().dropMessage(5, "You are too far away.");
                }
            } else {
                c.getPlayer().dropMessage(5, "You don't have the item required.");
            }
        } else {
            //just hit it
            reactor.hitReactor(c);
        }
    }
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:29,代码来源:PlayersHandler.java

示例8: handle

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
@PacketHandler(opcode = RecvPacketOpcode.CHANGE_KEYMAP)
public static void handle(MapleClient c, LittleEndianAccessor lea) {
	if (c.getPlayer() == null){
		return;
	}
	if (lea.available() > 8L) {
		handleKeyBindingChanges(c, lea);
	} else {
		handleQuests(c, lea);
	}
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:12,代码来源:ChangeKeymapHandler.java

示例9: handle

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
public static void handle(MapleClient c, LittleEndianAccessor lea) {
	final int charId = lea.readInt();
	lea.readByte(); // 1? 
       lea.readByte(); // 1?
	
       final String currentpw = c.getSecondPassword();
       
       if (!c.isLoggedIn() || (currentpw != null && (!currentpw.equals(""))) || !c.login_Auth(charId) || ChannelServer.getInstance(c.getChannel()) == null || !WorldOption.isExists(c.getWorld())) {
           System.out.println("The session wants to close");
       	c.getSession().close();
           return;
       }
       c.updateMacs(lea.readMapleAsciiString());
       if (lea.available() != 0) {
           final String setpassword = lea.readMapleAsciiString();

           if (setpassword.length() >= 6 && setpassword.length() <= 16) {
               c.setSecondPassword(setpassword);
               c.updateSecondPassword();
           } else {
               c.getSession().write(LoginPacket.secondPwError((byte) 0x14));
               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));
   
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:34,代码来源:CreateWithoutSecondPassword.java

示例10: handle

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
@PacketHandler(opcode = RecvPacketOpcode.PONG)
public static void handle(MapleClient c, LittleEndianAccessor lea) {
	
	if (lea.available() > 0) {
		
		if(lea.readInt() == 28)
			c.getSession().write(LoginPacket.getPing());
		
	}
	// c.pongReceived();
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:12,代码来源:PongHandler.java

示例11: NPCMoreTalk

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
public static void NPCMoreTalk(final LittleEndianAccessor slea, final MapleClient c) {
    System.out.println("lastmasg6");
    final byte lastMsg = slea.readByte(); // 00 (last msg type I think)
    if (lastMsg == 9 && slea.available() >= 4) {
        slea.readShort();
    }
    final byte action = slea.readByte(); // 00 = end chat, 01 == follow
    if (((lastMsg == 0x12 && c.getPlayer().getDirection() >= 0) || (lastMsg == 0x12 && c.getPlayer().getDirection() == -1)) && action == 1) {
        byte lastbyte = slea.readByte(); // 00 = end chat, 01 == follow
        if (lastbyte == 0) {
            c.getSession().write(CWvsContext.enableActions());
        } else {
            MapScriptMethods.startDirectionInfo(c.getPlayer(), lastMsg == 0x13);
            c.getSession().write(CWvsContext.enableActions());
        }
        return;
    }
    final NPCConversationManager cm = NPCScriptManager.getInstance().getCM(c);
    System.out.println("lastmasg7");
    /*if (cm != null && lastMsg == 0x17) {
     c.getPlayer().handleDemonJob(slea.readInt());
     return;
     }*/
    System.out.println("LastMsg: " + lastMsg);
    if (cm == null || c.getPlayer().getConversation() == 0 || cm.getLastMsg() != lastMsg) {
        System.out.println("lastmasg7");
        return;
    }
    cm.setLastMsg((byte) -1);

    if (lastMsg == 1) {
        NPCScriptManager.getInstance().action(c, action, lastMsg, -1);
        if (action != 0) {
            cm.setGetText(slea.readMapleAsciiString());
            if (cm.getType() == 0) {
                NPCScriptManager.getInstance().startQuest(c, action, lastMsg, -1);
            } else if (cm.getType() == 1) {
                NPCScriptManager.getInstance().endQuest(c, action, lastMsg, -1);
            } else {
                NPCScriptManager.getInstance().action(c, action, lastMsg, -1);
            }
        } else {
            cm.dispose();
        }
    } else if (lastMsg == 0x17) {
        NPCScriptManager.getInstance().action(c, (byte) 1, lastMsg, action);
    } else {
        System.out.println("lastmasg");
        int selection = -1;
        if (slea.available() >= 4) {
            selection = slea.readInt();
        } else if (slea.available() > 0) {
            selection = slea.readByte();
        }
        if (lastMsg == 4 && selection == -1) {
            System.out.println("lastmasg2");
            cm.dispose();
            return;//h4x
        }
        if (selection >= -1 && action != -1) {
            System.out.println("lastmasg3");
            if (cm.getType() == 0) {
                NPCScriptManager.getInstance().startQuest(c, action, lastMsg, selection);
            } else if (cm.getType() == 1) {
                NPCScriptManager.getInstance().endQuest(c, action, lastMsg, selection);
            } else {
                NPCScriptManager.getInstance().action(c, action, lastMsg, selection);
            }
        } else {
            cm.dispose();
        }
    }
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:74,代码来源:NPCHandler.java

示例12: RPSGame

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
public static final void RPSGame(LittleEndianAccessor slea, MapleClient c) {
    if ((slea.available() == 0L) || (c.getPlayer() == null) || (c.getPlayer().getMap() == null) || (!c.getPlayer().getMap().containsNPC(9000019))) {
        if ((c.getPlayer() != null) && (c.getPlayer().getRPS() != null)) {
            c.getPlayer().getRPS().dispose(c);
        }
        return;
    }
    byte mode = slea.readByte();
    switch (mode) {
        case 0:
        case 5:
            if (c.getPlayer().getRPS() != null) {
                c.getPlayer().getRPS().reward(c);
            }
            if (c.getPlayer().getMeso() >= 1000L) {
                c.getPlayer().setRPS(new RockPaperScissors(c, mode));
            } else {
                c.getSession().write(CField.getRPSMode((byte) 8, -1, -1, -1));
            }
            break;
        case 1:
            if ((c.getPlayer().getRPS() == null) || (!c.getPlayer().getRPS().answer(c, slea.readByte()))) {
                c.getSession().write(CField.getRPSMode((byte) 13, -1, -1, -1));
            }
            break;
        case 2:
            if ((c.getPlayer().getRPS() == null) || (!c.getPlayer().getRPS().timeOut(c))) {
                c.getSession().write(CField.getRPSMode((byte) 13, -1, -1, -1));
            }
            break;
        case 3:
            if ((c.getPlayer().getRPS() == null) || (!c.getPlayer().getRPS().nextRound(c))) {
                c.getSession().write(CField.getRPSMode((byte) 13, -1, -1, -1));
            }
            break;
        case 4:
            if (c.getPlayer().getRPS() != null) {
                c.getPlayer().getRPS().dispose(c);
            } else {
                c.getSession().write(CField.getRPSMode((byte) 13, -1, -1, -1));
            }
            break;
    }
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:45,代码来源:NPCHandler.java

示例13: handle

import tools.data.LittleEndianAccessor; //导入方法依赖的package包/类
@PacketHandler(opcode = RecvPacketOpcode.CHAR_SELECT_NO_PIC)
public static void handle (MapleClient c, LittleEndianAccessor lea) {
	lea.readByte(); // 1?
       lea.readByte(); // 1?
       final int charid = lea.readInt();
       
       /*if (view) {
           c.setChannel(1);
           c.setWorld(lea.readInt());
       }*/
       
       final String currentpw = c.getSecondPassword();
       if (!c.isLoggedIn() || loginFailCount(c) || (currentpw != null && !currentpw.equals("")) || !c.login_Auth(charid) || ChannelServer.getInstance(c.getChannel()) == null || !WorldOption.isExists(c.getWorld())) {
           c.getSession().close();
           return;
       }
       //lea.skip(1); //prevents the ArrayIndexArrayOutOfBounds exception. Don't know what it is yet.
       c.updateMacs(lea.readMapleAsciiString());
       
       lea.readMapleAsciiString();
       
       if (lea.available() != 0) {
           final String setpassword = lea.readMapleAsciiString();

           if (setpassword.length() >= 6 && setpassword.length() <= 16) {
               c.setSecondPassword(setpassword);
               c.updateSecondPassword();
           } else {
               c.getSession().write(LoginPacket.secondPwError((byte) 0x14));
               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));
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:42,代码来源:CharacterWithoutSecondPassword.java


注:本文中的tools.data.LittleEndianAccessor.available方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。