MapleCharacter.java
资源名称:src.rar [点击查看]
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:217k
源码类别:
游戏
开发平台:
Java
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- maxhp = Math.min(30000, maxhp);
- maxmp = Math.min(30000, maxmp);
- List<Pair<MapleStat, Integer>> statup = new ArrayList<Pair<MapleStat, Integer>>(8);
- statup.add(new Pair<MapleStat, Integer>(MapleStat.AVAILABLEAP, Integer.valueOf(remainingAp)));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.MAXHP, Integer.valueOf(maxhp)));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.MAXMP, Integer.valueOf(maxmp)));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.HP, Integer.valueOf(maxhp)));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.MP, Integer.valueOf(maxmp)));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.EXP, Integer.valueOf(exp.get())));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.LEVEL, Integer.valueOf(level)));
- if (job != MapleJob.BEGINNER) {
- remainingSp += 30;
- statup.add(new Pair<MapleStat, Integer>(MapleStat.AVAILABLESP, Integer.valueOf(remainingSp)));
- }
- setHp(maxhp);
- setMp(maxmp);
- getClient().getSession().write(MaplePacketCreator.updatePlayerStats(statup));
- getMap().broadcastMessage(this, MaplePacketCreator.showLevelup(getId()), false);
- recalcLocalStats();
- silentPartyUpdate();
- guildUpdate();
- }
- public MapleInventory getInventory(MapleInventoryType type) {
- return inventory[type.ordinal()];
- }
- public MapleShop getShop() {
- return shop;
- }
- public void setShop(MapleShop shop) {
- this.shop = shop;
- }
- public int getMeso() {
- return meso.get();
- }
- public int getSavedLocation(SavedLocationType type) {
- return savedLocations[type.ordinal()];
- }
- public void saveLocation(SavedLocationType type) {
- savedLocations[type.ordinal()] = getMapId();
- }
- public void clearSavedLocation(SavedLocationType type) {
- savedLocations[type.ordinal()] = -1;
- }
- public void setMeso(int set) {
- meso.set(set);
- updateSingleStat(MapleStat.MESO, set, false);
- }
- public void gainMeso(int gain) {
- gainMeso(gain, true, false, false);
- }
- public void gainMeso(int gain, boolean show) {
- gainMeso(gain, show, false, false);
- }
- public void gainMeso(int gain, boolean show, boolean enableActions) {
- gainMeso(gain, show, enableActions, false);
- }
- public void gainMeso(int gain, boolean show, boolean enableActions, boolean inChat) {
- int newVal;
- if (meso.get() + gain >= Integer.MAX_VALUE) {
- meso.set(Integer.MAX_VALUE);
- newVal = Integer.MAX_VALUE;
- } else if (meso.get() + gain < 0) {
- meso.set(0);
- newVal = 0;
- } else {
- newVal = meso.addAndGet(gain);
- }
- updateSingleStat(MapleStat.MESO, newVal, enableActions);
- if (show) {
- client.getSession().write(MaplePacketCreator.getShowMesoGain(gain, inChat));
- }
- }
- /**
- * Adds this monster to the controlled list. The monster must exist on the Map.
- *
- * @param monster
- */
- public void controlMonster(MapleMonster monster, boolean aggro) {
- monster.setController(this);
- controlled.add(monster);
- client.getSession().write(MaplePacketCreator.controlMonster(monster, false, aggro));
- }
- public void stopControllingMonster(MapleMonster monster) {
- controlled.remove(monster);
- }
- public void checkMonsterAggro(MapleMonster monster) {
- if (!monster.isControllerHasAggro()) {
- if (monster.getController() == this) {
- monster.setControllerHasAggro(true);
- } else {
- monster.switchController(this, true);
- }
- }
- }
- public Collection<MapleMonster> getControlledMonsters() {
- return Collections.unmodifiableCollection(controlled);
- }
- public int getNumControlledMonsters() {
- return controlled.size();
- }
- @Override
- public String toString() {
- return "Character: " + this.name;
- }
- public int getAccountID() {
- return accountid;
- }
- public void mobKilled(int id) {
- for (MapleQuestStatus q : quests.values()) {
- if (q.getStatus() == MapleQuestStatus.Status.COMPLETED || q.getQuest().canComplete(this, null)) {
- continue;
- }
- if (q.mobKilled(id) && !(q.getQuest() instanceof MapleCustomQuest)) {
- client.getSession().write(MaplePacketCreator.updateQuestMobKills(q));
- if (q.getQuest().canComplete(this, null)) {
- client.getSession().write(MaplePacketCreator.getShowQuestCompletion(q.getQuest().getId()));
- }
- }
- }
- }
- public final List<MapleQuestStatus> getStartedQuests() {
- List<MapleQuestStatus> ret = new LinkedList<MapleQuestStatus>();
- for (MapleQuestStatus q : quests.values()) {
- if (q.getStatus().equals(MapleQuestStatus.Status.STARTED) && !(q.getQuest() instanceof MapleCustomQuest)) {
- ret.add(q);
- }
- }
- return Collections.unmodifiableList(ret);
- }
- public final List<MapleQuestStatus> getCompletedQuests() {
- List<MapleQuestStatus> ret = new LinkedList<MapleQuestStatus>();
- for (MapleQuestStatus q : quests.values()) {
- if (q.getStatus().equals(MapleQuestStatus.Status.COMPLETED) && !(q.getQuest() instanceof MapleCustomQuest)) {
- ret.add(q);
- }
- }
- return Collections.unmodifiableList(ret);
- }
- public IPlayerInteractionManager getInteraction() {
- return interaction;
- }
- public void setInteraction(IPlayerInteractionManager box) {
- interaction = box;
- }
- public Map<ISkill, SkillEntry> getSkills() {
- return Collections.unmodifiableMap(skills);
- }
- public void dispelSkill(int skillid) {
- LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList<MapleBuffStatValueHolder>(effects.values());
- for (MapleBuffStatValueHolder mbsvh : allBuffs) {
- if (skillid == 0) {
- if (mbsvh.effect.isSkill()) {
- switch (mbsvh.effect.getSourceId()) {
- case 1004:
- case 1321007:
- case 2121005:
- case 2221005:
- case 2311006:
- case 2321003:
- case 3111002:
- case 3111005:
- case 3211002:
- case 3211005:
- case 4111002:
- cancelEffect(mbsvh.effect, false, mbsvh.startTime);
- }
- }
- } else {
- if (mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skillid) {
- cancelEffect(mbsvh.effect, false, mbsvh.startTime);
- }
- }
- }
- }
- public boolean isActiveBuffedValue(int skillid) {
- LinkedList<MapleBuffStatValueHolder> allBuffs = new LinkedList<MapleBuffStatValueHolder>(effects.values());
- for (MapleBuffStatValueHolder mbsvh : allBuffs) {
- if (mbsvh.effect.isSkill() && mbsvh.effect.getSourceId() == skillid) {
- return true;
- }
- }
- return false;
- }
- public int getSkillLevel(ISkill skill) {
- SkillEntry ret = skills.get(skill);
- if (ret == null) {
- return 0;
- }
- return ret.skillevel;
- }
- public int getMasterLevel(ISkill skill) {
- SkillEntry ret = skills.get(skill);
- if (ret == null) {
- return 0;
- }
- return ret.masterlevel;
- }
- // the equipped inventory only contains equip... I hope
- public int getTotalDex() {
- return localdex;
- }
- public int getTotalInt() {
- return localint;
- }
- public int getTotalStr() {
- return localstr;
- }
- public int getTotalLuk() {
- return localluk;
- }
- public int getTotalMagic() {
- return magic;
- }
- public double getSpeedMod() {
- return speedMod;
- }
- public double getJumpMod() {
- return jumpMod;
- }
- public int getTotalWatk() {
- return watk;
- }
- public static int rand(int lbound, int ubound) {
- return (int) ((Math.random() * (ubound - lbound + 1)) + lbound);
- }
- public int getMaxDis(MapleCharacter player) {
- IItem weapon_item = player.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -11);
- if (weapon_item != null) {
- MapleWeaponType weapon = MapleItemInformationProvider.getInstance().getWeaponType(weapon_item.getItemId());
- if (weapon == MapleWeaponType.SPEAR || weapon == MapleWeaponType.POLE_ARM) {
- maxDis = 106;
- }
- if (weapon == MapleWeaponType.DAGGER || weapon == MapleWeaponType.SWORD1H || weapon == MapleWeaponType.AXE1H || weapon == MapleWeaponType.BLUNT1H) {
- maxDis = 63;
- }
- if (weapon == MapleWeaponType.SWORD2H || weapon == MapleWeaponType.AXE1H || weapon == MapleWeaponType.BLUNT1H) {
- maxDis = 73;
- }
- if (weapon == MapleWeaponType.STAFF || weapon == MapleWeaponType.WAND) {
- maxDis = 51;
- }
- if (weapon == MapleWeaponType.CLAW) {
- skil = SkillFactory.getSkill(4000001);
- skill = player.getSkillLevel(skil);
- if (skill > 0) {
- maxDis = (skil.getEffect(player.getSkillLevel(skil)).getRange()) + 205;
- } else {
- maxDis = 205;
- }
- }
- if (weapon == MapleWeaponType.BOW || weapon == MapleWeaponType.CROSSBOW) {
- skil = SkillFactory.getSkill(3000002);
- skill = player.getSkillLevel(skil);
- if (skill > 0) {
- maxDis = (skil.getEffect(player.getSkillLevel(skil)).getRange()) + 270;
- } else {
- maxDis = 270;
- }
- }
- }
- return maxDis;
- }
- public int getMesoMode() {
- return Mesomode;
- }
- public MonsterCarnival getMonsterCarnival() {
- return monsterCarnival;
- }
- public void setMonsterCarnival(MonsterCarnival monsterCarnival) {
- this.monsterCarnival = monsterCarnival;
- }
- public int getReborns() {
- return reborns;
- }
- public void gainReborns(int reborns) {
- this.reborns += 1;
- }
- public void gainvip(int vip) {
- this.vip += 1;
- }
- public int calculateMaxBaseDamage(int watk) {
- int maxbasedamage;
- if (watk == 0) {
- maxbasedamage = 1;
- } else {
- IItem weapon_item = getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -11);
- if (weapon_item != null) {
- MapleWeaponType weapon = MapleItemInformationProvider.getInstance().getWeaponType(weapon_item.getItemId());
- int mainstat;
- int secondarystat;
- if (weapon == MapleWeaponType.BOW || weapon == MapleWeaponType.CROSSBOW) {
- mainstat = localdex;
- secondarystat = localstr;
- } else if (getJob().isA(MapleJob.THIEF) && (weapon == MapleWeaponType.CLAW || weapon == MapleWeaponType.DAGGER)) {
- mainstat = localluk;
- secondarystat = localdex + localstr;
- } else {
- mainstat = localstr;
- secondarystat = localdex;
- }
- maxbasedamage = (int) (((weapon.getMaxDamageMultiplier() * mainstat + secondarystat) / 100.0) * watk);
- //just some saveguard against rounding errors, we want to a/b for this
- maxbasedamage += 10;
- } else {
- maxbasedamage = 0;
- }
- }
- return maxbasedamage;
- }
- public int calculateMinBaseDamage(MapleCharacter player) {
- int minbasedamage = 0;
- int atk = player.getTotalWatk();
- if (atk == 0) {
- minbasedamage = 1;
- } else {
- IItem weapon_item = getInventory(MapleInventoryType.EQUIPPED).getItem((byte) - 11);
- if (weapon_item != null) {
- MapleWeaponType weapon = MapleItemInformationProvider.getInstance().getWeaponType(weapon_item.getItemId());
- //mastery start
- if (player.getJob().isA(MapleJob.FIGHTER)) {
- skil = SkillFactory.getSkill(1100000);
- skill = player.getSkillLevel(skil);
- if (skill > 0) {
- sword = ((skil.getEffect(player.getSkillLevel(skil)).getMastery() * 5 + 10) / 100);
- } else {
- sword = 0.1;
- }
- } else {
- skil = SkillFactory.getSkill(1200000);
- skill = player.getSkillLevel(skil);
- if (skill > 0) {
- sword = ((skil.getEffect(player.getSkillLevel(skil)).getMastery() * 5 + 10) / 100);
- } else {
- sword = 0.1;
- }
- }
- skil = SkillFactory.getSkill(1100001);
- skill = player.getSkillLevel(skil);
- if (skill > 0) {
- axe = ((skil.getEffect(player.getSkillLevel(skil)).getMastery() * 5 + 10) / 100);
- } else {
- axe = 0.1;
- }
- skil = SkillFactory.getSkill(1200001);
- skill = player.getSkillLevel(skil);
- if (skill > 0) {
- blunt = ((skil.getEffect(player.getSkillLevel(skil)).getMastery() * 5 + 10) / 100);
- } else {
- blunt = 0.1;
- }
- skil = SkillFactory.getSkill(1300000);
- skill = player.getSkillLevel(skil);
- if (skill > 0) {
- spear = ((skil.getEffect(player.getSkillLevel(skil)).getMastery() * 5 + 10) / 100);
- } else {
- spear = 0.1;
- }
- skil = SkillFactory.getSkill(1300001);
- skill = player.getSkillLevel(skil);
- if (skill > 0) {
- polearm = ((skil.getEffect(player.getSkillLevel(skil)).getMastery() * 5 + 10) / 100);
- } else {
- polearm = 0.1;
- }
- skil = SkillFactory.getSkill(3200000);
- skill = player.getSkillLevel(skil);
- if (skill > 0) {
- crossbow = ((skil.getEffect(player.getSkillLevel(skil)).getMastery() * 5 + 10) / 100);
- } else {
- crossbow = 0.1;
- }
- skil = SkillFactory.getSkill(3100000);
- skill = player.getSkillLevel(skil);
- if (skill > 0) {
- bow = ((skil.getEffect(player.getSkillLevel(skil)).getMastery() * 5 + 10) / 100);
- } else {
- bow = 0.1;
- }
- //end mastery
- if (weapon == MapleWeaponType.CROSSBOW) {
- minbasedamage = (int) (localdex * 0.9 * 3.6 * crossbow + localstr) / 100 * (atk + 15);
- }
- if (weapon == MapleWeaponType.BOW) {
- minbasedamage = (int) (localdex * 0.9 * 3.4 * bow + localstr) / 100 * (atk + 15);
- }
- if (getJob().isA(MapleJob.THIEF) && (weapon == MapleWeaponType.DAGGER)) {
- minbasedamage = (int) (localluk * 0.9 * 3.6 * dagger + localstr + localdex) / 100 * atk;
- }
- if (!getJob().isA(MapleJob.THIEF) && (weapon == MapleWeaponType.DAGGER)) {
- minbasedamage = (int) (localstr * 0.9 * 4.0 * dagger + localdex) / 100 * atk;
- }
- if (getJob().isA(MapleJob.THIEF) && (weapon == MapleWeaponType.CLAW)) {
- minbasedamage = (int) (localluk * 0.9 * 3.6 * claw + localstr + localdex) / 100 * (atk + 15);
- }
- if (weapon == MapleWeaponType.SPEAR) {
- minbasedamage = (int) (localstr * 0.9 * 3.0 * spear + localdex) / 100 * atk;
- }
- if (weapon == MapleWeaponType.POLE_ARM) {
- minbasedamage = (int) (localstr * 0.9 * 3.0 * polearm + localdex) / 100 * atk;
- }
- if (weapon == MapleWeaponType.SWORD1H) {
- minbasedamage = (int) (localstr * 0.9 * 4.0 * sword + localdex) / 100 * atk;
- }
- if (weapon == MapleWeaponType.SWORD2H) {
- minbasedamage = (int) (localstr * 0.9 * 4.6 * sword + localdex) / 100 * atk;
- }
- if (weapon == MapleWeaponType.AXE1H) {
- minbasedamage = (int) (localstr * 0.9 * 3.2 * axe + localdex) / 100 * atk;
- }
- if (weapon == MapleWeaponType.BLUNT1H) {
- minbasedamage = (int) (localstr * 0.9 * 3.2 * blunt + localdex) / 100 * atk;
- }
- if (weapon == MapleWeaponType.AXE2H) {
- minbasedamage = (int) (localstr * 0.9 * 3.4 * axe + localdex) / 100 * atk;
- }
- if (weapon == MapleWeaponType.BLUNT2H) {
- minbasedamage = (int) (localstr * 0.9 * 3.4 * blunt + localdex) / 100 * atk;
- }
- if (weapon == MapleWeaponType.STAFF || weapon == MapleWeaponType.WAND) {
- minbasedamage = (int) (localstr * 0.9 * 3.0 * staffwand + localdex) / 100 * atk;
- }
- }
- }
- return minbasedamage;
- }
- public int getRandomage(MapleCharacter player) {
- int maxdamage = player.getCurrentMaxBaseDamage();
- int mindamage = player.calculateMinBaseDamage(player);
- return MapleCharacter.rand(mindamage, maxdamage);
- }
- public void levelUp() {
- ISkill improvingMaxHP = null;
- int improvingMaxHPLevel = 0;
- ISkill improvingMaxMP = SkillFactory.getSkill(2000001);
- int improvingMaxMPLevel = getSkillLevel(improvingMaxMP);
- remainingAp += 5 + getVip();
- if (job == MapleJob.BEGINNER) {
- maxhp += rand(12, 16);
- maxmp += rand(10, 12);
- } else if (job.isA(MapleJob.WARRIOR)) {
- improvingMaxHP = SkillFactory.getSkill(1000001);
- improvingMaxHPLevel = getSkillLevel(improvingMaxHP);
- maxhp += rand(24, 28);
- maxmp += rand(4, 6);
- } else if (job.isA(MapleJob.MAGICIAN)) {
- maxhp += rand(10, 14);
- maxmp += rand(22, 24);
- } else if (job.isA(MapleJob.BOWMAN) || job.isA(MapleJob.THIEF)) {
- maxhp += rand(20, 24);
- maxmp += rand(14, 16);
- } else if (job.isA(MapleJob.GM)) {
- maxhp += 30000;
- maxmp += 30000;
- } else if (job.isA(MapleJob.PIRATE)) {
- improvingMaxHP = SkillFactory.getSkill(5100000);
- improvingMaxHPLevel = getSkillLevel(improvingMaxHP);
- maxhp += rand(22, 28);
- maxmp += rand(18, 23);
- }
- if (improvingMaxHPLevel > 0 && (job.isA(MapleJob.WARRIOR) || job.isA(MapleJob.PIRATE)))
- maxhp += improvingMaxHP.getEffect(improvingMaxHPLevel).getX();
- if (improvingMaxMPLevel > 0 && (job.isA(MapleJob.MAGICIAN) || job == MapleJob.CRUSADER || job == MapleJob.HERO))
- maxmp += improvingMaxMP.getEffect(improvingMaxMPLevel).getX();
- maxmp += getTotalInt() / 10;
- exp.addAndGet(-ExpTable.getExpNeededForLevel(level));
- level += 1;
- if (juankuan == 1888)
- {
- getClient().getSession().write(MaplePacketCreator.serverNotice(1, "恭喜,你的慈善捐款的数目已经达到" + getjuankuan() + "亿冒险币.."));
- getClient().getSession().write(MaplePacketCreator.serverNotice(1, "恭喜玩家:" + getName() + "的慈善捐款的数目已经达到" + getjuankuan() + "亿冒险币!"));
- }
- if (getLevel() == 250) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到250级.让我们一起来喝彩他吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 249) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到249级.他还差最后一步就到250级.他的精神是崇高无上的!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 240) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到240级.让我们一起来喝彩他吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 239) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到239级.他还差最后一步就到240级.让我们为他加油吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 230) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到230级.让我们一起来喝彩他吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 229) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到229级.他还差最后一步就到230级.让我们为他加油吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 220) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到220级.让我们一起来喝彩他吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 219) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到219级.他还差最后一步就到220级.让我们为他加油吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 210) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到210级.让我们一起来喝彩他吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 209) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到209级.他还差最后一步就到210级.让我们为他加油吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 200) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到200级.让我们一起来喝彩他吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- if (getLevel() == 199) {
- exp.set(0);
- if(exp.get() > 0)
- exp.set(0);
- MaplePacket packet = MaplePacketCreator.serverNotice(6, "[公告事项]:恭喜玩家 " + getName() + " 终于辛苦达到199级.他还差最后一步就到200级了.让我们为他加油吧!");
- try {
- getClient().getChannelServer().getWorldInterface().broadcastMessage(getName(), packet.getBytes());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- //70,120自动转职
- NPCScriptManager npc = NPCScriptManager.getInstance();
- if (level == 10 || level == 30) {
- npc.start(client, 1002006, null, null);
- }
- if (level == 255) {
- npc.start(client, 1002006, null, null);
- }
- if (level == 70) {
- int[] autojob = {110, 120, 130, 210, 220, 230, 310, 320, 410, 420, 510, 520};
- for (int j : autojob) {
- if (getJob().getId() == j) {
- changeJob(MapleJob.getById(getJob().getId()+1));
- }
- }
- }
- if (level == 120) {
- int[] autojob = {111, 121, 131, 211, 221, 231, 311, 321, 411, 421, 511, 521};
- for (int j : autojob) {
- if (getJob().getId() == j) {
- changeJob(MapleJob.getById(getJob().getId()+1));
- }
- }
- }
- //结束
- maxhp = Math.min(30000, maxhp);
- maxmp = Math.min(30000, maxmp);
- List<Pair<MapleStat, Integer>> statup = new ArrayList<Pair<MapleStat, Integer>>(8);
- statup.add(new Pair<MapleStat, Integer>(MapleStat.AVAILABLEAP, Integer.valueOf(remainingAp)));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.MAXHP, Integer.valueOf(maxhp)));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.MAXMP, Integer.valueOf(maxmp)));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.HP, maxhp));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.MP, maxmp));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.EXP, Integer.valueOf(exp.get())));
- statup.add(new Pair<MapleStat, Integer>(MapleStat.LEVEL, Integer.valueOf(level)));
- if (job != MapleJob.BEGINNER) {//新手
- remainingSp += 3;
- statup.add(new Pair<MapleStat, Integer>(MapleStat.AVAILABLESP, Integer.valueOf(remainingSp)));
- }
- setHp(maxhp);
- setMp(maxmp);
- getClient().getSession().write(MaplePacketCreator.updatePlayerStats(statup));
- getMap().broadcastMessage(this, MaplePacketCreator.showForeignEffect(getId(), 0), false);
- recalcLocalStats();
- silentPartyUpdate();
- guildUpdate();
- }
- public void setExpEnabled(boolean c) {
- this.expEnabled = c;
- }
- public void gainFame(int delta) {
- this.addFame(delta);
- this.updateSingleStat(MapleStat.FAME, this.fame);
- }
- public int getCpqRanking() {
- return cpqRanking;
- }
- public void setCpqRanking(int cpqRanking) {
- this.cpqRanking = cpqRanking;
- }
- public long getLastPlayerKill() {
- return playerkill;
- }
- public void setLastPlayerKill(long Z) {
- playerkill = Z;
- }
- public void setPlayerShop(MaplePlayerShop playerShop) {
- this.playerShop = playerShop;
- }
- public boolean isChallenged() {
- return challenged;
- }
- public void changeKeybinding(int key, MapleKeyBinding keybinding) {
- if (keybinding.getType() != 0) {
- keymap.put(Integer.valueOf(key), keybinding);
- } else {
- keymap.remove(Integer.valueOf(key));
- }
- }
- public void sendKeymap() {
- getClient().getSession().write(MaplePacketCreator.getKeymap(keymap));
- }
- public void sendMacros() {
- boolean macros = false;
- for (int i = 0; i < 5; i++) {
- if (skillMacros[i] != null) {
- macros = true;
- }
- }
- if (macros) {
- getClient().getSession().write(MaplePacketCreator.getMacros(skillMacros));
- }
- }
- public int hasexp() {
- if (getLevel()<=30){
- return 4;//低于30级打怪得到5倍经验
- }else if (getLevel()>=31 && getLevel()<=70 && getVip()<9){
- return 3;//31-70级4倍经验
- }else if (getLevel()>=71 && getLevel()<=90 && getVip()<8){
- return 2;
- }else if (getLevel()>=91 && getLevel()<=120 && getVip()<5){
- return 1;
- }else{
- return 0;
- }
- }
- public void updateMacros(int position, SkillMacro updateMacro) {
- skillMacros[position] = updateMacro;
- }
- public void setSlot(int slotid) {
- slots = slotid;
- }
- public int getSlot() {
- return slots;
- }
- public int getSlots(byte b) {
- for (Pair<Byte, Integer> curPair : inventorySlots)
- if (curPair.getLeft() == b)
- return curPair.getRight();
- return 100;
- }
- public void tempban(String reason, Calendar duration, int greason) {
- tempban(reason, duration, greason, client.getAccID());
- client.getSession().write(MaplePacketCreator.sendGMPolice(greason, reason, (int) (duration.getTimeInMillis() / 1000))); //put duration as seconds
- TimerManager.getInstance().schedule(new Runnable() {
- public void run() {
- client.getSession().close();
- }
- }, 10000);
- }
- public static boolean tempban(String reason, Calendar duration, int greason, int accountid) {
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("UPDATE accounts SET tempban = ?, banreason = ?, greason = ? WHERE id = ?");
- Timestamp TS = new Timestamp(duration.getTimeInMillis());
- ps.setTimestamp(1, TS);
- ps.setString(2, reason);
- ps.setInt(3, greason);
- ps.setInt(4, accountid);
- ps.executeUpdate();
- ps.close();
- return true;
- } catch (SQLException ex) {
- System.err.println("Error while tempbanning");
- }
- return false;
- }
- public void ban(String reason, boolean permBan) {
- if (!client.isGuest()) {
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps;
- if (permBan) {
- getClient().banMacs();
- ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)");
- String[] ipSplit = client.getSession().getRemoteAddress().toString().split(":");
- ps.setString(1, ipSplit[0]);
- ps.executeUpdate();
- ps.close();
- }
- ps = con.prepareStatement("UPDATE accounts SET banned = ?, banreason = ?, greason = ? WHERE id = ?");
- ps.setInt(1, 1);
- ps.setString(2, reason);
- ps.setInt(3, 12);
- ps.setInt(4, accountid);
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- System.err.println("Error while banning");
- }
- }
- client.getSession().write(MaplePacketCreator.sendGMPolice(0, reason, 1000000)); // Thanks zerofusion.
- TimerManager.getInstance().schedule(new Runnable() {
- public void run() {
- client.getSession().close();
- }
- }, 10000);
- }
- public int getAuto(String type) {
- ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps;
- String name = this.getName();
- int autoint = 0;
- try {
- ps = con.prepareStatement("SELECT * FROM characters WHERE name = ?");
- ps.setString(1, name);
- ResultSet rs = ps.executeQuery();
- if (!rs.next())
- {
- ps.close();
- }
- autoint = rs.getInt("auto"+type);
- ps.close();
- return autoint;
- }
- catch (SQLException e) {cm.dropMessage("Exception has occured: "+e);}
- return autoint;
- }
- public void setAuto(String type, int num) {
- ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps;
- String name = this.getName();
- try {
- ps = con.prepareStatement("UPDATE characters SET auto"+type+" = "+num+" WHERE name = ?");
- ps.setString(1, name);
- ps.executeUpdate();
- ps.close();
- }
- catch (SQLException e) {cm.dropMessage("Exception has occured: "+e); return;}
- }
- public static boolean ban(String id, String reason, boolean accountId) {
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps;
- if (id.matches("/[0-9]{1,3}\..*")) {
- //ps = con.prepareStatement("INSERT INTO ipbans VALUES (DEFAULT, ?)");
- ps = con.prepareStatement("INSERT INTO macbans VALUES (DEFAULT, ?)");
- ps.setString(1, id);
- ps.executeUpdate();
- ps.close();
- }
- if (accountId) {
- ps = con.prepareStatement("SELECT id FROM accounts WHERE name = ?");
- } else {
- ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
- }
- boolean ret = false;
- ps.setString(1, id);
- ResultSet rs = ps.executeQuery();
- if (rs.next()) {
- ps = con.prepareStatement("UPDATE accounts SET banned = 1, banreason = ? WHERE id = ?");
- ps.setString(1, reason);
- ps.setInt(2, rs.getInt(1));
- ps.executeUpdate();
- ret = true;
- }
- rs.close();
- ps.close();
- return ret;
- } catch (SQLException ex) {
- System.err.println("Error while banning");
- }
- return false;
- }
- public static int getAccIdFromCNAME(String name) {
- Connection con = DatabaseConnection.getConnection();
- try {
- PreparedStatement ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
- ps.setString(1, name);
- ResultSet rs = ps.executeQuery();
- if (!rs.next()) {
- ps.close();
- return -1;
- }
- int id_ = rs.getInt("accountid");
- ps.close();
- return id_;
- } catch (SQLException e) {
- System.err.println("ERROR");
- }
- return -1;
- }
- public void setChallenged(boolean challenged) {
- this.challenged = challenged;
- }
- /**
- * Oid of players is always = the cid
- */
- @Override
- public int getObjectId() {
- return getId();
- }
- /**
- * Throws unsupported operation exception, oid of players is read only
- */
- @Override
- public void setObjectId(int id) {
- throw new UnsupportedOperationException();
- }
- public MapleStorage getStorage() {
- return storage;
- }
- public int getCurrentMaxHp() {
- return localmaxhp;
- }
- public int getCurrentMaxMp() {
- return localmaxmp;
- }
- public int getCurrentMaxBaseDamage() {
- return localmaxbasedamage;
- }
- public int getTotalMdef() {
- return mdef;
- }
- public int getTotalWdef() {
- return wdef;
- }
- public void addVisibleMapObject(MapleMapObject mo) {
- visibleMapObjects.add(mo);
- }
- public void removeVisibleMapObject(MapleMapObject mo) {
- visibleMapObjects.remove(mo);
- }
- public boolean isMapObjectVisible(MapleMapObject mo) {
- return visibleMapObjects.contains(mo);
- }
- public Collection<MapleMapObject> getVisibleMapObjects() {
- return Collections.unmodifiableCollection(visibleMapObjects);
- }
- public boolean isAlive() {
- return this.hp > 0;
- }
- public boolean isDead() {
- return this.hp <= 0;
- }
- @Override
- public void sendDestroyData(MapleClient client) {
- client.getSession().write(MaplePacketCreator.removePlayerFromMap(this.getObjectId()));
- }
- @Override
- public void sendSpawnData(MapleClient client) {
- if ((this.isHidden() && client.getPlayer().isGM()) || !this.isHidden()) {
- client.getSession().write(MaplePacketCreator.spawnPlayerMapobject(this));
- for (int i = 0; i < 3; i++) {
- if (pets[i] != null) {
- client.getSession().write(MaplePacketCreator.showPet(this, pets[i], false, false));
- } else {
- break;
- }
- }
- }
- }
- private void recalcLocalStats() {
- int oldmaxhp = localmaxhp;
- localmaxhp = getMaxHp();
- localmaxmp = getMaxMp();
- localdex = getDex();
- localint = getInt();
- localstr = getStr();
- localluk = getLuk();
- int speed = 100;
- int jump = 100;
- magic = localint;
- watk = 0;
- wdef = 0;
- mdef = 0;
- for (IItem item : getInventory(MapleInventoryType.EQUIPPED)) {
- IEquip equip = (IEquip) item;
- localmaxhp += equip.getHp();
- localmaxmp += equip.getMp();
- localdex += equip.getDex();
- localint += equip.getInt();
- localstr += equip.getStr();
- localluk += equip.getLuk();
- magic += equip.getMatk() + equip.getInt();
- watk += equip.getWatk();
- speed += equip.getSpeed();
- jump += equip.getJump();
- wdef += equip.getWdef();
- mdef += equip.getMdef();
- }
- magic = Math.min(magic, 2000);
- Integer hbhp = getBuffedValue(MapleBuffStat.HYPERBODYHP);
- if (hbhp != null) {
- localmaxhp += (hbhp.doubleValue() / 100) * localmaxhp;
- }
- Integer hbmp = getBuffedValue(MapleBuffStat.HYPERBODYMP);
- if (hbmp != null) {
- localmaxmp += (hbmp.doubleValue() / 100) * localmaxmp;
- }
- localmaxhp = Math.min(30000, localmaxhp);
- localmaxmp = Math.min(30000, localmaxmp);
- Integer watkbuff = getBuffedValue(MapleBuffStat.WATK);
- if (watkbuff != null) {
- watk += watkbuff.intValue();
- }
- if (job.isA(MapleJob.BOWMAN)) {
- ISkill expert = null;
- if (job.isA(MapleJob.CROSSBOWMASTER)) {
- expert = SkillFactory.getSkill(3220004);
- } else if (job.isA(MapleJob.BOWMASTER)) {
- expert = SkillFactory.getSkill(3120005);
- }
- if (expert != null) {
- int boostLevel = getSkillLevel(expert);
- if (boostLevel > 0) {
- watk += expert.getEffect(boostLevel).getX();
- }
- }
- }
- Integer matkbuff = getBuffedValue(MapleBuffStat.MATK);
- if (matkbuff != null) {
- magic += matkbuff.intValue();
- }
- Integer speedbuff = getBuffedValue(MapleBuffStat.SPEED);
- if (speedbuff != null) {
- speed += speedbuff.intValue();
- }
- Integer jumpbuff = getBuffedValue(MapleBuffStat.JUMP);
- if (jumpbuff != null) {
- jump += jumpbuff.intValue();
- }
- if (speed > 140) {
- speed = 140;
- }
- if (jump > 123) {
- jump = 123;
- }
- speedMod = speed / 100.0;
- jumpMod = jump / 100.0;
- Integer mount = getBuffedValue(MapleBuffStat.MONSTER_RIDING);
- if (mount != null) {
- jumpMod = 1.23;
- switch (mount.intValue()) {
- case 1:
- speedMod = 1.5;
- break;
- case 2:
- speedMod = 1.7;
- break;
- case 3:
- speedMod = 1.8;
- break;
- case 5:
- speedMod = 1.0;
- jumpMod = 1.0;
- break;
- default:
- speedMod = 2.0;
- }
- }
- localmaxbasedamage = calculateMaxBaseDamage(watk);
- if (oldmaxhp != 0 && oldmaxhp != localmaxhp) {
- updatePartyMemberHP();
- }
- }
- public void Mount(int id, int skillid) {
- maplemount = new MapleMount(this, id, skillid);
- }
- public MapleMount getMount() {
- return maplemount;
- }
- public void equipChanged() {
- getMap().broadcastMessage(this, MaplePacketCreator.updateCharLook(this), false);
- recalcLocalStats();
- enforceMaxHpMp();
- if (getClient().getPlayer().getMessenger() != null) {
- WorldChannelInterface wci = ChannelServer.getInstance(getClient().getChannel()).getWorldInterface();
- try {
- wci.updateMessenger(getClient().getPlayer().getMessenger().getId(), getClient().getPlayer().getName(), getClient().getChannel());
- } catch (RemoteException e) {
- getClient().getChannelServer().reconnectWorld();
- }
- }
- }
- public MaplePet getPet(int index) {
- return pets[index];
- }
- public void addPet(MaplePet pet) {
- for (int i = 0; i < 3; i++) {
- if (pets[i] == null) {
- pets[i] = pet;
- return;
- }
- }
- }
- public void removePet(MaplePet pet, boolean shift_left) {
- int slot = -1;
- for (int i = 0; i < 3; i++) {
- if (pets[i] != null) {
- if (pets[i].getUniqueId() == pet.getUniqueId()) {
- pets[i] = null;
- slot = i;
- break;
- }
- }
- }
- if (shift_left) {
- if (slot > -1) {
- for (int i = slot; i < 3; i++) {
- if (i != 2) {
- pets[i] = pets[i + 1];
- } else {
- pets[i] = null;
- }
- }
- }
- }
- }
- public int getNoPets() {
- int ret = 0;
- for (int i = 0; i < 3; i++) {
- if (pets[i] != null) {
- ret++;
- } else {
- break;
- }
- }
- return ret;
- }
- public int getPetIndex(MaplePet pet) {
- for (int i = 0; i < 3; i++) {
- if (pets[i] != null) {
- if (pets[i].getUniqueId() == pet.getUniqueId()) {
- return i;
- }
- } else {
- break;
- }
- }
- return -1;
- }
- public int getPetIndex(int petId) {
- for (int i = 0; i < 3; i++) {
- if (pets[i] != null) {
- if (pets[i].getUniqueId() == petId) {
- return i;
- }
- } else {
- break;
- }
- }
- return -1;
- }
- public int getNextEmptyPetIndex() {
- for (int i = 0; i < 3; i++) {
- if (pets[i] == null) {
- return i;
- }
- }
- return 3;
- }
- public MaplePet[] getPets() {
- return pets;
- }
- public void unequipAllPets() {
- for (int i = 0; i < 3; i++) {
- if (pets[i] != null) {
- unequipPet(pets[i], true);
- cancelFullnessSchedule(i);
- } else {
- break;
- }
- }
- }
- public void unequipPet(MaplePet pet, boolean shift_left) {
- unequipPet(pet, shift_left, false);
- }
- public void unequipPet(MaplePet pet, boolean shift_left, boolean hunger) {
- cancelFullnessSchedule(getPetIndex(pet));
- pet.saveToDb();
- // Broadcast the packet to the map - with null instead of MaplePet
- getMap().broadcastMessage(this, MaplePacketCreator.showPet(this, pet, true, hunger), true);
- // Make a new list for the stat updates
- List<Pair<MapleStat, Integer>> stats = new ArrayList<Pair<MapleStat, Integer>>();
- stats.add(new Pair<MapleStat, Integer>(MapleStat.PET, Integer.valueOf(0)));
- // Write the stat update to the player...
- getClient().getSession().write(MaplePacketCreator.petStatUpdate(this));
- getClient().getSession().write(MaplePacketCreator.enableActions());
- // Un-assign the pet set to the player
- removePet(pet, shift_left);
- }
- public void shiftPetsRight() {
- if (pets[2] == null) {
- pets[2] = pets[1];
- pets[1] = pets[0];
- pets[0] = null;
- }
- }
- public FameStatus canGiveFame(MapleCharacter from) {
- if (lastfametime >= System.currentTimeMillis() - 60 * 60 * 24 * 1000) {
- return FameStatus.NOT_TODAY;
- } else if (lastmonthfameids.contains(Integer.valueOf(from.getId()))) {
- return FameStatus.NOT_THIS_MONTH;
- } else {
- return FameStatus.OK;
- }
- }
- public void hasGivenFame(MapleCharacter to) {
- lastfametime = System.currentTimeMillis();
- lastmonthfameids.add(Integer.valueOf(to.getId()));
- Connection con = DatabaseConnection.getConnection();
- try {
- PreparedStatement ps = con.prepareStatement("INSERT INTO famelog (characterid, characterid_to) VALUES (?, ?)");
- ps.setInt(1, getId());
- ps.setInt(2, to.getId());
- ps.executeUpdate();
- ps.close();
- } catch (SQLException e) {
- System.err.println("ERROR writing famelog for char " + getName() + " to " + to.getName());
- }
- }
- public MapleParty getParty() {
- return party;
- }
- public int getPartyId() {
- return (party != null ? party.getId() : -1);
- }
- public int getWorld() {
- return world;
- }
- public void setWorld(int world) {
- this.world = world;
- }
- public void setParty(MapleParty party) {
- this.party = party;
- }
- public MapleTrade getTrade() {
- return trade;
- }
- public void setTrade(MapleTrade trade) {
- this.trade = trade;
- }
- public EventInstanceManager getEventInstance() {
- return eventInstance;
- }
- public void setEventInstance(EventInstanceManager eventInstance) {
- this.eventInstance = eventInstance;
- }
- public void addDoor(MapleDoor door) {
- doors.add(door);
- }
- public void clearDoors() {
- doors.clear();
- }
- public List<MapleDoor> getDoors() {
- return new ArrayList<MapleDoor>(doors);
- }
- public boolean canDoor() {
- return canDoor;
- }
- public void disableDoor() {
- canDoor = false;
- TimerManager tMan = TimerManager.getInstance();
- tMan.schedule(new Runnable() {
- @Override
- public void run() {
- canDoor = true;
- }
- }, 5000);
- }
- public Map<Integer, MapleSummon> getSummons() {
- return summons;
- }
- public int getChair() {
- return chair;
- }
- public int getItemEffect() {
- return itemEffect;
- }
- public void setChair(int chair) {
- this.chair = chair;
- }
- public void setItemEffect(int itemEffect) {
- this.itemEffect = itemEffect;
- }
- @Override
- public Collection<MapleInventory> allInventories() {
- return Arrays.asList(inventory);
- }
- @Override
- public MapleMapObjectType getType() {
- return MapleMapObjectType.PLAYER;
- }
- public int getGuildId() {
- return guildid;
- }
- public int getGuildRank() {
- return guildrank;
- }
- public void setGuildId(int _id) {
- guildid = _id;
- if (guildid > 0) {
- if (mgc == null) {
- mgc = new MapleGuildCharacter(this);
- } else {
- mgc.setGuildId(guildid);
- }
- } else {
- mgc = null;
- }
- }
- public void setGuildRank(int _rank) {
- guildrank = _rank;
- if (mgc != null) {
- mgc.setGuildRank(_rank);
- }
- }
- public void setAllianceRank(int rank) {
- allianceRank = rank;
- if (mgc != null) {
- mgc.setAllianceRank(rank);
- }
- }
- public int getAllianceRank() {
- return this.allianceRank;
- }
- public MapleGuildCharacter getMGC() {
- return mgc;
- }
- public void guildUpdate() {
- if (this.guildid <= 0) {
- return;
- }
- mgc.setLevel(this.level);
- mgc.setJobId(this.job.getId());
- try {
- this.client.getChannelServer().getWorldInterface().memberLevelJobUpdate(this.mgc);
- int allianceId = getGuild().getAllianceId();
- if (allianceId > 0) {
- client.getChannelServer().getWorldInterface().allianceMessage(allianceId, MaplePacketCreator.updateAllianceJobLevel(this), getId(), -1);
- }
- } catch (RemoteException re) {
- System.err.println("RemoteExcept while trying to update level/job in guild.");
- }
- }
- private NumberFormat nf = new DecimalFormat("#,###,###,###");
- public String guildCost() {
- return nf.format(MapleGuild.CREATE_GUILD_COST);
- }
- public String emblemCost() {
- return nf.format(MapleGuild.CHANGE_EMBLEM_COST);
- }
- public String capacityCost() {
- return nf.format(MapleGuild.INCREASE_CAPACITY_COST);
- }
- public void genericGuildMessage(int code) {
- this.client.getSession().write(MaplePacketCreator.genericGuildMessage((byte) code));
- }
- public void disbandGuild() {
- if (guildid <= 0 || guildrank != 1) {
- log.warn(this.name + " tried to disband and s/he is either not in a guild or not leader.");
- return;
- }
- try {
- client.getChannelServer().getWorldInterface().disbandGuild(this.guildid);
- } catch (RemoteException e) {
- client.getChannelServer().reconnectWorld();
- System.err.println("Error while disbanding guild.");
- }
- }
- public void increaseGuildCapacity() {
- if (this.getMeso() < MapleGuild.INCREASE_CAPACITY_COST) {
- client.getSession().write(MaplePacketCreator.serverNotice(1, "You do not have enough mesos."));
- return;
- }
- if (this.guildid <= 0) {
- log.info(this.name + " is trying to increase guild capacity without being in the guild.");
- return;
- }
- try {
- client.getChannelServer().getWorldInterface().increaseGuildCapacity(this.guildid);
- } catch (RemoteException e) {
- client.getChannelServer().reconnectWorld();
- System.err.println("Error while increasing capacity.");
- return;
- }
- this.gainMeso(-MapleGuild.INCREASE_CAPACITY_COST, true, false, true);
- }
- public void saveGuildStatus() {
- Connection con = DatabaseConnection.getConnection();
- try {
- PreparedStatement ps = con.prepareStatement("UPDATE characters SET guildid = ?, guildrank = ?, allianceRank = ? WHERE id = ?");
- ps.setInt(1, this.guildid);
- ps.setInt(2, this.guildrank);
- ps.setInt(3, this.allianceRank);
- ps.setInt(4, this.id);
- ps.execute();
- ps.close();
- } catch (SQLException se) {
- System.err.println("SQL error: " + se.getLocalizedMessage());
- }
- }
- /**
- * Allows you to change someone's NXCash, Maple Points, and Gift Tokens!
- *
- * Created by Acrylic/Penguins
- *
- * @param type: 0 = NX, 1 = MP, 2 = GT
- * @param quantity: how much to modify it by. Negatives subtract points, Positives add points.
- */
- public void modifyCSPoints(int type, int quantity) {
- switch (type) {
- case 1:
- this.paypalnx += quantity;
- break;
- case 2:
- this.maplepoints += quantity;
- break;
- case 4:
- this.cardnx += quantity;
- break;
- }
- }
- public int getCSPoints(int type) {
- switch (type) {
- case 1:
- return this.paypalnx;
- case 2:
- return this.maplepoints;
- case 4:
- return this.cardnx;
- default:
- return 0;
- }
- }
- public boolean haveItem(int itemid, int quantity, boolean checkEquipped, boolean greaterOrEquals) {
- int possesed = getItemQuantity(itemid, checkEquipped);
- if (greaterOrEquals) {
- return possesed >= quantity;
- } else {
- return possesed == quantity;
- }
- }
- public void makeVip() {
- this.client.getSession().close();
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("UPDATE characters SET vip = ? WHERE id = ?");
- ps.setInt(1, 1);
- ps.setInt(2, this.id);
- ps.executeUpdate();
- ps.close();
- }
- catch (SQLException ex) {
- }
- }
- public void unVip() {
- this.client.getSession().close();
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("UPDATE characters SET vip = ? WHERE id = ?");
- ps.setInt(1, 0);
- ps.setInt(2, this.id);
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- }
- }
- public void makeVip2() {
- this.client.getSession().close();
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("UPDATE characters SET vip = ? WHERE id = ?");
- ps.setInt(1, 2);
- ps.setInt(2, this.id);
- ps.executeUpdate();
- ps.close();
- }
- catch (SQLException ex) {
- }
- }
- public void makeVip3() {
- this.client.getSession().close();
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("UPDATE characters SET vip = ? WHERE id = ?");
- ps.setInt(1, 3);
- ps.setInt(2, this.id);
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- }
- }
- public void makeVip4() {
- this.client.getSession().close();
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("UPDATE characters SET vip = ? WHERE id = ?");
- ps.setInt(1, 4);
- ps.setInt(2, this.id);
- ps.executeUpdate();
- ps.close();
- }
- catch (SQLException ex) {
- }
- }
- private static class MapleBuffStatValueHolder {
- public MapleStatEffect effect;
- public long startTime;
- public int value;
- public ScheduledFuture<?> schedule;
- public MapleBuffStatValueHolder(MapleStatEffect effect, long startTime, ScheduledFuture<?> schedule, int value) {
- super();
- this.effect = effect;
- this.startTime = startTime;
- this.schedule = schedule;
- this.value = value;
- }
- }
- public static class MapleCoolDownValueHolder {
- public int skillId;
- public long startTime;
- public long length;
- public ScheduledFuture<?> timer;
- public MapleCoolDownValueHolder(int skillId, long startTime, long length, ScheduledFuture<?> timer) {
- super();
- this.skillId = skillId;
- this.startTime = startTime;
- this.length = length;
- this.timer = timer;
- }
- }
- public static class SkillEntry {
- public int skillevel;
- public int masterlevel;
- public SkillEntry(int skillevel, int masterlevel) {
- this.skillevel = skillevel;
- this.masterlevel = masterlevel;
- }
- @Override
- public String toString() {
- return skillevel + ":" + masterlevel;
- }
- }
- public enum FameStatus {
- OK, NOT_TODAY, NOT_THIS_MONTH
- }
- public int getBuddyCapacity() {
- return buddylist.getCapacity();
- }
- public void setBuddyCapacity(int capacity) {
- buddylist.setCapacity(capacity);
- client.getSession().write(MaplePacketCreator.updateBuddyCapacity(capacity));
- }
- public MapleMessenger getMessenger() {
- return messenger;
- }
- public void setMessenger(MapleMessenger messenger) {
- this.messenger = messenger;
- }
- public void checkMessenger() {
- if (messenger != null && messengerposition < 4 && messengerposition > -1) {
- try {
- WorldChannelInterface wci = ChannelServer.getInstance(client.getChannel()).getWorldInterface();
- MapleMessengerCharacter messengerplayer = new MapleMessengerCharacter(client.getPlayer(), messengerposition);
- wci.silentJoinMessenger(messenger.getId(), messengerplayer, messengerposition);
- wci.updateMessenger(getClient().getPlayer().getMessenger().getId(), getClient().getPlayer().getName(), getClient().getChannel());
- } catch (RemoteException e) {
- client.getChannelServer().reconnectWorld();
- }
- }
- }
- public int getMessengerPosition() {
- return messengerposition;
- }
- public void setMessengerPosition(int position) {
- this.messengerposition = position;
- }
- public int hasEXPCard() {
- int hr = Calendar.getInstance().get(Calendar.HOUR_OF_DAY); //增加时间函数
- if ((haveItem(5211048) && hr > 0 && hr < 24)
- || (haveItem(5211000) && hr > 17 && hr < 21)
- || (haveItem(5211014) && hr > 6 && hr < 12)
- || (haveItem(5211015) && hr > 9 && hr < 15)
- || (haveItem(5211016) && hr > 12 && hr < 18)
- || (haveItem(5211017) && hr > 15 && hr < 21)
- || (haveItem(5211018) && hr > 14)
- || (haveItem(5211039) && hr < 5)
- || (haveItem(5211042) && hr > 2 && hr < 8)
- || (haveItem(5211045) && hr > 5 && hr < 11)) {
- return 2;
- }
- return 1;
- }
- public void setInCS(boolean yesno) {
- this.incs = yesno;
- }
- public boolean inCS() {
- return this.incs;
- }
- public void setInMTS(boolean yesno) {
- this.inmts = yesno;
- }
- public boolean inMTS() {
- return this.inmts;
- }
- public void addCooldown(int skillId, long startTime, long length, ScheduledFuture<?> timer) {
- if (this.coolDowns.containsKey(Integer.valueOf(skillId))) {
- this.coolDowns.remove(skillId);
- }
- this.coolDowns.put(Integer.valueOf(skillId), new MapleCoolDownValueHolder(skillId, startTime, length, timer));
- }
- public void removeCooldown(int skillId) {
- if (this.coolDowns.containsKey(Integer.valueOf(skillId))) {
- this.coolDowns.remove(Integer.valueOf(skillId));
- client.getSession().write(MaplePacketCreator.skillCooldown(skillId, 0));
- }
- }
- public boolean skillisCooling(int skillId) {
- return this.coolDowns.containsKey(Integer.valueOf(skillId));
- }
- public void giveCoolDowns(final List<PlayerCoolDownValueHolder> cooldowns) {
- for (PlayerCoolDownValueHolder cooldown : cooldowns) {
- int time = (int) ((cooldown.length + cooldown.startTime) - System.currentTimeMillis());
- ScheduledFuture<?> timer = TimerManager.getInstance().schedule(new CancelCooldownAction(this, cooldown.skillId), time);
- addCooldown(cooldown.skillId, System.currentTimeMillis(), time, timer);
- }
- }
- public void giveCoolDowns(final int skillid, long starttime, long length) {
- int time = (int) ((length + starttime) - System.currentTimeMillis());
- ScheduledFuture<?> timer = TimerManager.getInstance().schedule(new CancelCooldownAction(this, skillid), time);
- addCooldown(skillid, System.currentTimeMillis(), time, timer);
- }
- public List<PlayerCoolDownValueHolder> getAllCooldowns() {
- List<PlayerCoolDownValueHolder> ret = new ArrayList<PlayerCoolDownValueHolder>();
- for (MapleCoolDownValueHolder mcdvh : coolDowns.values()) {
- ret.add(new PlayerCoolDownValueHolder(mcdvh.skillId, mcdvh.startTime, mcdvh.length));
- }
- return ret;
- }
- public static class CancelCooldownAction implements Runnable {
- private int skillId;
- private WeakReference<MapleCharacter> target;
- public CancelCooldownAction(MapleCharacter target, int skillId) {
- this.target = new WeakReference<MapleCharacter>(target);
- this.skillId = skillId;
- }
- @Override
- public void run() {
- MapleCharacter realTarget = target.get();
- if (realTarget != null) {
- realTarget.removeCooldown(skillId);
- }
- }
- }
- public void giveDebuff(MapleDisease disease, MobSkill skill) {
- if (!isGM()) {
- synchronized (diseases) {
- if (isAlive() && !isActiveBuffedValue(2321005) && !diseases.contains(disease) && diseases.size() < 2) {
- diseases.add(disease);
- List<Pair<MapleDisease, Integer>> debuff = Collections.singletonList(new Pair<MapleDisease, Integer>(disease, Integer.valueOf(skill.getX())));
- long mask = 0;
- for (Pair<MapleDisease, Integer> statup : debuff) {
- mask |= statup.getLeft().getValue();
- }
- getClient().getSession().write(MaplePacketCreator.giveDebuff(mask, debuff, skill));
- getMap().broadcastMessage(this, MaplePacketCreator.giveForeignDebuff(id, mask, skill), false);
- if (isAlive()) {
- final MapleCharacter character = this;
- final MapleDisease disease_ = disease;
- TimerManager.getInstance().schedule(new Runnable() {
- @Override
- public void run() {
- if (character.diseases.contains(disease_)) {
- dispelDebuff(disease_);
- }
- }
- }, skill.getDuration());
- }
- }
- }
- }
- }
- public void dispelDebuff(MapleDisease debuff) {
- if (diseases.contains(debuff)) {
- diseases.remove(debuff);
- long mask = debuff.getValue();
- getClient().getSession().write(MaplePacketCreator.cancelDebuff(mask));
- getMap().broadcastMessage(this, MaplePacketCreator.cancelForeignDebuff(id, mask), false);
- }
- }
- public MapleCharacter getPartner() {
- return client.getChannelServer().getPlayerStorage().getCharacterById(partnerid);
- }
- public void dispelDebuffs() {
- MapleDisease[] disease = {MapleDisease.POISON, MapleDisease.SLOW, MapleDisease.SEAL, MapleDisease.DARKNESS, MapleDisease.WEAKEN, MapleDisease.CURSE};
- for (int i = 0; i < diseases.size(); i++) {
- if (diseases.contains(disease[i])) {
- diseases.remove(disease);
- long mask = 0;
- for (MapleDisease statup : diseases) {
- mask |= statup.getValue();
- }
- getClient().getSession().write(MaplePacketCreator.cancelDebuff(mask));
- getMap().broadcastMessage(this, MaplePacketCreator.cancelForeignDebuff(id, mask), false);
- }
- }
- }
- public void setLevel(int level) {
- this.level = level - 1;
- }
- public void setMap(int PmapId) {
- this.mapid = PmapId;
- }
- public List<Integer> getQuestItemsToShow() {
- Set<Integer> delta = new HashSet<Integer>();
- for (Map.Entry<MapleQuest, MapleQuestStatus> questEntry : this.quests.entrySet()) {
- if (questEntry.getValue().getStatus() != MapleQuestStatus.Status.STARTED) {
- delta.addAll(questEntry.getKey().getQuestItemsToShowOnlyIfQuestIsActivated());
- }
- }
- List<Integer> returnThis = new ArrayList<Integer>();
- returnThis.addAll(delta);
- return Collections.unmodifiableList(returnThis);
- }
- public void showNote() throws SQLException {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("SELECT * FROM notes WHERE `to`=?", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
- ps.setInt(1, getId());
- ResultSet rs = ps.executeQuery();
- rs.last();
- int count = rs.getRow();
- rs.first();
- client.getSession().write(MaplePacketCreator.showNotes(rs, count));
- ps.close();
- }
- public int getMarriageQuestLevel() {
- return marriageQuestLevel;
- }
- public void setMarriageQuestLevel(int nf) {
- marriageQuestLevel = nf;
- }
- public void addMarriageQuestLevel() {
- marriageQuestLevel++;
- }
- public void subtractMarriageQuestLevel() {
- marriageQuestLevel -= 1;
- }
- public void setZakumLevel(int level) {
- this.zakumLvl = level;
- }
- public int getZakumLevel() {
- return this.zakumLvl;
- }
- public void addZakumLevel() {
- this.zakumLvl += 1;
- }
- public void subtractZakumLevel() {
- this.zakumLvl -= 1;
- }
- public void setPartnerId(int pem) {
- this.partnerid = pem;
- }
- public int getPartnerId() {
- return partnerid;
- }
- public void checkBerserk() {
- if (BerserkSchedule != null) {
- BerserkSchedule.cancel(false);
- }
- final MapleCharacter chr = this;
- ISkill BerserkX = SkillFactory.getSkill(1320006);
- final int skilllevel = getSkillLevel(BerserkX);
- if (chr.getJob().equals(MapleJob.DARKKNIGHT) && skilllevel >= 1) {
- MapleStatEffect ampStat = BerserkX.getEffect(skilllevel);
- int x = ampStat.getX();
- int HP = chr.getHp();
- int MHP = chr.getMaxHp();
- int ratio = HP * 100 / MHP;
- if (ratio > x) {
- Berserk = false;
- } else {
- Berserk = true;
- }
- BerserkSchedule = TimerManager.getInstance().register(new Runnable() {
- @Override
- public void run() {
- getClient().getSession().write(MaplePacketCreator.showOwnBerserk(skilllevel, Berserk));
- getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showBerserk(getId(), skilllevel, Berserk), false);
- }
- }, 5000, 3000);
- }
- }
- private void prepareBeholderEffect() {
- if (beholderHealingSchedule != null) {
- beholderHealingSchedule.cancel(false);
- }
- if (beholderBuffSchedule != null) {
- beholderBuffSchedule.cancel(false);
- }
- ISkill bHealing = SkillFactory.getSkill(1320008);
- if (getSkillLevel(bHealing) > 0) {
- final MapleStatEffect healEffect = bHealing.getEffect(getSkillLevel(bHealing));
- beholderHealingSchedule = TimerManager.getInstance().register(new Runnable() {
- @Override
- public void run() {
- addHP(healEffect.getHp());
- getClient().getSession().write(MaplePacketCreator.showOwnBuffEffect(1321007, 2));
- getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.summonSkill(getId(), 1321007, 5), true);
- getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showBuffeffect(getId(), 1321007, 2, (byte) 3), false);
- }
- }, healEffect.getX() * 1000, healEffect.getX() * 1000);
- }
- ISkill bBuffing = SkillFactory.getSkill(1320009);
- if (getSkillLevel(bBuffing) > 0) {
- final MapleStatEffect buffEffect = bBuffing.getEffect(getSkillLevel(bBuffing));
- beholderBuffSchedule = TimerManager.getInstance().register(new Runnable() {
- @Override
- public void run() {
- buffEffect.applyTo(MapleCharacter.this);
- getClient().getSession().write(MaplePacketCreator.beholderAnimation(getId(), 1320009));
- getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.summonSkill(getId(), 1321007, (int) (Math.random() * 3) + 6), true);
- getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showBuffeffect(getId(), 1321007, 2, (byte) 3), false);
- }
- }, buffEffect.getX() * 1000, buffEffect.getX() * 1000);
- }
- }
- public void setChalkboard(String text) {
- if (interaction != null) {
- return;
- }
- this.chalktext = text;
- for (FakeCharacter ch : fakes) {
- ch.getFakeChar().setChalkboard(text);
- }
- if (chalktext == null) {
- getMap().broadcastMessage(MaplePacketCreator.useChalkboard(this, true));
- } else {
- getMap().broadcastMessage(MaplePacketCreator.useChalkboard(this, false));
- }
- }
- public String getChalkboard() {
- return this.chalktext;
- }
- public void setDefaultKeyMap() {
- keymap.clear();
- int[] num1 = {2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 23, 25, 26, 27, 29, 31, 34, 35, 37, 38, 40, 41, 43, 44, 45, 46, 48, 50, 56, 57, 59, 60, 61, 62, 63, 64, 65};
- int[] num2 = {4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 6, 6, 6, 6, 6, 6, 6};
- int[] num3 = {10, 12, 13, 18, 24, 21, 8, 5, 0, 4, 1, 19, 14, 15, 52, 2, 17, 11, 3, 20, 16, 23, 9, 50, 51, 6, 22, 7, 53, 54, 100, 101, 102, 103, 104, 105, 106};
- for (int i = 0; i < num1.length; i++) {
- keymap.put(Integer.valueOf(num1[i]), new MapleKeyBinding(num2[i], num3[i]));
- }
- sendKeymap();
- }
- public void setReborns(int amt) {
- reborns = amt;
- }
- public void reloadFakeChars() {
- TimerManager.getInstance().schedule(new Runnable() {
- @Override
- public void run() {
- for (int i = 0; i < 1 && i + getFakeChars().size() <= 6; i++) {
- FakeCharacter fc = new FakeCharacter(getClient().getPlayer(), getId() + getFakeChars().size() + 1 + i);
- getFakeChars().add(fc);
- getClient().getChannelServer().addClone(fc);
- }
- }
- }, 5000);
- }
- public void upVip1() {
- client.getSession().close();
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("UPDATE characters SET vip = ? WHERE id = ?");
- ps.setInt(1, 1);
- ps.setInt(2, id);
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- System.err.println("Error while changing status"+ ex);
- }
- }
- public void upVip2() {
- client.getSession().close();
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("UPDATE characters SET vip = ? WHERE id = ?");
- ps.setInt(1, 2);
- ps.setInt(2, id);
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- System.err.println("Error while changing status"+ ex);
- }
- }
- public void upVip3() {
- client.getSession().close();
- try {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("UPDATE characters SET vip = ? WHERE id = ?");
- ps.setInt(1, 3);
- ps.setInt(2, id);
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- System.err.println("Error while changing status"+ ex);
- }
- }
- public boolean isApprovedList() {
- String[] approvedArray = {"Administrator", "Admin"};
- for (String approved : approvedArray) {
- if (getName().equals(approved)) {
- return true;
- }
- }
- return false;
- }
- public int gmLevel() {
- return gmLevel;
- }
- public void gainExp(int gain, boolean show, boolean inChat, boolean white, boolean etcLose) {
- int levelCap = getClient().getChannelServer().getLevelCap();
- if (!etcLose && gain < 0) {
- gain += Integer.MAX_VALUE;
- if (getLevel() < levelCap) levelUp();
- while (gain > 0) {
- gain -= (ExpTable.getExpNeededForLevel(level) - this.exp.get());
- if (getLevel() < levelCap) levelUp();
- }
- setExp(0);
- updateSingleStat(MapleStat.EXP, exp.get());
- client.getSession().write(MaplePacketCreator.getShowExpGain(Integer.MAX_VALUE, inChat, white));
- return;
- }
- if (getLevel() < levelCap) {
- if ((long) this.exp.get() + (long) gain > (long) Integer.MAX_VALUE) {
- int gainFirst = ExpTable.getExpNeededForLevel(level) - this.exp.get();
- gain -= gainFirst + 1;
- this.gainExp(gainFirst + 1, false, inChat, white);
- }
- updateSingleStat(MapleStat.EXP, this.exp.addAndGet(gain));
- } else {
- return;
- }
- if (show && gain != 0) {
- client.getSession().write(MaplePacketCreator.getShowExpGain(gain, inChat, white));
- }
- if (level < levelCap && exp.get() >= ExpTable.getExpNeededForLevel(level)) {
- if (getClient().getChannelServer().getMultiLevel()) {
- while (level < levelCap && exp.get() >= ExpTable.getExpNeededForLevel(level)) {
- levelUp();
- }
- } else {
- levelUp();
- int need = ExpTable.getExpNeededForLevel(level);
- if (exp.get() >= need) {
- setExp(need - 1);
- updateSingleStat(MapleStat.EXP, exp.get());
- }
- }
- }
- }
- public void setvip(int r) {
- this.vip = r;
- }
- public MaplePlayerShop getPlayerShop() {
- return playerShop;
- }
- public void setPvpDeaths(int amount) {
- pvpdeaths = amount;
- }
- public void setPvpKills(int amount) {
- pvpkills = amount;
- }
- public void gainPvpDeath() {
- pvpdeaths += 1;
- }
- public void gainPvpKill() {
- pvpkills += 1;
- }
- public boolean getCanSmega() {
- return canSmega;
- }
- public void setCanSmega(boolean yn) {
- canSmega = yn;
- }
- public boolean getSmegaEnabled() {
- return smegaEnabled;
- }
- public void setSmegaEnabled(boolean yn) {
- smegaEnabled = yn;
- }
- public boolean getCanTalk() {
- return canTalk;
- }
- public boolean canTalk(boolean yn) {
- return canTalk = yn;
- }
- public int getPvpKills() {
- return pvpkills;
- }
- public int getEngagerId() throws SQLException {
- return getIdByName(getEngager(), 0);
- }
- public IItem lockitem(int slot, boolean lock) {
- byte set = (byte) 0;
- byte eqslot = (byte) slot;
- ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
- Equip nEquip = (Equip) this.getInventory(MapleInventoryType.EQUIP).getItem(eqslot);
- if (nEquip != null) {
- if (lock) {
- set = (byte) 1;
- cm.dropMessage("物品 " + slot + " 锁定成功");
- } else {
- cm.dropMessage("物品 " + slot + " 解锁成功");
- }
- nEquip.setLocked(set);
- getClient().getSession().write(MaplePacketCreator.getCharInfo(this));
- getMap().removePlayer(this);
- getMap().addPlayer(this);
- } else {
- cm.dropMessage("Item Slot " + slot + " Equip Null.");
- }
- return nEquip;
- }
- public int itemid(int slot) {
- byte eqslot = (byte) slot;
- int itemid = 0;
- ServernoticeMapleClientMessageCallback cm = new ServernoticeMapleClientMessageCallback(this.getClient());
- Equip nEquip = (Equip) this.getInventory(MapleInventoryType.EQUIP).getItem(eqslot);
- if (nEquip != null)
- itemid = nEquip.getItemId();
- else
- cm.dropMessage("Item Slot " + slot + " Equip Null.");
- return itemid;
- }
- public MapleGuild getGuild() {
- try {
- return getClient().getChannelServer().getWorldInterface().getGuild(getGuildId(), null);
- } catch (RemoteException ex) {
- client.getChannelServer().reconnectWorld();
- }
- return null;
- }
- public void gainGP(int amount) {
- getGuild().gainGP(amount);
- }
- public int getBombPoints() {
- return bombpoints;
- }
- public void setBombPoints(int bombpoints) {
- this.bombpoints = bombpoints;
- }
- public void addBuddyCapacity(int capacity) {
- buddylist.addCapacity(capacity);
- client.getSession().write(MaplePacketCreator.updateBuddyCapacity(getBuddyCapacity()));
- }
- public void maxSkill(int skillid) {
- if (Math.floor(skillid / 10000) == getJob().getId() || isGM() || skillid < 2000) { // lmao im lazy
- ISkill skill_ = SkillFactory.getSkill(skillid);
- int maxlevel = skill_.getMaxLevel(); // TODO - Find a less laggy way.. our xml style skill maxer was fine T____T
- changeSkillLevel(skill_, maxlevel, maxlevel);
- }
- }
- public void maxAllSkills() {
- int[] skillId = {8, /*1000, 1001, 1002,*/ 1003, 1004, 1000000, 1000001, 1000002, 1001003, 1001004, 1001005, 2000000, 2000001,
- 2001002, 2001003, 2001004, 2001005, 3000000, 3000001, 3000002, 3001003, 3001004, 3001005, 4000000, 4000001, 4001002, 4001003,
- 4001334, 4001344, 1100000, 1100001, 1100002, 1100003, 1101004, 1101005, 1101006, 1101007, 1200000, 1200001, 1200002, 1200003,
- 1201004, 1201005, 1201006, 1201007, 1300000, 1300001, 1300002, 1300003, 1301004, 1301005, 1301006, 1301007, 2100000, 2101001,
- 2101002, 2101003, 2101004, 2101005, 2200000, 2201001, 2201002, 2201003, 2201004, 2201005, 2300000, 2301001, 2301002, 2301003,
- 2301004, 2301005, 3100000, 3100001, 3101002, 3101003, 3101004, 3101005, 3200000, 3200001, 3201002, 3201003, 3201004, 3201005,
- 4100000, 4100001, 4100002, 4101003, 4101004, 4101005, 4200000, 4200001, 4201002, 4201003, 4201004, 4201005, 1110000, 1110001,
- 1111002, 1111003, 1111004, 1111005, 1111006, 1111007, 1111008, 1210000, 1210001, 1211002, 1211003, 1211004, 1211005, 1211006,
- 1211007, 1211008, 1211009, 1310000, 1311001, 1311002, 1311003, 1311004, 1311005, 1311006, 1311007, 1311008, 2110000, 2110001,
- 2111002, 2111003, 2111004, 2111005, 2111006, 2210000, 2210001, 2211002, 2211003, 2211004, 2211005, 2211006, 2310000, 2311001,
- 2311002, 2311003, 2311004, 2311005, 2311006, 3110000, 3110001, 3111002, 3111003, 3111004, 3111005, 3111006, 3210000, 3210001,
- 3211002, 3211003, 3211004, 3211005, 3211006, 4110000, 4111001, 4111002, 4111003, 4111004, 4111005, 4111006, 4210000, 4211001,
- 4211002, 4211003, 4211004, 4211005, 4211006, 1120003, 1120004, 1120005, 1121000, 1121001, 1121002, 1121006, 1121008, 1121010,
- 1121011, 1220005, 1220006, 1220010, 1221000, 1221001, 1221002, 1221003, 1221004, 1221007, 1221009, 1221011, 1221012, 1320005,
- 1320006, 1320008, 1320009, 1321000, 1321001, 1321002, 1321003, 1321007, 1321010, 2121000, 2121001, 2121002, 2121003, 2121004,
- 2121005, 2121006, 2121007, 2121008, 2221000, 2221001, 2221002, 2221003, 2221004, 2221005, 2221006, 2221007, 2221008, 2321000,
- 2321001, 2321002, 2321003, 2321004, 2321005, 2321006, 2321007, 2321008, 2321009, 3120005, 3121000, 3121002, 3121003, 3121004,
- 3121006, 3121007, 3121008, 3121009, 3220004, 3221000, 3221001, 3221002, 3221003, 3221005, 3221006, 3221007, 3221008, 4120002,
- 4120005, 4121000, 4121003, 4121004, 4121006, 4121007, 4121008, 4121009, 4220002, 4220005, 4221000, 4221001, 4221003, 4221004,
- 4221006, 4221007, 4221008, 5000000, 5001001, 5001002, 5001003, 5001005, 5100000, 5100001, 5101002, 5101003, 5101004, 5101005,
- 5101006, 5101007, 5200000, 5201001, 5201002, 5201003, 5201004, 5201005, 5201006, 5110000, 5110001, 5111002, 5111004, 5111005,
- 5111006, 5220011, 5221010, 5221009, 5221008, 5221007, 5221006, 5221004, 5221003, 5220002, 5220001, 5221000, 5121010, 5121009,
- 5121008, 5121007, 5121005, 5121004, 5121003, 5121002, 5121001, 5121000, 5211006, 5211005, 5211004, 5211002, 5211001, 5210000,
- 9001000, 9001001, 9001002, 9101000, 9101001, 9101002, 9101003, 9101004, 9101005, 9101006, 9101007, 9101008
- };
- for (int skillzors_ : skillId) {
- maxSkill(skillzors_);
- }
- }
- public void unequipEverything() {
- MapleInventory equipped = this.getInventory(MapleInventoryType.EQUIPPED);
- List<Byte> position = new ArrayList<Byte>();
- for (IItem item : equipped.list()) {
- position.add(item.getPosition());
- }
- for (byte pos : position) {
- MapleInventoryManipulator.unequip(client, pos, getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
- }
- }
- public void setOffOnline(boolean online) {
- try {
- WorldChannelInterface wci = client.getChannelServer().getWorldInterface();
- if (online) { // Ugh should be one function --.
- wci.loggedOn(getName(), getId(), client.getChannel(), getBuddylist().getBuddyIds());
- } else {
- wci.loggedOff(getName(), getId(), client.getChannel(), getBuddylist().getBuddyIds());
- }
- } catch (RemoteException e) {
- client.getChannelServer().reconnectWorld();
- }
- }
- public static boolean unban(String name) {
- try {
- int accountid = -1;
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("SELECT accountid FROM characters WHERE name = ?");
- ps.setString(1, name);
- ResultSet rs = ps.executeQuery();
- if (rs.next()) {
- accountid = rs.getInt("accountid");
- }
- ps.close();
- rs.close();
- if (accountid == -1) {
- return false;
- }
- ps = con.prepareStatement("UPDATE accounts SET banned = -1 WHERE id = ?");
- ps.setInt(1, accountid);
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- System.err.println("Error while unbanning");
- return false;
- }
- return true;
- }
- public void dropMessage(String message) {
- dropMessage(6, message);
- }
- public void dropMessage(int type, String message) {
- client.getSession().write(MaplePacketCreator.serverNotice(type, message));
- }
- public void setClan(int num) {
- clan = num;
- }
- public int getClan() {
- return clan;
- }
- public void setJob(int job) {
- if (isfake) {
- this.job = MapleJob.getById(job);
- } else {
- this.changeJob(MapleJob.getById(job));
- }
- }
- public void setFake() {
- isfake = true;
- }
- public void setJob(MapleJob job) {
- this.changeJob(job);
- }
- public int isDonator() {
- return this.donatePoints;
- }
- public void setDonator(int set) {
- donatePoints = set;
- }
- public void setID(int id) {
- this.id = id;
- }
- public void setInventory(MapleInventoryType type, MapleInventory inv) {
- inventory[type.ordinal()] = inv;
- }
- public boolean hasFakeChar() {
- if (fakes.size() > 0) {
- return true;
- }
- return false;
- }
- public List<FakeCharacter> getFakeChars() {
- return fakes;
- }
- public void setGMText(int text) {
- gmtext = text;
- }
- public int getGMText() {
- return gmtext;
- }
- public void setExp(int set) {
- exp.set(set);
- if (exp.get() < 0) {
- exp.set(0);
- }
- }
- public void giveItemBuff(int itemID) {
- MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
- MapleStatEffect statEffect = mii.getItemEffect(itemID);
- statEffect.applyTo(this);
- }
- public void cancelAllDebuffs() {
- for (int i = 0; i < diseases.size(); i++) {
- diseases.remove(i);
- long mask = 0;
- for (MapleDisease statup : diseases) {
- mask |= statup.getValue();
- }
- getClient().getSession().write(MaplePacketCreator.cancelDebuff(mask));
- getMap().broadcastMessage(this, MaplePacketCreator.cancelForeignDebuff(id, mask), false);
- }
- }
- public List<MapleDisease> getDiseases() {
- return diseases;
- }
- @SuppressWarnings("unchecked")
- public void removeJobSkills() {
- HashMap<Integer, MapleKeyBinding> keymapCloned = (HashMap<Integer, MapleKeyBinding>) keymap.clone();
- for (Integer keys : keymapCloned.keySet()) {
- if (SkillFactory.getSkillName(keys) != null) {
- if (keymapCloned.get(keys).getAction() >= 1000000) {
- keymap.remove(keys);
- }
- }
- }
- sendKeymap();
- }
- /*
- public List<Integer> getJobs() {
- return jobs;
- }
- */
- public void changePage(int page) {
- this.currentPage = page;
- }
- public void changeTab(int tab) {
- this.currentTab = tab;
- }
- public void changeType(int type) {
- this.currentType = type;
- }
- public int getCurrentPage() {
- return currentPage;
- }
- public int getCurrentTab() {
- return currentTab;
- }
- public int getCurrentType() {
- return currentType;
- }
- public void handleEnergyChargeGain() {
- ISkill energycharge = SkillFactory.getSkill(5110001);
- int energyChargeSkillLevel = getSkillLevel(energycharge);
- MapleStatEffect ceffect = null;
- ceffect = energycharge.getEffect(energyChargeSkillLevel);
- if (energyChargeSkillLevel > 0) {
- if (energybar < 10000) {
- energybar = (energybar + 102);
- if (energybar > 10000) {
- energybar = 10000;
- }
- getClient().getSession().write(MaplePacketCreator.giveEnergyCharge(energybar * getClient().getChannelServer().getEnergyRate(), 0));
- }
- if (energybar >= 10000 && energybar < 11000) {
- energybar = 15000;
- TimerManager tMan = TimerManager.getInstance();
- tMan.schedule(new Runnable() {
- @Override
- public void run() {
- getClient().getSession().write(MaplePacketCreator.giveEnergyCharge(0, 0));
- energybar = 0;
- }
- }, ceffect.getDuration());
- }
- }
- }
- public int getEnergyBar() {
- return this.energybar;
- }
- public void setEnergyBar(int set) {
- energybar = set;
- }
- public long getAfkTime() {
- return afkTime;
- }
- public void resetAfkTime() {
- if (this.chalktext != null && this.chalktext.equals("I'm afk ! drop me a message <3")) {
- setChalkboard(null);
- }
- afkTime = System.currentTimeMillis();
- }
- public void setClient(MapleClient c) {
- client = c;
- }
- public boolean isFake() {
- return this.isfake;
- }
- public long getLastLogin() {
- return lastLogin;
- }
- public boolean hasMerchant() {
- return hasMerchant;
- }
- public void setHasMerchant(boolean set) {
- try {
- PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET HasMerchant = ? WHERE id = ?");
- ps.setInt(1, set ? 1 : 0);
- ps.setInt(2, getId());
- ps.executeUpdate();
- ps.close();
- } catch (SQLException se) {
- }
- hasMerchant = set;
- }
- public List<Integer> getVIPRockMaps(int type) {
- List<Integer> rockmaps = new LinkedList<Integer>();
- try {
- PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT mapid FROM VIPRockMaps WHERE cid = ? AND type = ?");
- ps.setInt(1, id);
- ps.setInt(2, type);
- ResultSet rs = ps.executeQuery();
- while (rs.next()) {
- rockmaps.add(rs.getInt("mapid"));
- }
- rs.close();
- ps.close();
- } catch (SQLException se) {
- return null;
- }
- return rockmaps;
- }
- //getBossLog module
- public int getBossLog(String bossid) {
- Connection con1 = DatabaseConnection.getConnection();
- try {
- int ret_count = 0;
- PreparedStatement ps;
- ps = con1.prepareStatement("select count(*) from bosslog where characterid = ? and bossid = ? and lastattempt >= subtime(current_timestamp, '1 0:0:0.0')");
- ps.setInt(1, id);
- ps.setString(2, bossid);
- ResultSet rs = ps.executeQuery();
- if (rs.next()) {
- ret_count = rs.getInt(1);
- } else {
- ret_count = -1;
- }
- rs.close();
- ps.close();
- return ret_count;
- } catch (Exception Ex) {
- System.err.println("Error while read bosslog.");
- return -1;
- }
- }
- public int getExt(String bossid) {
- Connection con1 = DatabaseConnection.getConnection();
- try {
- int ret_count = 0;
- PreparedStatement ps;
- ps = con1.prepareStatement("select count(*) from bosslog where characterid = ? and bossid = ? ");
- ps.setInt(1, id);
- ps.setString(2, bossid);
- ResultSet rs = ps.executeQuery();
- if (rs.next()) {
- ret_count = rs.getInt(1);
- } else {
- ret_count = -1;
- }
- rs.close();
- ps.close();
- return ret_count;
- } catch (Exception Ex) {
- System.err.println("Error while read bosslog.");
- return -1;
- }
- }
- public int getDay()
- {
- Calendar cal = Calendar.getInstance();
- int day = cal.get(7);
- return day;
- }
- public int getHour()
- {
- Calendar cal = Calendar.getInstance();
- int hour = cal.get(11);
- return hour;
- }
- public int getMin()
- {
- Calendar cal = Calendar.getInstance();
- int min = cal.get(12);
- return min;
- }
- public int getSec()
- {
- Calendar cal = Calendar.getInstance();
- int sec = cal.get(13);
- return sec;
- }
- public List<MTSItemInfo> getTransfer(int cid) {
- List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps;
- ResultSet rs;
- try
- {
- ps = con.prepareStatement("SELECT * FROM mts_items WHERE transfer = 1 AND seller = ? ORDER BY id DESC");
- ps.setInt(1, cid);
- rs = ps.executeQuery();
- while (rs.next()) {
- if(rs.getInt("type") != 1)
- {
- Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
- i.setOwner(rs.getString("owner"));
- items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
- } else {
- Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
- equip.setOwner(rs.getString("owner"));
- equip.setQuantity((short) 1);
- equip.setAcc((short) rs.getInt("acc"));
- equip.setAvoid((short) rs.getInt("avoid"));
- equip.setDex((short) rs.getInt("dex"));
- equip.setHands((short) rs.getInt("hands"));
- equip.setHp((short) rs.getInt("hp"));
- equip.setInt((short) rs.getInt("int"));
- equip.setJump((short) rs.getInt("jump"));
- equip.setLuk((short) rs.getInt("luk"));
- equip.setMatk((short) rs.getInt("matk"));
- equip.setMdef((short) rs.getInt("mdef"));
- equip.setMp((short) rs.getInt("mp"));
- equip.setSpeed((short) rs.getInt("speed"));
- equip.setStr((short) rs.getInt("str"));
- equip.setWatk((short) rs.getInt("watk"));
- equip.setWdef((short) rs.getInt("wdef"));
- equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
- equip.setLocked((byte) rs.getInt("locked"));
- equip.setLevel((byte) rs.getInt("level"));
- items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
- }
- }
- rs.close();
- ps.close();
- }
- catch(SQLException e) {
- log.error("Err7: " + e);
- }
- return items;
- }
- public void warpFreeMarket(){
- MapleClient c = getClient();
- if ((c.getPlayer().getMapId() != 910000000)) {
- if (c.getPlayer().isAlive() || c.getPlayer().getHp()>0) {
- new ServernoticeMapleClientMessageCallback(5, c).dropMessage("你被奇妙的拽到自由市场去啦.");
- c.getSession().write(MaplePacketCreator.enableActions());
- MapleMap to;
- MaplePortal pto;
- to = ChannelServer.getInstance(c.getChannel()).getMapFactory().getMap(910000000);
- c.getPlayer().saveLocation(SavedLocationType.FREE_MARKET);
- pto = to.getPortal("out00");
- c.getPlayer().changeMap(to, pto);
- } else {
- new ServernoticeMapleClientMessageCallback(5, c).dropMessage("GM是不会让你这个死人去自由市场滴.");
- c.getSession().write(MaplePacketCreator.enableActions());
- }
- } else {
- new ServernoticeMapleClientMessageCallback(5, c).dropMessage("你已经在自由市场里了哦!");
- c.getSession().write(MaplePacketCreator.enableActions());
- }
- }
- public void warpMTS(){
- MapleClient c = getClient();
- if (c.getPlayer().getNoPets() > 0) {
- c.getPlayer().unequipAllPets();
- }
- c.getPlayer().cancelAllBuffs();
- c.getPlayer().getMap().removePlayer(c.getPlayer());
- c.getSession().write(MaplePacketCreator.warpMTS(c));
- c.getPlayer().setInMTS(true);
- c.getSession().write(MaplePacketCreator.enableMTS());
- c.getSession().write(MaplePacketCreator.MTSWantedListingOver(0, 0));
- c.getSession().write(MaplePacketCreator.showMTSCash(c.getPlayer()));
- List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
- int pages = 0;
- try
- {
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = 1 AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
- ps.setInt(1, 0);
- ResultSet rs = ps.executeQuery();
- while (rs.next()) {
- if(rs.getInt("type") != 1)
- {
- Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
- i.setOwner(rs.getString("owner"));
- items.add(new MTSItemInfo(i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
- } else {
- Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
- equip.setOwner(rs.getString("owner"));
- equip.setQuantity((short) 1);
- equip.setAcc((short) rs.getInt("acc"));
- equip.setAvoid((short) rs.getInt("avoid"));
- equip.setDex((short) rs.getInt("dex"));
- equip.setHands((short) rs.getInt("hands"));
- equip.setHp((short) rs.getInt("hp"));
- equip.setInt((short) rs.getInt("int"));
- equip.setJump((short) rs.getInt("jump"));
- equip.setLuk((short) rs.getInt("luk"));
- equip.setMatk((short) rs.getInt("matk"));
- equip.setMdef((short) rs.getInt("mdef"));
- equip.setMp((short) rs.getInt("mp"));
- equip.setSpeed((short) rs.getInt("speed"));
- equip.setStr((short) rs.getInt("str"));
- equip.setWatk((short) rs.getInt("watk"));
- equip.setWdef((short) rs.getInt("wdef"));
- equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
- equip.setLocked((byte) rs.getInt("locked"));
- equip.setLevel((byte) rs.getInt("level"));
- items.add(new MTSItemInfo((IItem) equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
- }
- }
- rs.close();
- ps.close();
- ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items");
- rs = ps.executeQuery();
- if (rs.next()) {
- pages = (int) Math.ceil(rs.getInt(1) / 16);
- }
- rs.close();
- ps.close();
- }
- catch(SQLException e) {
- log.error("Err1: " + e);
- }
- c.getSession().write(MaplePacketCreator.sendMTS(items, 1, 0, 0, pages));
- c.getSession().write(MaplePacketCreator.TransferInventory(getTransfer(c.getPlayer().getId())));
- c.getSession().write(MaplePacketCreator.NotYetSoldInv(getNotYetSold(c.getPlayer().getId())));
- }
- public List<MTSItemInfo> getNotYetSold(int cid) {
- List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps;
- ResultSet rs;
- try
- {
- ps = con.prepareStatement("SELECT * FROM mts_items WHERE seller = ? AND transfer = 0 ORDER BY id DESC");
- ps.setInt(1, cid);
- rs = ps.executeQuery();
- while (rs.next()) {
- if(rs.getInt("type") != 1)
- {
- Item i = new Item(rs.getInt("itemid"), (byte)0, (short)rs.getInt("quantity"));
- i.setOwner(rs.getString("owner"));
- items.add(new MTSItemInfo((IItem)i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
- } else {
- Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
- equip.setOwner(rs.getString("owner"));
- equip.setQuantity((short) 1);
- equip.setAcc((short) rs.getInt("acc"));
- equip.setAvoid((short) rs.getInt("avoid"));
- equip.setDex((short) rs.getInt("dex"));
- equip.setHands((short) rs.getInt("hands"));
- equip.setHp((short) rs.getInt("hp"));
- equip.setInt((short) rs.getInt("int"));
- equip.setJump((short) rs.getInt("jump"));
- equip.setLuk((short) rs.getInt("luk"));
- equip.setMatk((short) rs.getInt("matk"));
- equip.setMdef((short) rs.getInt("mdef"));
- equip.setMp((short) rs.getInt("mp"));
- equip.setSpeed((short) rs.getInt("speed"));
- equip.setStr((short) rs.getInt("str"));
- equip.setWatk((short) rs.getInt("watk"));
- equip.setWdef((short) rs.getInt("wdef"));
- equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
- equip.setLocked((byte) rs.getInt("locked"));
- equip.setLevel((byte) rs.getInt("level"));
- items.add(new MTSItemInfo((IItem)equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
- }
- }
- rs.close();
- ps.close();
- }
- catch(SQLException e) {
- log.error("Err8: " + e);
- }
- return items;
- }
- //setBossLog module
- public void setBossLog(String bossid) {
- Connection con1 = DatabaseConnection.getConnection();
- try {
- PreparedStatement ps;
- ps = con1.prepareStatement("insert into bosslog (characterid, bossid) values (?,?)");
- ps.setInt(1, id);
- ps.setString(2, bossid);
- ps.executeUpdate();
- ps.close();
- } catch (Exception Ex) {
- log.error("Error while insert bosslog.", Ex);
- }
- }
- }